From 4f249289baa161ea9292c7b1e5f85008ca370fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Aug 2019 15:40:25 +0200 Subject: [PATCH 001/191] Remove offline slashing logic from staking. --- Cargo.lock | 1 - srml/aura/Cargo.toml | 2 - srml/aura/src/lib.rs | 8 +- srml/staking/src/lib.rs | 239 ++++++++++++++++---------------------- srml/staking/src/mock.rs | 2 - srml/staking/src/tests.rs | 237 +++---------------------------------- 6 files changed, 113 insertions(+), 376 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1d9a497939b7..a5bad3b07d845 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3636,7 +3636,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/srml/aura/Cargo.toml b/srml/aura/Cargo.toml index c1bf922a581af..4f0cb6233a3f4 100644 --- a/srml/aura/Cargo.toml +++ b/srml/aura/Cargo.toml @@ -14,7 +14,6 @@ substrate-primitives = { path = "../../core/primitives", default-features = fals 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 } -staking = { package = "srml-staking", path = "../staking", default-features = false } session = { package = "srml-session", path = "../session", default-features = false } substrate-consensus-aura-primitives = { path = "../../core/consensus/aura/primitives", default-features = false} @@ -34,7 +33,6 @@ std = [ "substrate-primitives/std", "system/std", "timestamp/std", - "staking/std", "inherents/std", "substrate-consensus-aura-primitives/std", ] diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index a0f7ad6242429..4073c6b0fe188 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -31,9 +31,6 @@ //! //! ## Related Modules //! -//! - [Staking](../srml_staking/index.html): The Staking module is called in Aura to enforce slashing -//! if validators miss a certain number of slots (see the [`StakingSlasher`](./struct.StakingSlasher.html) -//! struct and associated method). //! - [Timestamp](../srml_timestamp/index.html): The Timestamp module is used in Aura to track //! consensus rounds (via `slots`). //! - [Consensus](../srml_consensus/index.html): The Consensus module does not relate directly to Aura, @@ -289,16 +286,15 @@ impl OnTimestampSet for Module { /// A type for performing slashing based on Aura reports. pub struct StakingSlasher(::rstd::marker::PhantomData); -impl HandleReport for StakingSlasher { +impl HandleReport for StakingSlasher { fn handle_report(report: AuraReport) { - use staking::SessionInterface; let validators = T::SessionInterface::validators(); report.punish( validators.len(), |idx, slash_count| { let v = validators[idx].clone(); - staking::Module::::on_offline_validator(v, slash_count); + // TODO [slashing] Use report_offence here. } ); } diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index a1a555bcf5a0c..e22a56facedee 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -133,7 +133,8 @@ //! //! ## Usage //! -//! ### Example: Reporting Misbehavior +//! ### Example: Slashing a particular validator. +//! TODO [slashing] Figure out a better example. //! //! ``` //! use srml_support::{decl_module, dispatch::Result}; @@ -144,10 +145,10 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! /// Report whoever calls this function as offline once. -//! pub fn report_sender(origin) -> Result { +//! /// Slash a validator for an offence. +//! pub fn slash_myself(origin) -> Result { //! let reported = ensure_signed(origin)?; -//! >::on_offline_validator(reported, 1); +//! >::slash_validator(reported, 1_000); //! Ok(()) //! } //! } @@ -202,28 +203,6 @@ //! - Stash account, not increasing the staked value. //! - Stash account, also increasing the staked value. //! -//! ### Slashing details -//! -//! A validator can be _reported_ to be offline at any point via the public function -//! [`on_offline_validator`](enum.Call.html#variant.on_offline_validator). Each validator declares -//! how many times it can be _reported_ before it actually gets slashed via its -//! [`ValidatorPrefs::unstake_threshold`](./struct.ValidatorPrefs.html#structfield.unstake_threshold). -//! -//! On top of this, the Staking module also introduces an -//! [`OfflineSlashGrace`](./struct.Module.html#method.offline_slash_grace), which applies -//! to all validators and prevents them from getting immediately slashed. -//! -//! Essentially, a validator gets slashed once they have been reported more than -//! [`OfflineSlashGrace`] + [`ValidatorPrefs::unstake_threshold`] times. Getting slashed due to -//! offline report always leads to being _unstaked_ (_i.e._ removed as a validator candidate) as -//! the consequence. -//! -//! The base slash value is computed _per slash-event_ by multiplying -//! [`OfflineSlash`](./struct.Module.html#method.offline_slash) and the `total` `Exposure`. This -//! value is then multiplied by `2.pow(unstake_threshold)` to obtain the final slash value. All -//! individual accounts' punishments are capped at their total stake (NOTE: This cap should never -//! come into force in a correctly implemented, non-corrupted, well-configured system). -//! //! ### Additional Fund Management Operations //! //! Any funds already placed into stash can be the target of the following operations: @@ -296,7 +275,7 @@ use session::{historical::OnSessionEnding, SelectInitialValidators, SessionIndex use primitives::Perbill; use primitives::weights::SimpleDispatchInfo; use primitives::traits::{ - Convert, Zero, One, StaticLookup, CheckedSub, CheckedShl, Saturating, Bounded, + Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SaturatedConversion, SimpleArithmetic }; #[cfg(feature = "std")] @@ -305,10 +284,8 @@ use system::{ensure_signed, ensure_root}; use phragmen::{elect, ACCURACY, ExtendedBalance, equalize}; -const RECENT_OFFLINE_COUNT: usize = 32; const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4; const MAX_NOMINATIONS: usize = 16; -const MAX_UNSTAKE_THRESHOLD: u32 = 10; const MAX_UNLOCKING_CHUNKS: usize = 32; const STAKING_ID: LockIdentifier = *b"staking "; @@ -358,9 +335,6 @@ impl Default for RewardDestination { #[derive(PartialEq, Eq, Clone, Encode, Decode)] #[cfg_attr(feature = "std", derive(Debug))] pub struct ValidatorPrefs { - /// Validator should ensure this many more slashes than is necessary before being unstaked. - #[codec(compact)] - pub unstake_threshold: u32, /// Reward that validator takes up-front; only the rest is split between themselves and /// nominators. #[codec(compact)] @@ -370,7 +344,6 @@ pub struct ValidatorPrefs { impl Default for ValidatorPrefs { fn default() -> Self { ValidatorPrefs { - unstake_threshold: 3, validator_payment: Default::default(), } } @@ -550,10 +523,6 @@ decl_storage! { /// Minimum number of staking participants before emergency conditions are imposed. pub MinimumValidatorCount get(minimum_validator_count) config(): u32 = DEFAULT_MINIMUM_VALIDATOR_COUNT; - /// Slash, per validator that is taken for the first time they are found to be offline. - pub OfflineSlash get(offline_slash) config(): Perbill = Perbill::from_millionths(1000); - /// Number of instances of offline reports before slashing begins for validators. - pub OfflineSlashGrace get(offline_slash_grace) config(): u32; /// Any validators that may never be slashed or forcibly kicked. It's a Vec since they're /// easy to initialize and the performance hit is minimal (we expect no more than four @@ -603,14 +572,6 @@ decl_storage! { config.stakers.iter().map(|&(_, _, value, _)| value).min().unwrap_or_default() }): BalanceOf; - /// The number of times a given validator has been reported offline. This gets decremented - /// by one each era that passes. - pub SlashCount get(slash_count): map T::AccountId => u32; - - /// Most recent `RECENT_OFFLINE_COUNT` instances. (Who it was, when it was reported, how - /// many instances they were offline for). - 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. pub ForceNewEra get(forcing_new_era): bool; @@ -867,10 +828,6 @@ decl_module! { let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or("not a controller")?; let stash = &ledger.stash; - ensure!( - prefs.unstake_threshold <= MAX_UNSTAKE_THRESHOLD, - "unstake threshold too large" - ); >::remove(stash); >::insert(stash, prefs); } @@ -990,13 +947,6 @@ decl_module! { Self::apply_force_new_era() } - /// Set the offline slash grace period. - #[weight = SimpleDispatchInfo::FixedOperational(10_000)] - fn set_offline_slash_grace(origin, #[compact] new: u32) { - ensure_root(origin)?; - OfflineSlashGrace::put(new); - } - /// Set the validators who cannot be slashed (if any). #[weight = SimpleDispatchInfo::FixedOperational(10_000)] fn set_invulnerables(origin, validators: Vec) { @@ -1035,31 +985,43 @@ impl Module { /// Slash a given validator by a specific amount. Removes the slash from the validator's /// balance by preference, and reduces the nominators' balance if needed. - fn slash_validator(stash: &T::AccountId, slash: BalanceOf) { - // The exposure (backing stake) information of the validator to be slashed. - let exposure = Self::stakers(stash); - // The amount we are actually going to slash (can't be bigger than the validator's total - // exposure) - let slash = slash.min(exposure.total); - // The amount we'll slash from the validator's stash directly. - let own_slash = exposure.own.min(slash); - let (mut imbalance, missing) = T::Currency::slash(stash, own_slash); - let own_slash = own_slash - missing; - // The amount remaining that we can't slash from the validator, that must be taken from the - // nominators. - let rest_slash = slash - own_slash; - if !rest_slash.is_zero() { - // The total to be slashed from the nominators. - let total = exposure.total - exposure.own; - if !total.is_zero() { - for i in exposure.others.iter() { - let per_u64 = Perbill::from_rational_approximation(i.value, total); - // best effort - not much that can be done on fail. - imbalance.subsume(T::Currency::slash(&i.who, per_u64 * rest_slash).0) + /// + /// NOTE: This is called with the controller (not the stash) account id. + pub fn slash_validator(controller: T::AccountId, slash: BalanceOf) { + if let Some(l) = Self::ledger(&controller) { + let stash = l.stash; + + // Early exit if validator is invulnerable. + if Self::invulnerables().contains(&stash) { + return + } + + // The exposure (backing stake) information of the validator to be slashed. + let exposure = Self::stakers(&stash); + // The amount we are actually going to slash (can't be bigger than the validator's total + // exposure) + let slash = slash.min(exposure.total); + // The amount we'll slash from the validator's stash directly. + let own_slash = exposure.own.min(slash); + let (mut imbalance, missing) = T::Currency::slash(&stash, own_slash); + let own_slash = own_slash - missing; + // The amount remaining that we can't slash from the validator, that must be taken from the + // nominators. + let rest_slash = slash - own_slash; + if !rest_slash.is_zero() { + // The total to be slashed from the nominators. + let total = exposure.total - exposure.own; + if !total.is_zero() { + for i in exposure.others.iter() { + let per_u64 = Perbill::from_rational_approximation(i.value, total); + // best effort - not much that can be done on fail. + imbalance.subsume(T::Currency::slash(&i.who, per_u64 * rest_slash).0) + } } } + T::Slash::on_unbalanced(imbalance); + let _ = T::SessionInterface::disable_validator(&stash); } - T::Slash::on_unbalanced(imbalance); } /// Actually make a payment to a staker. This uses the currency's reward function @@ -1287,13 +1249,9 @@ impl Module { equalize::(&mut assignments_with_votes, &mut exposures, tolerance, iterations); } - // Clear Stakers and reduce their slash_count. + // Clear Stakers. for v in Self::current_elected().iter() { >::remove(v); - let slash_count = >::take(v); - if slash_count > 1 { - >::insert(v, slash_count - 1); - } } // Populate Stakers and figure out the minimum stake behind a slot. @@ -1337,67 +1295,66 @@ impl Module { >::remove(&controller); } >::remove(stash); - >::remove(stash); >::remove(stash); >::remove(stash); } - - /// Call when a validator is determined to be offline. `count` is the - /// number of offenses the validator has committed. - /// - /// NOTE: This is called with the controller (not the stash) account id. - pub fn on_offline_validator(controller: T::AccountId, count: usize) { - if let Some(l) = Self::ledger(&controller) { - let stash = l.stash; - - // Early exit if validator is invulnerable. - if Self::invulnerables().contains(&stash) { - return - } - - let slash_count = Self::slash_count(&stash); - let new_slash_count = slash_count + count as u32; - >::insert(&stash, new_slash_count); - let grace = Self::offline_slash_grace(); - - if RECENT_OFFLINE_COUNT > 0 { - let item = (stash.clone(), >::block_number(), count as u32); - >::mutate(|v| if v.len() >= RECENT_OFFLINE_COUNT { - let index = v.iter() - .enumerate() - .min_by_key(|(_, (_, block, _))| block) - .expect("v is non-empty; qed") - .0; - v[index] = item; - } else { - v.push(item); - }); - } - - let prefs = Self::validators(&stash); - let unstake_threshold = prefs.unstake_threshold.min(MAX_UNSTAKE_THRESHOLD); - let max_slashes = grace + unstake_threshold; - - let event = if new_slash_count > max_slashes { - let slash_exposure = Self::stakers(&stash).total; - let offline_slash_base = Self::offline_slash() * slash_exposure; - // They're bailing. - let slash = offline_slash_base - // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) - .checked_shl(unstake_threshold) - .map(|x| x.min(slash_exposure)) - .unwrap_or(slash_exposure); - let _ = Self::slash_validator(&stash, slash); - let _ = T::SessionInterface::disable_validator(&stash); - - RawEvent::OfflineSlash(stash.clone(), slash) - } else { - RawEvent::OfflineWarning(stash.clone(), slash_count) - }; - - Self::deposit_event(event); - } - } + // + // /// Call when a validator is determined to be offline. `count` is the + // /// number of offenses the validator has committed. + // /// + // /// NOTE: This is called with the controller (not the stash) account id. + // pub fn on_offline_validator(controller: T::AccountId, count: usize) { + // if let Some(l) = Self::ledger(&controller) { + // let stash = l.stash; + // + // // Early exit if validator is invulnerable. + // if Self::invulnerables().contains(&stash) { + // return + // } + // + // let slash_count = Self::slash_count(&stash); + // let new_slash_count = slash_count + count as u32; + // >::insert(&stash, new_slash_count); + // let grace = Self::offline_slash_grace(); + // + // if RECENT_OFFLINE_COUNT > 0 { + // let item = (stash.clone(), >::block_number(), count as u32); + // >::mutate(|v| if v.len() >= RECENT_OFFLINE_COUNT { + // let index = v.iter() + // .enumerate() + // .min_by_key(|(_, (_, block, _))| block) + // .expect("v is non-empty; qed") + // .0; + // v[index] = item; + // } else { + // v.push(item); + // }); + // } + // + // let prefs = Self::validators(&stash); + // let unstake_threshold = prefs.unstake_threshold.min(MAX_UNSTAKE_THRESHOLD); + // let max_slashes = grace + unstake_threshold; + // + // let event = if new_slash_count > max_slashes { + // let slash_exposure = Self::stakers(&stash).total; + // let offline_slash_base = Self::offline_slash() * slash_exposure; + // // They're bailing. + // let slash = offline_slash_base + // // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) + // .checked_shl(unstake_threshold) + // .map(|x| x.min(slash_exposure)) + // .unwrap_or(slash_exposure); + // let _ = Self::slash_validator(&stash, slash); + // let _ = T::SessionInterface::disable_validator(&stash); + // + // RawEvent::OfflineSlash(stash.clone(), slash) + // } else { + // RawEvent::OfflineWarning(stash.clone(), slash_count) + // }; + // + // Self::deposit_event(event); + // } + // } /// Add reward points to validator. /// diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index 426ba680a9e1e..98127326c25d5 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -306,8 +306,6 @@ impl ExtBuilder { ], validator_count: self.validator_count, minimum_validator_count: self.minimum_validator_count, - offline_slash: Perbill::from_percent(5), - offline_slash_grace: 0, invulnerables: vec![], }.assimilate_storage(&mut t, &mut c); diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 39409c2c39d97..1e78c1986d194 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -41,11 +41,11 @@ fn basic_setup_works() { // Account 1 does not control any stash assert_eq!(Staking::ledger(&1), None); - // ValidatorPrefs are default, thus unstake_threshold is 3, other values are default for their type + // ValidatorPrefs are default assert_eq!(>::enumerate().collect::>(), vec![ - (31, ValidatorPrefs { unstake_threshold: 3, validator_payment: 0 }), - (21, ValidatorPrefs { unstake_threshold: 3, validator_payment: 0 }), - (11, ValidatorPrefs { unstake_threshold: 3, validator_payment: 0 }) + (31, ValidatorPrefs::default()), + (21, ValidatorPrefs::default()), + (11, ValidatorPrefs::default()) ]); // Account 100 is the default nominator @@ -83,32 +83,16 @@ fn basic_setup_works() { // Initial Era and session assert_eq!(Staking::current_era(), 0); - // initial slash_count of validators - assert_eq!(Staking::slash_count(&11), 0); - assert_eq!(Staking::slash_count(&21), 0); - - // All exposures must be correct. - check_exposure_all(); - check_nominator_all(); - }); -} - -#[test] -fn no_offline_should_work() { - // Test the staking module works when no validators are offline - with_externalities(&mut ExtBuilder::default().build(), - || { - // Slashing begins for validators immediately if found offline - assert_eq!(Staking::offline_slash_grace(), 0); - // Account 10 has not been reported offline - assert_eq!(Staking::slash_count(&10), 0); // Account 10 has `balance_factor` free balance assert_eq!(Balances::free_balance(&10), 1); - // Nothing happens to Account 10, as expected - assert_eq!(Staking::slash_count(&10), 0); assert_eq!(Balances::free_balance(&10), 1); + // New era is not being forced assert!(!Staking::forcing_new_era()); + + // All exposures must be correct. + check_exposure_all(); + check_nominator_all(); }); } @@ -135,183 +119,6 @@ fn change_controller_works() { }) } -#[test] -fn invulnerability_should_work() { - // Test that users can be invulnerable from slashing and being kicked - with_externalities(&mut ExtBuilder::default().build(), - || { - // Make account 11 invulnerable - assert_ok!(Staking::set_invulnerables(Origin::ROOT, vec![11])); - // Give account 11 some funds - let _ = Balances::make_free_balance_be(&11, 70); - // There is no slash grace -- slash immediately. - assert_eq!(Staking::offline_slash_grace(), 0); - // Account 11 has not been slashed - assert_eq!(Staking::slash_count(&11), 0); - // Account 11 has the 70 funds we gave it above - assert_eq!(Balances::free_balance(&11), 70); - // Account 11 should be a validator - assert!(>::exists(&11)); - - // Set account 11 as an offline validator with a large number of reports - // Should exit early if invulnerable - Staking::on_offline_validator(10, 100); - - // Show that account 11 has not been touched - assert_eq!(Staking::slash_count(&11), 0); - assert_eq!(Balances::free_balance(&11), 70); - assert!(>::exists(&11)); - // New era not being forced - // NOTE: new era is always forced once slashing happens -> new validators need to be chosen. - assert!(!Staking::forcing_new_era()); - }); -} - -#[test] -fn offline_should_slash_and_disable() { - // Test that an offline validator gets slashed and kicked - with_externalities(&mut ExtBuilder::default().build(), || { - // Give account 10 some balance - let _ = Balances::make_free_balance_be(&11, 1000); - // Confirm account 10 is a validator - assert!(>::exists(&11)); - // Validators get slashed immediately - assert_eq!(Staking::offline_slash_grace(), 0); - // Unstake threshold is 3 - assert_eq!(Staking::validators(&11).unstake_threshold, 3); - // Account 10 has not been slashed before - assert_eq!(Staking::slash_count(&11), 0); - // Account 10 has the funds we just gave it - assert_eq!(Balances::free_balance(&11), 1000); - // Account 10 is not yet disabled. - assert!(!is_disabled(10)); - // Report account 10 as offline, one greater than unstake threshold - Staking::on_offline_validator(10, 4); - // Confirm user has been reported - assert_eq!(Staking::slash_count(&11), 4); - // Confirm balance has been reduced by 2^unstake_threshold * offline_slash() * amount_at_stake. - let slash_base = Staking::offline_slash() * Staking::stakers(11).total; - assert_eq!(Balances::free_balance(&11), 1000 - 2_u64.pow(3) * slash_base); - // Confirm account 10 has been disabled. - assert!(is_disabled(10)); - }); -} - -#[test] -fn offline_grace_should_delay_slashing() { - // Tests that with grace, slashing is delayed - with_externalities(&mut ExtBuilder::default().build(), || { - // Initialize account 10 with balance - let _ = Balances::make_free_balance_be(&11, 70); - // Verify account 11 has balance - assert_eq!(Balances::free_balance(&11), 70); - - // Set offline slash grace - let offline_slash_grace = 1; - assert_ok!(Staking::set_offline_slash_grace(Origin::ROOT, offline_slash_grace)); - assert_eq!(Staking::offline_slash_grace(), 1); - - // Check unstake_threshold is 3 (default) - let default_unstake_threshold = 3; - assert_eq!( - Staking::validators(&11), - ValidatorPrefs { unstake_threshold: default_unstake_threshold, validator_payment: 0 } - ); - - // Check slash count is zero - assert_eq!(Staking::slash_count(&11), 0); - - // Report account 10 up to the threshold - Staking::on_offline_validator(10, default_unstake_threshold as usize + offline_slash_grace as usize); - // Confirm slash count - assert_eq!(Staking::slash_count(&11), 4); - - // Nothing should happen - assert_eq!(Balances::free_balance(&11), 70); - - // Report account 10 one more time - Staking::on_offline_validator(10, 1); - assert_eq!(Staking::slash_count(&11), 5); - // User gets slashed - assert!(Balances::free_balance(&11) < 70); - // New era is forced - assert!(is_disabled(10)); - }); -} - - -#[test] -fn max_unstake_threshold_works() { - // Tests that max_unstake_threshold gets used when prefs.unstake_threshold is large - with_externalities(&mut ExtBuilder::default().build(), || { - const MAX_UNSTAKE_THRESHOLD: u32 = 10; - // Two users with maximum possible balance - let _ = Balances::make_free_balance_be(&11, u64::max_value()); - let _ = Balances::make_free_balance_be(&21, u64::max_value()); - - // Give them full exposure as a staker - >::insert(&11, Exposure { total: 1000000, own: 1000000, others: vec![]}); - >::insert(&21, Exposure { total: 2000000, own: 2000000, others: vec![]}); - - // Check things are initialized correctly - assert_eq!(Balances::free_balance(&11), u64::max_value()); - assert_eq!(Balances::free_balance(&21), u64::max_value()); - assert_eq!(Staking::offline_slash_grace(), 0); - // Account 10 will have max unstake_threshold - assert_ok!(Staking::validate(Origin::signed(10), ValidatorPrefs { - unstake_threshold: MAX_UNSTAKE_THRESHOLD, - validator_payment: 0, - })); - // Account 20 could not set their unstake_threshold past 10 - assert_noop!(Staking::validate(Origin::signed(20), ValidatorPrefs { - unstake_threshold: MAX_UNSTAKE_THRESHOLD + 1, - validator_payment: 0}), - "unstake threshold too large" - ); - // Give Account 20 unstake_threshold 11 anyway, should still be limited to 10 - >::insert(21, ValidatorPrefs { - unstake_threshold: MAX_UNSTAKE_THRESHOLD + 1, - validator_payment: 0, - }); - - OfflineSlash::put(Perbill::from_fraction(0.0001)); - - // Report each user 1 more than the max_unstake_threshold - Staking::on_offline_validator(10, MAX_UNSTAKE_THRESHOLD as usize + 1); - Staking::on_offline_validator(20, MAX_UNSTAKE_THRESHOLD as usize + 1); - - // Show that each balance only gets reduced by 2^max_unstake_threshold times 10% - // of their total stake. - assert_eq!(Balances::free_balance(&11), u64::max_value() - 2_u64.pow(MAX_UNSTAKE_THRESHOLD) * 100); - assert_eq!(Balances::free_balance(&21), u64::max_value() - 2_u64.pow(MAX_UNSTAKE_THRESHOLD) * 200); - }); -} - -#[test] -fn slashing_does_not_cause_underflow() { - // Tests that slashing more than a user has does not underflow - with_externalities(&mut ExtBuilder::default().build(), || { - // Verify initial conditions - assert_eq!(Balances::free_balance(&11), 1000); - assert_eq!(Staking::offline_slash_grace(), 0); - - // Set validator preference so that 2^unstake_threshold would cause overflow (greater than 64) - // FIXME: that doesn't overflow. - >::insert(11, ValidatorPrefs { - unstake_threshold: 10, - validator_payment: 0, - }); - - System::set_block_number(1); - Session::on_initialize(System::block_number()); - - // Should not panic - Staking::on_offline_validator(10, 100); - // Confirm that underflow has not occurred, and account balance is set to zero - assert_eq!(Balances::free_balance(&11), 0); - }); -} - #[test] fn rewards_should_work() { // should check that: @@ -750,11 +557,6 @@ fn nominators_also_get_slashed() { // A nominator should be slashed if the validator they nominated is slashed with_externalities(&mut ExtBuilder::default().nominate(false).build(), || { assert_eq!(Staking::validator_count(), 2); - // slash happens immediately. - assert_eq!(Staking::offline_slash_grace(), 0); - // Account 10 has not been reported offline - assert_eq!(Staking::slash_count(&10), 0); - OfflineSlash::put(Perbill::from_percent(12)); // Set payee to controller assert_ok!(Staking::set_payee(Origin::signed(10), RewardDestination::Controller)); @@ -781,9 +583,10 @@ fn nominators_also_get_slashed() { assert_eq!(Balances::total_balance(&2), initial_balance); // 10 goes offline - Staking::on_offline_validator(10, 4); + let slash = 4; + Staking::slash_validator(10, slash); let expo = Staking::stakers(10); - let slash_value = Staking::offline_slash() * expo.total * 2_u64.pow(3); + let slash_value = slash * expo.total * 2_u64.pow(3); let total_slash = expo.total.min(slash_value); let validator_slash = expo.own.min(total_slash); let nominator_slash = nominator_stake.min(total_slash - validator_slash); @@ -1063,7 +866,6 @@ fn validator_payment_prefs_work() { }); >::insert(&2, RewardDestination::Stash); >::insert(&11, ValidatorPrefs { - unstake_threshold: 3, validator_payment: validator_cut }); @@ -1300,13 +1102,6 @@ fn slot_stake_is_least_staked_validator_and_exposure_defines_maximum_punishment( // -- slot stake should also be updated. assert_eq!(Staking::slot_stake(), 69 + total_payout_0/2); - // If 10 gets slashed now, it will be slashed by 5% of exposure.total * 2.pow(unstake_thresh) - Staking::on_offline_validator(10, 4); - // Confirm user has been reported - assert_eq!(Staking::slash_count(&11), 4); - // check the balance of 10 (slash will be deducted from free balance.) - assert_eq!(Balances::free_balance(&11), _11_balance - _11_balance*5/100 * 2u64.pow(3)); - check_exposure_all(); check_nominator_all(); }); @@ -1328,8 +1123,6 @@ fn on_free_balance_zero_stash_removes_validator() { assert_eq!(Staking::bonded(&11), Some(10)); // Set some storage items which we expect to be cleaned up - // Initiate slash count storage item - Staking::on_offline_validator(10, 1); // Set payee information assert_ok!(Staking::set_payee(Origin::signed(10), RewardDestination::Stash)); @@ -1337,7 +1130,6 @@ fn on_free_balance_zero_stash_removes_validator() { assert!(>::exists(&10)); assert!(>::exists(&11)); assert!(>::exists(&11)); - assert!(>::exists(&11)); assert!(>::exists(&11)); // Reduce free_balance of controller to 0 @@ -1352,7 +1144,6 @@ fn on_free_balance_zero_stash_removes_validator() { assert!(>::exists(&10)); assert!(>::exists(&11)); assert!(>::exists(&11)); - assert!(>::exists(&11)); assert!(>::exists(&11)); // Reduce free_balance of stash to 0 @@ -1365,7 +1156,6 @@ fn on_free_balance_zero_stash_removes_validator() { assert!(!>::exists(&11)); assert!(!>::exists(&11)); assert!(!>::exists(&11)); - assert!(!>::exists(&11)); assert!(!>::exists(&11)); }); } @@ -1422,7 +1212,6 @@ fn on_free_balance_zero_stash_removes_nominator() { assert!(!>::exists(&11)); assert!(!>::exists(&11)); assert!(!>::exists(&11)); - assert!(!>::exists(&11)); assert!(!>::exists(&11)); }); } @@ -2070,7 +1859,7 @@ fn reward_validator_slashing_validator_doesnt_overflow() { ]}); // Check slashing - Staking::slash_validator(&11, reward_slash); + Staking::slash_validator(10, reward_slash); assert_eq!(Balances::total_balance(&11), stake - 1); assert_eq!(Balances::total_balance(&2), 1); }) From 9f1cad1efde3c76174dfc76dc615d093d0be6ad1 Mon Sep 17 00:00:00 2001 From: Fredrik Date: Tue, 6 Aug 2019 16:35:00 +0200 Subject: [PATCH 002/191] Initial version of reworked offence module, can report offences --- Cargo.lock | 19 +++++++++ Cargo.toml | 1 + node/runtime/Cargo.toml | 2 + srml/offences/Cargo.toml | 35 ++++++++++++++++ srml/offences/src/lib.rs | 86 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 143 insertions(+) create mode 100644 srml/offences/Cargo.toml create mode 100644 srml/offences/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index e1d9a497939b7..619abe6836a11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2356,6 +2356,7 @@ dependencies = [ "srml-grandpa 2.0.0", "srml-im-online 0.1.0", "srml-indices 2.0.0", + "srml-offences 1.0.0", "srml-session 2.0.0", "srml-staking 2.0.0", "srml-sudo 2.0.0", @@ -3889,6 +3890,24 @@ dependencies = [ "substrate-primitives 2.0.0", ] +[[package]] +name = "srml-offences" +version = "1.0.0" +dependencies = [ + "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", + "sr-primitives 2.0.0", + "sr-std 2.0.0", + "srml-balances 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", + "substrate-primitives 2.0.0", +] + [[package]] name = "srml-session" version = "2.0.0" diff --git a/Cargo.toml b/Cargo.toml index a6a7b8d17ba35..a06d8e0b3c41a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,6 +80,7 @@ members = [ "srml/im-online", "srml/indices", "srml/metadata", + "srml/offences", "srml/session", "srml/staking", "srml/sudo", diff --git a/node/runtime/Cargo.toml b/node/runtime/Cargo.toml index eca7c9ebb79db..4868304d42fc7 100644 --- a/node/runtime/Cargo.toml +++ b/node/runtime/Cargo.toml @@ -35,6 +35,7 @@ timestamp = { package = "srml-timestamp", path = "../../srml/timestamp", default treasury = { package = "srml-treasury", path = "../../srml/treasury", default-features = false } sudo = { package = "srml-sudo", path = "../../srml/sudo", default-features = false } im-online = { package = "srml-im-online", path = "../../srml/im-online", default-features = false } +offences = { package = "srml-offences", path = "../../srml/offences", default-features = false } node-primitives = { path = "../primitives", default-features = false } rustc-hex = { version = "2.0", optional = true } serde = { version = "1.0", optional = true } @@ -81,4 +82,5 @@ std = [ "substrate-keyring", "offchain-primitives/std", "im-online/std", + "offences/std", ] diff --git a/srml/offences/Cargo.toml b/srml/offences/Cargo.toml new file mode 100644 index 0000000000000..06d64361fbf68 --- /dev/null +++ b/srml/offences/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "srml-offences" +version = "1.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +balances = { package = "srml-balances", path = "../balances", default-features = false } +parity-codec = { version = "4.1.1", default-features = false } +rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +serde = { version = "1.0", optional = true } +sr-primitives = { path = "../../core/sr-primitives", default-features = false } +srml-support = { path = "../support", default-features = false } +srml-session = { path = "../session", default-features = false } +system = { package = "srml-system", path = "../system", default-features = false } + +[dev-dependencies] +balances = { package = "srml-balances", path = "../balances" } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +substrate-primitives = { path = "../../core/primitives" } +timestamp = { package = "srml-timestamp", path = "../timestamp" } +srml-staking = { path = "../staking" } + +[features] +default = ["std"] +std = [ + "balances/std", + "parity-codec/std", + "rstd/std", + "serde", + "sr-primitives/std", + "srml-session/std", + "srml-support/std", + "system/std", +] diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs new file mode 100644 index 0000000000000..c249df6d871ec --- /dev/null +++ b/srml/offences/src/lib.rs @@ -0,0 +1,86 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! # Offences Module +//! +//! Tracks reported offences + +// Ensure we're `no_std` when compiling for Wasm. +#![cfg_attr(not(feature = "std"), no_std)] +#![warn(missing_docs, rust_2018_idioms)] + +use srml_support::{ + StorageDoubleMap, Parameter, decl_module, decl_storage, +}; +use parity_codec::{Decode, Encode}; +use rstd::vec::Vec; +use sr_primitives::traits::{Member, TypedKey}; + +/// Offences trait +pub trait Trait: system::Trait { + /// The identifier type for an authority. + type AuthorityId: Member + Parameter + Default + TypedKey + Decode + Encode + AsRef<[u8]>; +} + +// The kind of offence, is a binary representing some kind identifier +// e.g. `b"im-online:off"`, `b"babe:equivocatio"` +// TODO [slashing]: Is there something better we can have here that is more natural but still +// flexible? as you see in examples, they get cut off with long names. +type Kind = [u8; 16]; +// The TimeSlot is the integer identifying for which timeslot this offence matters. For grandpa this +// is a Round ID, for babe it's a block number, for offline it's a SessionIndex. +type TimeSlot = u128; + +decl_storage! { + trait Store for Module as Offences { + /// Offence reports is a double_map of the kind, timeslot to a vec of authorities. + /// It's important that we store all authorities reported for an offence for any kind and + /// timeslot since the slashing will increase based on the length of this vec. + OffenceReports get(offence_reports): double_map Kind, blake2_256(TimeSlot) => Vec; + } +} + +decl_module! { + /// Offences module, currently just responsible for taking offence reports. + pub struct Module for enum Call where origin: T::Origin {} +} + +/// Trait for reporting offences +pub trait OffenceReporter { + /// Report offence for a kind, time_slot and authority + fn report_offence( + kind: Kind, + time_slot: TimeSlot, + authority: AuthorityId, + ) -> (); +} + +impl OffenceReporter for Module { + // Implementation of report_offence, where it checks if an offence is already reported for an + // authority and otherwise stores that report. + // TODO [slashing]: This should probably then trigger the `on_offence` to those listening? + fn report_offence( + kind: Kind, + time_slot: TimeSlot, + authority: T::AuthorityId, + ) -> () { + let mut offending_authorities = >::get(&kind, &time_slot); + if !offending_authorities.contains(&authority) { + offending_authorities.push(authority); + >::insert(&kind, &time_slot, &offending_authorities); + } + } +} From 89e623bbb8bff899649fa38f30f47d4fb86bfa47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Aug 2019 16:46:03 +0200 Subject: [PATCH 003/191] Clean up staking example. --- srml/staking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index e22a56facedee..88b3f508dc100 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -148,7 +148,7 @@ //! /// Slash a validator for an offence. //! pub fn slash_myself(origin) -> Result { //! let reported = ensure_signed(origin)?; -//! >::slash_validator(reported, 1_000); +//! >::slash_validator(reported, 1_000.into()); //! Ok(()) //! } //! } From 0e1d398bd2daf2f9118ad8b1e64b061c96844721 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 16:46:21 +0200 Subject: [PATCH 004/191] Commit SlashingOffence --- srml/support/src/traits.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index aca056eb50a8e..091d52c5c03e9 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -22,7 +22,7 @@ use crate::rstd::{result, marker::PhantomData, ops::Div}; use crate::codec::{Codec, Encode, Decode}; use substrate_primitives::u32_trait::Value as U32; use crate::runtime_primitives::traits::{MaybeSerializeDebug, SimpleArithmetic, Saturating}; -use crate::runtime_primitives::ConsensusEngineId; +use crate::runtime_primitives::{ConsensusEngineId, Perbill}; use super::for_each_tuple; @@ -640,3 +640,31 @@ pub trait ChangeMembers { impl ChangeMembers for () { fn change_members(_incoming: &[T], _outgoing: &[T], _new_set: &[T]) {} } + +/// A trait that is implemented by each kind of offence. +pub trait SlashingOffence { + /// Identifier which is unique for this kind of an offence. + const ID: [u8; 16]; + + /// What is the session index this offence happened in. + /// + /// The value returned by this function is going to be used for querying the validator set for + /// for the `slash_percentage` function. If the session index cannot be pinpointed precisely (as + /// in case with GRANDPA offences) then this function should return the closest session index + /// with the same validator set. + fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. + + /// A point in time when this offence happened. + /// + /// The timescale is abstract and it doesn't have to be the same across different + /// implementations of this trait. For example, for GRANDPA it could represent a round number + /// and for BABE it could be a slot number. + fn time_slot(&self) -> u128; // TODO [slashing]: Should be a TimeSlot. + + /// A percentage of the total exposure that should be slashed for this + /// particular offence kind for the given parameters. + /// + /// `offenders` - the number of offences of this kind at the particular `time_slot`. + /// `validators_count` - the cardinality of the validator set at the time of offence. + fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill; +} From d5c9cd1e6b5d5a06a0f87324df4701ee0682bf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Aug 2019 17:11:46 +0200 Subject: [PATCH 005/191] Force new era on slash. --- srml/staking/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 88b3f508dc100..d20a41d3c43f1 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1005,8 +1005,8 @@ impl Module { let own_slash = exposure.own.min(slash); let (mut imbalance, missing) = T::Currency::slash(&stash, own_slash); let own_slash = own_slash - missing; - // The amount remaining that we can't slash from the validator, that must be taken from the - // nominators. + // The amount remaining that we can't slash from the validator, + // that must be taken from the nominators. let rest_slash = slash - own_slash; if !rest_slash.is_zero() { // The total to be slashed from the nominators. @@ -1021,6 +1021,7 @@ impl Module { } T::Slash::on_unbalanced(imbalance); let _ = T::SessionInterface::disable_validator(&stash); + Self::apply_force_new_era(); } } From 45e59073345cb8a2dd936b9a1148bfc62678a96f Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 17:34:25 +0200 Subject: [PATCH 006/191] Add offenders in the SlashingOffence trait. --- srml/support/src/traits.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index 091d52c5c03e9..62fe49109c353 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -642,10 +642,15 @@ impl ChangeMembers for () { } /// A trait that is implemented by each kind of offence. -pub trait SlashingOffence { +pub trait SlashingOffence { /// Identifier which is unique for this kind of an offence. const ID: [u8; 16]; + /// The list of all offenders involved in this incident. + /// + /// The list has no duplicates, so it is rather a set. + fn offenders(&self) -> Vec; + /// What is the session index this offence happened in. /// /// The value returned by this function is going to be used for querying the validator set for From b93118f70fee48611ea6cc0083a947c6204dab50 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 17:34:38 +0200 Subject: [PATCH 007/191] Introduce the ReportOffence trait. --- srml/offences/src/lib.rs | 39 ++++++++++++++++---------------------- srml/support/src/traits.rs | 5 +++++ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index c249df6d871ec..b1445e7a68a1c 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -20,10 +20,11 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -#![warn(missing_docs, rust_2018_idioms)] +#![warn(missing_docs)] use srml_support::{ StorageDoubleMap, Parameter, decl_module, decl_storage, + traits::{SlashingOffence, ReportOffence}, }; use parity_codec::{Decode, Encode}; use rstd::vec::Vec; @@ -58,29 +59,21 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -/// Trait for reporting offences -pub trait OffenceReporter { - /// Report offence for a kind, time_slot and authority - fn report_offence( - kind: Kind, - time_slot: TimeSlot, - authority: AuthorityId, - ) -> (); -} - -impl OffenceReporter for Module { +impl> ReportOffence + for Module +{ // Implementation of report_offence, where it checks if an offence is already reported for an // authority and otherwise stores that report. - // TODO [slashing]: This should probably then trigger the `on_offence` to those listening? - fn report_offence( - kind: Kind, - time_slot: TimeSlot, - authority: T::AuthorityId, - ) -> () { - let mut offending_authorities = >::get(&kind, &time_slot); - if !offending_authorities.contains(&authority) { - offending_authorities.push(authority); - >::insert(&kind, &time_slot, &offending_authorities); - } + fn report_offence(_reporters: &[T::AuthorityId], offence: &O) { + let offenders = offence.offenders(); + let time_slot = offence.time_slot(); + + >::mutate(&O::ID, &time_slot, |offending_authorities| { + for offender in offenders { + if !offending_authorities.contains(&offender) { + offending_authorities.push(offender); + } + } + }); } } diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index 62fe49109c353..16db030b7cf0f 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -673,3 +673,8 @@ pub trait SlashingOffence { /// `validators_count` - the cardinality of the validator set at the time of offence. fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill; } + +pub trait ReportOffence> { + /// Report an offence from the given `reporters`. + fn report_offence(reporters: &[Reporter], offence: &Offence); +} From 051001a3644cfece663c2a06f22ceb042cb48bd9 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 17:48:05 +0200 Subject: [PATCH 008/191] Rename `Offence`. --- srml/offences/src/lib.rs | 4 ++-- srml/support/src/traits.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index b1445e7a68a1c..2d7287a795990 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -24,7 +24,7 @@ use srml_support::{ StorageDoubleMap, Parameter, decl_module, decl_storage, - traits::{SlashingOffence, ReportOffence}, + traits::{Offence, ReportOffence}, }; use parity_codec::{Decode, Encode}; use rstd::vec::Vec; @@ -59,7 +59,7 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -impl> ReportOffence +impl> ReportOffence for Module { // Implementation of report_offence, where it checks if an offence is already reported for an diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index 16db030b7cf0f..255a30e48315a 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -641,8 +641,10 @@ impl ChangeMembers for () { fn change_members(_incoming: &[T], _outgoing: &[T], _new_set: &[T]) {} } -/// A trait that is implemented by each kind of offence. -pub trait SlashingOffence { +/// A trait implemented by an offence report. +/// +/// Examples of offences include: a BABE equivocation or a GRANDPA unjustified vote. +pub trait Offence { /// Identifier which is unique for this kind of an offence. const ID: [u8; 16]; @@ -674,7 +676,8 @@ pub trait SlashingOffence { fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill; } -pub trait ReportOffence> { - /// Report an offence from the given `reporters`. - fn report_offence(reporters: &[Reporter], offence: &Offence); +/// A trait for decoupling offence reporters from the actual handling of offence reports. +pub trait ReportOffence> { + /// Report an `offence` from the given `reporters`. + fn report_offence(reporters: &[Reporter], offence: &O); } From 2dae936ad7fc9d6fcafa2eced74f558234f1a22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Aug 2019 17:57:34 +0200 Subject: [PATCH 009/191] Add on_before_session_ending handler. --- srml/session/src/lib.rs | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/srml/session/src/lib.rs b/srml/session/src/lib.rs index 8589f92006d88..700b585f5db4b 100644 --- a/srml/session/src/lib.rs +++ b/srml/session/src/lib.rs @@ -168,6 +168,7 @@ impl< } /// An event handler for when the session is ending. +/// TODO [slashing] consider renaming to OnSessionStarting pub trait OnSessionEnding { /// Handle the fact that the session is ending, and optionally provide the new validator set. /// @@ -182,7 +183,7 @@ impl OnSessionEnding for () { fn on_session_ending(_: SessionIndex, _: SessionIndex) -> Option> { None } } -/// Handler for when a session keys set changes. +/// Handler for session lifecycle events. pub trait SessionHandler { /// Session set has changed; act appropriately. fn on_new_session( @@ -191,24 +192,45 @@ pub trait SessionHandler { queued_validators: &[(ValidatorId, Ks)], ); + /// A notification for end of the session. + /// + /// Note it is triggered before any `OnSessionEnding` handlers, + /// so we can still affect the validator set. + fn on_before_session_ending(); + /// A validator got disabled. Act accordingly until a new session begins. fn on_disabled(validator_index: usize); } -/// One session-key type handler. +/// A session handler for specific key type. pub trait OneSessionHandler { /// The key type expected. type Key: Decode + Default + TypedKey; - fn on_new_session<'a, I: 'a>(changed: bool, validators: I, queued_validators: I) - where I: Iterator, ValidatorId: 'a; - fn on_disabled(i: usize); + /// Session set has changed; act appropriately. + fn on_new_session<'a, I: 'a>( + _changed: bool, + _validators: I, + _queued_validators: I + ) where I: Iterator, ValidatorId: 'a; + + + /// A notification for end of the session. + /// + /// Note it is triggered before any `OnSessionEnding` handlers, + /// so we can still affect the validator set. + fn on_before_session_ending(); + + /// A validator got disabled. Act accordingly until a new session begins. + fn on_disabled(_validator_index: usize); + } macro_rules! impl_session_handlers { () => ( impl SessionHandler for () { fn on_new_session(_: bool, _: &[(AId, Ks)], _: &[(AId, Ks)]) {} + fn on_before_session_ending() {} fn on_disabled(_: usize) {} } ); @@ -230,6 +252,13 @@ macro_rules! impl_session_handlers { $t::on_new_session(changed, our_keys, queued_keys); )* } + + fn on_before_session_ending() { + $( + $t::on_before_session_ending(); + )* + } + fn on_disabled(i: usize) { $( $t::on_disabled(i); From 5c3a2493c40f469dd22b65d95c58467aa989487f Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 18:11:42 +0200 Subject: [PATCH 010/191] Move offence related stuff under sr-primitives. --- core/sr-primitives/src/lib.rs | 1 + core/sr-primitives/src/offence.rs | 75 +++++++++++++++++++++++++++++++ srml/offences/src/lib.rs | 19 +++----- srml/support/src/traits.rs | 43 +----------------- 4 files changed, 83 insertions(+), 55 deletions(-) create mode 100644 core/sr-primitives/src/offence.rs diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index 922fe7f9defdb..383e27e542dd3 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -47,6 +47,7 @@ use traits::{SaturatedConversion, UniqueSaturatedInto, Saturating, Bounded, Chec pub mod generic; pub mod transaction_validity; +pub mod offence; /// Re-export these since they're only "kind of" generic. pub use generic::{DigestItem, Digest}; diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs new file mode 100644 index 0000000000000..477f76345d6ad --- /dev/null +++ b/core/sr-primitives/src/offence.rs @@ -0,0 +1,75 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Common traits and types that are useful for describing offences for usage in environments +//! that use staking. + +use crate::Perbill; + +/// The kind of an offence, is a byte string representing some kind identifier +/// e.g. `b"im-online:off"`, `b"babe:equivocatio"` +// TODO [slashing]: Is there something better we can have here that is more natural but still +// flexible? as you see in examples, they get cut off with long names. +pub type Kind = [u8; 16]; + +/// A type that represents a point in time on an abstract timescale. +/// +/// This type is not tied to a particular timescale and can be used for representing instants on +/// different timescales. Examples of such timescales would be the following: for GRANDPA is a round +/// ID, for BABE it's a slot number and for offline it's a session index. The only requirement is +/// that such timescale could be represented by a single `u128` value. +pub type TimeSlot = u128; + +/// A trait implemented by an offence report. +/// +/// Examples of offences include: a BABE equivocation or a GRANDPA unjustified vote. +pub trait Offence { + /// Identifier which is unique for this kind of an offence. + const ID: Kind; + + /// The list of all offenders involved in this incident. + /// + /// The list has no duplicates, so it is rather a set. + fn offenders(&self) -> Vec; + + /// What is the session index this offence happened in. + /// + /// The value returned by this function is going to be used for querying the validator set for + /// for the `slash_percentage` function. If the session index cannot be pinpointed precisely (as + /// in case with GRANDPA offences) then this function should return the closest session index + /// with the same validator set. + fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. + + /// A point in time when this offence happened. + /// + /// The timescale is abstract and it doesn't have to be the same across different + /// implementations of this trait. For example, for GRANDPA it could represent a round number + /// and for BABE it could be a slot number. + fn time_slot(&self) -> TimeSlot; + + /// A percentage of the total exposure that should be slashed for this + /// particular offence kind for the given parameters. + /// + /// `offenders` - the number of offences of this kind at the particular `time_slot`. + /// `validators_count` - the cardinality of the validator set at the time of offence. + fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill; +} + +/// A trait for decoupling offence reporters from the actual handling of offence reports. +pub trait ReportOffence> { + /// Report an `offence` from the given `reporters`. + fn report_offence(reporters: &[Reporter], offence: &O); +} diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 2d7287a795990..1b19c11e6147d 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -24,11 +24,13 @@ use srml_support::{ StorageDoubleMap, Parameter, decl_module, decl_storage, - traits::{Offence, ReportOffence}, }; use parity_codec::{Decode, Encode}; use rstd::vec::Vec; -use sr_primitives::traits::{Member, TypedKey}; +use sr_primitives::{ + traits::{Member, TypedKey}, + offence::{Offence, ReportOffence, TimeSlot, Kind}, +}; /// Offences trait pub trait Trait: system::Trait { @@ -36,15 +38,6 @@ pub trait Trait: system::Trait { type AuthorityId: Member + Parameter + Default + TypedKey + Decode + Encode + AsRef<[u8]>; } -// The kind of offence, is a binary representing some kind identifier -// e.g. `b"im-online:off"`, `b"babe:equivocatio"` -// TODO [slashing]: Is there something better we can have here that is more natural but still -// flexible? as you see in examples, they get cut off with long names. -type Kind = [u8; 16]; -// The TimeSlot is the integer identifying for which timeslot this offence matters. For grandpa this -// is a Round ID, for babe it's a block number, for offline it's a SessionIndex. -type TimeSlot = u128; - decl_storage! { trait Store for Module as Offences { /// Offence reports is a double_map of the kind, timeslot to a vec of authorities. @@ -62,12 +55,12 @@ decl_module! { impl> ReportOffence for Module { - // Implementation of report_offence, where it checks if an offence is already reported for an - // authority and otherwise stores that report. fn report_offence(_reporters: &[T::AuthorityId], offence: &O) { let offenders = offence.offenders(); let time_slot = offence.time_slot(); + // Check if an offence is already reported for the offender authorities and otherwise stores + // that report. >::mutate(&O::ID, &time_slot, |offending_authorities| { for offender in offenders { if !offending_authorities.contains(&offender) { diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index 255a30e48315a..aca056eb50a8e 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -22,7 +22,7 @@ use crate::rstd::{result, marker::PhantomData, ops::Div}; use crate::codec::{Codec, Encode, Decode}; use substrate_primitives::u32_trait::Value as U32; use crate::runtime_primitives::traits::{MaybeSerializeDebug, SimpleArithmetic, Saturating}; -use crate::runtime_primitives::{ConsensusEngineId, Perbill}; +use crate::runtime_primitives::ConsensusEngineId; use super::for_each_tuple; @@ -640,44 +640,3 @@ pub trait ChangeMembers { impl ChangeMembers for () { fn change_members(_incoming: &[T], _outgoing: &[T], _new_set: &[T]) {} } - -/// A trait implemented by an offence report. -/// -/// Examples of offences include: a BABE equivocation or a GRANDPA unjustified vote. -pub trait Offence { - /// Identifier which is unique for this kind of an offence. - const ID: [u8; 16]; - - /// The list of all offenders involved in this incident. - /// - /// The list has no duplicates, so it is rather a set. - fn offenders(&self) -> Vec; - - /// What is the session index this offence happened in. - /// - /// The value returned by this function is going to be used for querying the validator set for - /// for the `slash_percentage` function. If the session index cannot be pinpointed precisely (as - /// in case with GRANDPA offences) then this function should return the closest session index - /// with the same validator set. - fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. - - /// A point in time when this offence happened. - /// - /// The timescale is abstract and it doesn't have to be the same across different - /// implementations of this trait. For example, for GRANDPA it could represent a round number - /// and for BABE it could be a slot number. - fn time_slot(&self) -> u128; // TODO [slashing]: Should be a TimeSlot. - - /// A percentage of the total exposure that should be slashed for this - /// particular offence kind for the given parameters. - /// - /// `offenders` - the number of offences of this kind at the particular `time_slot`. - /// `validators_count` - the cardinality of the validator set at the time of offence. - fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill; -} - -/// A trait for decoupling offence reporters from the actual handling of offence reports. -pub trait ReportOffence> { - /// Report an `offence` from the given `reporters`. - fn report_offence(reporters: &[Reporter], offence: &O); -} From aaa8159daa037204b3488e8ba9cc6f9c3a1b8688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Aug 2019 18:21:10 +0200 Subject: [PATCH 011/191] Fix cargo check. --- core/sr-primitives/src/offence.rs | 2 +- node/cli/src/chain_spec.rs | 6 +----- srml/im-online/src/lib.rs | 4 ++++ srml/offences/src/lib.rs | 6 ++++++ srml/session/src/lib.rs | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 477f76345d6ad..5b9ee34d33973 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -43,7 +43,7 @@ pub trait Offence { /// The list of all offenders involved in this incident. /// /// The list has no duplicates, so it is rather a set. - fn offenders(&self) -> Vec; + fn offenders(&self) -> rstd::vec::Vec; /// What is the session index this offence happened in. /// diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 26e54f6ee650c..4f46972d9de00 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -21,7 +21,7 @@ use primitives::{ed25519, sr25519, Pair, crypto::UncheckedInto}; use node_primitives::{AccountId, Balance}; use node_runtime::{ BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig, - ElectionsConfig, GrandpaConfig, ImOnlineConfig, IndicesConfig, Perbill, + ElectionsConfig, GrandpaConfig, ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, WASM_BINARY, }; @@ -127,9 +127,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig { }), staking: Some(StakingConfig { current_era: 0, - offline_slash: Perbill::from_parts(1_000_000), validator_count: 7, - offline_slash_grace: 4, minimum_validator_count: 4, stakers: initial_authorities.iter().map(|x| { (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator) @@ -267,8 +265,6 @@ pub fn testnet_genesis( current_era: 0, minimum_validator_count: 1, validator_count: 2, - offline_slash: Perbill::zero(), - offline_slash_grace: 0, stakers: initial_authorities.iter().map(|x| { (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator) }).collect(), diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 7898fea8eb733..f90f542c56939 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -395,6 +395,10 @@ impl session::OneSessionHandler for Module { Self::new_session(); } + fn on_before_session_ending() { + // ignore + } + fn on_disabled(_i: usize) { // ignore } diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 1b19c11e6147d..704e1711ba514 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -63,10 +63,16 @@ impl> ReportOffence>::mutate(&O::ID, &time_slot, |offending_authorities| { for offender in offenders { + // TODO [slashing] This prevents slashing for multiple reports of the same kind at the same slot, + // note however that we might do that in the future if the reports are not exactly the same (dups). + // De-duplication of reports is tricky though, we need a canonical form of the report + // (for instance babe equivocation can have headers swapped). if !offending_authorities.contains(&offender) { offending_authorities.push(offender); + // TODO [slashing] trigger on_offence and calculate amounts } } }); + } } diff --git a/srml/session/src/lib.rs b/srml/session/src/lib.rs index 700b585f5db4b..1bb1e6613d00d 100644 --- a/srml/session/src/lib.rs +++ b/srml/session/src/lib.rs @@ -196,7 +196,7 @@ pub trait SessionHandler { /// /// Note it is triggered before any `OnSessionEnding` handlers, /// so we can still affect the validator set. - fn on_before_session_ending(); + fn on_before_session_ending() {} /// A validator got disabled. Act accordingly until a new session begins. fn on_disabled(validator_index: usize); @@ -219,7 +219,7 @@ pub trait OneSessionHandler { /// /// Note it is triggered before any `OnSessionEnding` handlers, /// so we can still affect the validator set. - fn on_before_session_ending(); + fn on_before_session_ending() {} /// A validator got disabled. Act accordingly until a new session begins. fn on_disabled(_validator_index: usize); From 06ee8131f44163518963b2c2f4cf636aa40f9c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 6 Aug 2019 18:46:44 +0200 Subject: [PATCH 012/191] Import new im-online implementation. --- node/cli/src/chain_spec.rs | 8 +- node/runtime/src/lib.rs | 5 +- srml/im-online/Cargo.toml | 15 +- srml/im-online/src/lib.rs | 491 +++++++++++++++++++------------------ 4 files changed, 262 insertions(+), 257 deletions(-) diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 4f46972d9de00..37281d02b70c8 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -161,7 +161,8 @@ fn staging_testnet_config_genesis() -> GenesisConfig { }), im_online: Some(ImOnlineConfig { gossip_at: 0, - last_new_era_start: 0, + // TODO [slashing] merge with gav-in-progress + keys: vec![], }), grandpa: Some(GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.3.clone(), 1)).collect(), @@ -300,9 +301,10 @@ pub fn testnet_genesis( babe: Some(BabeConfig { authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(), }), - im_online: Some(ImOnlineConfig{ + im_online: Some(ImOnlineConfig { gossip_at: 0, - last_new_era_start: 0, + // TODO [slashing] merge with gav-in-progress + keys: vec![], }), grandpa: Some(GrandpaConfig { authorities: initial_authorities.iter().map(|x| (x.3.clone(), 1)).collect(), diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index c2e05f1cb5507..33ccf9f67a9d6 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -368,12 +368,9 @@ impl sudo::Trait for Runtime { } impl im_online::Trait for Runtime { - type AuthorityId = BabeId; type Call = Call; type Event = Event; - type SessionsPerEra = SessionsPerEra; type UncheckedExtrinsic = UncheckedExtrinsic; - type IsValidAuthorityId = Babe; } impl grandpa::Trait for Runtime { @@ -414,7 +411,7 @@ construct_runtime!( Treasury: treasury::{Module, Call, Storage, Event}, Contracts: contracts, Sudo: sudo, - ImOnline: im_online::{default, ValidateUnsigned}, + ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, } ); diff --git a/srml/im-online/Cargo.toml b/srml/im-online/Cargo.toml index 5ca5e0c533d19..e0a70e8817f9f 100644 --- a/srml/im-online/Cargo.toml +++ b/srml/im-online/Cargo.toml @@ -6,24 +6,25 @@ edition = "2018" [dependencies] parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] } -primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } -rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } serde = { version = "1.0", optional = true } session = { package = "srml-session", path = "../session", default-features = false } +sr-io = { path = "../../core/sr-io", default-features = false } +sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-std = { path = "../../core/sr-std", default-features = false } srml-support = { path = "../support", default-features = false } -sr-io = { package = "sr-io", path = "../../core/sr-io", default-features = false } -substrate_primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } +substrate-primitives = { path = "../../core/primitives", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } [features] default = ["std"] std = [ "parity-codec/std", - "primitives/std", - "rstd/std", "serde", "session/std", - "srml-support/std", "sr-io/std", + "sr-primitives/std", + "sr-std/std", + "srml-support/std", + "substrate-primitives/std", "system/std", ] diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index f90f542c56939..9a70ce42357b0 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -37,7 +37,6 @@ //! //! ### Public Functions //! -//! - `is_online_in_current_era` - True if the validator sent a heartbeat in the current era. //! - `is_online_in_current_session` - True if the validator sent a heartbeat in the current session. //! //! ## Usage @@ -51,9 +50,9 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn is_online(origin, authority_id: T::AuthorityId) -> Result { +//! pub fn is_online(origin, authority_index: u32) -> Result { //! let _sender = ensure_signed(origin)?; -//! let _is_online = >::is_online_in_current_era(&authority_id); +//! let _is_online = >::is_online_in_current_session(authority_index); //! Ok(()) //! } //! } @@ -69,25 +68,49 @@ #![cfg_attr(not(feature = "std"), no_std)] use substrate_primitives::{ - crypto::TypedKey, offchain::CryptoKey, - offchain::OpaqueNetworkState, - offchain::StorageKind, - sr25519, ed25519, + //crypto::{CryptoType, KeyTypeId}, + offchain::{self, OpaqueNetworkState, StorageKind}, }; use parity_codec::{Encode, Decode}; -use primitives::{ - ApplyError, traits::{Member, IsMember, Extrinsic as ExtrinsicT}, +use session::SessionIndex; +use sr_primitives::{ + ApplyError, traits::{Extrinsic as ExtrinsicT}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, }; -use rstd::prelude::*; -use session::SessionIndex; +use sr_std::prelude::*; use sr_io::Printable; use srml_support::{ - Parameter, StorageValue, decl_module, decl_event, decl_storage, - traits::Get, StorageDoubleMap, print, + StorageValue, decl_module, decl_event, decl_storage, + StorageDoubleMap, print, }; use system::ensure_none; +mod app { +// TODO [slashing] +// pub use app_crypto::sr25519 as crypto; +// use app_crypto::{app_crypto, key_types::IM_ONLINE, sr25519}; +// +// app_crypto!(sr25519, IM_ONLINE); + pub use substrate_primitives::sr25519 as crypto; + #[cfg(feature = "std")] + pub use self::crypto::{Pair, Public, Signature}; + #[cfg(not(feature = "std"))] + pub use self::crypto::{Public, Signature}; +// TODO [slashing] +} + +/// A Babe authority keypair. Necessarily equivalent to the schnorrkel public key used in +/// the main Babe module. If that ever changes, then this must, too. +#[cfg(feature = "std")] +pub type AuthorityPair = app::Pair; + +/// A Babe authority signature. +pub type AuthoritySignature = app::Signature; + +/// A Babe authority identifier. Necessarily equivalent to the schnorrkel public key used in +/// the main Babe module. If that ever changes, then this must, too. +pub type AuthorityId = app::Public; + // The local storage database key under which the worker progress status // is tracked. const DB_KEY: &[u8] = b"srml/im-online-worker-status"; @@ -106,8 +129,8 @@ struct WorkerStatus { // Error which may occur while executing the off-chain code. enum OffchainErr { - DecodeAuthorityId, DecodeWorkerStatus, + NoKeys, ExtrinsicCreation, FailedSigning, NetworkState, @@ -117,8 +140,8 @@ enum OffchainErr { impl Printable for OffchainErr { fn print(self) { match self { - OffchainErr::DecodeAuthorityId => print("Offchain error: decoding AuthorityId failed!"), OffchainErr::DecodeWorkerStatus => print("Offchain error: decoding WorkerStatus failed!"), + OffchainErr::NoKeys => print("Offchain error: could not find local keys!"), OffchainErr::ExtrinsicCreation => print("Offchain error: extrinsic creation failed!"), OffchainErr::FailedSigning => print("Offchain error: signing failed!"), OffchainErr::NetworkState => print("Offchain error: fetching network state failed!"), @@ -127,272 +150,260 @@ impl Printable for OffchainErr { } } -/// Heartbeat which is send/received. +pub type AuthIndex = u32; + +/// Heartbeat which is sent/received. #[derive(Encode, Decode, Clone, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] -pub struct Heartbeat +pub struct Heartbeat where BlockNumber: PartialEq + Eq + Decode + Encode, { block_number: BlockNumber, network_state: OpaqueNetworkState, - session_index: session::SessionIndex, - authority_id: AuthorityId, + session_index: SessionIndex, + authority_index: AuthIndex, } pub trait Trait: system::Trait + session::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From + Into<::Event>; /// The function call. type Call: From>; /// A extrinsic right from the external world. This is unchecked and so /// can contain a signature. - type UncheckedExtrinsic: ExtrinsicT + Encode + Decode; - - /// The identifier type for an authority. - type AuthorityId: Member + Parameter + Default + TypedKey + Decode + Encode + AsRef<[u8]>; - - /// Number of sessions per era. - type SessionsPerEra: Get; - - /// Determine if an `AuthorityId` is a valid authority. - type IsValidAuthorityId: IsMember; + type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; } decl_event!( - pub enum Event where - ::BlockNumber, - ::AuthorityId - { - /// A new heartbeat was received at this `BlockNumber` from `AuthorityId` - HeartbeatReceived(BlockNumber, AuthorityId), + pub enum Event { + /// A new heartbeat was received from `AuthorityId` + HeartbeatReceived(AuthorityId), } ); decl_storage! { trait Store for Module as ImOnline { - // The block number when we should gossip. + /// The block number when we should gossip. GossipAt get(gossip_at) config(): T::BlockNumber; - // The session index when the last new era started. - LastNewEraStart get(last_new_era_start) config(): Option; + /// The current set of keys that may issue a heartbeat. + Keys get(keys) config(): Vec; - // For each session index we keep a mapping of `AuthorityId` to - // `offchain::OpaqueNetworkState`. - ReceivedHeartbeats get(received_heartbeats): double_map session::SessionIndex, - blake2_256(T::AuthorityId) => Vec; + /// For each session index we keep a mapping of `AuthorityId` + /// to `offchain::OpaqueNetworkState`. + ReceivedHeartbeats get(received_heartbeats): double_map SessionIndex, + blake2_256(AuthIndex) => Vec; } } + decl_module! { pub struct Module for enum Call where origin: T::Origin { - /// Number of sessions per era. - const SessionsPerEra: session::SessionIndex = T::SessionsPerEra::get(); - - fn deposit_event() = default; + fn deposit_event() = default; fn heartbeat( origin, - heartbeat: Heartbeat, - _signature: Vec + heartbeat: Heartbeat, + _signature: AuthoritySignature ) { ensure_none(origin)?; let current_session = >::current_index(); - let exists = >::exists(¤t_session, &heartbeat.authority_id); - if !exists { - let now = >::block_number(); - Self::deposit_event(RawEvent::HeartbeatReceived(now, heartbeat.authority_id.clone())); + let exists = ::exists( + ¤t_session, + &heartbeat.authority_index + ); + let keys = Keys::get(); + let public = keys.get(heartbeat.authority_index as usize); + if let (true, Some(public)) = (!exists, public) { + Self::deposit_event(Event::HeartbeatReceived(public.clone())); let network_state = heartbeat.network_state.encode(); - >::insert(¤t_session, &heartbeat.authority_id, &network_state); + ::insert( + ¤t_session, + &heartbeat.authority_index, + &network_state + ); } } // Runs after every block. fn offchain_worker(now: T::BlockNumber) { - fn gossip_at(block_number: T::BlockNumber) -> Result<(), OffchainErr> { - // we run only when a local authority key is configured - if let Ok(key) = sr_io::pubkey(CryptoKey::AuthorityKey) { - let authority_id = ::AuthorityId::decode(&mut &key[..]) - .ok_or(OffchainErr::DecodeAuthorityId)?; - let network_state = - sr_io::network_state().map_err(|_| OffchainErr::NetworkState)?; - let heartbeat_data = Heartbeat { - block_number, - network_state, - session_index: >::current_index(), - authority_id, - }; - - let signature = sr_io::sign(CryptoKey::AuthorityKey, &heartbeat_data.encode()) - .map_err(|_| OffchainErr::FailedSigning)?; - let call = Call::heartbeat(heartbeat_data, signature); - let ex = T::UncheckedExtrinsic::new_unsigned(call.into()) - .ok_or(OffchainErr::ExtrinsicCreation)?; - sr_io::submit_transaction(&ex) - .map_err(|_| OffchainErr::SubmitTransaction)?; - - // once finished we set the worker status without comparing - // if the existing value changed in the meantime. this is - // because at this point the heartbeat was definitely submitted. - set_worker_status::(block_number, true); - } - Ok(()) - } - - fn compare_and_set_worker_status( - gossipping_at: T::BlockNumber, - done: bool, - curr_worker_status: Option>, - ) -> bool { - let enc = WorkerStatus { - done, - gossipping_at, - }; - sr_io::local_storage_compare_and_set( - StorageKind::PERSISTENT, - DB_KEY, - curr_worker_status.as_ref().map(Vec::as_slice), - &enc.encode() - ) - } + Self::offchain(now); + } + } +} - fn set_worker_status( - gossipping_at: T::BlockNumber, - done: bool, - ) { - let enc = WorkerStatus { - done, - gossipping_at, - }; - sr_io::local_storage_set( - StorageKind::PERSISTENT, DB_KEY, &enc.encode()); - } +impl Module { + /// Returns `true` if a heartbeat has been received for the authority at `authority_index` in + /// the authorities series, during the current session. Otherwise `false`. + pub fn is_online_in_current_session(authority_index: AuthIndex) -> bool { + let current_session = >::current_index(); + ::exists(¤t_session, &authority_index) + } - // Checks if a heartbeat gossip already occurred at this block number. - // Returns a tuple of `(current worker status, bool)`, whereby the bool - // is true if not yet gossipped. - fn check_not_yet_gossipped( - now: T::BlockNumber, - next_gossip: T::BlockNumber, - ) -> Result<(Option>, bool), OffchainErr> { - let last_gossip = sr_io::local_storage_get(StorageKind::PERSISTENT, DB_KEY); - match last_gossip { - Some(last) => { - let worker_status: WorkerStatus = Decode::decode(&mut &last[..]) - .ok_or(OffchainErr::DecodeWorkerStatus)?; - - let was_aborted = !worker_status.done && worker_status.gossipping_at < now; - - // another off-chain worker is currently in the process of submitting - let already_submitting = - !worker_status.done && worker_status.gossipping_at == now; - - let not_yet_gossipped = - worker_status.done && worker_status.gossipping_at < next_gossip; - - let ret = (was_aborted && !already_submitting) || not_yet_gossipped; - Ok((Some(last), ret)) - }, - None => Ok((None, true)), - } + fn offchain(now: T::BlockNumber) { + let next_gossip = >::get(); + let check = Self::check_not_yet_gossipped(now, next_gossip); + let (curr_worker_status, not_yet_gossipped) = match check { + Ok((s, v)) => (s, v), + Err(err) => { + print(err); + return; + }, + }; + if next_gossip < now && not_yet_gossipped { + let value_set = Self::compare_and_set_worker_status(now, false, curr_worker_status); + if !value_set { + // value could not be set in local storage, since the value was + // different from `curr_worker_status`. this indicates that + // another worker was running in parallel. + return; } - let next_gossip = >::get(); - let check = check_not_yet_gossipped::(now, next_gossip); - let (curr_worker_status, not_yet_gossipped) = match check { - Ok((s, v)) => (s, v), - Err(err) => { - print(err); - return; - }, - }; - if next_gossip < now && not_yet_gossipped { - let value_set = compare_and_set_worker_status::(now, false, curr_worker_status); - if !value_set { - // value could not be set in local storage, since the value was - // different from `curr_worker_status`. this indicates that - // another worker was running in parallel. - return; - } - - match gossip_at::(now) { - Ok(_) => {}, - Err(err) => print(err), - } + match Self::do_gossip_at(now) { + Ok(_) => {}, + Err(err) => print(err), } } } -} -impl Module { - /// Returns `true` if a heartbeat has been received for `AuthorityId` - /// during the current era. Otherwise `false`. - pub fn is_online_in_current_era(authority_id: &T::AuthorityId) -> bool { - let curr = >::current_index(); - match LastNewEraStart::get() { - Some(start) => { - // iterate over every session - for index in start..curr { - if >::exists(&index, authority_id) { - return true; - } - } - false - }, - None => >::exists(&curr, authority_id), + fn do_gossip_at(block_number: T::BlockNumber) -> Result<(), OffchainErr> { + // we run only when a local authority key is configured + + // TODO [slashing] + // let key_type = KeyTypeId(*b"imon"); + // let local_keys = sr_io::public_keys(AuthorityId::KIND, key_type) + // .map_err(|_| OffchainErr::NoKeys)?; + let local_keys = vec![ + sr_io::pubkey(offchain::CryptoKey::AuthorityKey) + .map_err(|_| OffchainErr::NoKeys)? + ]; + // TODO [slashing] + + let authorities = Keys::get(); + let maybe_key = authorities.into_iter() + .enumerate() + .filter_map(|(index, id)| { + let id = app::crypto::Public::from(id); + let id_slice: &[u8] = id.as_ref(); + + local_keys + .iter() + // TODO [slashing] + //.find(|k| &*k.public == id_slice) + .find(|k| k.as_slice() == id_slice) + // TODO [slashing] + .map(|key| (index as u32, key.clone())) + }) + .next(); + if let Some((authority_index, key)) = maybe_key { + let network_state = + sr_io::network_state().map_err(|_| OffchainErr::NetworkState)?; + let heartbeat_data = Heartbeat { + block_number, + network_state, + session_index: >::current_index(), + authority_index, + }; + + // TODO [slashing] + let key = offchain::CryptoKey::AuthorityKey; + // TODO [slashing] + let signature = sr_io::sign(key, &heartbeat_data.encode()) + .map_err(|_| OffchainErr::FailedSigning)?; + let signature = AuthoritySignature::decode(&mut &*signature) + .ok_or(OffchainErr::ExtrinsicCreation)?; + let call = Call::heartbeat(heartbeat_data, signature); + let ex = T::UncheckedExtrinsic::new_unsigned(call.into()) + .ok_or(OffchainErr::ExtrinsicCreation)?; + sr_io::submit_transaction(&ex) + .map_err(|_| OffchainErr::SubmitTransaction)?; + + // once finished we set the worker status without comparing + // if the existing value changed in the meantime. this is + // because at this point the heartbeat was definitely submitted. + Self::set_worker_status(block_number, true); } + Ok(()) } - /// Returns `true` if a heartbeat has been received for `AuthorityId` - /// during the current session. Otherwise `false`. - pub fn is_online_in_current_session(authority_id: &T::AuthorityId) -> bool { - let current_session = >::current_index(); - >::exists(¤t_session, authority_id) + fn compare_and_set_worker_status( + gossipping_at: T::BlockNumber, + done: bool, + curr_worker_status: Option>, + ) -> bool { + let enc = WorkerStatus { + done, + gossipping_at, + }; + sr_io::local_storage_compare_and_set( + StorageKind::PERSISTENT, + DB_KEY, + curr_worker_status.as_ref().map(Vec::as_slice), + &enc.encode() + ) } - /// Session has just changed. - fn new_session() { - let now = >::block_number(); - >::put(now); - - let current_session = >::current_index(); - - match LastNewEraStart::get() { - Some(last_new_era_start) => { - let sessions_per_era = T::SessionsPerEra::get(); - - let new_era = current_session - last_new_era_start > sessions_per_era; - if new_era { - LastNewEraStart::put(current_session); - Self::remove_heartbeats(); - } - }, - None => LastNewEraStart::put(current_session), + fn set_worker_status( + gossipping_at: T::BlockNumber, + done: bool, + ) { + let enc = WorkerStatus { + done, + gossipping_at, }; + sr_io::local_storage_set( + StorageKind::PERSISTENT, DB_KEY, &enc.encode()); } - // Remove all stored heartbeats. - fn remove_heartbeats() { - let curr = >::current_index(); - match LastNewEraStart::get() { - Some(start) => { - for index in start..curr { - >::remove_prefix(&index); - } + // Checks if a heartbeat gossip already occurred at this block number. + // Returns a tuple of `(current worker status, bool)`, whereby the bool + // is true if not yet gossipped. + fn check_not_yet_gossipped( + now: T::BlockNumber, + next_gossip: T::BlockNumber, + ) -> Result<(Option>, bool), OffchainErr> { + let last_gossip = sr_io::local_storage_get(StorageKind::PERSISTENT, DB_KEY); + match last_gossip { + Some(last) => { + let worker_status: WorkerStatus = Decode::decode(&mut &last[..]) + .ok_or(OffchainErr::DecodeWorkerStatus)?; + + let was_aborted = !worker_status.done && worker_status.gossipping_at < now; + + // another off-chain worker is currently in the process of submitting + let already_submitting = + !worker_status.done && worker_status.gossipping_at == now; + + let not_yet_gossipped = + worker_status.done && worker_status.gossipping_at < next_gossip; + + let ret = (was_aborted && !already_submitting) || not_yet_gossipped; + Ok((Some(last), ret)) }, - None => >::remove_prefix(&curr), + None => Ok((None, true)), } } + } impl session::OneSessionHandler for Module { - type Key = ::AuthorityId; + type Key = AuthorityId; + + fn on_new_session<'a, I: 'a>(_changed: bool, _validators: I, next_validators: I) + where I: Iterator + { + // Reset heartbeats + ::remove_prefix(&>::current_index()); - fn on_new_session<'a, I: 'a>(_changed: bool, _validators: I, _next_validators: I) { - Self::new_session(); + // Tell the offchain worker to start making the next session's heartbeats. + >::put(>::block_number()); + + // Remember who the authorities are for the new session. + Keys::put(next_validators.map(|x| x.1).collect::>()); } fn on_before_session_ending() { @@ -409,55 +420,49 @@ impl srml_support::unsigned::ValidateUnsigned for Module { fn validate_unsigned(call: &Self::Call) -> srml_support::unsigned::TransactionValidity { if let Call::heartbeat(heartbeat, signature) = call { - // verify that the incoming (unverified) pubkey is actually an authority id - let is_authority = T::IsValidAuthorityId::is_member(&heartbeat.authority_id); - if !is_authority { - return TransactionValidity::Invalid(ApplyError::BadSignature as i8); - } - - if >::is_online_in_current_session(&heartbeat.authority_id) { + if >::is_online_in_current_session(heartbeat.authority_index) { // we already received a heartbeat for this authority - return TransactionValidity::Invalid(ApplyError::BadSignature as i8); + return TransactionValidity::Invalid(ApplyError::Stale as i8); } - if signature.len() != 64 { - return TransactionValidity::Invalid(ApplyError::BadSignature as i8); + // check if session index from heartbeat is recent + let current_session = >::current_index(); + if heartbeat.session_index != current_session { + return TransactionValidity::Invalid(ApplyError::Stale as i8); } - let signature = { - let mut array = [0; 64]; - array.copy_from_slice(&signature); // panics if not enough, hence the check above - array - }; - - let encoded_heartbeat = heartbeat.encode(); - - let signature_valid = match ::KEY_TYPE { - ed25519::Public::KEY_TYPE => - sr_io::ed25519_verify(&signature, &encoded_heartbeat, &heartbeat.authority_id), - sr25519::Public::KEY_TYPE => - sr_io::sr25519_verify(&signature, &encoded_heartbeat, &heartbeat.authority_id), - _ => return TransactionValidity::Invalid(ApplyError::BadSignature as i8), + // verify that the incoming (unverified) pubkey is actually an authority id + let keys = Keys::get(); + let authority_id = match keys.get(heartbeat.authority_index as usize) { + Some(id) => id, + None => return TransactionValidity::Invalid(ApplyError::BadSignature as i8), }; + // check signature (this is expensive so we do it last). + let signature_valid = heartbeat.using_encoded(|encoded_heartbeat| { + // TODO [slashing] + // let sig: &app::crypto::Signature = signature.as_ref(); + let sig: &app::crypto::Signature = signature; + // TODO [slashing] + sr_io::sr25519_verify( + sig.as_ref(), + encoded_heartbeat, + &authority_id + ) + }); if !signature_valid { return TransactionValidity::Invalid(ApplyError::BadSignature as i8); } - // check if session index from heartbeat is recent - let current_session = >::current_index(); - if heartbeat.session_index < current_session { - return TransactionValidity::Invalid(ApplyError::BadSignature as i8); - } - return TransactionValidity::Valid(ValidTransaction { priority: 0, requires: vec![], - provides: vec![encoded_heartbeat], + provides: vec![(current_session, authority_id).encode()], longevity: TransactionLongevity::max_value(), propagate: true, }) } + TransactionValidity::Invalid(0) } } From a807daea6bf2a060433d9f215bfe350def2fb1c6 Mon Sep 17 00:00:00 2001 From: Fredrik Date: Tue, 6 Aug 2019 19:01:32 +0200 Subject: [PATCH 013/191] Adding validator count to historical session storage as it's needed for slash calculations --- srml/session/src/historical.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index c6755c3ba3592..f397cc60e6c9e 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -37,6 +37,8 @@ use substrate_trie::{MemoryDB, Trie, TrieMut, TrieDBMut, TrieDB, Recorder}; use super::{SessionIndex, Module as SessionModule}; +type ValidatorCount = u32; + /// Trait necessary for the historical module. pub trait Trait: super::Trait { /// Full identification of the validator. @@ -55,8 +57,8 @@ pub trait Trait: super::Trait { decl_storage! { trait Store for Module as Session { - /// Mapping from historical session indices to session-data root hash. - HistoricalSessions get(historical_root): map SessionIndex => Option; + /// Mapping from historical session indices to session-data root hash and validator count. + HistoricalSessions get(historical_root): map SessionIndex => Option<(T::Hash, ValidatorCount)>; /// Queued full identifications for queued sessions whose validators have become obsolete. CachedObsolete get(cached_obsolete): map SessionIndex => Option>; @@ -121,8 +123,9 @@ impl crate::OnSessionEnding for NoteHistoricalRoot< // do all of this _before_ calling the other `on_session_ending` impl // so that we have e.g. correct exposures from the _current_. + let count = >::validators().len() as u32; match ProvingTrie::::generate_for(ending) { - Ok(trie) => >::insert(ending, &trie.root), + Ok(trie) => >::insert(ending, &(trie.root, count)), Err(reason) => { print("Failed to generate historical ancestry-inclusion proof."); print(reason); @@ -300,7 +303,7 @@ impl> srml_support::traits::KeyOwnerProofSystem<(KeyTyp T::FullIdentificationOf::convert(owner.clone()).map(move |id| (owner, id)) ) } else { - let root = >::get(&proof.session)?; + let (root, _) = >::get(&proof.session)?; let trie = ProvingTrie::::from_nodes(root, &proof.trie_nodes); trie.query(id, data.as_ref()) From 32cba20be91c8baa290d5f4ee15ec894f03e6b8d Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 21:47:10 +0200 Subject: [PATCH 014/191] Add a comment about offence. --- core/sr-primitives/src/offence.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 5b9ee34d33973..ab13ed6d40f37 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -35,6 +35,8 @@ pub type TimeSlot = u128; /// A trait implemented by an offence report. /// +/// This trait assumes that the offence is legitimate and was validated already. +/// /// Examples of offences include: a BABE equivocation or a GRANDPA unjustified vote. pub trait Offence { /// Identifier which is unique for this kind of an offence. From 39f7ed06a8ebb837e2fa94a2c89d0cba7d9e8a50 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 21:48:01 +0200 Subject: [PATCH 015/191] Add BabeEquivocationOffence --- core/sr-primitives/src/lib.rs | 5 ++++ srml/babe/src/lib.rs | 49 +++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index 383e27e542dd3..a2d5c3b57a783 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -324,6 +324,11 @@ impl Perbill { Perbill(part as u32) } + + /// Take out the raw parts-per-billions. + pub fn into_parts(self) -> u32 { + self.0 + } } impl ops::Mul for Perbill diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index c75869ab579d6..5d48458a684a1 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -17,15 +17,19 @@ //! Consensus extension module for BABE consensus. #![cfg_attr(not(feature = "std"), no_std)] -#![forbid(unused_must_use, unsafe_code, unused_variables, dead_code)] +#![forbid(unused_must_use, unsafe_code, unused_variables)] + +// TODO: @marcio uncomment this when BabeEquivocation is integrated. +// #![forbid(dead_code)] pub use timestamp; use rstd::{result, prelude::*}; use srml_support::{decl_storage, decl_module, StorageValue, traits::FindAuthor, traits::Get}; use timestamp::{OnTimestampSet}; -use primitives::{generic::DigestItem, ConsensusEngineId}; +use primitives::{generic::DigestItem, ConsensusEngineId, Perbill}; use primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; +use primitives::offence::{Offence, TimeSlot, Kind}; #[cfg(feature = "std")] use timestamp::TimestampInherentData; use parity_codec::{Encode, Decode}; @@ -218,6 +222,47 @@ impl session::ShouldEndSession for Module { } } +// TODO [slashing]: @marcio use this, remove the dead_code annotation. +/// A BABE equivocation offence. +#[allow(dead_code)] +struct BabeEquivocationOffence { + /// A babe slot number in which this incident happened. + slot: u64, + /// The index of the session during which this incident heppened. + session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The authority which produced the equivocation. + offender: AuthorityId, +} + +impl Offence for BabeEquivocationOffence { + const ID: Kind = *b"babe:equivocatio"; + + fn offenders(&self) -> Vec { + let mut offender = Vec::with_capacity(1); + offender.push(self.offender.clone()); + offender + } + + fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.session_index + } + + fn time_slot(&self) -> TimeSlot { + self.slot as TimeSlot + } + + fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill { + // the formula is min((3k / n)^2, 1) + let x = Perbill::from_rational_approximation(3 * offenders, validators_count); + + // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. + // The conversion to u64 is performed to guarantee it fits. + let x = x.into_parts(); + let x = ((x as u64 * x as u64) / 1_000_000_000) as u32; + Perbill::from_parts(x) + } +} + impl Module { /// Determine the BABE slot duration based on the Timestamp module configuration. pub fn slot_duration() -> T::Moment { From c5579b329d6cc06d8b654e305ad924b9aa8b2dc5 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 22:07:03 +0200 Subject: [PATCH 016/191] GrandpaEquivocationOffence --- srml/babe/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 5d48458a684a1..ed67841c15f86 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -223,7 +223,7 @@ impl session::ShouldEndSession for Module { } // TODO [slashing]: @marcio use this, remove the dead_code annotation. -/// A BABE equivocation offence. +/// A BABE equivocation offence report. #[allow(dead_code)] struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 9615953e67683..bc81c635ea23f 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -377,3 +377,48 @@ impl finality_tracker::OnFinalizationStalled for Modul >::put((further_wait, median)); } } + +// TODO [slashing]: Integrate this. +/// A grandpa equivocation offence report. +#[allow(dead_code)] +struct GrandpaEquivocationOffence { + /// Round in which the incident happened. + round: u64, + /// This is the approximate session index (most likely the start of the era). + /// + /// We use an approximate session index since GRANDPA is progressing asynchronously w.r.t. + /// to block production algorithm. But an offence still has to provide session index for + /// querying the historical validator set for reports for previous eras. + approx_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The authority which produced this equivocation. + offender: AuthorityId, +} + +impl Offence for GrandpaEquivocationOffence { + const ID: Kind = *b"grandpa:equivoca"; + + fn offenders(&self) -> Vec { + let mut offender = Vec::with_capacity(1); + offender.push(self.offender.clone()); + offender + } + + fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.approx_session_index + } + + fn time_slot(&self) -> TimeSlot { + self.round as TimeSlot + } + + fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill { + // the formula is min((3k / n)^2, 1) + let x = Perbill::from_rational_approximation(3 * offenders, validators_count); + + // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. + // The conversion to u64 is performed to guarantee it fits. + let x = x.into_parts(); + let x = ((x as u64 * x as u64) / 1_000_000_000) as u32; + Perbill::from_parts(x) + } +} From ecd8d818bed73b0cb914a9945774b90cb8b06b11 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Aug 2019 22:53:44 +0200 Subject: [PATCH 017/191] slash_fraction and fix --- core/sr-primitives/src/offence.rs | 6 +++--- srml/babe/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index ab13ed6d40f37..6fbf53cfeb4b4 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -50,7 +50,7 @@ pub trait Offence { /// What is the session index this offence happened in. /// /// The value returned by this function is going to be used for querying the validator set for - /// for the `slash_percentage` function. If the session index cannot be pinpointed precisely (as + /// for the `slash_fraction` function. If the session index cannot be pinpointed precisely (as /// in case with GRANDPA offences) then this function should return the closest session index /// with the same validator set. fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. @@ -62,12 +62,12 @@ pub trait Offence { /// and for BABE it could be a slot number. fn time_slot(&self) -> TimeSlot; - /// A percentage of the total exposure that should be slashed for this + /// A slash fraction of the total exposure that should be slashed for this /// particular offence kind for the given parameters. /// /// `offenders` - the number of offences of this kind at the particular `time_slot`. /// `validators_count` - the cardinality of the validator set at the time of offence. - fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill; + fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill; } /// A trait for decoupling offence reporters from the actual handling of offence reports. diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index ed67841c15f86..c9345850692e2 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -251,7 +251,7 @@ impl Offence for BabeEquivocationOffence { self.slot as TimeSlot } - fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill { + fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill { // the formula is min((3k / n)^2, 1) let x = Perbill::from_rational_approximation(3 * offenders, validators_count); diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index bc81c635ea23f..0080c219a0d02 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -36,7 +36,9 @@ use srml_support::{ decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue }; use primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, traits::CurrentHeight + generic::{DigestItem, OpaqueDigestItemId}, traits::CurrentHeight, + Perbill, + offence::{TimeSlot, Offence, Kind}, }; use fg_primitives::{ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID}; pub use fg_primitives::{AuthorityId, AuthorityWeight}; @@ -411,7 +413,7 @@ impl Offence for GrandpaEquivocationOffence { self.round as TimeSlot } - fn slash_percentage(&self, offenders: u32, validators_count: u32) -> Perbill { + fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill { // the formula is min((3k / n)^2, 1) let x = Perbill::from_rational_approximation(3 * offenders, validators_count); From cfe194dc13fc521ed641f5ef3158f748fb9b7679 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 00:29:02 +0200 Subject: [PATCH 018/191] current_era_start_session_index --- core/sr-primitives/src/offence.rs | 10 +++------- srml/babe/src/lib.rs | 8 ++++---- srml/grandpa/src/lib.rs | 14 +++++--------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 6fbf53cfeb4b4..9a6cb3a005913 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -47,13 +47,9 @@ pub trait Offence { /// The list has no duplicates, so it is rather a set. fn offenders(&self) -> rstd::vec::Vec; - /// What is the session index this offence happened in. - /// - /// The value returned by this function is going to be used for querying the validator set for - /// for the `slash_fraction` function. If the session index cannot be pinpointed precisely (as - /// in case with GRANDPA offences) then this function should return the closest session index - /// with the same validator set. - fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. + /// The session index which is used for querying the validator set for the `slash_fraction` + /// function. + fn current_era_start_session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. /// A point in time when this offence happened. /// diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index c9345850692e2..a641818ade953 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -228,8 +228,8 @@ impl session::ShouldEndSession for Module { struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. slot: u64, - /// The index of the session during which this incident heppened. - session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The session index that starts an era in which the incident happened. + current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The authority which produced the equivocation. offender: AuthorityId, } @@ -243,8 +243,8 @@ impl Offence for BabeEquivocationOffence { offender } - fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. - self.session_index + fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.current_era_start_session_index } fn time_slot(&self) -> TimeSlot { diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 0080c219a0d02..c0e10258ec168 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -384,14 +384,10 @@ impl finality_tracker::OnFinalizationStalled for Modul /// A grandpa equivocation offence report. #[allow(dead_code)] struct GrandpaEquivocationOffence { - /// Round in which the incident happened. + /// A round in which the incident happened. round: u64, - /// This is the approximate session index (most likely the start of the era). - /// - /// We use an approximate session index since GRANDPA is progressing asynchronously w.r.t. - /// to block production algorithm. But an offence still has to provide session index for - /// querying the historical validator set for reports for previous eras. - approx_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The session index that starts an era in which the incident happened. + current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The authority which produced this equivocation. offender: AuthorityId, } @@ -405,8 +401,8 @@ impl Offence for GrandpaEquivocationOffence { offender } - fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. - self.approx_session_index + fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.current_era_start_session_index } fn time_slot(&self) -> TimeSlot { From 4cb0bfe6e32c2e300766b195b7670fdb3f0cd799 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 12:19:37 +0200 Subject: [PATCH 019/191] UnresponsivnessOffence --- core/sr-primitives/src/offence.rs | 2 +- srml/babe/src/lib.rs | 2 ++ srml/grandpa/src/lib.rs | 2 ++ srml/im-online/src/lib.rs | 43 ++++++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 9a6cb3a005913..220575c1fb316 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -20,7 +20,7 @@ use crate::Perbill; /// The kind of an offence, is a byte string representing some kind identifier -/// e.g. `b"im-online:off"`, `b"babe:equivocatio"` +/// e.g. `b"im-online:offlin"`, `b"babe:equivocatio"` // TODO [slashing]: Is there something better we can have here that is more natural but still // flexible? as you see in examples, they get cut off with long names. pub type Kind = [u8; 16]; diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index a641818ade953..06f4c967a5045 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -255,8 +255,10 @@ impl Offence for BabeEquivocationOffence { // the formula is min((3k / n)^2, 1) let x = Perbill::from_rational_approximation(3 * offenders, validators_count); + // _ ^ 2 // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. // The conversion to u64 is performed to guarantee it fits. + // TODO: #3189 should fix this. let x = x.into_parts(); let x = ((x as u64 * x as u64) / 1_000_000_000) as u32; Perbill::from_parts(x) diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index c0e10258ec168..bc9da5637c8fe 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -413,8 +413,10 @@ impl Offence for GrandpaEquivocationOffence { // the formula is min((3k / n)^2, 1) let x = Perbill::from_rational_approximation(3 * offenders, validators_count); + // _ ^ 2 // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. // The conversion to u64 is performed to guarantee it fits. + // TODO: #3189 should fix this. let x = x.into_parts(); let x = ((x as u64 * x as u64) / 1_000_000_000) as u32; Perbill::from_parts(x) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 9a70ce42357b0..7b3c3226a4c44 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -74,8 +74,9 @@ use substrate_primitives::{ use parity_codec::{Encode, Decode}; use session::SessionIndex; use sr_primitives::{ - ApplyError, traits::{Extrinsic as ExtrinsicT}, + Perbill, ApplyError, traits::{Extrinsic as ExtrinsicT}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, + offence::{Offence, TimeSlot, Kind}, }; use sr_std::prelude::*; use sr_io::Printable; @@ -466,3 +467,43 @@ impl srml_support::unsigned::ValidateUnsigned for Module { TransactionValidity::Invalid(0) } } + +/// An offense which is filed if a validator didn't send a heartbeat message. +struct UnresponsivnessOffence { + /// The session index that starts an era in which the incident happened. + current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The session index at which we file this report. + /// + /// It acts as a time measure for unresponsivness reports. + session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// Authorities which were unresponsive during the current epoch. + offenders: Vec, +} + +impl Offence for UnresponsivnessOffence { + const ID: Kind = *b"im-online:offlin"; + + fn offenders(&self) -> Vec { + self.offenders.clone() + } + + fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.current_era_start_session_index + } + + fn time_slot(&self) -> TimeSlot { + self.session_index as TimeSlot + } + + fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill { + // the formula is min((3 * (k - 1)) / n, 1) * 0.05 + let x = Perbill::from_rational_approximation(3 * (offenders - 1), validators_count); + + // _ * 0.05 + // For now, Perbill doesn't support multiplication other than an integer so we perform + // a manual scaling. + // TODO: #3189 should fix this. + let p = (x.into_parts() as u64 * 50_000_000u64) / 1_000_000_000u64; + Perbill::from_parts(p as u32) + } +} From 7ede025eae6cd1d173394c12f8f2af2e1c6aa2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 12:17:26 +0200 Subject: [PATCH 020/191] Finalise OnOffenceHandler traits, and stub impl for staking. --- core/sr-primitives/src/offence.rs | 63 ++++++++++++++-- srml/babe/src/lib.rs | 8 +- srml/grandpa/src/lib.rs | 8 +- srml/im-online/src/lib.rs | 2 +- srml/offences/Cargo.toml | 8 +- srml/offences/src/lib.rs | 118 ++++++++++++++++++++++++------ srml/staking/src/lib.rs | 91 ++++++++++++++--------- 7 files changed, 227 insertions(+), 71 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 220575c1fb316..4fa6cf265064c 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -17,6 +17,9 @@ //! Common traits and types that are useful for describing offences for usage in environments //! that use staking. +use rstd::vec::Vec; + +use codec::{Encode, Decode}; use crate::Perbill; /// The kind of an offence, is a byte string representing some kind identifier @@ -25,6 +28,14 @@ use crate::Perbill; // flexible? as you see in examples, they get cut off with long names. pub type Kind = [u8; 16]; +/// Number of times the offence of this authority was already reported in the past. +/// +/// Note we don't buffer offence reporting so everytime we see a new offence +/// of the same kind, we will report past authorities again. +/// This counter keeps track of how many times the authority was already reported in the past, +/// so that we can slash it accordingly. +pub type OffenceCount = u32; + /// A type that represents a point in time on an abstract timescale. /// /// This type is not tied to a particular timescale and can be used for representing instants on @@ -45,7 +56,7 @@ pub trait Offence { /// The list of all offenders involved in this incident. /// /// The list has no duplicates, so it is rather a set. - fn offenders(&self) -> rstd::vec::Vec; + fn offenders(&self) -> Vec; /// The session index which is used for querying the validator set for the `slash_fraction` /// function. @@ -61,13 +72,55 @@ pub trait Offence { /// A slash fraction of the total exposure that should be slashed for this /// particular offence kind for the given parameters. /// - /// `offenders` - the number of offences of this kind at the particular `time_slot`. + /// `offenders_count` - the count of unique offending authorities /// `validators_count` - the cardinality of the validator set at the time of offence. - fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill; + fn slash_fraction( + &self, + offenders_count: u32, + validators_count: u32, + ) -> Perbill; } /// A trait for decoupling offence reporters from the actual handling of offence reports. pub trait ReportOffence> { - /// Report an `offence` from the given `reporters`. - fn report_offence(reporters: &[Reporter], offence: &O); + /// Report an `offence` and reward the `reporter`. + fn report_offence(reporter: Option, offence: O) -> Result<(), ()>; +} + +/// A trait to take action on an offence. +/// +/// Used to decouple the module that handles offences and +/// the one that should punish for those offences. +pub trait OnOffenceHandler { + /// A handler for offence of particular kind. + /// + /// Note that this contains a list of all previous offenders + /// as well. The implementer should cater for a case, where + /// the same authorities were reported for the same offence + /// in the past (see `OffenceCount`). + /// + /// The vector of `slash_fraction` contains perbils + /// the authorities should be slashed and is computed + /// according to the `OffenceCount` already. + fn on_offence( + offenders: &[OffenceDetails], + slash_fraction: &[Perbill], + ); +} + +/// A details about an offending authority for a particular kind of offence. +#[derive(Clone, PartialEq, Eq, Encode, Decode)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct OffenceDetails { + /// The offending authority id + pub offender: Offender, + /// A number of times the authority was already reported for this offence. + /// + /// Since we punish all authorities for that made the same offence in the past as well + /// we keep track the "age" of the report, so that the slashes can be lowered + /// in case the authority was already slashed in the past. + /// Note that we don't buffer slashes and instead use this approach. + pub count: OffenceCount, + /// A list of reporters of offences of this authority id. + pub reporters: Vec, } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 06f4c967a5045..824b64abc9b7c 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -251,9 +251,13 @@ impl Offence for BabeEquivocationOffence { self.slot as TimeSlot } - fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill { + fn slash_fraction( + &self, + offenders_count: u32, + validators_count: u32, + ) -> Perbill { // the formula is min((3k / n)^2, 1) - let x = Perbill::from_rational_approximation(3 * offenders, validators_count); + let x = Perbill::from_rational_approximation(3 * offenders_count, validators_count); // _ ^ 2 // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index bc9da5637c8fe..ac95087ab956f 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -409,9 +409,13 @@ impl Offence for GrandpaEquivocationOffence { self.round as TimeSlot } - fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill { + fn slash_fraction( + &self, + offenders_count: u32, + validators_count: u32, + ) -> Perbill { // the formula is min((3k / n)^2, 1) - let x = Perbill::from_rational_approximation(3 * offenders, validators_count); + let x = Perbill::from_rational_approximation(3 * offenders_count, validators_count); // _ ^ 2 // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 7b3c3226a4c44..faed1d1eb38f6 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -408,7 +408,7 @@ impl session::OneSessionHandler for Module { } fn on_before_session_ending() { - // ignore + // TODO [slashing] report validators } fn on_disabled(_i: usize) { diff --git a/srml/offences/Cargo.toml b/srml/offences/Cargo.toml index 06d64361fbf68..feb1019c4dd72 100644 --- a/srml/offences/Cargo.toml +++ b/srml/offences/Cargo.toml @@ -9,9 +9,9 @@ balances = { package = "srml-balances", path = "../balances", default-features = parity-codec = { version = "4.1.1", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } serde = { version = "1.0", optional = true } +session = { package = "srml-session", path = "../session", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } -srml-support = { path = "../support", default-features = false } -srml-session = { path = "../session", default-features = false } +support = { package = "srml-support", path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } [dev-dependencies] @@ -28,8 +28,8 @@ std = [ "parity-codec/std", "rstd/std", "serde", + "session/std", "sr-primitives/std", - "srml-session/std", - "srml-support/std", + "support/std", "system/std", ] diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 704e1711ba514..d49aed1a798ea 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -22,28 +22,36 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] -use srml_support::{ - StorageDoubleMap, Parameter, decl_module, decl_storage, -}; use parity_codec::{Decode, Encode}; use rstd::vec::Vec; +use session::{Module as Session, SessionIndex, historical}; +use support::{ + StorageDoubleMap, Parameter, decl_module, decl_storage, +}; use sr_primitives::{ + Perbill, traits::{Member, TypedKey}, - offence::{Offence, ReportOffence, TimeSlot, Kind}, + offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, }; /// Offences trait -pub trait Trait: system::Trait { +pub trait Trait: system::Trait + session::Trait + historical::Trait { /// The identifier type for an authority. type AuthorityId: Member + Parameter + Default + TypedKey + Decode + Encode + AsRef<[u8]>; + /// A handler called for every offence report. + type OnOffenceHandler: OnOffenceHandler; } decl_storage! { trait Store for Module as Offences { - /// Offence reports is a double_map of the kind, timeslot to a vec of authorities. + /// A mapping between unique `TimeSlots` within a particular session and the offence `Kind` into + /// a vector of offending authorities. + /// /// It's important that we store all authorities reported for an offence for any kind and /// timeslot since the slashing will increase based on the length of this vec. - OffenceReports get(offence_reports): double_map Kind, blake2_256(TimeSlot) => Vec; + OffenceReports get(offence_reports): + double_map Kind, blake2_256((SessionIndex, TimeSlot)) + => Vec>; } } @@ -52,27 +60,93 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -impl> ReportOffence +impl> ReportOffence for Module { - fn report_offence(_reporters: &[T::AuthorityId], offence: &O) { + fn report_offence(reporter: Option, offence: O) -> Result<(), ()> { let offenders = offence.offenders(); let time_slot = offence.time_slot(); + let session = offence.current_era_start_session_index(); - // Check if an offence is already reported for the offender authorities and otherwise stores - // that report. - >::mutate(&O::ID, &time_slot, |offending_authorities| { - for offender in offenders { - // TODO [slashing] This prevents slashing for multiple reports of the same kind at the same slot, - // note however that we might do that in the future if the reports are not exactly the same (dups). - // De-duplication of reports is tricky though, we need a canonical form of the report - // (for instance babe equivocation can have headers swapped). - if !offending_authorities.contains(&offender) { - offending_authorities.push(offender); - // TODO [slashing] trigger on_offence and calculate amounts + // Check if an offence is already reported for the offender authorities + // and otherwise stores that report. + let all_offenders = > + ::mutate(&O::ID, &(session, time_slot), |offending_authorities| { + for offender in offenders { + // TODO [slashing] This prevents slashing for multiple reports of the same kind at the same slot, + // note however that we might do that in the future if the reports are not exactly the same (dups). + // De-duplication of reports is tricky though, we need a canonical form of the report + // (for instance babe equivocation can have headers swapped). + if let Some(details) = offending_authorities + .iter_mut() + .find(|details| details.offender == offender) + { + details.count += 1; + if let Some(ref reporter) = reporter { + if !details.reporters.contains(reporter) { + details.reporters.push(reporter.clone()); + } + } + } else { + offending_authorities.push(OffenceDetails { + offender, + count: 0, + reporters: reporter.clone().into_iter().collect(), + }); + } } - } - }); + offending_authorities.clone() + }); + + // TODO [slashing] Use CurrentEraStartSessionIndex from staking to figure out if it's in current session. + let validators_count = if session == >::current_index() { + >::validators().len() as u32 + } else if let Some((_, count)) = >::historical_root(session) { + count + } else { + // session index seems invalid, we should pprobably just return an error. + return Err(()) + }; + + + let offenders_count = all_offenders.len() as u32; + let expected_fraction = offence.slash_fraction(offenders_count, validators_count); + let slash_perbil = all_offenders + .iter() + .map(|details| { + if details.count > 0 { + let previous_fraction = offence.slash_fraction( + offenders_count.saturating_sub(details.count), + validators_count, + ); + let perbil = expected_fraction + .into_parts() + .saturating_sub(previous_fraction.into_parts()); + Perbill::from_parts(perbil) + } else { + expected_fraction.clone() + } + }) + .collect::>(); + + T::OnOffenceHandler::on_offence( + &all_offenders, + &slash_perbil + ); + + return Ok(()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn should_trigger_on_offence_handler() { + // TODO [slashing] implement me + assert_eq!(true, false); + } +} + diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index d20a41d3c43f1..5d3af961ba2e2 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -273,6 +273,7 @@ use srml_support::{ }; use session::{historical::OnSessionEnding, SelectInitialValidators, SessionIndex}; use primitives::Perbill; +use primitives::offence::{OnOffenceHandler, OffenceDetails}; use primitives::weights::SimpleDispatchInfo; use primitives::traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, @@ -985,44 +986,32 @@ impl Module { /// Slash a given validator by a specific amount. Removes the slash from the validator's /// balance by preference, and reduces the nominators' balance if needed. - /// - /// NOTE: This is called with the controller (not the stash) account id. - pub fn slash_validator(controller: T::AccountId, slash: BalanceOf) { - if let Some(l) = Self::ledger(&controller) { - let stash = l.stash; - - // Early exit if validator is invulnerable. - if Self::invulnerables().contains(&stash) { - return - } - - // The exposure (backing stake) information of the validator to be slashed. - let exposure = Self::stakers(&stash); - // The amount we are actually going to slash (can't be bigger than the validator's total - // exposure) - let slash = slash.min(exposure.total); - // The amount we'll slash from the validator's stash directly. - let own_slash = exposure.own.min(slash); - let (mut imbalance, missing) = T::Currency::slash(&stash, own_slash); - let own_slash = own_slash - missing; - // The amount remaining that we can't slash from the validator, - // that must be taken from the nominators. - let rest_slash = slash - own_slash; - if !rest_slash.is_zero() { - // The total to be slashed from the nominators. - let total = exposure.total - exposure.own; - if !total.is_zero() { - for i in exposure.others.iter() { - let per_u64 = Perbill::from_rational_approximation(i.value, total); - // best effort - not much that can be done on fail. - imbalance.subsume(T::Currency::slash(&i.who, per_u64 * rest_slash).0) - } + fn slash_validator(stash: T::AccountId, slash: BalanceOf) { + // The exposure (backing stake) information of the validator to be slashed. + let exposure = Self::stakers(&stash); + // The amount we are actually going to slash (can't be bigger than the validator's total + // exposure) + let slash = slash.min(exposure.total); + // The amount we'll slash from the validator's stash directly. + let own_slash = exposure.own.min(slash); + let (mut imbalance, missing) = T::Currency::slash(&stash, own_slash); + let own_slash = own_slash - missing; + // The amount remaining that we can't slash from the validator, + // that must be taken from the nominators. + let rest_slash = slash - own_slash; + if !rest_slash.is_zero() { + // The total to be slashed from the nominators. + let total = exposure.total - exposure.own; + if !total.is_zero() { + for i in exposure.others.iter() { + let per_u64 = Perbill::from_rational_approximation(i.value, total); + // best effort - not much that can be done on fail. + imbalance.subsume(T::Currency::slash(&i.who, per_u64 * rest_slash).0) } } - T::Slash::on_unbalanced(imbalance); - let _ = T::SessionInterface::disable_validator(&stash); - Self::apply_force_new_era(); } + // TODO [slashing] Distribute reward to reporters? + T::Slash::on_unbalanced(imbalance); } /// Actually make a payment to a staker. This uses the currency's reward function @@ -1080,6 +1069,8 @@ impl Module { fn new_session(session_index: SessionIndex) -> Option<(Vec, Vec<(T::AccountId, Exposure>)>)> { + // TODO [slashing] The new era should be SessionsPerEra long, so + // we should use CurrentEraStartSessionIndexS to calculate end of the era. if ForceNewEra::take() || session_index % T::SessionsPerEra::get() == 0 { let validators = T::SessionInterface::validators(); let prior = validators.into_iter() @@ -1462,3 +1453,33 @@ impl SelectInitialValidators for Module { >::select_validators().1 } } + +// TODO [ToDr] Should it be AccountId or AuthorityId? +impl OnOffenceHandler for Module { + fn on_offence( + offenders: &[OffenceDetails], + slash_fraction: &[Perbill], + ) { + for (details, slash_fraction) in offenders.iter().zip(slash_fraction) { + if let Some(l) = Self::ledger(&details.offender) { + let stash = l.stash; + + // Early exit if validator is invulnerable. + if Self::invulnerables().contains(&stash) { + return + } + + + // let slash_exposure = Self::stakers(&stash).total; + // let amount = offline_slash_base + // // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) + // .checked_shl(unstake_threshold) + // .map(|x| x.min(slash_exposure)) + // .unwrap_or(slash_exposure); + // Self::slash_validator(details.offender, amount) + let _ = T::SessionInterface::disable_validator(&stash); + Self::apply_force_new_era(); + } + } + } +} From a56a7b47afd886ec8140afd6500267e4f6dda30c Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 12:30:55 +0200 Subject: [PATCH 021/191] slash_fraction doesn't really need &self --- core/sr-primitives/src/offence.rs | 1 - srml/babe/src/lib.rs | 1 - srml/grandpa/src/lib.rs | 1 - srml/im-online/src/lib.rs | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 4fa6cf265064c..dc75d1e9da848 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -75,7 +75,6 @@ pub trait Offence { /// `offenders_count` - the count of unique offending authorities /// `validators_count` - the cardinality of the validator set at the time of offence. fn slash_fraction( - &self, offenders_count: u32, validators_count: u32, ) -> Perbill; diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 824b64abc9b7c..01a6cc5bf05bf 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -252,7 +252,6 @@ impl Offence for BabeEquivocationOffence { } fn slash_fraction( - &self, offenders_count: u32, validators_count: u32, ) -> Perbill { diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index ac95087ab956f..7055317abf52f 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -410,7 +410,6 @@ impl Offence for GrandpaEquivocationOffence { } fn slash_fraction( - &self, offenders_count: u32, validators_count: u32, ) -> Perbill { diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index faed1d1eb38f6..9934aeec1d06b 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -495,7 +495,7 @@ impl Offence for UnresponsivnessOffence { self.session_index as TimeSlot } - fn slash_fraction(&self, offenders: u32, validators_count: u32) -> Perbill { + fn slash_fraction(offenders: u32, validators_count: u32) -> Perbill { // the formula is min((3 * (k - 1)) / n, 1) * 0.05 let x = Perbill::from_rational_approximation(3 * (offenders - 1), validators_count); From da2cc8390982c14b6ff0dd8079ad3a28ae07310f Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 12:52:59 +0200 Subject: [PATCH 022/191] Note that offenders count is greater than 0 --- core/sr-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index dc75d1e9da848..f2b8855415f41 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -72,7 +72,7 @@ pub trait Offence { /// A slash fraction of the total exposure that should be slashed for this /// particular offence kind for the given parameters. /// - /// `offenders_count` - the count of unique offending authorities + /// `offenders_count` - the count of unique offending authorities. It is >0. /// `validators_count` - the cardinality of the validator set at the time of offence. fn slash_fraction( offenders_count: u32, From 61c6c223233218110bf6608d2c4fb10078d93336 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 13:00:17 +0200 Subject: [PATCH 023/191] Add a test to ensure that I got the math right --- srml/im-online/src/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 9934aeec1d06b..12a6a16d61bc3 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -507,3 +507,28 @@ impl Offence for UnresponsivnessOffence { Perbill::from_parts(p as u32) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_unresponsivness_slash_fraction() { + // A single case of unresponsivness is not slashed. + assert_eq!( + UnresponsivnessOffence::slash_fraction(1, 50), + Perbill::zero(), + ); + + assert_eq!( + UnresponsivnessOffence::slash_fraction(3, 50), + Perbill::from_parts(6000000), // 0.6% + ); + + // One third offline should be punished around 5%. + assert_eq!( + UnresponsivnessOffence::slash_fraction(17, 50), + Perbill::from_parts(48000000), // 4.8% + ); + } +} From f7a8711ed2aa6d3c6ec28af84e32d80848f84504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 13:32:11 +0200 Subject: [PATCH 024/191] Use FullIdentification in offences. --- core/sr-primitives/src/offence.rs | 3 +++ srml/babe/src/lib.rs | 14 ++++++++++---- srml/grandpa/src/lib.rs | 14 ++++++++++---- srml/im-online/src/lib.rs | 6 ++++++ srml/offences/src/lib.rs | 32 ++++++++++--------------------- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index f2b8855415f41..b63a86ca2042e 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -62,6 +62,9 @@ pub trait Offence { /// function. fn current_era_start_session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. + /// Return a validators count at the time when the offence took place. + fn validators_count(&self) -> u32; + /// A point in time when this offence happened. /// /// The timescale is abstract and it doesn't have to be the same across different diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 6f2753e5dfd98..547b16f32284f 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -248,19 +248,21 @@ impl session::ShouldEndSession for Module { // TODO [slashing]: @marcio use this, remove the dead_code annotation. /// A BABE equivocation offence report. #[allow(dead_code)] -struct BabeEquivocationOffence { +struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. slot: u64, /// The session index that starts an era in which the incident happened. current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The size of the validator set at the time of the offence. + validators_count: u32, /// The authority which produced the equivocation. - offender: AuthorityId, + offender: FullIdentification, } -impl Offence for BabeEquivocationOffence { +impl Offence for BabeEquivocationOffence { const ID: Kind = *b"babe:equivocatio"; - fn offenders(&self) -> Vec { + fn offenders(&self) -> Vec { let mut offender = Vec::with_capacity(1); offender.push(self.offender.clone()); offender @@ -270,6 +272,10 @@ impl Offence for BabeEquivocationOffence { self.current_era_start_session_index } + fn validators_count(&self) -> u32 { + self.validators_count + } + fn time_slot(&self) -> TimeSlot { self.slot as TimeSlot } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 9905a7e5ec0a4..3df06bd8bf5a6 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -382,19 +382,21 @@ impl finality_tracker::OnFinalizationStalled for Modul // TODO [slashing]: Integrate this. /// A grandpa equivocation offence report. #[allow(dead_code)] -struct GrandpaEquivocationOffence { +struct GrandpaEquivocationOffence { /// A round in which the incident happened. round: u64, /// The session index that starts an era in which the incident happened. current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The size of the validator set at the time of the offence. + validators_count: u32, /// The authority which produced this equivocation. - offender: AuthorityId, + offender: FullIdentification, } -impl Offence for GrandpaEquivocationOffence { +impl Offence for GrandpaEquivocationOffence { const ID: Kind = *b"grandpa:equivoca"; - fn offenders(&self) -> Vec { + fn offenders(&self) -> Vec { let mut offender = Vec::with_capacity(1); offender.push(self.offender.clone()); offender @@ -404,6 +406,10 @@ impl Offence for GrandpaEquivocationOffence { self.current_era_start_session_index } + fn validators_count(&self) -> u32 { + self.validators_count + } + fn time_slot(&self) -> TimeSlot { self.round as TimeSlot } diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 5a9a938bae45e..ac200fce8f6e4 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -476,6 +476,8 @@ struct UnresponsivnessOffence { /// /// It acts as a time measure for unresponsivness reports. session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The size of the validator set in current session/era. + validators_count: u32, /// Authorities which were unresponsive during the current epoch. offenders: Vec, } @@ -491,6 +493,10 @@ impl Offence for UnresponsivnessOffence { self.current_era_start_session_index } + fn validators_count(&self) -> u32 { + self.validators_count + } + fn time_slot(&self) -> TimeSlot { self.session_index as TimeSlot } diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index b67b312323b92..286367f1293c6 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -22,26 +22,23 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] -use codec::{Decode, Encode}; use rstd::vec::Vec; -use session::{Module as Session, SessionIndex, historical}; +use session::{SessionIndex, historical}; use support::{ - StorageDoubleMap, Parameter, decl_module, decl_storage, + StorageDoubleMap, decl_module, decl_storage, }; use sr_primitives::{ Perbill, - traits::{Member, TypedKey}, offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, }; /// Offences trait -pub trait Trait: system::Trait + session::Trait + historical::Trait { - /// The identifier type for an authority. - type AuthorityId: Member + Parameter + Default + TypedKey + Decode + Encode + AsRef<[u8]>; +pub trait Trait: system::Trait + historical::Trait { /// A handler called for every offence report. - type OnOffenceHandler: OnOffenceHandler; + type OnOffenceHandler: OnOffenceHandler; } +/// The offences module. decl_storage! { trait Store for Module as Offences { /// A mapping between unique `TimeSlots` within a particular session and the offence `Kind` into @@ -51,7 +48,7 @@ decl_storage! { /// timeslot since the slashing will increase based on the length of this vec. OffenceReports get(offence_reports): double_map Kind, blake2_256((SessionIndex, TimeSlot)) - => Vec>; + => Vec>; } } @@ -60,13 +57,15 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -impl> ReportOffence - for Module +impl> ReportOffence + for Module where + T::FullIdentification: Clone, { fn report_offence(reporter: Option, offence: O) -> Result<(), ()> { let offenders = offence.offenders(); let time_slot = offence.time_slot(); let session = offence.current_era_start_session_index(); + let validators_count = offence.validators_count(); // Check if an offence is already reported for the offender authorities // and otherwise stores that report. @@ -99,17 +98,6 @@ impl> ReportOffence>::current_index() { - >::validators().len() as u32 - } else if let Some((_, count)) = >::historical_root(session) { - count - } else { - // session index seems invalid, we should pprobably just return an error. - return Err(()) - }; - - let offenders_count = all_offenders.len() as u32; let expected_fraction = O::slash_fraction(offenders_count, validators_count); let slash_perbil = all_offenders From 7b14a3709e7ee3a7e0c07dcb7dc6a08fbeff8815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 16:15:40 +0200 Subject: [PATCH 025/191] Use FullIndentification. --- srml/offences/src/lib.rs | 11 ++++----- srml/session/src/historical.rs | 2 +- srml/staking/src/lib.rs | 45 ++++++++++++++++++++-------------- srml/support/src/traits.rs | 6 ++--- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 286367f1293c6..51a0844bc4a3c 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -23,7 +23,7 @@ #![warn(missing_docs)] use rstd::vec::Vec; -use session::{SessionIndex, historical}; +use session::{SessionIndex, historical::{self, IdentificationTuple}}; use support::{ StorageDoubleMap, decl_module, decl_storage, }; @@ -35,10 +35,9 @@ use sr_primitives::{ /// Offences trait pub trait Trait: system::Trait + historical::Trait { /// A handler called for every offence report. - type OnOffenceHandler: OnOffenceHandler; + type OnOffenceHandler: OnOffenceHandler>; } -/// The offences module. decl_storage! { trait Store for Module as Offences { /// A mapping between unique `TimeSlots` within a particular session and the offence `Kind` into @@ -48,7 +47,7 @@ decl_storage! { /// timeslot since the slashing will increase based on the length of this vec. OffenceReports get(offence_reports): double_map Kind, blake2_256((SessionIndex, TimeSlot)) - => Vec>; + => Vec>>; } } @@ -57,9 +56,9 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -impl> ReportOffence +impl>> ReportOffence, O> for Module where - T::FullIdentification: Clone, + IdentificationTuple: Clone, { fn report_offence(reporter: Option, offence: O) -> Result<(), ()> { let offenders = offence.offenders(); diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index 9850638c1e336..772b9672dd455 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -281,7 +281,7 @@ impl> srml_support::traits::KeyOwnerProofSystem<(KeyTyp for Module { type Proof = Proof; - type FullIdentification = IdentificationTuple; + type IdentificationTuple = IdentificationTuple; fn prove(key: (KeyTypeId, D)) -> Option { let session = >::current_index(); diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index c959c440fe20e..f86dde684ca92 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1454,32 +1454,39 @@ impl SelectInitialValidators for Module { } } -// TODO [ToDr] Should it be AccountId or AuthorityId? -impl OnOffenceHandler for Module { +impl OnOffenceHandler> for Module where + T: session::Trait::AccountId>, + T: session::historical::Trait< + FullIdentification = Exposure<::AccountId, BalanceOf>, + FullIdentificationOf = ExposureOf, + >, + T::SessionHandler: session::SessionHandler<::AccountId>, + T::OnSessionEnding: session::OnSessionEnding<::AccountId>, + T::SelectInitialValidators: session::SelectInitialValidators<::AccountId>, + T::ValidatorIdOf: Convert<::AccountId, Option<::AccountId>> +{ fn on_offence( - offenders: &[OffenceDetails], + offenders: &[OffenceDetails>], slash_fraction: &[Perbill], ) { for (details, slash_fraction) in offenders.iter().zip(slash_fraction) { - if let Some(l) = Self::ledger(&details.offender) { - let stash = l.stash; + let stash = &details.offender.0; - // Early exit if validator is invulnerable. - if Self::invulnerables().contains(&stash) { - return - } + // Early exit if validator is invulnerable. + if Self::invulnerables().contains(stash) { + return + } - // let slash_exposure = Self::stakers(&stash).total; - // let amount = offline_slash_base - // // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) - // .checked_shl(unstake_threshold) - // .map(|x| x.min(slash_exposure)) - // .unwrap_or(slash_exposure); - // Self::slash_validator(details.offender, amount) - let _ = T::SessionInterface::disable_validator(&stash); - Self::apply_force_new_era(); - } + // let slash_exposure = Self::stakers(&stash).total; + // let amount = offline_slash_base + // // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) + // .checked_shl(unstake_threshold) + // .map(|x| x.min(slash_exposure)) + // .unwrap_or(slash_exposure); + // Self::slash_validator(details.offender, amount) + let _ = T::SessionInterface::disable_validator(stash); + Self::apply_force_new_era(); } } } diff --git a/srml/support/src/traits.rs b/srml/support/src/traits.rs index 5f1d7c32ef40e..86db0c54ef8ee 100644 --- a/srml/support/src/traits.rs +++ b/srml/support/src/traits.rs @@ -117,8 +117,8 @@ pub trait VerifySeal { pub trait KeyOwnerProofSystem { /// The proof of membership itself. type Proof: Codec; - /// The full identification of a key owner. - type FullIdentification: Codec; + /// The full identification of a key owner and the stash account. + type IdentificationTuple: Codec; /// Prove membership of a key owner in the current block-state. /// @@ -131,7 +131,7 @@ pub trait KeyOwnerProofSystem { /// Check a proof of membership on-chain. Return `Some` iff the proof is /// valid and recent enough to check. - fn check_proof(key: Key, proof: Self::Proof) -> Option; + fn check_proof(key: Key, proof: Self::Proof) -> Option; } /// Handler for when some currency "account" decreased in balance for From cea7edce69d39ccefa88bff005433e5af33f86fb Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 16:18:46 +0200 Subject: [PATCH 026/191] Hook up the offences module. --- node/runtime/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index bd0d0c5939327..3d0ecb24619a6 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -372,6 +372,10 @@ impl im_online::Trait for Runtime { type Call = Call; type Event = Event; type UncheckedExtrinsic = UncheckedExtrinsic; + +impl offences::Trait for Runtime { + type AuthorityId = BabeId; // TODO [slashing]: What should this be??? + type OnOffenceHandler = Staking; } impl grandpa::Trait for Runtime { @@ -413,6 +417,7 @@ construct_runtime!( Contracts: contracts, Sudo: sudo, ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, + Offences: offences::{Module, Call, Storage}, } ); From da01b46433f799d7a52e87bc78d664d7f4e00d4b Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 16:20:14 +0200 Subject: [PATCH 027/191] Report unresponsive validators --- core/sr-primitives/src/traits.rs | 6 ++++++ node/runtime/src/lib.rs | 3 +++ srml/im-online/src/lib.rs | 37 +++++++++++++++++++++++++++----- srml/staking/src/lib.rs | 6 ++++++ 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index ce67a888bc467..b1622f11bf819 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -1018,6 +1018,12 @@ pub trait ValidateUnsigned { fn validate_unsigned(call: &Self::Call) -> TransactionValidity; } +/// A trait for fetching the current era start session index. +pub trait CurrentEraStartSessionIndex { + /// Returns a session index which is starts an era. + fn current_era_start_session_index() -> u32; // TODO [slashing]: Should be a SessionIndex. +} + /// Opaque datatype that may be destructured into a series of raw byte slices (which represent /// individual keys). pub trait OpaqueKeys: Clone { diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 3d0ecb24619a6..35ea7157cccd3 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -372,6 +372,9 @@ impl im_online::Trait for Runtime { type Call = Call; type Event = Event; type UncheckedExtrinsic = UncheckedExtrinsic; + type ReportUnresponsivness = Offences; + type CurrentEraStartSessionIndex = Staking; +} impl offences::Trait for Runtime { type AuthorityId = BabeId; // TODO [slashing]: What should this be??? diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index ac200fce8f6e4..3d9a74cb1dd87 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -74,9 +74,9 @@ use substrate_primitives::{ use codec::{Encode, Decode}; use session::SessionIndex; use sr_primitives::{ - Perbill, ApplyError, traits::{Extrinsic as ExtrinsicT}, + Perbill, ApplyError, traits::{Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, - offence::{Offence, TimeSlot, Kind}, + offence::{ReportOffence, Offence, TimeSlot, Kind}, }; use sr_std::prelude::*; use sr_io::Printable; @@ -175,6 +175,12 @@ pub trait Trait: system::Trait + session::Trait { /// A extrinsic right from the external world. This is unchecked and so /// can contain a signature. type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; + + /// A type that gives us ability to submit unresponsivness offence reports. + type ReportUnresponsivness: ReportOffence; + + /// A function that returns the session index that started the current era. + type CurrentEraStartSessionIndex: CurrentEraStartSessionIndex; } decl_event!( @@ -408,7 +414,27 @@ impl session::OneSessionHandler for Module { } fn on_before_session_ending() { - // TODO [slashing] report validators + let current_session = >::current_index(); + + let keys = Keys::get(); + let mut unresponsive = vec![]; + for (auth_idx, auth_key) in keys.iter().enumerate() { + if !::exists(¤t_session, &(auth_idx as u32)) { + unresponsive.push(auth_key.clone()); + } + } + + let current_era_start_session_index = + T::CurrentEraStartSessionIndex::current_era_start_session_index(); + + let offence = UnresponsivnessOffence { + session_index: current_session, + current_era_start_session_index, + offenders: unresponsive, + }; + + // TODO [slashing]: Handle the result. Just write a proof? + T::ReportUnresponsivness::report_offence(None, offence); } fn on_disabled(_i: usize) { @@ -469,12 +495,13 @@ impl srml_support::unsigned::ValidateUnsigned for Module { } /// An offense which is filed if a validator didn't send a heartbeat message. -struct UnresponsivnessOffence { +pub struct UnresponsivnessOffence { /// The session index that starts an era in which the incident happened. current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The session index at which we file this report. /// - /// It acts as a time measure for unresponsivness reports. + /// It acts as a time measure for unresponsivness reports and effectively will always point + /// at the end of the session. session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The size of the validator set in current session/era. validators_count: u32, diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index f86dde684ca92..1398f0b614dda 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1387,6 +1387,12 @@ impl OnFreeBalanceZero for Module { } } +impl primitives::traits::CurrentEraStartSessionIndex for Module { + fn current_era_start_session_index() -> u32 { + CurrentEraStartSessionIndex::get() + } +} + /// Add reward points to block authors: /// * 20 points to the block producer for producing a (non-uncle) block in the relay chain, /// * 2 points to the block producer for each reference to a previously unreferenced uncle, and From e25b43a6026042fa5e57ddb4ef0f6373d88cea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 16:33:51 +0200 Subject: [PATCH 028/191] Make sure eras have the same length. --- srml/im-online/src/lib.rs | 2 ++ srml/staking/src/lib.rs | 7 +++---- srml/staking/src/tests.rs | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 3d9a74cb1dd87..08d0fd5f8b584 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -426,10 +426,12 @@ impl session::OneSessionHandler for Module { let current_era_start_session_index = T::CurrentEraStartSessionIndex::current_era_start_session_index(); + let validators_count = keys.len() as u32; let offence = UnresponsivnessOffence { session_index: current_session, current_era_start_session_index, + validators_count, offenders: unresponsive, }; diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 1398f0b614dda..9164091f14db8 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1069,9 +1069,8 @@ impl Module { fn new_session(session_index: SessionIndex) -> Option<(Vec, Vec<(T::AccountId, Exposure>)>)> { - // TODO [slashing] The new era should be SessionsPerEra long, so - // we should use CurrentEraStartSessionIndexS to calculate end of the era. - if ForceNewEra::take() || session_index % T::SessionsPerEra::get() == 0 { + let era_length = session_index.checked_sub(Self::current_era_start_session_index()).unwrap_or(0); + if ForceNewEra::take() || era_length == T::SessionsPerEra::get() { let validators = T::SessionInterface::validators(); let prior = validators.into_iter() .map(|v| { let e = Self::stakers(&v); (v, e) }) @@ -1387,7 +1386,7 @@ impl OnFreeBalanceZero for Module { } } -impl primitives::traits::CurrentEraStartSessionIndex for Module { +impl sr_primitives::traits::CurrentEraStartSessionIndex for Module { fn current_era_start_session_index() -> u32 { CurrentEraStartSessionIndex::get() } diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index f5ec91254c959..5a8652339e02a 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1902,3 +1902,23 @@ fn unbonded_balance_is_not_slashable() { assert_eq!(Staking::slashable_balance_of(&11), 200); }) } + +#[test] +fn era_is_always_same_length() { + with_externalities(&mut ExtBuilder::default().build(), || { + start_era(1); + assert_eq!(Staking::current_era_start_session_index(), SessionsPerEra::get()); + + start_era(2); + assert_eq!(Staking::current_era_start_session_index(), SessionsPerEra::get() * 2); + + let session = Session::current_index(); + ForceNewEra::put(true); + start_next_session(); + assert_eq!(Staking::current_era(), 3); + assert_eq!(Staking::current_era_start_session_index(), session + 1); + + start_era(4); + assert_eq!(Staking::current_era_start_session_index(), session + SessionsPerEra::get() + 1); + }); +} From 55aeff59a266d7f49e2588031c1089ebf0ab09c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 17:30:33 +0200 Subject: [PATCH 029/191] Slashing and rewards. --- node/runtime/src/lib.rs | 1 - srml/staking/src/lib.rs | 126 ++++++++++++++++------------------------ 2 files changed, 49 insertions(+), 78 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 35ea7157cccd3..fd143bd12899b 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -377,7 +377,6 @@ impl im_online::Trait for Runtime { } impl offences::Trait for Runtime { - type AuthorityId = BabeId; // TODO [slashing]: What should this be??? type OnOffenceHandler = Staking; } diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 9164091f14db8..dcbb45b770458 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -576,6 +576,11 @@ decl_storage! { /// True if the next session change will be a new era regardless of index. pub ForceNewEra get(forcing_new_era): bool; + /// The percentage of the slash that is distributed to reporters. + /// + /// The rest of the slashed value is handled by the `Slash`. + pub SlashRewardFraction get(slash_reward_fraction) config(): Perbill; + /// A mapping from still-bonded eras to the first session index of that era. BondedEras: Vec<(EraIndex, SessionIndex)>; } @@ -622,11 +627,8 @@ decl_event!( pub enum Event where Balance = BalanceOf, ::AccountId { /// All validators have been rewarded by the given balance. Reward(Balance), - /// One validator (and its nominators) has been given an offline-warning (it is still - /// within its grace). The accrued number of slashes is recorded, too. - OfflineWarning(AccountId, u32), /// One validator (and its nominators) has been slashed by the given amount. - OfflineSlash(AccountId, Balance), + Slash(AccountId, Balance), } ); @@ -984,17 +986,23 @@ impl Module { >::insert(controller, ledger); } - /// Slash a given validator by a specific amount. Removes the slash from the validator's - /// balance by preference, and reduces the nominators' balance if needed. - fn slash_validator(stash: T::AccountId, slash: BalanceOf) { - // The exposure (backing stake) information of the validator to be slashed. - let exposure = Self::stakers(&stash); + /// Slash a given validator by a specific amount with given (historical) exposure. + /// + /// Removes the slash from the validator's balance by preference, + /// and reduces the nominators' balance if needed. + /// + /// Returns the resulting `NegativeImbalance` to allow distributing the slashed amount. + fn slash_validator( + stash: &T::AccountId, + slash: BalanceOf, + exposure: &Exposure>, + ) -> NegativeImbalanceOf { // The amount we are actually going to slash (can't be bigger than the validator's total // exposure) let slash = slash.min(exposure.total); // The amount we'll slash from the validator's stash directly. let own_slash = exposure.own.min(slash); - let (mut imbalance, missing) = T::Currency::slash(&stash, own_slash); + let (mut imbalance, missing) = T::Currency::slash(stash, own_slash); let own_slash = own_slash - missing; // The amount remaining that we can't slash from the validator, // that must be taken from the nominators. @@ -1010,8 +1018,13 @@ impl Module { } } } - // TODO [slashing] Distribute reward to reporters? - T::Slash::on_unbalanced(imbalance); + + // trigger the event + Self::deposit_event( + RawEvent::Slash(stash.clone(), slash) + ); + + imbalance } /// Actually make a payment to a staker. This uses the currency's reward function @@ -1289,63 +1302,6 @@ impl Module { >::remove(stash); >::remove(stash); } - // - // /// Call when a validator is determined to be offline. `count` is the - // /// number of offenses the validator has committed. - // /// - // /// NOTE: This is called with the controller (not the stash) account id. - // pub fn on_offline_validator(controller: T::AccountId, count: usize) { - // if let Some(l) = Self::ledger(&controller) { - // let stash = l.stash; - // - // // Early exit if validator is invulnerable. - // if Self::invulnerables().contains(&stash) { - // return - // } - // - // let slash_count = Self::slash_count(&stash); - // let new_slash_count = slash_count + count as u32; - // >::insert(&stash, new_slash_count); - // let grace = Self::offline_slash_grace(); - // - // if RECENT_OFFLINE_COUNT > 0 { - // let item = (stash.clone(), >::block_number(), count as u32); - // >::mutate(|v| if v.len() >= RECENT_OFFLINE_COUNT { - // let index = v.iter() - // .enumerate() - // .min_by_key(|(_, (_, block, _))| block) - // .expect("v is non-empty; qed") - // .0; - // v[index] = item; - // } else { - // v.push(item); - // }); - // } - // - // let prefs = Self::validators(&stash); - // let unstake_threshold = prefs.unstake_threshold.min(MAX_UNSTAKE_THRESHOLD); - // let max_slashes = grace + unstake_threshold; - // - // let event = if new_slash_count > max_slashes { - // let slash_exposure = Self::stakers(&stash).total; - // let offline_slash_base = Self::offline_slash() * slash_exposure; - // // They're bailing. - // let slash = offline_slash_base - // // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) - // .checked_shl(unstake_threshold) - // .map(|x| x.min(slash_exposure)) - // .unwrap_or(slash_exposure); - // let _ = Self::slash_validator(&stash, slash); - // let _ = T::SessionInterface::disable_validator(&stash); - // - // RawEvent::OfflineSlash(stash.clone(), slash) - // } else { - // RawEvent::OfflineWarning(stash.clone(), slash_count) - // }; - // - // Self::deposit_event(event); - // } - // } /// Add reward points to validator. /// @@ -1474,24 +1430,40 @@ impl OnOffenceHandler>], slash_fraction: &[Perbill], ) { + let mut remaining_imbalance = >::zero(); + let slash_reward_fraction = SlashRewardFraction::get(); + for (details, slash_fraction) in offenders.iter().zip(slash_fraction) { let stash = &details.offender.0; + let exposure = &details.offender.1; // Early exit if validator is invulnerable. if Self::invulnerables().contains(stash) { return } - - // let slash_exposure = Self::stakers(&stash).total; - // let amount = offline_slash_base - // // Multiply slash_mantissa by 2^(unstake_threshold with upper bound) - // .checked_shl(unstake_threshold) - // .map(|x| x.min(slash_exposure)) - // .unwrap_or(slash_exposure); - // Self::slash_validator(details.offender, amount) + // make sure to disable validator in next sessions let _ = T::SessionInterface::disable_validator(stash); + // force a new era, to select a new validator set Self::apply_force_new_era(); + + // now slash the validator and distribute the rewards + let slash_exposure = exposure.total; + let amount = *slash_fraction * slash_exposure; + let imbalance = Self::slash_validator(stash, amount, exposure); + + // distribute the rewards according to the slash + let slash_reward = slash_reward_fraction * imbalance.peek(); + if !slash_reward.is_zero() { + let (reward, rest) = imbalance.split(slash_reward); + // TODO [slashing] split between reporters + remaining_imbalance.subsume(rest); + } else { + remaining_imbalance.subsume(imbalance); + } } + + // Handle the rest of imbalances + T::Slash::on_unbalanced(remaining_imbalance); } } From 0c8b03f4494d24634942a80f32ebc7e47410cd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 17:45:51 +0200 Subject: [PATCH 030/191] Fix compilation. --- node/cli/src/chain_spec.rs | 3 +++ srml/im-online/Cargo.toml | 2 +- srml/im-online/src/lib.rs | 25 +++++++++++++++++-------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 0ad9f3331c986..75eaed3cd3937 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -31,6 +31,7 @@ use substrate_service; use hex_literal::hex; use substrate_telemetry::TelemetryEndpoints; use grandpa::AuthorityId as GrandpaId; +use sr_primitives::Perbill; const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; @@ -133,6 +134,7 @@ fn staging_testnet_config_genesis() -> GenesisConfig { (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator) }).collect(), invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(), + slash_reward_fraction: Perbill::from_percent(10), }), democracy: Some(DemocracyConfig::default()), collective_Instance1: Some(CouncilConfig { @@ -270,6 +272,7 @@ pub fn testnet_genesis( (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator) }).collect(), invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(), + slash_reward_fraction: Perbill::from_percent(10), }), democracy: Some(DemocracyConfig::default()), collective_Instance1: Some(CouncilConfig { diff --git a/srml/im-online/Cargo.toml b/srml/im-online/Cargo.toml index fee2ba4bc2295..f7b43eee99a79 100644 --- a/srml/im-online/Cargo.toml +++ b/srml/im-online/Cargo.toml @@ -16,7 +16,7 @@ srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } [features] -default = ["std"] +default = ["std", "session/historical"] std = [ "codec/std", "serde", diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 08d0fd5f8b584..076ce699e1649 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -72,7 +72,10 @@ use substrate_primitives::{ offchain::{self, OpaqueNetworkState, StorageKind}, }; use codec::{Encode, Decode}; -use session::SessionIndex; +use session::{ + SessionIndex, + historical::IdentificationTuple +}; use sr_primitives::{ Perbill, ApplyError, traits::{Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, @@ -165,7 +168,7 @@ pub struct Heartbeat authority_index: AuthIndex, } -pub trait Trait: system::Trait + session::Trait { +pub trait Trait: system::Trait + session::historical::Trait { /// The overarching event type. type Event: From + Into<::Event>; @@ -177,7 +180,11 @@ pub trait Trait: system::Trait + session::Trait { type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; /// A type that gives us ability to submit unresponsivness offence reports. - type ReportUnresponsivness: ReportOffence; + type ReportUnresponsivness: ReportOffence< + Self::AccountId, + IdentificationTuple, + UnresponsivnessOffence>, + >; /// A function that returns the session index that started the current era. type CurrentEraStartSessionIndex: CurrentEraStartSessionIndex; @@ -432,7 +439,9 @@ impl session::OneSessionHandler for Module { session_index: current_session, current_era_start_session_index, validators_count, - offenders: unresponsive, + // TODO [slashing] figure out the IdentificationTuples for offenders. + //offenders: unresponsive, + offenders: vec![], }; // TODO [slashing]: Handle the result. Just write a proof? @@ -497,7 +506,7 @@ impl srml_support::unsigned::ValidateUnsigned for Module { } /// An offense which is filed if a validator didn't send a heartbeat message. -pub struct UnresponsivnessOffence { +pub struct UnresponsivnessOffence { /// The session index that starts an era in which the incident happened. current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The session index at which we file this report. @@ -508,13 +517,13 @@ pub struct UnresponsivnessOffence { /// The size of the validator set in current session/era. validators_count: u32, /// Authorities which were unresponsive during the current epoch. - offenders: Vec, + offenders: Vec, } -impl Offence for UnresponsivnessOffence { +impl Offence for UnresponsivnessOffence { const ID: Kind = *b"im-online:offlin"; - fn offenders(&self) -> Vec { + fn offenders(&self) -> Vec { self.offenders.clone() } From 382ffa3239d36775a80487290aace4b76d3712e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 17:58:15 +0200 Subject: [PATCH 031/191] Distribute rewards. --- srml/staking/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index dcbb45b770458..16dcaf43c5b7b 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1455,8 +1455,16 @@ impl OnOffenceHandler Date: Wed, 7 Aug 2019 16:28:19 +0200 Subject: [PATCH 032/191] Supply validators_count --- srml/im-online/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 076ce699e1649..aaa0c79635f39 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -436,6 +436,7 @@ impl session::OneSessionHandler for Module { let validators_count = keys.len() as u32; let offence = UnresponsivnessOffence { + validators_count: keys.len() as u32, session_index: current_session, current_era_start_session_index, validators_count, From fae60b9f2a19dd8886badcaec87a05bdfebfc84e Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 18:06:10 +0200 Subject: [PATCH 033/191] Use identificationTuple in Unresponsivness report --- core/sr-primitives/src/traits.rs | 13 +++++-- node/runtime/src/lib.rs | 1 + srml/im-online/src/lib.rs | 60 ++++++++++++++++++++++---------- srml/staking/src/lib.rs | 10 +++++- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index b1622f11bf819..b8c8e69c40308 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -1018,12 +1018,21 @@ pub trait ValidateUnsigned { fn validate_unsigned(call: &Self::Call) -> TransactionValidity; } -/// A trait for fetching the current era start session index. +// TODO [slashing]: move into staking-primitives? +/// A trait for fetching the session index which started the current era. pub trait CurrentEraStartSessionIndex { - /// Returns a session index which is starts an era. + /// Returns the session index which started the current era. fn current_era_start_session_index() -> u32; // TODO [slashing]: Should be a SessionIndex. } +// TODO [slashing]: move into staking-primitives? +/// A trait for fetching a validator id by the given index. +pub trait ValidatorIdByIndex { + /// Return a validator identification by the given index in the current elected set of the era, + // or `None` if `validator_index` is out of range. + fn validator_id_by_index(validator_index: u32) -> Option; +} + /// Opaque datatype that may be destructured into a series of raw byte slices (which represent /// individual keys). pub trait OpaqueKeys: Clone { diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index ea8cd309c7704..4fc15b4efa8b2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -374,6 +374,7 @@ impl im_online::Trait for Runtime { type UncheckedExtrinsic = UncheckedExtrinsic; type ReportUnresponsivness = Offences; type CurrentEraStartSessionIndex = Staking; + type ValidatorIdByIndex = Staking; } impl offences::Trait for Runtime { diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index aaa0c79635f39..8054759e940c1 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -74,10 +74,11 @@ use substrate_primitives::{ use codec::{Encode, Decode}; use session::{ SessionIndex, - historical::IdentificationTuple + historical::IdentificationTuple, }; use sr_primitives::{ - Perbill, ApplyError, traits::{Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex}, + Perbill, ApplyError, + traits::{ValidatorIdByIndex, Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex, Convert}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, offence::{ReportOffence, Offence, TimeSlot, Kind}, }; @@ -180,14 +181,18 @@ pub trait Trait: system::Trait + session::historical::Trait { type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; /// A type that gives us ability to submit unresponsivness offence reports. - type ReportUnresponsivness: ReportOffence< - Self::AccountId, - IdentificationTuple, - UnresponsivnessOffence>, - >; + type ReportUnresponsivness: + ReportOffence< + Self::AccountId, + IdentificationTuple, + UnresponsivnessOffence>, + >; /// A function that returns the session index that started the current era. type CurrentEraStartSessionIndex: CurrentEraStartSessionIndex; + + /// A type that returns a validator id from the current elected set of the era. + type ValidatorIdByIndex: ValidatorIdByIndex<::ValidatorId>; } decl_event!( @@ -408,7 +413,8 @@ impl session::OneSessionHandler for Module { type Key = AuthorityId; fn on_new_session<'a, I: 'a>(_changed: bool, _validators: I, next_validators: I) - where I: Iterator + where + I: Iterator, { // Reset heartbeats ::remove_prefix(&>::current_index()); @@ -425,23 +431,39 @@ impl session::OneSessionHandler for Module { let keys = Keys::get(); let mut unresponsive = vec![]; - for (auth_idx, auth_key) in keys.iter().enumerate() { - if !::exists(¤t_session, &(auth_idx as u32)) { - unresponsive.push(auth_key.clone()); + for auth_idx in 0..keys.len() { + let auth_idx = auth_idx as u32; + if !::exists(¤t_session, &auth_idx) { + // Get the validator id by the index of its session key and then use this + // validator id to get the full identification. In practice it cannot return `None` + // since we are querying when the session hasn't yet ended. + let validator_id = T::ValidatorIdByIndex::validator_id_by_index(auth_idx).expect( + "auth_idx is an index `0..keys.len()`; + `keys` is populated from the current elected set; + `validator_id_by_index` queries validators from the current elected set; + thus it can't return `None`; + qed", + ); + let full_identification = T::FullIdentificationOf::convert(validator_id.clone()) + .expect( + "the validator id is from the current era; + the mapping between the validator id and its full identification should be valid; + thus it can't return `None`; + qed", + ); + + unresponsive.push((validator_id, full_identification)); } } let current_era_start_session_index = T::CurrentEraStartSessionIndex::current_era_start_session_index(); let validators_count = keys.len() as u32; - let offence = UnresponsivnessOffence { - validators_count: keys.len() as u32, session_index: current_session, current_era_start_session_index, validators_count, - // TODO [slashing] figure out the IdentificationTuples for offenders. - //offenders: unresponsive, + offenders: unresponsive, offenders: vec![], }; @@ -507,7 +529,7 @@ impl srml_support::unsigned::ValidateUnsigned for Module { } /// An offense which is filed if a validator didn't send a heartbeat message. -pub struct UnresponsivnessOffence { +pub struct UnresponsivnessOffence { /// The session index that starts an era in which the incident happened. current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The session index at which we file this report. @@ -517,14 +539,14 @@ pub struct UnresponsivnessOffence { session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The size of the validator set in current session/era. validators_count: u32, - /// Authorities which were unresponsive during the current epoch. + /// Authorities which were unresponsive during the current era. offenders: Vec, } -impl Offence for UnresponsivnessOffence { +impl Offence for UnresponsivnessOffence { const ID: Kind = *b"im-online:offlin"; - fn offenders(&self) -> Vec { + fn offenders(&self) -> Vec { self.offenders.clone() } diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 16dcaf43c5b7b..3d79499925f9c 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -277,7 +277,7 @@ use sr_primitives::offence::{OnOffenceHandler, OffenceDetails}; use sr_primitives::weights::SimpleDispatchInfo; use sr_primitives::traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, - SimpleArithmetic, SaturatedConversion, + SimpleArithmetic, SaturatedConversion, ValidatorIdByIndex, }; #[cfg(feature = "std")] use sr_primitives::{Serialize, Deserialize}; @@ -1475,3 +1475,11 @@ impl OnOffenceHandler ValidatorIdByIndex for Module { + fn validator_id_by_index(validator_index: u32) -> Option { + Self::current_elected() + .get(validator_index as usize) + .cloned() + } +} From 6af9ffcb8ae114534f2805f44c49d658be343e21 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 18:17:59 +0200 Subject: [PATCH 034/191] Fix merge. --- Cargo.lock | 2 +- srml/im-online/src/lib.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fe238f1aa679..37ecab1593df8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4434,8 +4434,8 @@ dependencies = [ name = "substrate-consensus-babe-primitives" version = "2.0.0" dependencies = [ - "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-client 2.0.0", diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 8054759e940c1..5f0e1bac8115d 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -464,7 +464,6 @@ impl session::OneSessionHandler for Module { current_era_start_session_index, validators_count, offenders: unresponsive, - offenders: vec![], }; // TODO [slashing]: Handle the result. Just write a proof? @@ -540,7 +539,7 @@ pub struct UnresponsivnessOffence { /// The size of the validator set in current session/era. validators_count: u32, /// Authorities which were unresponsive during the current era. - offenders: Vec, + offenders: Vec, } impl Offence for UnresponsivnessOffence { From f2f91abf05b855e66b2f41803d473f99119ad22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 18:54:49 +0200 Subject: [PATCH 035/191] Make sure we don't slash if amount is zero. --- core/sr-primitives/src/offence.rs | 2 +- srml/offences/src/lib.rs | 4 +--- srml/staking/src/lib.rs | 14 ++++++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index b63a86ca2042e..75a9855a10185 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -86,7 +86,7 @@ pub trait Offence { /// A trait for decoupling offence reporters from the actual handling of offence reports. pub trait ReportOffence> { /// Report an `offence` and reward the `reporter`. - fn report_offence(reporter: Option, offence: O) -> Result<(), ()>; + fn report_offence(reporter: Option, offence: O); } /// A trait to take action on an offence. diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 51a0844bc4a3c..0b86252df96c1 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -60,7 +60,7 @@ impl>> ReportOffence where IdentificationTuple: Clone, { - fn report_offence(reporter: Option, offence: O) -> Result<(), ()> { + fn report_offence(reporter: Option, offence: O) { let offenders = offence.offenders(); let time_slot = offence.time_slot(); let session = offence.current_era_start_session_index(); @@ -121,8 +121,6 @@ impl>> ReportOffence OnOffenceHandler Date: Wed, 7 Aug 2019 18:56:55 +0200 Subject: [PATCH 036/191] We don't return an error from report_offence anymo --- srml/im-online/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 5f0e1bac8115d..e3ca478281f6f 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -466,7 +466,6 @@ impl session::OneSessionHandler for Module { offenders: unresponsive, }; - // TODO [slashing]: Handle the result. Just write a proof? T::ReportUnresponsivness::report_offence(None, offence); } From fdbc3bdf8c3f635e4e3e1b6564eae2db62a5cce7 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 18:57:22 +0200 Subject: [PATCH 037/191] We actually can use vec! --- srml/babe/src/lib.rs | 4 +--- srml/grandpa/src/lib.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 547b16f32284f..3a67b30d8c1ec 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -263,9 +263,7 @@ impl Offence for BabeEquivocation const ID: Kind = *b"babe:equivocatio"; fn offenders(&self) -> Vec { - let mut offender = Vec::with_capacity(1); - offender.push(self.offender.clone()); - offender + vec![self.offender.clone()] } fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 3df06bd8bf5a6..4ff6a5fc8be33 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -397,9 +397,7 @@ impl Offence for GrandpaEquivocat const ID: Kind = *b"grandpa:equivoca"; fn offenders(&self) -> Vec { - let mut offender = Vec::with_capacity(1); - offender.push(self.offender.clone()); - offender + vec![self.offender.clone()] } fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. From c10166641985f7992479cad89b6d13133f56bc51 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 20:02:05 +0200 Subject: [PATCH 038/191] Prevent division by zero if the reporters is empty --- srml/staking/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 0d8e1c25fde4b..bc9f4ac845a83 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1460,9 +1460,10 @@ impl OnOffenceHandler Date: Wed, 7 Aug 2019 21:36:01 +0200 Subject: [PATCH 039/191] offence_forces_new_era/nominators_also_get_slashed --- srml/staking/src/mock.rs | 6 +++-- srml/staking/src/tests.rs | 57 +++++++++++++++++++++++++++++++-------- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index c7cbff2757e69..f9e3debf5406a 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -71,8 +71,8 @@ impl session::SessionHandler for TestSessionHandler { } } -pub fn is_disabled(validator: AccountId) -> bool { - let stash = Staking::ledger(&validator).unwrap().stash; +pub fn is_disabled(controller: AccountId) -> bool { + let stash = Staking::ledger(&controller).unwrap().stash; SESSION.with(|d| d.borrow().1.contains(&stash)) } @@ -297,6 +297,7 @@ impl ExtBuilder { let _ = GenesisConfig::{ current_era: 0, stakers: vec![ + // (stash, controller, staked_amount, status) (11, 10, balance_factor * 1000, StakerStatus::::Validator), (21, 20, stake_21, StakerStatus::::Validator), (31, 30, stake_31, StakerStatus::::Validator), @@ -307,6 +308,7 @@ impl ExtBuilder { validator_count: self.validator_count, minimum_validator_count: self.minimum_validator_count, invulnerables: vec![], + slash_reward_fraction: Perbill::from_percent(10), }.assimilate_storage(&mut t, &mut c); let _ = session::GenesisConfig:: { diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 5a8652339e02a..fdd4d5f9bfc19 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -19,7 +19,10 @@ use super::*; use runtime_io::with_externalities; use phragmen; -use sr_primitives::traits::OnInitialize; +use sr_primitives::{ + traits::OnInitialize, + offence::{OffenceDetails, OnOffenceHandler}, +}; use srml_support::{assert_ok, assert_noop, assert_eq_uvec, EnumerableStorageMap}; use mock::*; use srml_support::traits::{Currency, ReservableCurrency}; @@ -555,6 +558,10 @@ fn nominating_and_rewards_should_work() { #[test] fn nominators_also_get_slashed() { // A nominator should be slashed if the validator they nominated is slashed + // Here is the breakdown of roles: + // 10 - is the controller of 11 + // 11 - is the stash. + // 2 - is the nominator of 20, 10 with_externalities(&mut ExtBuilder::default().nominate(false).build(), || { assert_eq!(Staking::validator_count(), 2); @@ -567,15 +574,11 @@ fn nominators_also_get_slashed() { let _ = Balances::make_free_balance_be(i, initial_balance); } - // 2 will nominate for 10 + // 2 will nominate for 10, 20 let nominator_stake = 500; assert_ok!(Staking::bond(Origin::signed(1), 2, nominator_stake, RewardDestination::default())); assert_ok!(Staking::nominate(Origin::signed(2), vec![20, 10])); - let total_payout = current_total_payout_for_duration(3); - assert!(total_payout > 100); // Test is meaningfull if reward something - >::add_reward_points_to_validator(11, 1); - // new era, pay rewards, start_era(1); @@ -583,16 +586,25 @@ fn nominators_also_get_slashed() { assert_eq!(Balances::total_balance(&2), initial_balance); // 10 goes offline - let slash = 4; - Staking::slash_validator(10, slash); - let expo = Staking::stakers(10); - let slash_value = slash * expo.total * 2_u64.pow(3); + Staking::on_offence( + &[OffenceDetails { + offender: ( + 11, + dbg!(Staking::stakers(&11)), + ), + count: 1, + reporters: vec![], + }], + &[Perbill::from_percent(5)], + ); + let expo = Staking::stakers(11); + let slash_value = 50; let total_slash = expo.total.min(slash_value); let validator_slash = expo.own.min(total_slash); let nominator_slash = nominator_stake.min(total_slash - validator_slash); // initial + first era reward + slash - assert_eq!(Balances::total_balance(&10), initial_balance + total_payout - validator_slash); + assert_eq!(Balances::total_balance(&11), initial_balance - validator_slash); assert_eq!(Balances::total_balance(&2), initial_balance - nominator_slash); check_exposure_all(); check_nominator_all(); @@ -1922,3 +1934,26 @@ fn era_is_always_same_length() { assert_eq!(Staking::current_era_start_session_index(), session + SessionsPerEra::get() + 1); }); } + +#[test] +fn offence_forces_new_era() { + with_externalities(&mut ExtBuilder::default().build(), || { + Staking::on_offence( + &[OffenceDetails { + offender: ( + 11, + Exposure { + own: 500, + total: 500, + others: vec![], + }, + ), + count: 1, + reporters: vec![], + }], + &[Perbill::from_percent(5)], + ); + + assert!(Staking::forcing_new_era()); + }); +} From b7989c93b516583adcd0457af1c50161f7ce5778 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 21:39:42 +0200 Subject: [PATCH 040/191] advance_session --- srml/staking/src/mock.rs | 5 +++++ srml/staking/src/tests.rs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index f9e3debf5406a..5d76c0a5864d5 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -394,6 +394,11 @@ pub fn bond_nominator(acc: u64, val: u64, target: Vec) { assert_ok!(Staking::nominate(Origin::signed(acc), target)); } +pub fn advance_session() { + let current_index = Session::current_index(); + start_session(current_index + 1); +} + pub fn start_session(session_index: session::SessionIndex) { // Compensate for session delay let session_index = session_index + 1; diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index fdd4d5f9bfc19..abecb42fc7ae2 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1926,7 +1926,7 @@ fn era_is_always_same_length() { let session = Session::current_index(); ForceNewEra::put(true); - start_next_session(); + advance_session(); assert_eq!(Staking::current_era(), 3); assert_eq!(Staking::current_era_start_session_index(), session + 1); @@ -1935,6 +1935,9 @@ fn era_is_always_same_length() { }); } +// TODO: a slash is performed according to the exposure, not the current balance. +// TODO: a validator is disabled + #[test] fn offence_forces_new_era() { with_externalities(&mut ExtBuilder::default().build(), || { From 21c1131dd05016e20ffd491fb7ba122e4abfa2b6 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 22:06:35 +0200 Subject: [PATCH 041/191] Fix tests. --- srml/staking/src/tests.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index abecb42fc7ae2..a49e2c352d4a8 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1871,7 +1871,7 @@ fn reward_validator_slashing_validator_doesnt_overflow() { ]}); // Check slashing - Staking::slash_validator(10, reward_slash); + let _ = Staking::slash_validator(&11, reward_slash, &Staking::stakers(&11)); assert_eq!(Balances::total_balance(&11), stake - 1); assert_eq!(Balances::total_balance(&2), 1); }) @@ -1945,11 +1945,7 @@ fn offence_forces_new_era() { &[OffenceDetails { offender: ( 11, - Exposure { - own: 500, - total: 500, - others: vec![], - }, + Staking::stakers(&11), ), count: 1, reporters: vec![], From e9029f84b86fabe80ab7a8d7b56da8d6869f4ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 22:15:57 +0200 Subject: [PATCH 042/191] Update srml/staking/src/lib.rs Co-Authored-By: Robert Habermeier --- srml/staking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index bc9f4ac845a83..3c8f0fcb63254 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -145,7 +145,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! /// Slash a validator for an offence. +//! /// Slash a validator for an offence. //! pub fn slash_myself(origin) -> Result { //! let reported = ensure_signed(origin)?; //! >::slash_validator(reported, 1_000.into()); From e40e448661ae3c379951873f56bcea65e09667b8 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 22:17:01 +0200 Subject: [PATCH 043/191] slashing_performed_according_exposure --- srml/staking/src/tests.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index a49e2c352d4a8..439e260a1e2e6 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1936,7 +1936,6 @@ fn era_is_always_same_length() { } // TODO: a slash is performed according to the exposure, not the current balance. -// TODO: a validator is disabled #[test] fn offence_forces_new_era() { @@ -1956,3 +1955,32 @@ fn offence_forces_new_era() { assert!(Staking::forcing_new_era()); }); } + +#[test] +fn slashing_performed_according_exposure() { + // This test checks that slashing is performed according the exposure (or more precisely, + // historical exposure), not the current balance. + with_externalities(&mut ExtBuilder::default().build(), || { + assert_eq!(Staking::stakers(&11).own, 1000); + + // Handle an offence with a historical exposure. + Staking::on_offence( + &[OffenceDetails { + offender: ( + 11, + Exposure { + total: 500, + own: 500, + others: vec![], + }, + ), + count: 1, + reporters: vec![], + }], + &[Perbill::from_percent(50)], + ); + + // The stash account should be slashed for 250 (50% of 500). + assert_eq!(Balances::free_balance(&11), 1000 - 250); + }); +} From 63f08a0f5c885b24687113182dea3c9e472c3027 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 22:30:57 +0200 Subject: [PATCH 044/191] Check that reporters receive their slice. --- srml/staking/src/tests.rs | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 439e260a1e2e6..53cc5a1761a15 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1935,8 +1935,6 @@ fn era_is_always_same_length() { }); } -// TODO: a slash is performed according to the exposure, not the current balance. - #[test] fn offence_forces_new_era() { with_externalities(&mut ExtBuilder::default().build(), || { @@ -1984,3 +1982,30 @@ fn slashing_performed_according_exposure() { assert_eq!(Balances::free_balance(&11), 1000 - 250); }); } + +#[test] +fn reporters_receive_their_slice() { + // This test verifies that the reporters of the offence receive their slice from the slashed + // amount. + with_externalities(&mut ExtBuilder::default().build(), || { + // The reporters' reward is calculated from the total exposure. + assert_eq!(Staking::stakers(&11).total, 1250); + + // Handle an offence with a historical exposure. + Staking::on_offence( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + count: 1, + reporters: vec![1, 2], + }], + &[Perbill::from_percent(50)], + ); + + // 1250 x 50% (slash fraction) x 10% (rewards slice) + assert_eq!(Balances::free_balance(&1), 10 + 31); + assert_eq!(Balances::free_balance(&2), 20 + 31); + }); +} From fdb9d15a4448f3c82ac4ffba248e45edaaef8928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 7 Aug 2019 22:32:06 +0200 Subject: [PATCH 045/191] Small clean-up. --- srml/im-online/src/lib.rs | 2 -- srml/offences/src/lib.rs | 33 +++++++++++++++++---------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 910aa1770e0bb..9f116f7e4ff9f 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -125,7 +125,6 @@ struct WorkerStatus { // Error which may occur while executing the off-chain code. enum OffchainErr { DecodeWorkerStatus, - NoKeys, ExtrinsicCreation, FailedSigning, NetworkState, @@ -136,7 +135,6 @@ impl Printable for OffchainErr { fn print(self) { match self { OffchainErr::DecodeWorkerStatus => print("Offchain error: decoding WorkerStatus failed!"), - OffchainErr::NoKeys => print("Offchain error: could not find local keys!"), OffchainErr::ExtrinsicCreation => print("Offchain error: extrinsic creation failed!"), OffchainErr::FailedSigning => print("Offchain error: signing failed!"), OffchainErr::NetworkState => print("Offchain error: fetching network state failed!"), diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 27232b9ef8112..b1cdce80f463b 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -68,6 +68,7 @@ impl>> ReportOffence> ::mutate(&O::ID, &(session, time_slot), |offending_authorities| { for offender in offenders { @@ -75,19 +76,8 @@ impl>> ReportOffence>> ReportOffence 0 { + if details.count > 1 { let previous_fraction = O::slash_fraction( - offenders_count.saturating_sub(details.count), + offenders_count.saturating_sub(details.count - 1), validators_count, ); let perbil = expected_fraction From 39cdeb652eb8a42b1c4b007bd8347b48852795ee Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 22:39:34 +0200 Subject: [PATCH 046/191] invulnerables_are_not_slashed --- srml/staking/src/mock.rs | 8 +++++++- srml/staking/src/tests.rs | 24 +++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index ab667f5bb21f5..35cd1c365cf97 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -203,6 +203,7 @@ pub struct ExtBuilder { minimum_validator_count: u32, fair: bool, num_validators: Option, + invulnerables: Vec, } impl Default for ExtBuilder { @@ -215,6 +216,7 @@ impl Default for ExtBuilder { minimum_validator_count: 0, fair: true, num_validators: None, + invulnerables: vec![], } } } @@ -248,6 +250,10 @@ impl ExtBuilder { self.num_validators = Some(num_validators); self } + pub fn invulnerables(mut self, invulnerables: Vec) -> Self { + self.invulnerables = invulnerables; + self + } pub fn set_associated_consts(&self) { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); } @@ -308,7 +314,7 @@ impl ExtBuilder { ], validator_count: self.validator_count, minimum_validator_count: self.minimum_validator_count, - invulnerables: vec![], + invulnerables: self.invulnerables, slash_reward_fraction: Perbill::from_percent(10), }.assimilate_storage(&mut t, &mut c); diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 53cc5a1761a15..1a54d6281e4ce 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1991,7 +1991,6 @@ fn reporters_receive_their_slice() { // The reporters' reward is calculated from the total exposure. assert_eq!(Staking::stakers(&11).total, 1250); - // Handle an offence with a historical exposure. Staking::on_offence( &[OffenceDetails { offender: ( @@ -2009,3 +2008,26 @@ fn reporters_receive_their_slice() { assert_eq!(Balances::free_balance(&2), 20 + 31); }); } + +#[test] +fn invulnerables_are_not_slashed() { + with_externalities(&mut ExtBuilder::default().invulnerables(vec![11]).build(), || { + assert_eq!(Balances::free_balance(&11), 1000); + + Staking::on_offence( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + count: 1, + reporters: vec![], + }], + &[Perbill::from_percent(50)], + ); + + // The validator hasn't been slashed. + assert_eq!(Balances::free_balance(&11), 1000); + }); +} + From 67b0a50d60339c90b311b3fe77700feb2622e331 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 22:48:27 +0200 Subject: [PATCH 047/191] Minor clean ups. --- core/sr-primitives/src/offence.rs | 2 +- srml/staking/src/lib.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 75a9855a10185..6bcdf2f6ea779 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -103,7 +103,7 @@ pub trait OnOffenceHandler { /// /// The vector of `slash_fraction` contains perbils /// the authorities should be slashed and is computed - /// according to the `OffenceCount` already. + /// according to the `OffenceCount` already. This is of the same length as `offenders.` fn on_offence( offenders: &[OffenceDetails], slash_fraction: &[Perbill], diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 3c8f0fcb63254..3598952d554cb 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1456,12 +1456,12 @@ impl OnOffenceHandler OnOffenceHandler Date: Wed, 7 Aug 2019 22:50:11 +0200 Subject: [PATCH 048/191] Improve docs. --- core/sr-primitives/src/offence.rs | 4 +++- srml/staking/src/tests.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 6bcdf2f6ea779..2e1ed9b203514 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -104,6 +104,7 @@ pub trait OnOffenceHandler { /// The vector of `slash_fraction` contains perbils /// the authorities should be slashed and is computed /// according to the `OffenceCount` already. This is of the same length as `offenders.` + /// Zero is a valid value for a fraction. fn on_offence( offenders: &[OffenceDetails], slash_fraction: &[Perbill], @@ -123,6 +124,7 @@ pub struct OffenceDetails { /// in case the authority was already slashed in the past. /// Note that we don't buffer slashes and instead use this approach. pub count: OffenceCount, - /// A list of reporters of offences of this authority id. + /// A list of reporters of offences of this authority id. Possibily empty where there is no + /// particular reporters. pub reporters: Vec, } diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 1a54d6281e4ce..cf002e258076d 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -2011,6 +2011,7 @@ fn reporters_receive_their_slice() { #[test] fn invulnerables_are_not_slashed() { + // For invulnerable validators no slashing is performed. with_externalities(&mut ExtBuilder::default().invulnerables(vec![11]).build(), || { assert_eq!(Balances::free_balance(&11), 1000); From 9c43140dcbea0a305094f5f5cadb6baf501660b7 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 7 Aug 2019 22:57:15 +0200 Subject: [PATCH 049/191] dont_slash_if_fraction_is_zero --- srml/staking/src/tests.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index cf002e258076d..add98cd33429b 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -2027,8 +2027,32 @@ fn invulnerables_are_not_slashed() { &[Perbill::from_percent(50)], ); - // The validator hasn't been slashed. + // The validator hasn't been slashed. The new era is not forced. assert_eq!(Balances::free_balance(&11), 1000); + assert!(!Staking::forcing_new_era()); }); } +#[test] +fn dont_slash_if_fraction_is_zero() { + // Don't slash if the fraction is zero. + with_externalities(&mut ExtBuilder::default().build(), || { + assert_eq!(Balances::free_balance(&11), 1000); + + Staking::on_offence( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + count: 1, + reporters: vec![], + }], + &[Perbill::from_percent(0)], + ); + + // The validator hasn't been slashed. The new era is not forced. + assert_eq!(Balances::free_balance(&11), 1000); + assert!(!Staking::forcing_new_era()); + }); +} From c65854ca464880926cd8df1d179197c1077e7f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 00:39:31 +0200 Subject: [PATCH 050/191] Remove session dependency from offences. --- Cargo.lock | 3 - core/sr-primitives/src/offence.rs | 11 +++ node/runtime/src/lib.rs | 1 + srml/offences/Cargo.toml | 5 -- srml/offences/src/lib.rs | 34 ++++---- srml/offences/src/mock.rs | 126 ++++++++++++++++++++++++++++++ srml/offences/src/tests.rs | 45 +++++++++++ 7 files changed, 198 insertions(+), 27 deletions(-) create mode 100644 srml/offences/src/mock.rs create mode 100644 srml/offences/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index bc45b6f1c494c..65eb8b5b7af25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3997,11 +3997,8 @@ dependencies = [ "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-balances 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", "substrate-primitives 2.0.0", ] diff --git a/core/sr-primitives/src/offence.rs b/core/sr-primitives/src/offence.rs index 2e1ed9b203514..67ba50df2fdcb 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-primitives/src/offence.rs @@ -89,6 +89,10 @@ pub trait ReportOffence> { fn report_offence(reporter: Option, offence: O); } +impl> ReportOffence for () { + fn report_offence(_reporter: Option, _offence: O) {} +} + /// A trait to take action on an offence. /// /// Used to decouple the module that handles offences and @@ -111,6 +115,13 @@ pub trait OnOffenceHandler { ); } +impl OnOffenceHandler for () { + fn on_offence( + _offenders: &[OffenceDetails], + _slash_fraction: &[Perbill], + ) {} +} + /// A details about an offending authority for a particular kind of offence. #[derive(Clone, PartialEq, Eq, Encode, Decode)] #[cfg_attr(feature = "std", derive(Debug))] diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 566111bd5da9e..b5e65e99cb805 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -401,6 +401,7 @@ impl im_online::Trait for Runtime { } impl offences::Trait for Runtime { + type IdentificationTuple = historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/srml/offences/Cargo.toml b/srml/offences/Cargo.toml index 90af5194db5a5..e8717a77697b5 100644 --- a/srml/offences/Cargo.toml +++ b/srml/offences/Cargo.toml @@ -9,17 +9,13 @@ balances = { package = "srml-balances", path = "../balances", default-features = codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } serde = { version = "1.0", optional = true } -session = { package = "srml-session", path = "../session", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } support = { package = "srml-support", path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } [dev-dependencies] -balances = { package = "srml-balances", path = "../balances" } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } substrate-primitives = { path = "../../core/primitives" } -timestamp = { package = "srml-timestamp", path = "../timestamp" } -srml-staking = { path = "../staking" } [features] default = ["std"] @@ -28,7 +24,6 @@ std = [ "codec/std", "rstd/std", "serde", - "session/std", "sr-primitives/std", "support/std", "system/std", diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index b1cdce80f463b..1080e51f60ace 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -22,20 +22,28 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] +mod mock; +mod tests; + use rstd::vec::Vec; -use session::{SessionIndex, historical::{self, IdentificationTuple}}; use support::{ - StorageDoubleMap, decl_module, decl_storage, + StorageDoubleMap, decl_module, decl_storage, Parameter, }; use sr_primitives::{ Perbill, offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, }; +/// A session index. +/// TODO [slashing] move SessionIndex out of `srml-session` and use it here. +pub type SessionIndex = u32; + /// Offences trait -pub trait Trait: system::Trait + historical::Trait { +pub trait Trait: system::Trait { + /// Full identification of the validator. + type IdentificationTuple: Parameter; /// A handler called for every offence report. - type OnOffenceHandler: OnOffenceHandler>; + type OnOffenceHandler: OnOffenceHandler; } decl_storage! { @@ -47,7 +55,7 @@ decl_storage! { /// timeslot since the slashing will increase based on the length of this vec. OffenceReports get(offence_reports): double_map Kind, blake2_256((SessionIndex, TimeSlot)) - => Vec>>; + => Vec>; } } @@ -56,9 +64,9 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -impl>> ReportOffence, O> +impl> ReportOffence for Module where - IdentificationTuple: Clone, + T::IdentificationTuple: Clone, { fn report_offence(reporter: Option, offence: O) { let offenders = offence.offenders(); @@ -126,15 +134,3 @@ impl>> ReportOffence. + +//! Test utilities + +#![cfg(test)] + +use std::cell::RefCell; +use crate::{Module, Trait}; +use sr_primitives::Perbill; +use sr_primitives::offence::{self, OffenceDetails, TimeSlot}; +use sr_primitives::testing::Header; +use sr_primitives::traits::{IdentityLookup, BlakeTwo256}; +use substrate_primitives::{H256, Blake2Hasher}; +use support::{impl_outer_origin, parameter_types}; +use {runtime_io, system}; + +impl_outer_origin!{ + pub enum Origin for Runtime {} +} + +pub struct OnOffenceHandler; + +thread_local! { + pub static ON_OFFENCE_PERBILL: RefCell> = RefCell::new(Default::default()); +} + +impl offence::OnOffenceHandler for OnOffenceHandler { + fn on_offence( + _offenders: &[OffenceDetails], + slash_fraction: &[Perbill], + ) { + ON_OFFENCE_PERBILL.with(|f| { + *f.borrow_mut() = slash_fraction.to_vec(); + }); + } +} + +// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. +#[derive(Clone, PartialEq, Eq, Debug)] +pub struct Runtime; +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); +} +impl system::Trait for Runtime { + type Origin = Origin; + type Index = u64; + type BlockNumber = u64; + type Call = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type WeightMultiplierUpdate = (); + type Event = (); + type BlockHashCount = BlockHashCount; + type MaximumBlockWeight = MaximumBlockWeight; + type MaximumBlockLength = MaximumBlockLength; + type AvailableBlockRatio = AvailableBlockRatio; +} + +impl Trait for Runtime { + type IdentificationTuple = u64; + type OnOffenceHandler = OnOffenceHandler; +} + +pub fn new_test_ext() -> runtime_io::TestExternalities { + let t = system::GenesisConfig::default().build_storage::().unwrap().0; + t.into() +} + +/// Offences module. +pub type Offences = Module; + +pub const KIND: [u8; 16] = *b"test_report_1234"; + +pub struct Offence { + pub validators_count: u32, + pub session_index: u32, + pub offenders: Vec, + pub time_slot: TimeSlot, +} + +impl offence::Offence for Offence { + const ID: offence::Kind = KIND; + + fn offenders(&self) -> Vec { + self.offenders.clone() + } + + fn current_era_start_session_index(&self) -> u32 { + self.session_index + } + + fn validators_count(&self) -> u32 { + self.validators_count + } + + fn time_slot(&self) -> TimeSlot { + self.time_slot + } + + fn slash_fraction( + offenders_count: u32, + validators_count: u32, + ) -> Perbill { + Perbill::from_percent(offenders_count * 100 / validators_count) + } +} diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs new file mode 100644 index 0000000000000..6bcd357f28027 --- /dev/null +++ b/srml/offences/src/tests.rs @@ -0,0 +1,45 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Tests for the module. + +#![cfg(test)] + +use super::*; +use crate::mock::{Offences, Offence, KIND, new_test_ext, ON_OFFENCE_PERBILL}; +use runtime_io::with_externalities; + +#[test] +fn should_report_an_authority_and_trigger_on_offence() { + with_externalities(&mut new_test_ext(), || { + let session_index = 5; + let time_slot = 42; + assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + + let offence = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + + Offences::report_offence(None, offence); + + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(20)]); + }); + }); +} From 77c23dceed80b40bb04e097397e120601afa8240 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 00:36:03 +0200 Subject: [PATCH 051/191] Introduce sr-staking-primitives --- Cargo.lock | 9 +++++++++ Cargo.toml | 1 + core/sr-staking-primitives/Cargo.toml | 11 +++++++++++ core/sr-staking-primitives/src/lib.rs | 22 ++++++++++++++++++++++ node/runtime/Cargo.toml | 2 ++ node/runtime/src/lib.rs | 2 +- srml/im-online/Cargo.toml | 2 ++ srml/im-online/src/lib.rs | 6 ++---- srml/offences/Cargo.toml | 2 ++ srml/offences/src/lib.rs | 2 ++ srml/session/Cargo.toml | 2 ++ srml/session/src/lib.rs | 4 +--- srml/session/src/mock.rs | 1 + srml/staking/Cargo.toml | 2 ++ srml/staking/src/lib.rs | 7 ++++--- srml/staking/src/mock.rs | 5 +++-- 16 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 core/sr-staking-primitives/Cargo.toml create mode 100644 core/sr-staking-primitives/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 65eb8b5b7af25..cc70130e71102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2371,6 +2371,7 @@ dependencies = [ "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "sr-version 2.0.0", "srml-authorship 0.1.0", @@ -3675,6 +3676,10 @@ dependencies = [ "wasmi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sr-staking-primitives" +version = "2.0.0" + [[package]] name = "sr-std" version = "2.0.0" @@ -3938,6 +3943,7 @@ dependencies = [ "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", "srml-support 2.0.0", @@ -3995,6 +4001,7 @@ dependencies = [ "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-balances 2.0.0", "srml-support 2.0.0", @@ -4012,6 +4019,7 @@ dependencies = [ "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", @@ -4031,6 +4039,7 @@ dependencies = [ "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-authorship 0.1.0", "srml-balances 2.0.0", diff --git a/Cargo.toml b/Cargo.toml index a6d25214704d9..d29dad92048c1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ members = [ "core/sr-api-macros", "core/sr-io", "core/sr-primitives", + "core/sr-staking-primitives", "core/sr-sandbox", "core/sr-std", "core/sr-version", diff --git a/core/sr-staking-primitives/Cargo.toml b/core/sr-staking-primitives/Cargo.toml new file mode 100644 index 0000000000000..9107a59d6f4de --- /dev/null +++ b/core/sr-staking-primitives/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "sr-staking-primitives" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] + +[features] +default = ["std"] +std = [] diff --git a/core/sr-staking-primitives/src/lib.rs b/core/sr-staking-primitives/src/lib.rs new file mode 100644 index 0000000000000..834155943a0cb --- /dev/null +++ b/core/sr-staking-primitives/src/lib.rs @@ -0,0 +1,22 @@ + +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +#![cfg_attr(not(feature = "std"), no_std)] + +//! A crate which contains primitives that are useful for implementation that uses staking +//! approaches in general. Definitions related to sessions, slashing, etc go here. + +/// Simple index type with which we can count sessions. +pub type SessionIndex = u32; + diff --git a/node/runtime/Cargo.toml b/node/runtime/Cargo.toml index e589deb88d568..188d0c6f97180 100644 --- a/node/runtime/Cargo.toml +++ b/node/runtime/Cargo.toml @@ -13,6 +13,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives" client = { package = "substrate-client", path = "../../core/client", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } offchain-primitives = { package = "substrate-offchain-primitives", path = "../../core/offchain/primitives", default-features = false } version = { package = "sr-version", path = "../../core/sr-version", default-features = false } support = { package = "srml-support", path = "../../srml/support", default-features = false } @@ -80,6 +81,7 @@ std = [ "serde", "session/std", "sr-primitives/std", + "sr-staking-primitives/std", "staking/std", "substrate-keyring", "substrate-session/std", diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index b5e65e99cb805..e7e7edd6a18c2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -225,7 +225,7 @@ impl session::historical::Trait for Runtime { } parameter_types! { - pub const SessionsPerEra: session::SessionIndex = 6; + pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6; pub const BondingDuration: staking::EraIndex = 24 * 28; } diff --git a/srml/im-online/Cargo.toml b/srml/im-online/Cargo.toml index d4591f0b730c1..5f7514755b72f 100644 --- a/srml/im-online/Cargo.toml +++ b/srml/im-online/Cargo.toml @@ -13,6 +13,7 @@ serde = { version = "1.0", optional = true } session = { package = "srml-session", path = "../session", default-features = false } sr-io = { path = "../../core/sr-io", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } @@ -27,6 +28,7 @@ std = [ "session/std", "sr-io/std", "sr-primitives/std", + "sr-staking-primitives/std", "srml-support/std", "system/std", ] diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 9f116f7e4ff9f..931ecd4c04246 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -71,10 +71,7 @@ use app_crypto::RuntimeAppPublic; use codec::{Encode, Decode}; use primitives::offchain::{OpaqueNetworkState, StorageKind}; use rstd::prelude::*; -use session::{ - SessionIndex, - historical::IdentificationTuple, -}; +use session::historical::IdentificationTuple; use sr_io::Printable; use sr_primitives::{ Perbill, ApplyError, @@ -82,6 +79,7 @@ use sr_primitives::{ traits::{ValidatorIdByIndex, Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex, Convert}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, }; +use sr_staking_primitives::SessionIndex; use srml_support::{ StorageValue, decl_module, decl_event, decl_storage, StorageDoubleMap, print, }; diff --git a/srml/offences/Cargo.toml b/srml/offences/Cargo.toml index e8717a77697b5..4dd12413f6729 100644 --- a/srml/offences/Cargo.toml +++ b/srml/offences/Cargo.toml @@ -10,6 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } serde = { version = "1.0", optional = true } sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } support = { package = "srml-support", path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } @@ -25,6 +26,7 @@ std = [ "rstd/std", "serde", "sr-primitives/std", + "sr-staking-primitives/std", "support/std", "system/std", ] diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 1080e51f60ace..105f1bf1b8c8b 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -26,6 +26,7 @@ mod mock; mod tests; use rstd::vec::Vec; +use session::historical::{self, IdentificationTuple}; use support::{ StorageDoubleMap, decl_module, decl_storage, Parameter, }; @@ -33,6 +34,7 @@ use sr_primitives::{ Perbill, offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, }; +use sr_staking_primitives::SessionIndex; /// A session index. /// TODO [slashing] move SessionIndex out of `srml-session` and use it here. diff --git a/srml/session/Cargo.toml b/srml/session/Cargo.toml index d084ab4261b3c..d0166997656ed 100644 --- a/srml/session/Cargo.toml +++ b/srml/session/Cargo.toml @@ -10,6 +10,7 @@ safe-mix = { version = "1.0", default-features = false} codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../core/sr-staking-primitives", 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 } @@ -31,6 +32,7 @@ std = [ "rstd/std", "srml-support/std", "sr-primitives/std", + "sr-staking-primitives/std", "timestamp/std", "substrate-trie/std" ] diff --git a/srml/session/src/lib.rs b/srml/session/src/lib.rs index b312c55da6ff9..5e2e2cac487fd 100644 --- a/srml/session/src/lib.rs +++ b/srml/session/src/lib.rs @@ -124,6 +124,7 @@ use codec::Decode; use sr_primitives::{KeyTypeId, AppKey}; use sr_primitives::weights::SimpleDispatchInfo; use sr_primitives::traits::{Convert, Zero, Member, OpaqueKeys}; +use sr_staking_primitives::SessionIndex; use srml_support::{ dispatch::Result, ConsensusEngineId, StorageValue, StorageDoubleMap, for_each_tuple, decl_module, decl_event, decl_storage, @@ -137,9 +138,6 @@ mod mock; #[cfg(feature = "historical")] pub mod historical; -/// Simple index type with which we can count sessions. -pub type SessionIndex = u32; - /// Decides whether the session should be ended. pub trait ShouldEndSession { /// Return `true` if the session should be ended. diff --git a/srml/session/src/mock.rs b/srml/session/src/mock.rs index 66bf93032d29f..7cd0f45447254 100644 --- a/srml/session/src/mock.rs +++ b/srml/session/src/mock.rs @@ -24,6 +24,7 @@ use sr_primitives::{ Perbill, impl_opaque_keys, traits::{BlakeTwo256, IdentityLookup, ConvertInto}, testing::{Header, UintAuthorityId} }; +use sr_staking_primitives::SessionIndex; impl_opaque_keys! { pub struct MockSessionKeys { diff --git a/srml/staking/Cargo.toml b/srml/staking/Cargo.toml index 5428d663f3f44..d985730912c56 100644 --- a/srml/staking/Cargo.toml +++ b/srml/staking/Cargo.toml @@ -12,6 +12,7 @@ substrate-keyring = { path = "../../core/keyring", optional = true } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } session = { package = "srml-session", path = "../session", default-features = false, features = ["historical"] } @@ -36,6 +37,7 @@ std = [ "runtime_io/std", "srml-support/std", "sr-primitives/std", + "sr-staking-primitives/std", "session/std", "system/std", "authorship/std", diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 3598952d554cb..1dbc36a2eba89 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -271,7 +271,7 @@ use srml_support::{ WithdrawReasons, WithdrawReason, OnUnbalanced, Imbalance, Get, Time } }; -use session::{historical::OnSessionEnding, SelectInitialValidators, SessionIndex}; +use session::{historical::OnSessionEnding, SelectInitialValidators}; use sr_primitives::Perbill; use sr_primitives::offence::{OnOffenceHandler, OffenceDetails}; use sr_primitives::weights::SimpleDispatchInfo; @@ -279,6 +279,7 @@ use sr_primitives::traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SimpleArithmetic, SaturatedConversion, ValidatorIdByIndex, }; +use sr_staking_primitives::SessionIndex; #[cfg(feature = "std")] use sr_primitives::{Serialize, Deserialize}; use system::{ensure_signed, ensure_root}; @@ -453,7 +454,7 @@ pub trait SessionInterface: system::Trait { /// Get the validators from session. fn validators() -> Vec; /// Prune historical session tries up to but not including the given index. - fn prune_historical_up_to(up_to: session::SessionIndex); + fn prune_historical_up_to(up_to: SessionIndex); } impl SessionInterface<::AccountId> for T where @@ -475,7 +476,7 @@ impl SessionInterface<::AccountId> for T where >::validators() } - fn prune_historical_up_to(up_to: session::SessionIndex) { + fn prune_historical_up_to(up_to: SessionIndex) { >::prune_up_to(up_to); } } diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index 35cd1c365cf97..e069ff1cb6f37 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -20,6 +20,7 @@ use std::{collections::HashSet, cell::RefCell}; use sr_primitives::Perbill; use sr_primitives::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize}; use sr_primitives::testing::{Header, UintAuthorityId}; +use sr_staking_primitives::SessionIndex; use primitives::{H256, Blake2Hasher}; use runtime_io; use srml_support::{assert_ok, impl_outer_origin, parameter_types, EnumerableStorageMap}; @@ -179,7 +180,7 @@ impl timestamp::Trait for Test { type MinimumPeriod = MinimumPeriod; } parameter_types! { - pub const SessionsPerEra: session::SessionIndex = 3; + pub const SessionsPerEra: SessionIndex = 3; pub const BondingDuration: EraIndex = 3; } impl Trait for Test { @@ -406,7 +407,7 @@ pub fn advance_session() { start_session(current_index + 1); } -pub fn start_session(session_index: session::SessionIndex) { +pub fn start_session(session_index: SessionIndex) { // Compensate for session delay let session_index = session_index + 1; for i in Session::current_index()..session_index { From 4384e6c8f8be9ade80bef8a3b066dab998097852 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 00:51:55 +0200 Subject: [PATCH 052/191] Move offence under sr_staking_primitives --- Cargo.lock | 7 +++++++ core/sr-primitives/src/lib.rs | 1 - core/sr-staking-primitives/Cargo.toml | 9 ++++++++- core/sr-staking-primitives/src/lib.rs | 2 ++ .../src/offence.rs | 2 +- srml/babe/Cargo.toml | 2 ++ srml/babe/src/lib.rs | 2 +- srml/grandpa/Cargo.toml | 2 ++ srml/grandpa/src/lib.rs | 2 +- srml/im-online/src/lib.rs | 6 ++++-- srml/offences/src/lib.rs | 6 +++--- srml/staking/src/lib.rs | 6 ++++-- 12 files changed, 35 insertions(+), 12 deletions(-) rename core/{sr-primitives => sr-staking-primitives}/src/offence.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index cc70130e71102..bba0abd0081e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3679,6 +3679,11 @@ dependencies = [ [[package]] name = "sr-staking-primitives" version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 2.0.0", + "sr-std 2.0.0", +] [[package]] name = "sr-std" @@ -3757,6 +3762,7 @@ dependencies = [ "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", "srml-staking 2.0.0", @@ -3926,6 +3932,7 @@ dependencies = [ "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-finality-tracker 2.0.0", "srml-session 2.0.0", diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index 29516095676ab..62b8d1969f351 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -50,7 +50,6 @@ use traits::{SaturatedConversion, UniqueSaturatedInto, Saturating, Bounded, Chec pub mod generic; pub mod transaction_validity; -pub mod offence; /// Re-export these since they're only "kind of" generic. pub use generic::{DigestItem, Digest}; diff --git a/core/sr-staking-primitives/Cargo.toml b/core/sr-staking-primitives/Cargo.toml index 9107a59d6f4de..25e8f4ccf1529 100644 --- a/core/sr-staking-primitives/Cargo.toml +++ b/core/sr-staking-primitives/Cargo.toml @@ -5,7 +5,14 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +sr-primitives = { path = "../sr-primitives", default-features = false } +rstd = { package = "sr-std", path = "../sr-std", default-features = false } [features] default = ["std"] -std = [] +std = [ + "codec/std", + "sr-primitives/std", + "rstd/std", +] diff --git a/core/sr-staking-primitives/src/lib.rs b/core/sr-staking-primitives/src/lib.rs index 834155943a0cb..5d932dc97a824 100644 --- a/core/sr-staking-primitives/src/lib.rs +++ b/core/sr-staking-primitives/src/lib.rs @@ -17,6 +17,8 @@ //! A crate which contains primitives that are useful for implementation that uses staking //! approaches in general. Definitions related to sessions, slashing, etc go here. +pub mod offence; + /// Simple index type with which we can count sessions. pub type SessionIndex = u32; diff --git a/core/sr-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs similarity index 99% rename from core/sr-primitives/src/offence.rs rename to core/sr-staking-primitives/src/offence.rs index 67ba50df2fdcb..146f3b35c28a0 100644 --- a/core/sr-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -20,7 +20,7 @@ use rstd::vec::Vec; use codec::{Encode, Decode}; -use crate::Perbill; +use sr_primitives::Perbill; /// The kind of an offence, is a byte string representing some kind identifier /// e.g. `b"im-online:offlin"`, `b"babe:equivocatio"` diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index 76bd849a95594..93b7880be0de3 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -11,6 +11,7 @@ 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 } +sr-staking-primitives = { path = "../../core/sr-staking-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 } @@ -32,6 +33,7 @@ std = [ "rstd/std", "srml-support/std", "sr-primitives/std", + "sr-staking-primitives/std", "system/std", "timestamp/std", "inherents/std", diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 3a67b30d8c1ec..b2635816d15f5 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -29,7 +29,7 @@ use srml_support::{decl_storage, decl_module, StorageValue, StorageMap, traits:: use timestamp::{OnTimestampSet}; use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill}; use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; -use sr_primitives::offence::{Offence, TimeSlot, Kind}; +use sr_staking_primitives::offence::{Offence, TimeSlot, Kind}; #[cfg(feature = "std")] use timestamp::TimestampInherentData; use codec::{Encode, Decode}; diff --git a/srml/grandpa/Cargo.toml b/srml/grandpa/Cargo.toml index 2466b8e012ec5..6f6d835bd3534 100644 --- a/srml/grandpa/Cargo.toml +++ b/srml/grandpa/Cargo.toml @@ -11,6 +11,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives" substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } session = { package = "srml-session", path = "../session", default-features = false } @@ -29,6 +30,7 @@ std = [ "rstd/std", "srml-support/std", "sr-primitives/std", + "sr-staking-primitives/std", "system/std", "session/std", "finality-tracker/std", diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 4ff6a5fc8be33..105e753e13a6c 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -38,8 +38,8 @@ use srml_support::{ use sr_primitives::{ generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, - offence::{TimeSlot, Offence, Kind}, }; +use sr_staking_primitives::offence::{TimeSlot, Offence, Kind}; use fg_primitives::{ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID}; pub use fg_primitives::{AuthorityId, AuthorityWeight}; use system::{ensure_signed, DigestOf}; diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 931ecd4c04246..1f12af2987020 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -75,11 +75,13 @@ use session::historical::IdentificationTuple; use sr_io::Printable; use sr_primitives::{ Perbill, ApplyError, - offence::{ReportOffence, Offence, TimeSlot, Kind}, traits::{ValidatorIdByIndex, Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex, Convert}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, }; -use sr_staking_primitives::SessionIndex; +use sr_staking_primitives::{ + SessionIndex, + offence::{ReportOffence, Offence, TimeSlot, Kind}, +}; use srml_support::{ StorageValue, decl_module, decl_event, decl_storage, StorageDoubleMap, print, }; diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 105f1bf1b8c8b..653dd950ef57e 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -30,11 +30,11 @@ use session::historical::{self, IdentificationTuple}; use support::{ StorageDoubleMap, decl_module, decl_storage, Parameter, }; -use sr_primitives::{ - Perbill, +use sr_primitives::Perbill; +use sr_staking_primitives::{ + SessionIndex, offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, }; -use sr_staking_primitives::SessionIndex; /// A session index. /// TODO [slashing] move SessionIndex out of `srml-session` and use it here. diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 1dbc36a2eba89..bb56ee46191b4 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -273,13 +273,15 @@ use srml_support::{ }; use session::{historical::OnSessionEnding, SelectInitialValidators}; use sr_primitives::Perbill; -use sr_primitives::offence::{OnOffenceHandler, OffenceDetails}; use sr_primitives::weights::SimpleDispatchInfo; use sr_primitives::traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SimpleArithmetic, SaturatedConversion, ValidatorIdByIndex, }; -use sr_staking_primitives::SessionIndex; +use sr_staking_primitives::{ + SessionIndex, + offence::{OnOffenceHandler, OffenceDetails}, +}; #[cfg(feature = "std")] use sr_primitives::{Serialize, Deserialize}; use system::{ensure_signed, ensure_root}; From 7d94eaffb379934dc5c375753408ff92c734864a Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 01:02:12 +0200 Subject: [PATCH 053/191] rename session_index --- core/sr-primitives/src/traits.rs | 15 --------------- core/sr-staking-primitives/src/lib.rs | 6 ++++++ core/sr-staking-primitives/src/offence.rs | 4 ++-- node/runtime/src/lib.rs | 1 - srml/babe/src/lib.rs | 8 ++++---- srml/grandpa/src/lib.rs | 6 +++--- srml/im-online/src/lib.rs | 18 +++++------------- srml/offences/src/lib.rs | 2 +- srml/staking/src/lib.rs | 10 ++-------- 9 files changed, 23 insertions(+), 47 deletions(-) diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index 33d24bff6c1b7..442aa9b0ac89a 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -1034,21 +1034,6 @@ pub trait ValidateUnsigned { fn validate_unsigned(call: &Self::Call) -> TransactionValidity; } -// TODO [slashing]: move into staking-primitives? -/// A trait for fetching the session index which started the current era. -pub trait CurrentEraStartSessionIndex { - /// Returns the session index which started the current era. - fn current_era_start_session_index() -> u32; // TODO [slashing]: Should be a SessionIndex. -} - -// TODO [slashing]: move into staking-primitives? -/// A trait for fetching a validator id by the given index. -pub trait ValidatorIdByIndex { - /// Return a validator identification by the given index in the current elected set of the era, - // or `None` if `validator_index` is out of range. - fn validator_id_by_index(validator_index: u32) -> Option; -} - /// Opaque datatype that may be destructured into a series of raw byte slices (which represent /// individual keys). pub trait OpaqueKeys: Clone { diff --git a/core/sr-staking-primitives/src/lib.rs b/core/sr-staking-primitives/src/lib.rs index 5d932dc97a824..303007280d7c6 100644 --- a/core/sr-staking-primitives/src/lib.rs +++ b/core/sr-staking-primitives/src/lib.rs @@ -22,3 +22,9 @@ pub mod offence; /// Simple index type with which we can count sessions. pub type SessionIndex = u32; +/// A trait for fetching a validator id by the given index. +pub trait ValidatorIdByIndex { + /// Return a validator identification by the given index in the current elected set of the era, + // or `None` if `validator_index` is out of range. + fn validator_id_by_index(validator_index: u32) -> Option; +} diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 146f3b35c28a0..9d4d45a8e13d1 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -60,7 +60,7 @@ pub trait Offence { /// The session index which is used for querying the validator set for the `slash_fraction` /// function. - fn current_era_start_session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. + fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. /// Return a validators count at the time when the offence took place. fn validators_count(&self) -> u32; @@ -69,7 +69,7 @@ pub trait Offence { /// /// The timescale is abstract and it doesn't have to be the same across different /// implementations of this trait. For example, for GRANDPA it could represent a round number - /// and for BABE it could be a slot number. + /// and for BABE it could be a slot number. This is used for looking the `offenders_count`. fn time_slot(&self) -> TimeSlot; /// A slash fraction of the total exposure that should be slashed for this diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index e7e7edd6a18c2..6502e00c885df 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -396,7 +396,6 @@ impl im_online::Trait for Runtime { type Event = Event; type UncheckedExtrinsic = UncheckedExtrinsic; type ReportUnresponsivness = Offences; - type CurrentEraStartSessionIndex = Staking; type ValidatorIdByIndex = Staking; } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index b2635816d15f5..188a431ac5a6a 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -251,8 +251,8 @@ impl session::ShouldEndSession for Module { struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. slot: u64, - /// The session index that starts an era in which the incident happened. - current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The session index in which the incident happened. + session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The size of the validator set at the time of the offence. validators_count: u32, /// The authority which produced the equivocation. @@ -266,8 +266,8 @@ impl Offence for BabeEquivocation vec![self.offender.clone()] } - fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. - self.current_era_start_session_index + fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.session_index } fn validators_count(&self) -> u32 { diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 105e753e13a6c..0240380dc3a93 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -386,7 +386,7 @@ struct GrandpaEquivocationOffence { /// A round in which the incident happened. round: u64, /// The session index that starts an era in which the incident happened. - current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. + session_index: u32, // TODO [slashing]: Should be a SessionIndex. /// The size of the validator set at the time of the offence. validators_count: u32, /// The authority which produced this equivocation. @@ -400,8 +400,8 @@ impl Offence for GrandpaEquivocat vec![self.offender.clone()] } - fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. - self.current_era_start_session_index + fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.session_index } fn validators_count(&self) -> u32 { diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 1f12af2987020..b40c7b1cabe86 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -75,11 +75,11 @@ use session::historical::IdentificationTuple; use sr_io::Printable; use sr_primitives::{ Perbill, ApplyError, - traits::{ValidatorIdByIndex, Extrinsic as ExtrinsicT, CurrentEraStartSessionIndex, Convert}, + traits::{Extrinsic as ExtrinsicT, Convert}, transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, }; use sr_staking_primitives::{ - SessionIndex, + SessionIndex, ValidatorIdByIndex, offence::{ReportOffence, Offence, TimeSlot, Kind}, }; use srml_support::{ @@ -176,9 +176,6 @@ pub trait Trait: system::Trait + session::historical::Trait { UnresponsivnessOffence>, >; - /// A function that returns the session index that started the current era. - type CurrentEraStartSessionIndex: CurrentEraStartSessionIndex; - /// A type that returns a validator id from the current elected set of the era. type ValidatorIdByIndex: ValidatorIdByIndex<::ValidatorId>; } @@ -420,12 +417,9 @@ impl session::OneSessionHandler for Module { } } - let current_era_start_session_index = - T::CurrentEraStartSessionIndex::current_era_start_session_index(); let validators_count = keys.len() as u32; let offence = UnresponsivnessOffence { session_index: current_session, - current_era_start_session_index, validators_count, offenders: unresponsive, }; @@ -485,9 +479,7 @@ impl srml_support::unsigned::ValidateUnsigned for Module { /// An offense which is filed if a validator didn't send a heartbeat message. pub struct UnresponsivnessOffence { - /// The session index that starts an era in which the incident happened. - current_era_start_session_index: u32, // TODO [slashing]: Should be a SessionIndex. - /// The session index at which we file this report. + /// The current session index in which we report the unresponsive validators. /// /// It acts as a time measure for unresponsivness reports and effectively will always point /// at the end of the session. @@ -505,8 +497,8 @@ impl Offence for UnresponsivnessOffence { self.offenders.clone() } - fn current_era_start_session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. - self.current_era_start_session_index + fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + self.session_index } fn validators_count(&self) -> u32 { diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 653dd950ef57e..a0b78a5771a42 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -73,7 +73,7 @@ impl> ReportOffence, offence: O) { let offenders = offence.offenders(); let time_slot = offence.time_slot(); - let session = offence.current_era_start_session_index(); + let session = offence.session_index(); let validators_count = offence.validators_count(); // Check if an offence is already reported for the offender authorities diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index bb56ee46191b4..0a3f9e7954f05 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -276,10 +276,10 @@ use sr_primitives::Perbill; use sr_primitives::weights::SimpleDispatchInfo; use sr_primitives::traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, - SimpleArithmetic, SaturatedConversion, ValidatorIdByIndex, + SimpleArithmetic, SaturatedConversion, }; use sr_staking_primitives::{ - SessionIndex, + SessionIndex, ValidatorIdByIndex, offence::{OnOffenceHandler, OffenceDetails}, }; #[cfg(feature = "std")] @@ -1345,12 +1345,6 @@ impl OnFreeBalanceZero for Module { } } -impl sr_primitives::traits::CurrentEraStartSessionIndex for Module { - fn current_era_start_session_index() -> u32 { - CurrentEraStartSessionIndex::get() - } -} - /// Add reward points to block authors: /// * 20 points to the block producer for producing a (non-uncle) block in the relay chain, /// * 2 points to the block producer for each reference to a previously unreferenced uncle, and From 97d4f5c8bd7ed92052d6391caf10f684a6622c67 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 01:08:44 +0200 Subject: [PATCH 054/191] Resolves todos re using SessionIndex --- core/sr-staking-primitives/src/offence.rs | 4 +++- srml/babe/src/lib.rs | 9 ++++++--- srml/grandpa/src/lib.rs | 11 +++++++---- srml/im-online/src/lib.rs | 4 ++-- srml/offences/src/lib.rs | 4 ---- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 9d4d45a8e13d1..1b47eb10a21d8 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -22,6 +22,8 @@ use rstd::vec::Vec; use codec::{Encode, Decode}; use sr_primitives::Perbill; +use crate::SessionIndex; + /// The kind of an offence, is a byte string representing some kind identifier /// e.g. `b"im-online:offlin"`, `b"babe:equivocatio"` // TODO [slashing]: Is there something better we can have here that is more natural but still @@ -60,7 +62,7 @@ pub trait Offence { /// The session index which is used for querying the validator set for the `slash_fraction` /// function. - fn session_index(&self) -> u32; // TODO [slashing]: Should be a SessionIndex. + fn session_index(&self) -> SessionIndex; /// Return a validators count at the time when the offence took place. fn validators_count(&self) -> u32; diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 188a431ac5a6a..bf82ffd77b42b 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -29,7 +29,10 @@ use srml_support::{decl_storage, decl_module, StorageValue, StorageMap, traits:: use timestamp::{OnTimestampSet}; use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill}; use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; -use sr_staking_primitives::offence::{Offence, TimeSlot, Kind}; +use sr_staking_primitives::{ + SessionIndex, + offence::{Offence, TimeSlot, Kind}, +}; #[cfg(feature = "std")] use timestamp::TimestampInherentData; use codec::{Encode, Decode}; @@ -252,7 +255,7 @@ struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. slot: u64, /// The session index in which the incident happened. - session_index: u32, // TODO [slashing]: Should be a SessionIndex. + session_index: SessionIndex, /// The size of the validator set at the time of the offence. validators_count: u32, /// The authority which produced the equivocation. @@ -266,7 +269,7 @@ impl Offence for BabeEquivocation vec![self.offender.clone()] } - fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + fn session_index(&self) -> SessionIndex { self.session_index } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 0240380dc3a93..5f1df2ceeb8bf 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -39,7 +39,10 @@ use sr_primitives::{ generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, }; -use sr_staking_primitives::offence::{TimeSlot, Offence, Kind}; +use sr_staking_primitives::{ + SessionIndex, + offence::{TimeSlot, Offence, Kind}, +}; use fg_primitives::{ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID}; pub use fg_primitives::{AuthorityId, AuthorityWeight}; use system::{ensure_signed, DigestOf}; @@ -385,8 +388,8 @@ impl finality_tracker::OnFinalizationStalled for Modul struct GrandpaEquivocationOffence { /// A round in which the incident happened. round: u64, - /// The session index that starts an era in which the incident happened. - session_index: u32, // TODO [slashing]: Should be a SessionIndex. + /// The session index in which the incident happened. + session_index: SessionIndex, /// The size of the validator set at the time of the offence. validators_count: u32, /// The authority which produced this equivocation. @@ -400,7 +403,7 @@ impl Offence for GrandpaEquivocat vec![self.offender.clone()] } - fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + fn session_index(&self) -> SessionIndex { self.session_index } diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index b40c7b1cabe86..4a7666a355966 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -483,7 +483,7 @@ pub struct UnresponsivnessOffence { /// /// It acts as a time measure for unresponsivness reports and effectively will always point /// at the end of the session. - session_index: u32, // TODO [slashing]: Should be a SessionIndex. + session_index: SessionIndex, /// The size of the validator set in current session/era. validators_count: u32, /// Authorities which were unresponsive during the current era. @@ -497,7 +497,7 @@ impl Offence for UnresponsivnessOffence { self.offenders.clone() } - fn session_index(&self) -> u32 { // TODO [slashing]: Should be a SessionIndex. + fn session_index(&self) -> SessionIndex { self.session_index } diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index a0b78a5771a42..95fedb2f8cc5f 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -36,10 +36,6 @@ use sr_staking_primitives::{ offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, }; -/// A session index. -/// TODO [slashing] move SessionIndex out of `srml-session` and use it here. -pub type SessionIndex = u32; - /// Offences trait pub trait Trait: system::Trait { /// Full identification of the validator. From b8f65a85d85837d4dd3a5d28c6ecf6091acac256 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 01:25:49 +0200 Subject: [PATCH 055/191] Fix staking tests. --- srml/staking/src/tests.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index add98cd33429b..5dcf42fab797a 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -19,10 +19,8 @@ use super::*; use runtime_io::with_externalities; use phragmen; -use sr_primitives::{ - traits::OnInitialize, - offence::{OffenceDetails, OnOffenceHandler}, -}; +use sr_primitives::traits::OnInitialize; +use sr_staking_primitives::offence::{OffenceDetails, OnOffenceHandler}; use srml_support::{assert_ok, assert_noop, assert_eq_uvec, EnumerableStorageMap}; use mock::*; use srml_support::traits::{Currency, ReservableCurrency}; From fe75ebe7c9c963c4830a993f0d3dad4b6ea60be8 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 01:26:13 +0200 Subject: [PATCH 056/191] Properly scale denominator. --- srml/babe/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index bf82ffd77b42b..a9c2c596942c3 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -293,7 +293,7 @@ impl Offence for BabeEquivocation // The conversion to u64 is performed to guarantee it fits. // TODO: #3189 should fix this. let x = x.into_parts(); - let x = ((x as u64 * x as u64) / 1_000_000_000) as u32; + let x = ((x as u64 * x as u64) / (1_000_000_000 * 1_000_000_000)) as u32; Perbill::from_parts(x) } } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 5f1df2ceeb8bf..49bda1420e5c3 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -427,7 +427,7 @@ impl Offence for GrandpaEquivocat // The conversion to u64 is performed to guarantee it fits. // TODO: #3189 should fix this. let x = x.into_parts(); - let x = ((x as u64 * x as u64) / 1_000_000_000) as u32; + let x = ((x as u64 * x as u64) / (1_000_000_000 * 1_000_000_000)) as u32; Perbill::from_parts(x) } } From 2ff220b845b49b7feb35565e69f9567dec0d1008 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 01:37:17 +0200 Subject: [PATCH 057/191] Fix UnresponsivnessOffence --- srml/im-online/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 4a7666a355966..a9e0400a9eb2f 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -530,18 +530,18 @@ mod tests { fn test_unresponsivness_slash_fraction() { // A single case of unresponsivness is not slashed. assert_eq!( - UnresponsivnessOffence::slash_fraction(1, 50), + UnresponsivnessOffence::<()>::slash_fraction(1, 50), Perbill::zero(), ); assert_eq!( - UnresponsivnessOffence::slash_fraction(3, 50), + UnresponsivnessOffence::<()>::slash_fraction(3, 50), Perbill::from_parts(6000000), // 0.6% ); // One third offline should be punished around 5%. assert_eq!( - UnresponsivnessOffence::slash_fraction(17, 50), + UnresponsivnessOffence::<()>::slash_fraction(17, 50), Perbill::from_parts(48000000), // 4.8% ); } From 00a8506046aecd7bdbd4aaebf6e5f8177870f380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 08:51:22 +0200 Subject: [PATCH 058/191] Fix compilation. --- node/runtime/src/lib.rs | 2 +- srml/offences/src/lib.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 6502e00c885df..0cbaeaa775463 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -400,7 +400,7 @@ impl im_online::Trait for Runtime { } impl offences::Trait for Runtime { - type IdentificationTuple = historical::IdentificationTuple; + type IdentificationTuple = session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 95fedb2f8cc5f..08be94de1e46c 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -26,7 +26,6 @@ mod mock; mod tests; use rstd::vec::Vec; -use session::historical::{self, IdentificationTuple}; use support::{ StorageDoubleMap, decl_module, decl_storage, Parameter, }; From eb790f274a523b36396c7dfaf371f11102c13dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 10:24:03 +0200 Subject: [PATCH 059/191] Tests for offences. --- srml/offences/src/mock.rs | 7 +-- srml/offences/src/tests.rs | 107 ++++++++++++++++++++++++++++++++++++- 2 files changed, 109 insertions(+), 5 deletions(-) diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index f1f23c3d5201e..74b70219532ec 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -21,7 +21,7 @@ use std::cell::RefCell; use crate::{Module, Trait}; use sr_primitives::Perbill; -use sr_primitives::offence::{self, OffenceDetails, TimeSlot}; +use sr_staking_primitives::offence::{self, OffenceDetails, TimeSlot}; use sr_primitives::testing::Header; use sr_primitives::traits::{IdentityLookup, BlakeTwo256}; use substrate_primitives::{H256, Blake2Hasher}; @@ -91,6 +91,7 @@ pub type Offences = Module; pub const KIND: [u8; 16] = *b"test_report_1234"; +#[derive(Clone)] pub struct Offence { pub validators_count: u32, pub session_index: u32, @@ -105,7 +106,7 @@ impl offence::Offence for Offence { self.offenders.clone() } - fn current_era_start_session_index(&self) -> u32 { + fn session_index(&self) -> u32 { self.session_index } @@ -121,6 +122,6 @@ impl offence::Offence for Offence { offenders_count: u32, validators_count: u32, ) -> Perbill { - Perbill::from_percent(offenders_count * 100 / validators_count) + Perbill::from_percent(5 + offenders_count * 100 / validators_count) } } diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index 6bcd357f28027..f3b00f617a443 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Tests for the module. +//! Tests for the offences module. #![cfg(test)] @@ -25,6 +25,7 @@ use runtime_io::with_externalities; #[test] fn should_report_an_authority_and_trigger_on_offence() { with_externalities(&mut new_test_ext(), || { + // given let session_index = 5; let time_slot = 42; assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); @@ -36,10 +37,112 @@ fn should_report_an_authority_and_trigger_on_offence() { offenders: vec![5], }; + // when Offences::report_offence(None, offence); + // then ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(20)]); + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); }); }); } + +#[test] +fn should_calculate_the_fraction_corectly() { + with_externalities(&mut new_test_ext(), || { + // given + let session_index = 5; + let time_slot = 42; + assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + let offence1 = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + let offence2 = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![4], + }; + + // when + Offences::report_offence(None, offence1); + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + }); + + Offences::report_offence(None, offence2); + + // then + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(20), Perbill::from_percent(45)]); + }); + }); +} + +#[test] +fn should_not_report_the_same_authority_twice_in_the_same_slot() { + with_externalities(&mut new_test_ext(), || { + // given + let session_index = 5; + let time_slot = 42; + assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + + let offence = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + Offences::report_offence(None, offence.clone()); + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + *f.borrow_mut() = vec![]; + }); + + // when + // reportfor the second time + Offences::report_offence(None, offence); + + // then + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![]); + }); + }); +} + + +#[test] +fn should_report_in_different_time_slot() { + with_externalities(&mut new_test_ext(), || { + // given + let session_index = 5; + let time_slot = 42; + assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + + let mut offence = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + Offences::report_offence(None, offence.clone()); + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + *f.borrow_mut() = vec![]; + }); + + // when + // reportfor the second time + offence.time_slot += 1; + Offences::report_offence(None, offence); + + // then + ON_OFFENCE_PERBILL.with(|f| { + assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + }); + }); +} + From 2d0881a38c4c67a10f2edfbd5a38bad0bd493a8f Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 11:08:42 +0200 Subject: [PATCH 060/191] Clean offences tests. --- srml/offences/src/mock.rs | 7 +++++++ srml/offences/src/tests.rs | 34 +++++++++++++++++----------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index 74b70219532ec..07deff71c2b0a 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -49,6 +49,13 @@ impl offence::OnOffenceHandler for OnOff } } +pub fn with_on_offence_perbill) -> R>(f: F) -> R { + // Feel free to rename this to _mut and add a version that makes `borrow` if required. + ON_OFFENCE_PERBILL.with(|on_offence_perbill| { + f(&mut *on_offence_perbill.borrow_mut()) + }) +} + // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, PartialEq, Eq, Debug)] pub struct Runtime; diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index f3b00f617a443..1654653754b71 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -19,7 +19,7 @@ #![cfg(test)] use super::*; -use crate::mock::{Offences, Offence, KIND, new_test_ext, ON_OFFENCE_PERBILL}; +use crate::mock::{Offences, Offence, KIND, new_test_ext, with_on_offence_perbill}; use runtime_io::with_externalities; #[test] @@ -41,8 +41,8 @@ fn should_report_an_authority_and_trigger_on_offence() { Offences::report_offence(None, offence); // then - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); }); } @@ -69,15 +69,15 @@ fn should_calculate_the_fraction_corectly() { // when Offences::report_offence(None, offence1); - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); Offences::report_offence(None, offence2); // then - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(20), Perbill::from_percent(45)]); + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(20), Perbill::from_percent(45)]); }); }); } @@ -97,9 +97,9 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { offenders: vec![5], }; Offences::report_offence(None, offence.clone()); - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); - *f.borrow_mut() = vec![]; + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); + f.clear(); }); // when @@ -107,8 +107,8 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { Offences::report_offence(None, offence); // then - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![]); + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![]); }); }); } @@ -129,9 +129,9 @@ fn should_report_in_different_time_slot() { offenders: vec![5], }; Offences::report_offence(None, offence.clone()); - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); - *f.borrow_mut() = vec![]; + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); + f.clear(); }); // when @@ -140,8 +140,8 @@ fn should_report_in_different_time_slot() { Offences::report_offence(None, offence); // then - ON_OFFENCE_PERBILL.with(|f| { - assert_eq!(f.borrow().clone(), vec![Perbill::from_percent(25)]); + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); }); } From 8b4cd8e01fa9cce5d8edc22c3e1946d14339ebae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 10:55:01 +0200 Subject: [PATCH 061/191] Fix staking doc test. --- core/cli/src/params.rs | 1 + srml/offences/src/lib.rs | 1 - srml/staking/src/lib.rs | 9 ++++----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/cli/src/params.rs b/core/cli/src/params.rs index 702416aa0c40c..5a8928c739066 100644 --- a/core/cli/src/params.rs +++ b/core/cli/src/params.rs @@ -133,6 +133,7 @@ pub struct NetworkConfigurationParams { } arg_enum! { + #[allow(missing_docs)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum NodeKeyType { Secp256k1, diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 08be94de1e46c..5a12bdac971ef 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -20,7 +20,6 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -#![warn(missing_docs)] mod mock; mod tests; diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 060d8d0d77347..8f0b8ad985690 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -133,8 +133,7 @@ //! //! ## Usage //! -//! ### Example: Slashing a particular validator. -//! TODO [slashing] Figure out a better example. +//! ### Example: Rewarding a validator by id. //! //! ``` //! use srml_support::{decl_module, dispatch::Result}; @@ -145,10 +144,10 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! /// Slash a validator for an offence. -//! pub fn slash_myself(origin) -> Result { +//! /// Reward a validator. +//! pub fn reward_myself(origin) -> Result { //! let reported = ensure_signed(origin)?; -//! >::slash_validator(reported, 1_000.into()); +//! >::reward_by_ids(vec![(reported, 10)]); //! Ok(()) //! } //! } From b9fa71b2dbc109c2925e37da93a10033cc43389d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 11:12:04 +0200 Subject: [PATCH 062/191] Bump spec version --- node/runtime/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 84c8f9d7912c9..76ed2b3a27c1b 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -80,8 +80,8 @@ 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: 135, - impl_version: 135, + spec_version: 136, + impl_version: 136, apis: RUNTIME_API_VERSIONS, }; From 6eb6cabae1cf28844060c08008e9229cc9a60427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 11:17:35 +0200 Subject: [PATCH 063/191] Fix aura tests. --- Cargo.lock | 1 + srml/aura/Cargo.toml | 2 ++ srml/aura/src/lib.rs | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 59fc038eb08fb..86f9d25d27999 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3729,6 +3729,7 @@ 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/srml/aura/Cargo.toml b/srml/aura/Cargo.toml index 7e93ab1980932..955831ba29910 100644 --- a/srml/aura/Cargo.toml +++ b/srml/aura/Cargo.toml @@ -15,6 +15,7 @@ app-crypto = { package = "substrate-application-crypto", path = "../../core/app 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 } +staking = { package = "srml-staking", path = "../staking", default-features = false } session = { package = "srml-session", path = "../session", default-features = false } substrate-consensus-aura-primitives = { path = "../../core/consensus/aura/primitives", default-features = false} @@ -34,6 +35,7 @@ std = [ "primitives/std", "system/std", "timestamp/std", + "staking/std", "inherents/std", "substrate-consensus-aura-primitives/std", "app-crypto/std", diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index b5f6d13c9bda1..af1600322f383 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -286,8 +286,9 @@ impl OnTimestampSet for Module { /// A type for performing slashing based on Aura reports. pub struct StakingSlasher(::rstd::marker::PhantomData); -impl HandleReport for StakingSlasher { +impl HandleReport for StakingSlasher { fn handle_report(report: AuraReport) { + use staking::SessionInterface; let validators = T::SessionInterface::validators(); report.punish( From 9e7e8ced73064d49ffd0260df99743fa718777e8 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 11:44:22 +0200 Subject: [PATCH 064/191] Fix node_executor --- node/executor/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/node/executor/src/lib.rs b/node/executor/src/lib.rs index d012d35778693..fa07959291692 100644 --- a/node/executor/src/lib.rs +++ b/node/executor/src/lib.rs @@ -375,8 +375,7 @@ mod tests { ], validator_count: 3, minimum_validator_count: 0, - offline_slash: Perbill::zero(), - offline_slash_grace: 0, + slash_reward_fraction: Perbill::from_percent(10), invulnerables: vec![alice(), bob(), charlie()], }), contracts: Some(ContractsConfig { From f23b2f3d1b22455a14445fe7cc13d86cf0307a38 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 12:33:08 +0200 Subject: [PATCH 065/191] Deposit an event on offence. --- node/runtime/src/lib.rs | 1 + srml/offences/src/lib.rs | 19 ++++++++-- srml/offences/src/mock.rs | 16 +++++++-- srml/offences/src/tests.rs | 73 +++++++++++++++++++++++++++++++++++++- 4 files changed, 104 insertions(+), 5 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 76ed2b3a27c1b..01049adbcfbc4 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -400,6 +400,7 @@ impl im_online::Trait for Runtime { } impl offences::Trait for Runtime { + type Event = Event; type IdentificationTuple = session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 5a12bdac971ef..c36b33b2e0ef2 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -26,7 +26,7 @@ mod tests; use rstd::vec::Vec; use support::{ - StorageDoubleMap, decl_module, decl_storage, Parameter, + StorageDoubleMap, decl_module, decl_event, decl_storage, Parameter, }; use sr_primitives::Perbill; use sr_staking_primitives::{ @@ -36,6 +36,8 @@ use sr_staking_primitives::{ /// Offences trait pub trait Trait: system::Trait { + /// The overarching event type. + type Event: From + Into<::Event>; /// Full identification of the validator. type IdentificationTuple: Parameter; /// A handler called for every offence report. @@ -55,9 +57,19 @@ decl_storage! { } } +decl_event!( + pub enum Event { + /// There is an offence reported of the given `kind` happened at the `session_index` and + /// (kind-specific) time slot. This event is not deposited for duplicate slashes. + Offence(Kind, SessionIndex, TimeSlot), + } +); + decl_module! { /// Offences module, currently just responsible for taking offence reports. - pub struct Module for enum Call where origin: T::Origin {} + pub struct Module for enum Call where origin: T::Origin { + fn deposit_event() = default; + } } impl> ReportOffence @@ -104,6 +116,9 @@ impl> ReportOffence; type Header = Header; type WeightMultiplierUpdate = (); - type Event = (); + type Event = TestEvent; type BlockHashCount = BlockHashCount; type MaximumBlockWeight = MaximumBlockWeight; type MaximumBlockLength = MaximumBlockLength; @@ -84,10 +84,21 @@ impl system::Trait for Runtime { } impl Trait for Runtime { + type Event = TestEvent; type IdentificationTuple = u64; type OnOffenceHandler = OnOffenceHandler; } +mod offences { + pub use crate::Event; +} + +impl_outer_event! { + pub enum TestEvent for Runtime { + offences, + } +} + pub fn new_test_ext() -> runtime_io::TestExternalities { let t = system::GenesisConfig::default().build_storage::().unwrap().0; t.into() @@ -95,6 +106,7 @@ pub fn new_test_ext() -> runtime_io::TestExternalities { /// Offences module. pub type Offences = Module; +pub type System = system::Module; pub const KIND: [u8; 16] = *b"test_report_1234"; diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index 1654653754b71..edc2490275f41 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -19,7 +19,8 @@ #![cfg(test)] use super::*; -use crate::mock::{Offences, Offence, KIND, new_test_ext, with_on_offence_perbill}; +use crate::mock::{Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_perbill}; +use system::{EventRecord, Phase}; use runtime_io::with_externalities; #[test] @@ -146,3 +147,73 @@ fn should_report_in_different_time_slot() { }); } +#[test] +fn should_deposit_event() { + with_externalities(&mut new_test_ext(), || { + // given + let session_index = 5; + let time_slot = 42; + assert_eq!( + Offences::offence_reports(&KIND, &(session_index, time_slot)), + vec![] + ); + + let offence = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + + // when + Offences::report_offence(None, offence); + + // then + assert_eq!( + System::events(), + vec![EventRecord { + phase: Phase::ApplyExtrinsic(0), + event: TestEvent::offences(crate::Event::Offence(KIND, session_index, time_slot)), + topics: vec![], + }] + ); + }); +} + +#[test] +fn doesnt_deposit_event_for_dups() { + with_externalities(&mut new_test_ext(), || { + // given + let session_index = 5; + let time_slot = 42; + assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + + let offence = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + Offences::report_offence(None, offence.clone()); + with_on_offence_perbill(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); + f.clear(); + }); + + // when + // report for the second time + Offences::report_offence(None, offence); + + // then + // there is only one event. + assert_eq!( + System::events(), + vec![EventRecord { + phase: Phase::ApplyExtrinsic(0), + event: TestEvent::offences(crate::Event::Offence(KIND, session_index, time_slot)), + topics: vec![], + }] + ); + }); +} + From 2de1c86ca9ca705cc54d5a177a6753f3bb34cc97 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 12:45:46 +0200 Subject: [PATCH 066/191] Fix compilation of node-runtime --- node/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 01049adbcfbc4..0a7386336788d 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -445,7 +445,7 @@ construct_runtime!( Contracts: contracts, Sudo: sudo, ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, - Offences: offences::{Module, Call, Storage}, + Offences: offences::{Module, Call, Storage, Event}, } ); From 6420e8049cba9bc49cef82b965d221f05f7a3bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 8 Aug 2019 12:42:45 +0200 Subject: [PATCH 067/191] Remove aura slashing logic. --- Cargo.lock | 1 - srml/aura/Cargo.toml | 24 +++++++------- srml/aura/src/lib.rs | 73 ++---------------------------------------- srml/aura/src/mock.rs | 2 -- srml/aura/src/tests.rs | 70 +++------------------------------------- 5 files changed, 18 insertions(+), 152 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 86f9d25d27999..59fc038eb08fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3729,7 +3729,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/srml/aura/Cargo.toml b/srml/aura/Cargo.toml index 955831ba29910..9a5bee6276760 100644 --- a/srml/aura/Cargo.toml +++ b/srml/aura/Cargo.toml @@ -5,19 +5,18 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -serde = { version = "1.0", optional = true } inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } +primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +serde = { version = "1.0", optional = true } +session = { package = "srml-session", path = "../session", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } -primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } -app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } srml-support = { path = "../support", default-features = false } +substrate-consensus-aura-primitives = { path = "../../core/consensus/aura/primitives", default-features = false} system = { package = "srml-system", path = "../system", default-features = false } timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false } -staking = { package = "srml-staking", path = "../staking", default-features = false } -session = { package = "srml-session", path = "../session", default-features = false } -substrate-consensus-aura-primitives = { path = "../../core/consensus/aura/primitives", default-features = false} [dev-dependencies] lazy_static = "1.0" @@ -27,16 +26,15 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io" } [features] default = ["std"] std = [ - "serde", + "app-crypto/std", "codec/std", + "inherents/std", + "primitives/std", "rstd/std", - "srml-support/std", + "serde", "sr-primitives/std", - "primitives/std", + "srml-support/std", + "substrate-consensus-aura-primitives/std", "system/std", "timestamp/std", - "staking/std", - "inherents/std", - "substrate-consensus-aura-primitives/std", - "app-crypto/std", ] diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index af1600322f383..6755e50f044a8 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -52,7 +52,7 @@ use codec::Encode; use srml_support::{decl_storage, decl_module, Parameter, storage::StorageValue, traits::Get}; use app_crypto::AppPublic; use sr_primitives::{ - traits::{SaturatedConversion, Saturating, Zero, One, Member, IsMember}, generic::DigestItem, + traits::{SaturatedConversion, Saturating, Zero, Member, IsMember}, generic::DigestItem, }; use timestamp::OnTimestampSet; #[cfg(feature = "std")] @@ -139,19 +139,7 @@ impl ProvideInherentData for InherentDataProvider { } } -/// Something that can handle Aura consensus reports. -pub trait HandleReport { - fn handle_report(report: AuraReport); -} - -impl HandleReport for () { - fn handle_report(_report: AuraReport) { } -} - pub trait Trait: timestamp::Trait { - /// The logic for handling reports. - type HandleReport: HandleReport; - /// The identifier type for an authority. type AuthorityId: Member + Parameter + AppPublic + Default; } @@ -215,34 +203,6 @@ impl IsMember for Module { } } -/// A report of skipped authorities in Aura. -#[derive(Clone, PartialEq, Eq)] -#[cfg_attr(feature = "std", derive(Debug))] -pub struct AuraReport { - // The first skipped slot. - start_slot: usize, - // The number of times authorities were skipped. - skipped: usize, -} - -impl AuraReport { - /// Call the closure with (`validator_indices`, `punishment_count`) for each - /// validator to punish. - pub fn punish(&self, validator_count: usize, mut punish_with: F) - where F: FnMut(usize, usize) - { - // If all validators have been skipped, then it implies some sort of - // systematic problem common to all rather than a minority of validators - // not fulfilling their specific duties. In this case, it doesn't make - // sense to punish anyone, so we guard against it. - if self.skipped < validator_count { - for index in 0..self.skipped { - punish_with((self.start_slot + index) % validator_count, 1); - } - } - } -} - impl Module { /// Determine the Aura slot-duration based on the Timestamp module configuration. pub fn slot_duration() -> T::Moment { @@ -251,7 +211,7 @@ impl Module { ::MinimumPeriod::get().saturating_mul(2.into()) } - fn on_timestamp_set(now: T::Moment, slot_duration: T::Moment) { + fn on_timestamp_set(now: T::Moment, slot_duration: T::Moment) { let last = Self::last(); ::LastTimestamp::put(now.clone()); @@ -262,42 +222,15 @@ impl Module { assert!(!slot_duration.is_zero(), "Aura slot duration cannot be zero."); let last_slot = last / slot_duration.clone(); - let first_skipped = last_slot.clone() + One::one(); let cur_slot = now / slot_duration; assert!(last_slot < cur_slot, "Only one block may be authored per slot."); - if cur_slot == first_skipped { return } - - let skipped_slots = cur_slot - last_slot - One::one(); - - H::handle_report(AuraReport { - start_slot: first_skipped.saturated_into::(), - skipped: skipped_slots.saturated_into::(), - }) } } impl OnTimestampSet for Module { fn on_timestamp_set(moment: T::Moment) { - Self::on_timestamp_set::(moment, Self::slot_duration()) - } -} - -/// A type for performing slashing based on Aura reports. -pub struct StakingSlasher(::rstd::marker::PhantomData); - -impl HandleReport for StakingSlasher { - fn handle_report(report: AuraReport) { - use staking::SessionInterface; - let validators = T::SessionInterface::validators(); - - report.punish( - validators.len(), - |idx, slash_count| { - let v = validators[idx].clone(); - // TODO [slashing] Use report_offence here. - } - ); + Self::on_timestamp_set(moment, Self::slot_duration()) } } diff --git a/srml/aura/src/mock.rs b/srml/aura/src/mock.rs index 7c5d862a50c8a..2030237b3b70b 100644 --- a/srml/aura/src/mock.rs +++ b/srml/aura/src/mock.rs @@ -69,7 +69,6 @@ impl timestamp::Trait for Test { } impl Trait for Test { - type HandleReport = (); type AuthorityId = AuthorityId; } @@ -81,5 +80,4 @@ pub fn new_test_ext(authorities: Vec) -> runtime_io::TestExternalities; pub type Aura = Module; diff --git a/srml/aura/src/tests.rs b/srml/aura/src/tests.rs index 12deeb99a8d3e..a90eddf18f730 100644 --- a/srml/aura/src/tests.rs +++ b/srml/aura/src/tests.rs @@ -18,75 +18,13 @@ #![cfg(test)] -use lazy_static::lazy_static; -use crate::mock::{System, Aura, new_test_ext}; -use sr_primitives::traits::Header; use runtime_io::with_externalities; -use parking_lot::Mutex; -use crate::{AuraReport, HandleReport}; +use crate::mock::{Aura, new_test_ext}; #[test] -fn aura_report_gets_skipped_correctly() { - let mut report = AuraReport { - start_slot: 3, - skipped: 15, - }; - - let mut validators = vec![0; 10]; - report.punish(10, |idx, count| validators[idx] += count); - assert_eq!(validators, vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); - - let mut validators = vec![0; 10]; - report.skipped = 5; - report.punish(10, |idx, count| validators[idx] += count); - assert_eq!(validators, vec![0, 0, 0, 1, 1, 1, 1, 1, 0, 0]); - - let mut validators = vec![0; 10]; - report.start_slot = 8; - report.punish(10, |idx, count| validators[idx] += count); - assert_eq!(validators, vec![1, 1, 1, 0, 0, 0, 0, 0, 1, 1]); - - let mut validators = vec![0; 4]; - report.start_slot = 1; - report.skipped = 3; - report.punish(4, |idx, count| validators[idx] += count); - assert_eq!(validators, vec![0, 1, 1, 1]); - - let mut validators = vec![0; 4]; - report.start_slot = 2; - report.punish(4, |idx, count| validators[idx] += count); - assert_eq!(validators, vec![1, 0, 1, 1]); -} - -#[test] -fn aura_reports_offline() { - lazy_static! { - static ref SLASH_COUNTS: Mutex> = Mutex::new(vec![0; 4]); - } - - struct HandleTestReport; - impl HandleReport for HandleTestReport { - fn handle_report(report: AuraReport) { - let mut counts = SLASH_COUNTS.lock(); - report.punish(counts.len(), |idx, count| counts[idx] += count); - } - } - +fn initial_values() { with_externalities(&mut new_test_ext(vec![0, 1, 2, 3]), || { - System::initialize(&1, &Default::default(), &Default::default(), &Default::default()); - let slot_duration = Aura::slot_duration(); - - Aura::on_timestamp_set::(5 * slot_duration, slot_duration); - let header = System::finalize(); - - // no slashing when last step was 0. - assert_eq!(SLASH_COUNTS.lock().as_slice(), &[0, 0, 0, 0]); - - System::initialize(&2, &header.hash(), &Default::default(), &Default::default()); - Aura::on_timestamp_set::(8 * slot_duration, slot_duration); - let _header = System::finalize(); - - // Steps 6 and 7 were skipped. - assert_eq!(SLASH_COUNTS.lock().as_slice(), &[0, 0, 1, 1]); + assert_eq!(Aura::last(), 0u64); + assert_eq!(Aura::authorities().len(), 4); }); } From 591fa51960142ed081d1087e7d7e2414a1af879f Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 13:04:04 +0200 Subject: [PATCH 068/191] Remove HandleReport --- node-template/runtime/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 2b9220c6e585b..1bbf79de41c75 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -143,7 +143,6 @@ impl system::Trait for Runtime { } impl aura::Trait for Runtime { - type HandleReport = (); type AuthorityId = AuraId; } From 0c4760f28274291a283fee7abbdc1803d93aa006 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 16:36:58 +0200 Subject: [PATCH 069/191] Update docs for timeslot. --- core/sr-staking-primitives/src/offence.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 1b47eb10a21d8..a3c80d36ebb0f 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -40,10 +40,8 @@ pub type OffenceCount = u32; /// A type that represents a point in time on an abstract timescale. /// -/// This type is not tied to a particular timescale and can be used for representing instants on -/// different timescales. Examples of such timescales would be the following: for GRANDPA is a round -/// ID, for BABE it's a slot number and for offline it's a session index. The only requirement is -/// that such timescale could be represented by a single `u128` value. +/// See `Offence::time_slot` for details. The only requirement is that such timescale could be +/// represented by a single `u128` value. pub type TimeSlot = u128; /// A trait implemented by an offence report. @@ -69,9 +67,15 @@ pub trait Offence { /// A point in time when this offence happened. /// - /// The timescale is abstract and it doesn't have to be the same across different - /// implementations of this trait. For example, for GRANDPA it could represent a round number - /// and for BABE it could be a slot number. This is used for looking the `offenders_count`. + /// This is used for looking up offences that happened at the "same time". + /// + /// The timescale is abstract and doesn't have to be the same across different implementations + /// of this trait. The value doesn't represent absolute timescale though since it is interpreted + /// along with the `session_index`. Two offences considered to happen at the same time iff + /// both `session_index` and `time_slot` are equal. + /// + /// As an example, for GRANDPA timescale could be a round number and for BABE it could be a slot + /// number. Note that for BABE the round number is reset each epoch. fn time_slot(&self) -> TimeSlot; /// A slash fraction of the total exposure that should be slashed for this From 48a33664ad6dd65fee39b68dbea52c816c061ccb Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 16:58:14 +0200 Subject: [PATCH 070/191] rename with_on_offence_fractions --- srml/offences/src/mock.rs | 7 +++---- srml/offences/src/tests.rs | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index 75efefd767f2e..1c98ccb6a764f 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -49,10 +49,9 @@ impl offence::OnOffenceHandler for OnOff } } -pub fn with_on_offence_perbill) -> R>(f: F) -> R { - // Feel free to rename this to _mut and add a version that makes `borrow` if required. - ON_OFFENCE_PERBILL.with(|on_offence_perbill| { - f(&mut *on_offence_perbill.borrow_mut()) +pub fn with_on_offence_fractions) -> R>(f: F) -> R { + ON_OFFENCE_PERBILL.with(|fractions| { + f(&mut *fractions.borrow_mut()) }) } diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index edc2490275f41..9007fe12449ef 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -19,7 +19,7 @@ #![cfg(test)] use super::*; -use crate::mock::{Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_perbill}; +use crate::mock::{Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_fractions}; use system::{EventRecord, Phase}; use runtime_io::with_externalities; @@ -42,7 +42,7 @@ fn should_report_an_authority_and_trigger_on_offence() { Offences::report_offence(None, offence); // then - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); }); @@ -70,14 +70,14 @@ fn should_calculate_the_fraction_corectly() { // when Offences::report_offence(None, offence1); - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); Offences::report_offence(None, offence2); // then - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(20), Perbill::from_percent(45)]); }); }); @@ -98,7 +98,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { offenders: vec![5], }; Offences::report_offence(None, offence.clone()); - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); }); @@ -108,7 +108,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { Offences::report_offence(None, offence); // then - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![]); }); }); @@ -130,7 +130,7 @@ fn should_report_in_different_time_slot() { offenders: vec![5], }; Offences::report_offence(None, offence.clone()); - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); }); @@ -141,7 +141,7 @@ fn should_report_in_different_time_slot() { Offences::report_offence(None, offence); // then - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); }); @@ -195,7 +195,7 @@ fn doesnt_deposit_event_for_dups() { offenders: vec![5], }; Offences::report_offence(None, offence.clone()); - with_on_offence_perbill(|f| { + with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); }); From 4bc4e6c0c2010973662c84148e872602f029ecb6 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 8 Aug 2019 17:03:50 +0200 Subject: [PATCH 071/191] Add should_properly_count_offences --- srml/offences/src/tests.rs | 47 +++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index 9007fe12449ef..54d456b332753 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -19,7 +19,9 @@ #![cfg(test)] use super::*; -use crate::mock::{Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_fractions}; +use crate::mock::{ + Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_fractions, +}; use system::{EventRecord, Phase}; use runtime_io::with_externalities; @@ -217,3 +219,46 @@ fn doesnt_deposit_event_for_dups() { }); } +#[test] +fn should_properly_count_offences() { + // We report two different authorities for the same issue. Ultimately, the 1st authority + // should have `count` equal 2 and the count of the 2nd one should be equal to 1. + with_externalities(&mut new_test_ext(), || { + // given + let session_index = 5; + let time_slot = 42; + assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + + let offence1 = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![5], + }; + let offence2 = Offence { + validators_count: 5, + session_index, + time_slot, + offenders: vec![4], + }; + Offences::report_offence(None, offence1); + with_on_offence_fractions(|f| { + assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); + f.clear(); + }); + + // when + // report for the second time + Offences::report_offence(None, offence2); + + // then + // the 1st authority should have count 2 and the 2nd one should be reported only once. + assert_eq!( + Offences::offence_reports(&KIND, &(session_index, time_slot)), + vec![ + OffenceDetails { offender: 5, count: 2, reporters: vec![] }, + OffenceDetails { offender: 4, count: 1, reporters: vec![] }, + ] + ); + }); +} From eb1de1932a53a7023ecf3b761ee9191a05556266 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 9 Aug 2019 11:58:02 +0200 Subject: [PATCH 072/191] Replace ValidatorIdByIndex with CurrentElectedSet ValidatorIdByIndex was querying the current_elected set in each call, doing loading (even though its from cache), deserializing and cloning of element. Instead of this it is more efficient to use `CurrentElectedSet`. As a small bonus, the invariant became a little bit easier: now we just rely on the fact that `keys` and `current_elected` set are of the same length rather than relying on the fact that `validator_id_by_index` would work similar to `<[T]>::get`. --- core/sr-staking-primitives/src/lib.rs | 10 ++++----- node/runtime/src/lib.rs | 2 +- srml/im-online/src/lib.rs | 30 +++++++++++++-------------- srml/staking/src/lib.rs | 13 ++++++------ 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/core/sr-staking-primitives/src/lib.rs b/core/sr-staking-primitives/src/lib.rs index 303007280d7c6..9ad90a8e2b296 100644 --- a/core/sr-staking-primitives/src/lib.rs +++ b/core/sr-staking-primitives/src/lib.rs @@ -17,14 +17,14 @@ //! A crate which contains primitives that are useful for implementation that uses staking //! approaches in general. Definitions related to sessions, slashing, etc go here. +use rstd::vec::Vec; + pub mod offence; /// Simple index type with which we can count sessions. pub type SessionIndex = u32; -/// A trait for fetching a validator id by the given index. -pub trait ValidatorIdByIndex { - /// Return a validator identification by the given index in the current elected set of the era, - // or `None` if `validator_index` is out of range. - fn validator_id_by_index(validator_index: u32) -> Option; +pub trait CurrentElectedSet { + /// Returns the validator ids for the currently elected validator set. + fn current_elected_set() -> Vec; } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 0a7386336788d..b046edf7e6bd8 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -396,7 +396,7 @@ impl im_online::Trait for Runtime { type Event = Event; type UncheckedExtrinsic = UncheckedExtrinsic; type ReportUnresponsivness = Offences; - type ValidatorIdByIndex = Staking; + type CurrentElectedSet = staking::CurrentElectedStashAccounts; } impl offences::Trait for Runtime { diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index a9e0400a9eb2f..24b9a9e45a60d 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -79,7 +79,7 @@ use sr_primitives::{ transaction_validity::{TransactionValidity, TransactionLongevity, ValidTransaction}, }; use sr_staking_primitives::{ - SessionIndex, ValidatorIdByIndex, + SessionIndex, CurrentElectedSet, offence::{ReportOffence, Offence, TimeSlot, Kind}, }; use srml_support::{ @@ -177,7 +177,7 @@ pub trait Trait: system::Trait + session::historical::Trait { >; /// A type that returns a validator id from the current elected set of the era. - type ValidatorIdByIndex: ValidatorIdByIndex<::ValidatorId>; + type CurrentElectedSet: CurrentElectedSet<::ValidatorId>; } decl_event!( @@ -388,28 +388,26 @@ impl session::OneSessionHandler for Module { } fn on_before_session_ending() { + let mut unresponsive = vec![]; + let current_session = >::current_index(); let keys = Keys::get(); - let mut unresponsive = vec![]; - for auth_idx in 0..keys.len() { + let current_elected = T::CurrentElectedSet::current_elected_set(); + + // The invariant is that these two are of the same length. + // TODO: What to do: Uncomment, ignore, a third option? + // assert_eq!(keys.len(), current_elected.len()); + + for (auth_idx, validator_id) in current_elected.into_iter().enumerate() { let auth_idx = auth_idx as u32; if !::exists(¤t_session, &auth_idx) { - // Get the validator id by the index of its session key and then use this - // validator id to get the full identification. In practice it cannot return `None` - // since we are querying when the session hasn't yet ended. - let validator_id = T::ValidatorIdByIndex::validator_id_by_index(auth_idx).expect( - "auth_idx is an index `0..keys.len()`; - `keys` is populated from the current elected set; - `validator_id_by_index` queries validators from the current elected set; - thus it can't return `None`; - qed", - ); let full_identification = T::FullIdentificationOf::convert(validator_id.clone()) .expect( - "the validator id is from the current era; + "we got the validator_id from current_elected; + current_elected is set of currently elected validators; the mapping between the validator id and its full identification should be valid; - thus it can't return `None`; + thus `FullIdentificationOf::convert` can't return `None`; qed", ); diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 8f0b8ad985690..c091f86e1a6b4 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -279,7 +279,7 @@ use sr_primitives::traits::{ SimpleArithmetic, SaturatedConversion, }; use sr_staking_primitives::{ - SessionIndex, ValidatorIdByIndex, + SessionIndex, CurrentElectedSet, offence::{OnOffenceHandler, OffenceDetails}, }; #[cfg(feature = "std")] @@ -1518,10 +1518,11 @@ impl OnOffenceHandler ValidatorIdByIndex for Module { - fn validator_id_by_index(validator_index: u32) -> Option { - Self::current_elected() - .get(validator_index as usize) - .cloned() +/// Returns the currently elected validator set represented by their stash accounts. +pub struct CurrentElectedStashAccounts(rstd::marker::PhantomData); + +impl CurrentElectedSet for CurrentElectedStashAccounts { + fn current_elected_set() -> Vec { + >::current_elected() } } From b0150947d874f1b39e69a3db82e6ec3ab10d39ef Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Mon, 12 Aug 2019 12:12:53 +0200 Subject: [PATCH 073/191] Clarify babe equivocation --- srml/babe/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index a9c2c596942c3..bbb9e15d91118 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -250,6 +250,8 @@ impl session::ShouldEndSession for Module { // TODO [slashing]: @marcio use this, remove the dead_code annotation. /// A BABE equivocation offence report. +/// +/// When a validator released two or more blocks at the same slot. #[allow(dead_code)] struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. From 1facbf835ed6f1c3d0919bf02079a13c4a3b5935 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 13 Aug 2019 00:58:10 +0200 Subject: [PATCH 074/191] Fix offences. --- srml/offences/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index 1c98ccb6a764f..211eef4ba7301 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -99,7 +99,7 @@ impl_outer_event! { } pub fn new_test_ext() -> runtime_io::TestExternalities { - let t = system::GenesisConfig::default().build_storage::().unwrap().0; + let t = system::GenesisConfig::default().build_storage::().unwrap(); t.into() } From 57bc7a2236eb5dde3f0d1ffd7f6a9962cccb6efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 13 Aug 2019 15:19:22 +0200 Subject: [PATCH 075/191] Rename validators_count to validator_set_count --- core/sr-io/src/lib.rs | 1 + core/sr-staking-primitives/src/offence.rs | 8 ++++---- srml/babe/src/lib.rs | 10 +++++----- srml/grandpa/src/lib.rs | 10 +++++----- srml/im-online/src/lib.rs | 14 +++++++------- srml/offences/src/lib.rs | 6 +++--- srml/offences/src/mock.rs | 10 +++++----- srml/offences/src/tests.rs | 18 +++++++++--------- 8 files changed, 39 insertions(+), 38 deletions(-) diff --git a/core/sr-io/src/lib.rs b/core/sr-io/src/lib.rs index 91b27efba0304..b79c13fb12934 100644 --- a/core/sr-io/src/lib.rs +++ b/core/sr-io/src/lib.rs @@ -269,6 +269,7 @@ export_api! { /// Even if this function returns `true`, it does not mean that any keys are configured /// and that the validator is registered in the chain. fn is_validator() -> bool; + /// Submit transaction to the pool. /// /// The transaction will end up in the pool. diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index a3c80d36ebb0f..24818c25d9c40 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -62,8 +62,8 @@ pub trait Offence { /// function. fn session_index(&self) -> SessionIndex; - /// Return a validators count at the time when the offence took place. - fn validators_count(&self) -> u32; + /// Return a validator set count at the time when the offence took place. + fn validator_set_count(&self) -> u32; /// A point in time when this offence happened. /// @@ -82,10 +82,10 @@ pub trait Offence { /// particular offence kind for the given parameters. /// /// `offenders_count` - the count of unique offending authorities. It is >0. - /// `validators_count` - the cardinality of the validator set at the time of offence. + /// `validator_set_count` - the cardinality of the validator set at the time of offence. fn slash_fraction( offenders_count: u32, - validators_count: u32, + validator_set_count: u32, ) -> Perbill; } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index bbb9e15d91118..8524d644ecb01 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -259,7 +259,7 @@ struct BabeEquivocationOffence { /// The session index in which the incident happened. session_index: SessionIndex, /// The size of the validator set at the time of the offence. - validators_count: u32, + validator_set_count: u32, /// The authority which produced the equivocation. offender: FullIdentification, } @@ -275,8 +275,8 @@ impl Offence for BabeEquivocation self.session_index } - fn validators_count(&self) -> u32 { - self.validators_count + fn validator_set_count(&self) -> u32 { + self.validator_set_count } fn time_slot(&self) -> TimeSlot { @@ -285,10 +285,10 @@ impl Offence for BabeEquivocation fn slash_fraction( offenders_count: u32, - validators_count: u32, + validator_set_count: u32, ) -> Perbill { // the formula is min((3k / n)^2, 1) - let x = Perbill::from_rational_approximation(3 * offenders_count, validators_count); + let x = Perbill::from_rational_approximation(3 * offenders_count, validator_set_count); // _ ^ 2 // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 49bda1420e5c3..b5e82a39b3f00 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -391,7 +391,7 @@ struct GrandpaEquivocationOffence { /// The session index in which the incident happened. session_index: SessionIndex, /// The size of the validator set at the time of the offence. - validators_count: u32, + validator_set_count: u32, /// The authority which produced this equivocation. offender: FullIdentification, } @@ -407,8 +407,8 @@ impl Offence for GrandpaEquivocat self.session_index } - fn validators_count(&self) -> u32 { - self.validators_count + fn validator_set_count(&self) -> u32 { + self.validator_set_count } fn time_slot(&self) -> TimeSlot { @@ -417,10 +417,10 @@ impl Offence for GrandpaEquivocat fn slash_fraction( offenders_count: u32, - validators_count: u32, + validator_set_count: u32, ) -> Perbill { // the formula is min((3k / n)^2, 1) - let x = Perbill::from_rational_approximation(3 * offenders_count, validators_count); + let x = Perbill::from_rational_approximation(3 * offenders_count, validator_set_count); // _ ^ 2 // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 8ec5639e7efd8..1d9a5e3e80d26 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -418,10 +418,10 @@ impl session::OneSessionHandler for Module { } } - let validators_count = keys.len() as u32; + let validator_set_count = keys.len() as u32; let offence = UnresponsivnessOffence { session_index: current_session, - validators_count, + validator_set_count, offenders: unresponsive, }; @@ -486,7 +486,7 @@ pub struct UnresponsivnessOffence { /// at the end of the session. session_index: SessionIndex, /// The size of the validator set in current session/era. - validators_count: u32, + validator_set_count: u32, /// Authorities which were unresponsive during the current era. offenders: Vec, } @@ -502,17 +502,17 @@ impl Offence for UnresponsivnessOffence { self.session_index } - fn validators_count(&self) -> u32 { - self.validators_count + fn validator_set_count(&self) -> u32 { + self.validator_set_count } fn time_slot(&self) -> TimeSlot { self.session_index as TimeSlot } - fn slash_fraction(offenders: u32, validators_count: u32) -> Perbill { + fn slash_fraction(offenders: u32, validator_set_count: u32) -> Perbill { // the formula is min((3 * (k - 1)) / n, 1) * 0.05 - let x = Perbill::from_rational_approximation(3 * (offenders - 1), validators_count); + let x = Perbill::from_rational_approximation(3 * (offenders - 1), validator_set_count); // _ * 0.05 // For now, Perbill doesn't support multiplication other than an integer so we perform diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index c36b33b2e0ef2..fb5c7a92bc874 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -80,7 +80,7 @@ impl> ReportOffence> ReportOffence 1 { let previous_fraction = O::slash_fraction( offenders_count.saturating_sub(details.count - 1), - validators_count, + validator_set_count, ); let perbil = expected_fraction .into_parts() diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index 211eef4ba7301..3c47192d00e9c 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -111,7 +111,7 @@ pub const KIND: [u8; 16] = *b"test_report_1234"; #[derive(Clone)] pub struct Offence { - pub validators_count: u32, + pub validator_set_count: u32, pub session_index: u32, pub offenders: Vec, pub time_slot: TimeSlot, @@ -128,8 +128,8 @@ impl offence::Offence for Offence { self.session_index } - fn validators_count(&self) -> u32 { - self.validators_count + fn validator_set_count(&self) -> u32 { + self.validator_set_count } fn time_slot(&self) -> TimeSlot { @@ -138,8 +138,8 @@ impl offence::Offence for Offence { fn slash_fraction( offenders_count: u32, - validators_count: u32, + validator_set_count: u32, ) -> Perbill { - Perbill::from_percent(5 + offenders_count * 100 / validators_count) + Perbill::from_percent(5 + offenders_count * 100 / validator_set_count) } } diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index 54d456b332753..7500039303436 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -34,7 +34,7 @@ fn should_report_an_authority_and_trigger_on_offence() { assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); let offence = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], @@ -58,13 +58,13 @@ fn should_calculate_the_fraction_corectly() { let time_slot = 42; assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); let offence1 = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], }; let offence2 = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![4], @@ -94,7 +94,7 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); let offence = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], @@ -126,7 +126,7 @@ fn should_report_in_different_time_slot() { assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); let mut offence = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], @@ -161,7 +161,7 @@ fn should_deposit_event() { ); let offence = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], @@ -191,7 +191,7 @@ fn doesnt_deposit_event_for_dups() { assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); let offence = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], @@ -230,13 +230,13 @@ fn should_properly_count_offences() { assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); let offence1 = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![5], }; let offence2 = Offence { - validators_count: 5, + validator_set_count: 5, session_index, time_slot, offenders: vec![4], From 0b57b0dd794ecc8947736c24f4c8514bb0352fb3 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 14 Aug 2019 14:22:39 +0200 Subject: [PATCH 076/191] Fix squaring. --- core/sr-primitives/src/lib.rs | 26 ++++++++++++++++++++++++++ srml/babe/src/lib.rs | 8 +------- srml/grandpa/src/lib.rs | 8 +------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/core/sr-primitives/src/lib.rs b/core/sr-primitives/src/lib.rs index 5e24accfdfaa0..a6a66b80d4c1e 100644 --- a/core/sr-primitives/src/lib.rs +++ b/core/sr-primitives/src/lib.rs @@ -299,6 +299,13 @@ impl Perbill { Perbill(part as u32) } + /// Return the product of multiplication of this value by itself. + pub fn square(self) -> Self { + let p: u64 = self.0 as u64 * self.0 as u64; + let q: u64 = 1_000_000_000 * 1_000_000_000; + Self::from_rational_approximation(p, q) + } + /// Take out the raw parts-per-billions. pub fn into_parts(self) -> u32 { self.0 @@ -964,4 +971,23 @@ mod tests { ((Into::::into(std::u128::MAX) * 999_999u32) / 1_000_000u32).as_u128() ); } + + #[test] + fn per_bill_square() { + const FIXTURES: &[(u32, u32)] = &[ + (0, 0), + (1250000, 1562), // (0.00125, 0.000001562) + (255300000, 65178090), // (0.2553, 0.06517809) + (500000000, 250000000), // (0.5, 0.25) + (999995000, 999990000), // (0.999995, 0.999990000, but ideally 0.99999000002) + (1000000000, 1000000000), + ]; + + for &(x, r) in FIXTURES { + assert_eq!( + Perbill::from_parts(x).square(), + Perbill::from_parts(r), + ); + } + } } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 8524d644ecb01..60bc33c0c8388 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -289,14 +289,8 @@ impl Offence for BabeEquivocation ) -> Perbill { // the formula is min((3k / n)^2, 1) let x = Perbill::from_rational_approximation(3 * offenders_count, validator_set_count); - // _ ^ 2 - // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. - // The conversion to u64 is performed to guarantee it fits. - // TODO: #3189 should fix this. - let x = x.into_parts(); - let x = ((x as u64 * x as u64) / (1_000_000_000 * 1_000_000_000)) as u32; - Perbill::from_parts(x) + x.square() } } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index b5e82a39b3f00..0698e322d4464 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -421,13 +421,7 @@ impl Offence for GrandpaEquivocat ) -> Perbill { // the formula is min((3k / n)^2, 1) let x = Perbill::from_rational_approximation(3 * offenders_count, validator_set_count); - // _ ^ 2 - // For now, Perbill doesn't support taking the power of it. Until it does, do it manually. - // The conversion to u64 is performed to guarantee it fits. - // TODO: #3189 should fix this. - let x = x.into_parts(); - let x = ((x as u64 * x as u64) / (1_000_000_000 * 1_000_000_000)) as u32; - Perbill::from_parts(x) + x.square() } } From 12baedaa55bfd5104b27070fab74043fde122655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 14:40:40 +0200 Subject: [PATCH 077/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: Gavin Wood --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 24818c25d9c40..a217ae318701a 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -111,7 +111,7 @@ pub trait OnOffenceHandler { /// the same authorities were reported for the same offence /// in the past (see `OffenceCount`). /// - /// The vector of `slash_fraction` contains perbils + /// The vector of `slash_fraction` contains `Perbill`s /// the authorities should be slashed and is computed /// according to the `OffenceCount` already. This is of the same length as `offenders.` /// Zero is a valid value for a fraction. From a88c5ace2e4aebc624c4229fbeb1fe3a8aa4d0b3 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 14 Aug 2019 14:54:01 +0200 Subject: [PATCH 078/191] Docs for CurrentElectedSet. --- core/sr-staking-primitives/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/sr-staking-primitives/src/lib.rs b/core/sr-staking-primitives/src/lib.rs index 9ad90a8e2b296..63a5eb29279d1 100644 --- a/core/sr-staking-primitives/src/lib.rs +++ b/core/sr-staking-primitives/src/lib.rs @@ -24,6 +24,8 @@ pub mod offence; /// Simple index type with which we can count sessions. pub type SessionIndex = u32; +/// A trait for getting the currently elected validator set without coupling to the module that +/// provides this information. pub trait CurrentElectedSet { /// Returns the validator ids for the currently elected validator set. fn current_elected_set() -> Vec; From 53b2c6449b41ced1dd3cfc5330e59e004187af78 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 14 Aug 2019 15:10:47 +0200 Subject: [PATCH 079/191] Don't punish only invulnerables --- srml/staking/src/lib.rs | 4 ++-- srml/staking/src/tests.rs | 45 +++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index 7fd5e1983d2c0..d10e2939c73cc 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -1493,9 +1493,9 @@ impl OnOffenceHandler Date: Wed, 14 Aug 2019 16:12:34 +0200 Subject: [PATCH 080/191] Use `get/insert` instead of `mutate`. --- srml/offences/src/lib.rs | 50 +++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index fb5c7a92bc874..f396e31223b28 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -85,31 +85,39 @@ impl> ReportOffence> - ::mutate(&O::ID, &(session, time_slot), |offending_authorities| { - for offender in offenders { - // TODO [slashing] This prevents slashing for multiple reports of the same kind at the same slot, - // note however that we might do that in the future if the reports are not exactly the same (dups). - // De-duplication of reports is tricky though, we need a canonical form of the report - // (for instance babe equivocation can have headers swapped). - if !offending_authorities.iter().any(|details| details.offender == offender) { - changed = true; - offending_authorities.push(OffenceDetails { - offender, - count: 0, - reporters: reporter.clone().into_iter().collect(), - }); - } + let all_offenders = { + // We have to return the modified list of offending authorities. If we were to use + // `mutate` we would have to clone the whole list in order to return it. + let mut offending_authorities = >::get(&O::ID, &(session, time_slot)); + + for offender in offenders { + // TODO [slashing] This prevents slashing for multiple reports of the same kind at the same slot, + // note however that we might do that in the future if the reports are not exactly the same (dups). + // De-duplication of reports is tricky though, we need a canonical form of the report + // (for instance babe equivocation can have headers swapped). + if !offending_authorities.iter().any(|details| details.offender == offender) { + changed = true; + offending_authorities.push(OffenceDetails { + offender, + count: 0, + reporters: reporter.clone().into_iter().collect(), + }); } + } - if changed { - for details in offending_authorities.iter_mut() { - details.count += 1; - } + if changed { + // Increase the count in each offence report. For just added offences the count is + // going to be increased from 0 to 1. + for details in offending_authorities.iter_mut() { + details.count += 1; } - offending_authorities.clone() - }); + // We pushed new items in the offending_authorities, so update it. + >::insert(&O::ID, &(session, time_slot), &offending_authorities); + } + + offending_authorities + }; if !changed { // The report contained only duplicates, so there is no need to slash again. From fa1d88eea79941b65fad86695413d3d8d750d332 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Wed, 14 Aug 2019 16:32:26 +0200 Subject: [PATCH 081/191] Fix compilation --- node/cli/src/chain_spec.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index d7497cd6762a7..ab2b33827c4d1 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -300,7 +300,6 @@ pub fn testnet_genesis( authorities: initial_authorities.iter().map(|x| (x.3.clone(), 1)).collect(), }), im_online: Some(ImOnlineConfig { - gossip_at: 0, keys: initial_authorities.iter().map(|x| x.4.clone()).collect(), }), grandpa: Some(GrandpaConfig { From 192e81157d8204c7a57e55a8d53b7ef90a9d26d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:16:25 +0200 Subject: [PATCH 082/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: Gavin Wood --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index a217ae318701a..e8cad6248fcfc 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -79,7 +79,7 @@ pub trait Offence { fn time_slot(&self) -> TimeSlot; /// A slash fraction of the total exposure that should be slashed for this - /// particular offence kind for the given parameters. + /// particular offence kind for the given parameters that happened at a singular `TimeSlot`. /// /// `offenders_count` - the count of unique offending authorities. It is >0. /// `validator_set_count` - the cardinality of the validator set at the time of offence. From 455dcac78ad8dca4733b9ef5ea6d6b9a00f0d9b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:17:01 +0200 Subject: [PATCH 083/191] Update srml/offences/src/lib.rs Co-Authored-By: Robert Habermeier --- srml/offences/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index f396e31223b28..47bcf30afc80e 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -149,7 +149,7 @@ impl> ReportOffence Date: Wed, 14 Aug 2019 18:17:15 +0200 Subject: [PATCH 084/191] Update srml/im-online/src/lib.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- srml/im-online/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 9141ccda1c1c5..54feb755619f3 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -478,7 +478,7 @@ impl srml_support::unsigned::ValidateUnsigned for Module { } } -/// An offense which is filed if a validator didn't send a heartbeat message. +/// An offense that is filed if a validator didn't send a heartbeat message. pub struct UnresponsivnessOffence { /// The current session index in which we report the unresponsive validators. /// From 7257ca9930b62146d1b26c7c7871b8fdc500bb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:17:26 +0200 Subject: [PATCH 085/191] Update srml/im-online/src/lib.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- srml/im-online/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 54feb755619f3..e0146d5c47ef2 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -487,7 +487,7 @@ pub struct UnresponsivnessOffence { session_index: SessionIndex, /// The size of the validator set in current session/era. validator_set_count: u32, - /// Authorities which were unresponsive during the current era. + /// Authorities that were unresponsive during the current era. offenders: Vec, } From 542de32e2c7f83eae6854b293357bca3a39a3080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:17:41 +0200 Subject: [PATCH 086/191] Update srml/im-online/src/lib.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- srml/im-online/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index e0146d5c47ef2..8ecaf95e3c0de 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -168,7 +168,7 @@ pub trait Trait: system::Trait + session::historical::Trait { /// can contain a signature. type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; - /// A type that gives us ability to submit unresponsivness offence reports. + /// A type that gives us the ability to submit unresponsiveness offence reports. type ReportUnresponsivness: ReportOffence< Self::AccountId, From e02ef2f6ceb6849640b3b05c89e124b6388e7521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:18:37 +0200 Subject: [PATCH 087/191] Update srml/babe/src/lib.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- srml/babe/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 60bc33c0c8388..8ae370849c7c7 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -260,7 +260,7 @@ struct BabeEquivocationOffence { session_index: SessionIndex, /// The size of the validator set at the time of the offence. validator_set_count: u32, - /// The authority which produced the equivocation. + /// The authority that produced the equivocation. offender: FullIdentification, } From 08366c0e31f2491a2dc79fa6f707b90b6cf391fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:19:33 +0200 Subject: [PATCH 088/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index e8cad6248fcfc..7b525cb6c3d70 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -141,7 +141,7 @@ pub struct OffenceDetails { /// in case the authority was already slashed in the past. /// Note that we don't buffer slashes and instead use this approach. pub count: OffenceCount, - /// A list of reporters of offences of this authority id. Possibily empty where there is no + /// A list of reporters of offences of this authority ID. Possibly empty where there are no /// particular reporters. pub reporters: Vec, } From 3f398c4837823703c4508d6577a63f1b4aec41c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:19:42 +0200 Subject: [PATCH 089/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 7b525cb6c3d70..8e9e915d09e4c 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -104,7 +104,7 @@ impl> ReportOffence { - /// A handler for offence of particular kind. + /// A handler for an offence of a particular kind. /// /// Note that this contains a list of all previous offenders /// as well. The implementer should cater for a case, where From fe3094c3a6ea34301fceccf78904575b653d9e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:19:52 +0200 Subject: [PATCH 090/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 8e9e915d09e4c..c396d648d95af 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -71,7 +71,7 @@ pub trait Offence { /// /// The timescale is abstract and doesn't have to be the same across different implementations /// of this trait. The value doesn't represent absolute timescale though since it is interpreted - /// along with the `session_index`. Two offences considered to happen at the same time iff + /// along with the `session_index`. Two offences are considered to happen at the same time iff /// both `session_index` and `time_slot` are equal. /// /// As an example, for GRANDPA timescale could be a round number and for BABE it could be a slot From 9b4263c7dc9ac4d1c96c965a5c6e862cab5f1ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:20:03 +0200 Subject: [PATCH 091/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index c396d648d95af..eb6edc62fbcef 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -32,7 +32,7 @@ pub type Kind = [u8; 16]; /// Number of times the offence of this authority was already reported in the past. /// -/// Note we don't buffer offence reporting so everytime we see a new offence +/// Note that we don't buffer offence reporting, so every time we see a new offence /// of the same kind, we will report past authorities again. /// This counter keeps track of how many times the authority was already reported in the past, /// so that we can slash it accordingly. From ce5e8ed5611bc0fa17c2adf7ae2fe75afd871de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:20:12 +0200 Subject: [PATCH 092/191] Update core/sr-staking-primitives/src/offence.rs Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index eb6edc62fbcef..8f4a167427cec 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -58,7 +58,7 @@ pub trait Offence { /// The list has no duplicates, so it is rather a set. fn offenders(&self) -> Vec; - /// The session index which is used for querying the validator set for the `slash_fraction` + /// The session index that is used for querying the validator set for the `slash_fraction` /// function. fn session_index(&self) -> SessionIndex; From 758a1ecd4b9a96f7388a65e4b24218d8560a29fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 15:16:18 +0200 Subject: [PATCH 093/191] Add aura todo. --- srml/aura/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/srml/aura/src/lib.rs b/srml/aura/src/lib.rs index 6755e50f044a8..8de005d66d26c 100644 --- a/srml/aura/src/lib.rs +++ b/srml/aura/src/lib.rs @@ -225,6 +225,8 @@ impl Module { let cur_slot = now / slot_duration; assert!(last_slot < cur_slot, "Only one block may be authored per slot."); + + // TODO [#3398] Generate offence report for all authorities that skipped their slots. } } From d58208b47440ef8c0b34e3dde5ab2b697803b8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 15:18:29 +0200 Subject: [PATCH 094/191] Allow multiple reports for single offence report. --- core/sr-staking-primitives/src/offence.rs | 6 +++--- srml/offences/src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 8f4a167427cec..098e6119b1bc0 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -91,12 +91,12 @@ pub trait Offence { /// A trait for decoupling offence reporters from the actual handling of offence reports. pub trait ReportOffence> { - /// Report an `offence` and reward the `reporter`. - fn report_offence(reporter: Option, offence: O); + /// Report an `offence` and reward given `reporters`. + fn report_offence(reporters: Vec, offence: O); } impl> ReportOffence for () { - fn report_offence(_reporter: Option, _offence: O) {} + fn report_offence(_reporters: Vec, _offence: O) {} } /// A trait to take action on an offence. diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 47bcf30afc80e..5268afd1c500d 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -76,7 +76,7 @@ impl> ReportOffence where T::IdentificationTuple: Clone, { - fn report_offence(reporter: Option, offence: O) { + fn report_offence(reporters: Vec, offence: O) { let offenders = offence.offenders(); let time_slot = offence.time_slot(); let session = offence.session_index(); @@ -100,7 +100,7 @@ impl> ReportOffence Date: Wed, 14 Aug 2019 18:14:51 +0200 Subject: [PATCH 095/191] Fix slash_fraction calculation. --- core/sr-staking-primitives/src/offence.rs | 7 --- srml/im-online/src/lib.rs | 2 +- srml/offences/src/lib.rs | 75 +++++++++++++---------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 098e6119b1bc0..11604af942722 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -134,13 +134,6 @@ impl OnOffenceHandler for () { pub struct OffenceDetails { /// The offending authority id pub offender: Offender, - /// A number of times the authority was already reported for this offence. - /// - /// Since we punish all authorities for that made the same offence in the past as well - /// we keep track the "age" of the report, so that the slashes can be lowered - /// in case the authority was already slashed in the past. - /// Note that we don't buffer slashes and instead use this approach. - pub count: OffenceCount, /// A list of reporters of offences of this authority ID. Possibly empty where there are no /// particular reporters. pub reporters: Vec, diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 8ecaf95e3c0de..93c624ee547de 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -425,7 +425,7 @@ impl session::OneSessionHandler for Module { offenders: unresponsive, }; - T::ReportUnresponsivness::report_offence(None, offence); + T::ReportUnresponsivness::report_offence(vec![], offence); } fn on_disabled(_i: usize) { diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 5268afd1c500d..f146e583efd4e 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -24,7 +24,10 @@ mod mock; mod tests; -use rstd::vec::Vec; +use rstd::{ + collections::btree_set::BTreeSet, + vec::Vec, +}; use support::{ StorageDoubleMap, decl_module, decl_event, decl_storage, Parameter, }; @@ -39,7 +42,7 @@ pub trait Trait: system::Trait { /// The overarching event type. type Event: From + Into<::Event>; /// Full identification of the validator. - type IdentificationTuple: Parameter; + type IdentificationTuple: Parameter + Ord; /// A handler called for every offence report. type OnOffenceHandler: OnOffenceHandler; } @@ -84,7 +87,7 @@ impl> ReportOffence> ReportOffence>::insert(&O::ID, &(session, time_slot), &offending_authorities); - } - offending_authorities }; - if !changed { + let offenders_count = all_offenders.len() as u32; + let previous_offenders_count = offenders_count - new_offenders.len() as u32; + + if previous_offenders_count != offenders_count { // The report contained only duplicates, so there is no need to slash again. return } @@ -127,29 +120,43 @@ impl> ReportOffence 0 { + let previous_fraction = O::slash_fraction( + offenders_count.saturating_sub(previous_offenders_count), + validator_set_count, + ); + let numerator = new_fraction + .into_parts() + .saturating_sub(previous_fraction.into_parts()); + let denominator = Perbill::from_parts(Perbill::one().into_parts() - previous_fraction.into_parts()); + Perbill::from_parts(denominator * numerator) + } else { + new_fraction.clone() + }; + + // calculate how much to slash + let slash_perbill = all_offenders .iter() - .map(|details| { - if details.count > 1 { - let previous_fraction = O::slash_fraction( - offenders_count.saturating_sub(details.count - 1), - validator_set_count, - ); - let perbil = expected_fraction - .into_parts() - .saturating_sub(previous_fraction.into_parts()); - Perbill::from_parts(perbil) - } else { - expected_fraction.clone() - } + .map(|details| if previous_offenders_count > 0 && new_offenders.contains(&details.offender) { + new_fraction.clone() + } else { + old_fraction.clone() }) .collect::>(); T::OnOffenceHandler::on_offence( &all_offenders, - &slash_perbil, + &slash_perbill, ); } } From dd58c067f7ebbff4e7dbdee603508f1302376f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:20:36 +0200 Subject: [PATCH 096/191] Fix typos. --- srml/im-online/src/lib.rs | 24 ++++++++++++------------ srml/offences/src/tests.rs | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 93c624ee547de..d9b0b045dab0b 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -169,11 +169,11 @@ pub trait Trait: system::Trait + session::historical::Trait { type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; /// A type that gives us the ability to submit unresponsiveness offence reports. - type ReportUnresponsivness: + type ReportUnresponsiveness: ReportOffence< Self::AccountId, IdentificationTuple, - UnresponsivnessOffence>, + UnresponsivenessOffence>, >; /// A type that returns a validator id from the current elected set of the era. @@ -419,13 +419,13 @@ impl session::OneSessionHandler for Module { } let validator_set_count = keys.len() as u32; - let offence = UnresponsivnessOffence { + let offence = UnresponsivenessOffence { session_index: current_session, validator_set_count, offenders: unresponsive, }; - T::ReportUnresponsivness::report_offence(vec![], offence); + T::ReportUnresponsivenes::report_offence(vec![], offence); } fn on_disabled(_i: usize) { @@ -479,10 +479,10 @@ impl srml_support::unsigned::ValidateUnsigned for Module { } /// An offense that is filed if a validator didn't send a heartbeat message. -pub struct UnresponsivnessOffence { +pub struct UnresponsivenessOffence { /// The current session index in which we report the unresponsive validators. /// - /// It acts as a time measure for unresponsivness reports and effectively will always point + /// It acts as a time measure for unresponsiveness reports and effectively will always point /// at the end of the session. session_index: SessionIndex, /// The size of the validator set in current session/era. @@ -491,7 +491,7 @@ pub struct UnresponsivnessOffence { offenders: Vec, } -impl Offence for UnresponsivnessOffence { +impl Offence for UnresponsivenessOffence { const ID: Kind = *b"im-online:offlin"; fn offenders(&self) -> Vec { @@ -528,21 +528,21 @@ mod tests { use super::*; #[test] - fn test_unresponsivness_slash_fraction() { - // A single case of unresponsivness is not slashed. + fn test_unresponsiveness_slash_fraction() { + // A single case of unresponsiveness is not slashed. assert_eq!( - UnresponsivnessOffence::<()>::slash_fraction(1, 50), + UnresponsivenessOffence::<()>::slash_fraction(1, 50), Perbill::zero(), ); assert_eq!( - UnresponsivnessOffence::<()>::slash_fraction(3, 50), + UnresponsivenessOffence::<()>::slash_fraction(3, 50), Perbill::from_parts(6000000), // 0.6% ); // One third offline should be punished around 5%. assert_eq!( - UnresponsivnessOffence::<()>::slash_fraction(17, 50), + UnresponsivenessOffence::<()>::slash_fraction(17, 50), Perbill::from_parts(48000000), // 4.8% ); } diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index 7500039303436..bfbd6f65f18f6 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -256,8 +256,8 @@ fn should_properly_count_offences() { assert_eq!( Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![ - OffenceDetails { offender: 5, count: 2, reporters: vec![] }, - OffenceDetails { offender: 4, count: 1, reporters: vec![] }, + OffenceDetails { offender: 5, reporters: vec![] }, + OffenceDetails { offender: 4, reporters: vec![] }, ] ); }); From 0c656970fedd54d536c9db11a69064fea39163c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 18:35:49 +0200 Subject: [PATCH 097/191] Fix compilation and tests. --- node/runtime/src/lib.rs | 2 +- srml/im-online/src/lib.rs | 2 +- srml/offences/src/lib.rs | 12 ++++++++---- srml/offences/src/tests.rs | 30 +++++++++++++++--------------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 3d1b67f8896c1..5c1ba95598bd5 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -395,7 +395,7 @@ impl im_online::Trait for Runtime { type Call = Call; type Event = Event; type UncheckedExtrinsic = UncheckedExtrinsic; - type ReportUnresponsivness = Offences; + type ReportUnresponsiveness = Offences; type CurrentElectedSet = staking::CurrentElectedStashAccounts; } diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index d9b0b045dab0b..021a7f58d2443 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -425,7 +425,7 @@ impl session::OneSessionHandler for Module { offenders: unresponsive, }; - T::ReportUnresponsivenes::report_offence(vec![], offence); + T::ReportUnresponsiveness::report_offence(vec![], offence); } fn on_disabled(_i: usize) { diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index f146e583efd4e..3a014c133b064 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -99,6 +99,7 @@ impl> ReportOffence> ReportOffence>::insert(&O::ID, &(session, time_slot), &all_offenders); + + let offenders_count = all_offenders.len() as u32; + let previous_offenders_count = offenders_count - new_offenders.len() as u32; + // The report is not a duplicate. Deposit an event. Self::deposit_event(Event::Offence(O::ID, session, time_slot)); diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index bfbd6f65f18f6..2cc320387cc72 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -41,7 +41,7 @@ fn should_report_an_authority_and_trigger_on_offence() { }; // when - Offences::report_offence(None, offence); + Offences::report_offence(vec![], offence); // then with_on_offence_fractions(|f| { @@ -51,7 +51,7 @@ fn should_report_an_authority_and_trigger_on_offence() { } #[test] -fn should_calculate_the_fraction_corectly() { +fn should_calculate_the_fraction_correctly() { with_externalities(&mut new_test_ext(), || { // given let session_index = 5; @@ -71,16 +71,16 @@ fn should_calculate_the_fraction_corectly() { }; // when - Offences::report_offence(None, offence1); + Offences::report_offence(vec![], offence1); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); }); - Offences::report_offence(None, offence2); + Offences::report_offence(vec![], offence2); // then with_on_offence_fractions(|f| { - assert_eq!(f.clone(), vec![Perbill::from_percent(20), Perbill::from_percent(45)]); + assert_eq!(f.clone(), vec![Perbill::from_percent(15), Perbill::from_percent(45)]); }); }); } @@ -99,15 +99,15 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { time_slot, offenders: vec![5], }; - Offences::report_offence(None, offence.clone()); + Offences::report_offence(vec![], offence.clone()); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); }); // when - // reportfor the second time - Offences::report_offence(None, offence); + // report for the second time + Offences::report_offence(vec![], offence); // then with_on_offence_fractions(|f| { @@ -131,7 +131,7 @@ fn should_report_in_different_time_slot() { time_slot, offenders: vec![5], }; - Offences::report_offence(None, offence.clone()); + Offences::report_offence(vec![], offence.clone()); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -140,7 +140,7 @@ fn should_report_in_different_time_slot() { // when // reportfor the second time offence.time_slot += 1; - Offences::report_offence(None, offence); + Offences::report_offence(vec![], offence); // then with_on_offence_fractions(|f| { @@ -168,7 +168,7 @@ fn should_deposit_event() { }; // when - Offences::report_offence(None, offence); + Offences::report_offence(vec![], offence); // then assert_eq!( @@ -196,7 +196,7 @@ fn doesnt_deposit_event_for_dups() { time_slot, offenders: vec![5], }; - Offences::report_offence(None, offence.clone()); + Offences::report_offence(vec![], offence.clone()); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -204,7 +204,7 @@ fn doesnt_deposit_event_for_dups() { // when // report for the second time - Offences::report_offence(None, offence); + Offences::report_offence(vec![], offence); // then // there is only one event. @@ -241,7 +241,7 @@ fn should_properly_count_offences() { time_slot, offenders: vec![4], }; - Offences::report_offence(None, offence1); + Offences::report_offence(vec![], offence1); with_on_offence_fractions(|f| { assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); f.clear(); @@ -249,7 +249,7 @@ fn should_properly_count_offences() { // when // report for the second time - Offences::report_offence(None, offence2); + Offences::report_offence(vec![], offence2); // then // the 1st authority should have count 2 and the 2nd one should be reported only once. From 6ddad41e90fe16e53be9f04993ffb737cb87d70e Mon Sep 17 00:00:00 2001 From: Jim Posen Date: Thu, 8 Aug 2019 15:02:04 +0200 Subject: [PATCH 098/191] srml-contracts: Refactor away some duplication in runtime functions. (#3257) * srml-contracts: Storage access micro-optimization. * srml-contracts: Refactor runtime functions to reduce duplication. * Bump node runtime impl version. --- srml/contracts/src/wasm/runtime.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/srml/contracts/src/wasm/runtime.rs b/srml/contracts/src/wasm/runtime.rs index ecc4dfc7fb592..511c2941313c5 100644 --- a/srml/contracts/src/wasm/runtime.rs +++ b/srml/contracts/src/wasm/runtime.rs @@ -269,6 +269,24 @@ fn read_sandbox_memory_as( D::decode(&mut &buf[..]).map_err(|_| sandbox::HostError) } +/// Read designated chunk from the sandbox memory, consuming an appropriate amount of +/// gas, and attempt to decode into the specified type. +/// +/// Returns `Err` if one of the following conditions occurs: +/// +/// - calculating the gas cost resulted in overflow. +/// - out of gas +/// - requested buffer is not within the bounds of the sandbox memory. +/// - the buffer contents cannot be decoded as the required type. +fn read_sandbox_memory_as( + ctx: &mut Runtime, + ptr: u32, + len: u32, +) -> Result { + let buf = read_sandbox_memory(ctx, ptr, len)?; + D::decode(&mut &buf[..]).map_err(|_| sandbox::HostError) +} + /// Write the given buffer to the designated location in the sandbox memory, consuming /// an appropriate amount of gas. /// From 246b5b1a257cf30d21868e88309e1c2794b3c90c Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 8 Aug 2019 15:05:25 +0200 Subject: [PATCH 099/191] Child storage tests and genesis fix. (#3185) * Using child storage, (srml-support only), test failing . * fix simple tests. * Enumerable by requiring owned struct (previous form only allow &'static). Broken tests are from genesis init. * implement for_child_keys_with_prefix * indent * clear_child_prefix fix. * clear_child_prefix fix 2. * fix for storage_impl, if/when allowing child and not child this could be reverted. * Fix lot of urlinked child genesis, still need to look upon actual genesis srml module code. Probably still a lot of broken code needing debugging. * switch well_known_key to their associated module child trie. Fix a genesis init (balance). Complete some testing. Comment some tests before using. * fixing test runtime child keys * latest commit fix broken genesis init * fix system balances child name. * Important fix: storage_root from test externalities need children (it is already the case for ext). * executive root with child calculation * Avoid empty trie on test ext. * Symetric removal of key for system. * commenting changes related tests. * Remove child module specifics. * fix issues. * fix some formatting * fix bench and bump runtime * Remove extend_storage_overlays, assimilate_storage do the same as is proper considering srml macro. * Fix warning for assimilate. * Removing kill as they do not impact any test cases. * Use tuple of storage map instead of two parameters. This changes the behavior of decl_storage genesis build closure (breaking api). * Do not use build storage before assimilate. * fix error * Update core/state-machine/src/backend.rs --- srml/staking/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index a93cfcf01e0d3..e0a90cce9ba29 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -315,8 +315,8 @@ impl ExtBuilder { ], validator_count: self.validator_count, minimum_validator_count: self.minimum_validator_count, - invulnerables: self.invulnerables, slash_reward_fraction: Perbill::from_percent(10), + invulnerables: self.invulnerables, ..Default::default() }.assimilate_storage(&mut storage); From cf31399bf326275788b1c600b0ba701d1be1168a Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 27 Jul 2019 16:32:18 +0200 Subject: [PATCH 100/191] Add transaction pool to Babe check header --- core/consensus/babe/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index e46594dd1e876..e798c21aba3d2 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -463,8 +463,7 @@ fn find_next_epoch_digest(header: &B::Header) -> Result /// unsigned. This is required for security and must not be changed. /// /// This digest item will always return `Some` when used with `as_babe_pre_digest`. -// FIXME #1018 needs misbehavior types. The `transaction_pool` parameter will be -// used to submit such misbehavior reports. +// FIXME #1018 needs misbehavior types fn check_header( client: &C, slot_now: u64, From 907ceaab3e5c8179c4f415306566f1846312d2c3 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 30 Jul 2019 12:15:30 +0200 Subject: [PATCH 101/191] Add tx pool to Aura import_queue --- core/consensus/aura/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 74799837c4047..67e2305b4ff4f 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -389,9 +389,6 @@ fn find_pre_digest(header: &B::Header) -> Result( client: &C, slot_now: u64, @@ -710,6 +707,7 @@ pub fn import_queue( let verifier = AuraVerifier { client: client.clone(), inherent_data_providers, + transaction_pool, phantom: PhantomData, transaction_pool, }; From af317719466e9ed7503507ab32db802e293b5621 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 30 Jul 2019 12:46:41 +0200 Subject: [PATCH 102/191] Fix tests, node-template --- core/consensus/aura/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 67e2305b4ff4f..2ffbb7ba4406a 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -809,7 +809,8 @@ mod tests { inherent_data_providers, transaction_pool: Default::default(), phantom: Default::default(), - } + transaction_pool: Default::default(), + }) }, PeersClient::Light(_) => unreachable!("No (yet) tests for light client + Aura"), } From a9c58c5ce2255046d2d956edb98f2b69556dc02e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 30 Jul 2019 13:45:22 +0200 Subject: [PATCH 103/191] Add comments regarding unused _transaction_pool --- core/consensus/babe/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index e798c21aba3d2..e46594dd1e876 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -463,7 +463,8 @@ fn find_next_epoch_digest(header: &B::Header) -> Result /// unsigned. This is required for security and must not be changed. /// /// This digest item will always return `Some` when used with `as_babe_pre_digest`. -// FIXME #1018 needs misbehavior types +// FIXME #1018 needs misbehavior types. The `transaction_pool` parameter will be +// used to submit such misbehavior reports. fn check_header( client: &C, slot_now: u64, From ee582c45db5ae8fb25093d27caefdc1dbae02f08 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 10:56:13 +0200 Subject: [PATCH 104/191] Add AuthorshipEquivocation trait --- Cargo.lock | 7 +++ core/consensus/babe/src/lib.rs | 5 +- core/consensus/common/primitives/Cargo.toml | 4 ++ core/consensus/common/primitives/src/lib.rs | 48 ++++++++++++++ core/consensus/slots/Cargo.toml | 1 + core/consensus/slots/src/aux_schema.rs | 69 +++++++++++---------- 6 files changed, 98 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdbcedbdf6b30..0b73a4d9de59b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4531,10 +4531,16 @@ dependencies = [ name = "substrate-consensus-common-primitives" version = "2.0.0" dependencies = [ +<<<<<<< HEAD "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Add AuthorshipEquivocation trait "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-client 2.0.0", + "substrate-primitives 2.0.0", ] [[package]] @@ -4573,6 +4579,7 @@ dependencies = [ "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", + "substrate-consensus-common-primitives 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index e46594dd1e876..541792c73accb 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -527,14 +527,15 @@ fn check_header( slot_now, slot_number, &header, + sig, author, ).map_err(|e| e.to_string())? { info!( "Slot author {:?} is equivocating at slot {} with headers {:?} and {:?}", author, slot_number, - equivocation_proof.fst_header().hash(), - equivocation_proof.snd_header().hash(), + equivocation_proof.first_header().hash(), + equivocation_proof.second_header().hash(), ); } diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index de59c3723dd7d..f3b2e7180a3c3 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -10,6 +10,8 @@ codec = { package = "parity-scale-codec", default-features = false, version = "1 client = { package = "substrate-client", path = "../../../client", default-features = false } sr-primitives = { path = "../../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } +serde = { version = "1.0", optional = true, features = ["derive"] } +primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } [features] default = ["std"] @@ -18,4 +20,6 @@ std = [ "client/std", "codec/std", "sr-primitives/std" + "primitives/std", + "serde" ] diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index f6c1800081f90..82ae66d71af34 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -21,6 +21,11 @@ use codec::Codec; use client::decl_runtime_apis; use rstd::vec::Vec; +use parity_codec::{Encode, Decode, Codec}; +#[cfg(feature = "std")] +use serde::Serialize; +use sr_primitives::{traits::{Header, Verify}}; + decl_runtime_apis! { /// Common consensus runtime api. @@ -29,3 +34,46 @@ decl_runtime_apis! { fn authorities() -> Vec; } } + +pub trait AuthorshipEquivocationProof { + type Header: Header; + type Signature: Verify; + type Identity: Codec; + type InclusionProof: Codec; + + /// Create an equivocation proof for AuRa or Babe. + fn new( + identity: Self::Identity, + identity_proof: Option, + slot: u64, + first_header: Self::Header, + second_header: Self::Header, + first_signature: Self::Signature, + second_signature: Self::Signature, + ) -> Self; + + /// Get the slot where the equivocation happened. + fn slot(&self) -> u64; + + /// Check the validity of the equivocation. + /// Includes checking signatures, identity inclusion, same slot and distinct headers. + fn is_valid(&self) -> bool; + + /// Get the identity of the suspect of equivocating. + fn identity(&self) -> &Self::Identity; + + /// Get the proof of inclusion of the identity in the validator set. + fn identity_proof(&self) -> Option<&Self::InclusionProof>; + + /// Get the first header involved in the equivocation. + fn first_header(&self) -> &Self::Header; + + /// Get the second header involved in the equivocation. + fn second_header(&self) -> &Self::Header; + + /// Get signature for the first header involved in the equivocation. + fn first_signature(&self) -> &Self::Signature; + + /// Get signature for the second header involved in the equivocation. + fn second_signature(&self) -> &Self::Signature; +} diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index f74837a62f9de..6801ff622c14d 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -11,6 +11,7 @@ client = { package = "substrate-client", path = "../../client" } primitives = { package = "substrate-primitives", path = "../../primitives" } sr-primitives = { path = "../../sr-primitives" } consensus_common = { package = "substrate-consensus-common", path = "../common" } +consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } inherents = { package = "substrate-inherents", path = "../../inherents" } futures-preview = "=0.3.0-alpha.17" futures-timer = "0.2.1" diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 1d54cb5c2ee6c..e7780fec72c94 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -16,10 +16,12 @@ //! Schema for slots in the aux-db. -use codec::{Encode, Decode}; +use codec::{Encode, Decode, Codec}; use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; -use sr_primitives::traits::Header; +use sr_primitives::traits::{Header, Verify}; +use consensus_common_primitives::AuthorshipEquivocationProof; +use std::ops::Deref; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; @@ -52,37 +54,29 @@ pub struct EquivocationProof { snd_header: H, } -impl EquivocationProof { - /// Get the slot number where the equivocation happened. - pub fn slot(&self) -> u64 { - self.slot - } - - /// Get the first header involved in the equivocation. - pub fn fst_header(&self) -> &H { - &self.fst_header - } - - /// Get the second header involved in the equivocation. - pub fn snd_header(&self) -> &H { - &self.snd_header - } -} - /// Checks if the header is an equivocation and returns the proof in that case. /// /// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY. -pub fn check_equivocation( +pub fn check_equivocation( backend: &C, slot_now: u64, slot: u64, header: &H, - signer: &P, -) -> ClientResult>> + signature: V, + signer: &V::Signer, +) -> ClientResult> where H: Header, C: AuxStore, P: Clone + Encode + Decode + PartialEq, + V: Verify + Codec + Clone, + ::Signer: Clone + Codec + PartialEq, + E: AuthorshipEquivocationProof< + Header=H, + Signature=V, + Identity=::Signer, + InclusionProof=P + >, { // We don't check equivocations for old headers out of our capacity. if slot_now - slot > MAX_SLOT_CAPACITY { @@ -90,29 +84,36 @@ pub fn check_equivocation( } // Key for this slot. - let mut curr_slot_key = SLOT_HEADER_MAP_KEY.to_vec(); - slot.using_encoded(|s| curr_slot_key.extend(s)); + let mut current_slot_key = SLOT_HEADER_MAP_KEY.to_vec(); + slot.using_encoded(|s| current_slot_key.extend(s)); // Get headers of this slot. - let mut headers_with_sig = load_decode::<_, Vec<(H, P)>>(backend, &curr_slot_key[..])? - .unwrap_or_else(Vec::new); + let mut headers_with_signature = load_decode::<_, Vec<(H, V, V::Signer)>>( + backend.deref(), + ¤t_slot_key[..], + )? + .unwrap_or_else(Vec::new); // Get first slot saved. let slot_header_start = SLOT_HEADER_START.to_vec(); let first_saved_slot = load_decode::<_, u64>(backend, &slot_header_start[..])? .unwrap_or(slot); - for (prev_header, prev_signer) in headers_with_sig.iter() { + for (prev_header, prev_signature, prev_signer) in headers_with_signature.iter() { // A proof of equivocation consists of two headers: // 1) signed by the same voter, if prev_signer == signer { // 2) with different hash if header.hash() != prev_header.hash() { - return Ok(Some(EquivocationProof { - slot, // 3) and mentioning the same slot. - fst_header: prev_header.clone(), - snd_header: header.clone(), - })); + return Ok(Some(AuthorshipEquivocationProof::new( + signer.clone(), + None, + slot, + prev_header.clone(), + header.clone(), + prev_signature.clone(), + signature.clone(), + ))); } else { // We don't need to continue in case of duplicated header, // since it's already saved and a possible equivocation @@ -136,11 +137,11 @@ pub fn check_equivocation( } } - headers_with_sig.push((header.clone(), signer.clone())); + headers_with_signature.push((header.clone(), signature.clone(), signer.clone())); backend.insert_aux( &[ - (&curr_slot_key[..], headers_with_sig.encode().as_slice()), + (¤t_slot_key[..], headers_with_signature.encode().as_slice()), (&slot_header_start[..], new_first_saved_slot.encode().as_slice()), ], &keys_to_delete.iter().map(|k| &k[..]).collect::>()[..], From d9a869f591135d91ad7d56b284e276b005aa220b Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 11:22:03 +0200 Subject: [PATCH 105/191] Add BabeEquivocation struct --- Cargo.lock | 3 + core/consensus/babe/Cargo.toml | 5 +- core/consensus/babe/primitives/Cargo.toml | 2 + core/consensus/babe/primitives/src/lib.rs | 116 +++++++++++++++++++++- core/consensus/babe/src/lib.rs | 8 +- srml/session/src/historical.rs | 2 +- 6 files changed, 130 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0b73a4d9de59b..8c4059e025f66 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4475,11 +4475,13 @@ dependencies = [ "sr-primitives 2.0.0", "sr-version 2.0.0", "srml-babe 2.0.0", + "srml-session 2.0.0", "srml-support 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common 2.0.0", + "substrate-consensus-common-primitives 2.0.0", "substrate-consensus-slots 2.0.0", "substrate-consensus-uncles 2.0.0", "substrate-executor 2.0.0", @@ -4505,6 +4507,7 @@ dependencies = [ "sr-std 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", + "substrate-consensus-common-primitives 2.0.0", "substrate-consensus-slots 2.0.0", ] diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 9490887ba34bc..9d0d557dc8fb1 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -20,9 +20,12 @@ inherents = { package = "substrate-inherents", path = "../../inherents" } substrate-telemetry = { path = "../../telemetry" } keystore = { package = "substrate-keystore", path = "../../keystore" } srml-babe = { path = "../../../srml/babe" } +srml-session = { path = "../../../srml/session" } + client = { package = "substrate-client", path = "../../client" } -consensus-common = { package = "substrate-consensus-common", path = "../common" } uncles = { package = "substrate-consensus-uncles", path = "../uncles" } +consensus_common = { package = "substrate-consensus-common", path = "../common" } +consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } slots = { package = "substrate-consensus-slots", path = "../slots" } sr-primitives = { path = "../../sr-primitives" } fork-tree = { path = "../../utils/fork-tree" } diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 5f7fbe4fd8129..3133e914daf7b 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -13,6 +13,7 @@ app-crypto = { package = "substrate-application-crypto", path = "../../../applic slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } +consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../../common/primitives", default-features = false } [features] default = ["std"] @@ -24,4 +25,5 @@ std = [ "schnorrkel", "slots", "app-crypto/std", + "consensus_common_primitives/std", ] diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index f4da908080c8b..b79a5137bd7da 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -21,10 +21,12 @@ mod digest; -use codec::{Encode, Decode}; +use codec::{Encode, Decode, Codec}; use rstd::vec::Vec; -use sr_primitives::ConsensusEngineId; +use sr_primitives::{ConsensusEngineId, traits::{Verify, Header}}; +use primitives::sr25519; use substrate_client::decl_runtime_apis; +use consensus_common_primitives::AuthorshipEquivocationProof; #[cfg(feature = "std")] pub use digest::{BabePreDigest, CompatibleDigestItem}; @@ -140,6 +142,116 @@ impl slots::SlotData for BabeConfiguration { const SLOT_KEY: &'static [u8] = b"babe_bootstrap_data"; } +/// Represents an Babe equivocation proof. +#[derive(Debug, Clone, Encode, Decode, PartialEq)] +pub struct BabeEquivocationProof { + identity: I, + identity_proof: Option

, + slot: u64, + first_header: H, + second_header: H, + first_signature: S, + second_signature: S, +} + +impl AuthorshipEquivocationProof for BabeEquivocationProof +where + H: Header, + S: Verify + Codec, + I: Codec, + P: Codec, +{ + type Header = H; + type Signature = S; + type Identity = I; + type InclusionProof = P; + + /// Create a new Babe equivocation proof. + fn new( + identity: I, + identity_proof: Option

, + slot: u64, + first_header: H, + second_header: H, + first_signature: S, + second_signature: S, + ) -> Self { + BabeEquivocationProof { + identity, + identity_proof, + slot, + first_header, + second_header, + first_signature, + second_signature, + } + } + + /// Get the slot where the equivocation happened. + fn slot(&self) -> u64 { + self.slot + } + + /// Check the validity of the equivocation proof. + fn is_valid(&self) -> bool { + // let first_header = self.first_header(); + // let second_header = self.second_header(); + + // if first_header == second_header { + // return false + // } + + // let maybe_first_slot = get_slot::(first_header); + // let maybe_second_slot = get_slot::(second_header); + + // if maybe_first_slot.is_ok() && maybe_first_slot == maybe_second_slot { + // // TODO: Check that author matches slot author (improve HistoricalSession). + // let author = self.identity(); + + // if !self.first_signature().verify(first_header.hash().as_ref(), author) { + // return false + // } + + // if !self.second_signature().verify(second_header.hash().as_ref(), author) { + // return false + // } + + // return true; + // } + + false + } + + /// Get the identity of the suspect of equivocating. + fn identity(&self) -> &I { + &self.identity + } + + /// Get the identity proof. + fn identity_proof(&self) -> Option<&P> { + self.identity_proof.as_ref() + } + + /// Get the first header involved in the equivocation. + fn first_header(&self) -> &H { + &self.first_header + } + + /// Get the second header involved in the equivocation. + fn second_header(&self) -> &H { + &self.second_header + } + + fn first_signature(&self) -> &S { + &self.first_signature + } + + fn second_signature(&self) -> &S { + &self.second_signature + } +} + + decl_runtime_apis! { /// API necessary for block authorship with BABE. pub trait BabeApi { diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 541792c73accb..a2f4ed8abb18f 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -76,13 +76,15 @@ use futures::{prelude::*, future}; use futures01::Stream as _; use futures_timer::Delay; use log::{error, warn, debug, info, trace}; +use srml_session::historical::Proof; +use consensus_common_primitives::AuthorshipEquivocationProof; use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, SignedDuration}; mod aux_schema; #[cfg(test)] mod tests; -pub use babe_primitives::{AuthorityId, AuthorityPair, AuthoritySignature}; +pub use babe_primitives::{AuthorityId, AuthorityPair, AuthoritySignature, BabeEquivocationProof}; /// A slot duration. Create with `get_or_compute`. // FIXME: Once Rust has higher-kinded types, the duplication between this @@ -522,7 +524,9 @@ fn check_header( threshold {} exceeded", author, threshold)); } - if let Some(equivocation_proof) = check_equivocation( + if let Some(equivocation_proof) = check_equivocation::< + _, _, BabeEquivocationProof, _, _ + >( client, slot_now, slot_number, diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index 7e4686e92327f..f3a8a549a610b 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -271,7 +271,7 @@ impl ProvingTrie { } /// Proof of ownership of a specific key. -#[derive(Encode, Decode, Clone)] +#[derive(Encode, Decode, Clone, PartialEq)] pub struct Proof { session: SessionIndex, trie_nodes: Vec>, From 5bcedda4e1d1ac8c0ed67d5f214d71a22b5bdffb Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 11:48:02 +0200 Subject: [PATCH 106/191] Add report_equivocation to Babe --- Cargo.lock | 1 + core/consensus/babe/primitives/src/lib.rs | 3 +++ srml/babe/Cargo.toml | 1 + srml/babe/src/lib.rs | 31 ++++++++++++++++++++--- srml/session/src/historical.rs | 5 +++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8c4059e025f66..a98043aaf5084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3762,6 +3762,7 @@ dependencies = [ "srml-system 2.0.0", "srml-timestamp 2.0.0", "substrate-consensus-babe-primitives 2.0.0", + "substrate-consensus-common-primitives 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", ] diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index b79a5137bd7da..857670b3573c4 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -49,6 +49,9 @@ pub type AuthoritySignature = app::Signature; /// the main Babe module. If that ever changes, then this must, too. pub type AuthorityId = app::Public; +/// A Babe authority signature. +pub type AuthoritySignature = sr25519::Signature; + /// The `ConsensusEngineId` of BABE. pub const BABE_ENGINE_ID: ConsensusEngineId = *b"BABE"; diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index 93b7880be0de3..253068c609073 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -17,6 +17,7 @@ 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 } session = { package = "srml-session", path = "../session", default-features = false } +consensus-common-primitives = { package = "substrate-consensus-common-primitives", path = "../../core/consensus/common/primitives", default-features = false } babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 8ae370849c7c7..8c1b593cb9f34 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -25,9 +25,12 @@ pub use timestamp; use rstd::{result, prelude::*}; -use srml_support::{decl_storage, decl_module, StorageValue, StorageMap, traits::FindAuthor, traits::Get}; +use srml_support::{ + decl_storage, decl_module, StorageValue, StorageMap, + traits::{FindAuthor, Get, KeyOwnerProofSystem} +}; use timestamp::{OnTimestampSet}; -use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill}; +use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId}; use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; use sr_staking_primitives::{ SessionIndex, @@ -39,12 +42,17 @@ use codec::{Encode, Decode}; use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; -use babe_primitives::{BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest}; -pub use babe_primitives::{AuthorityId, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; +use session::historical::Proof; +use system::ensure_signed; +use consensus_common_primitives::AuthorshipEquivocationProof; +use babe_primitives::{BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, BabeEquivocationProof}; +pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; /// The BABE inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot"; +/// The type of the BABE equivocation. +pub type BabeEquivocation

= BabeEquivocationProof; /// The type of the BABE inherent. pub type InherentType = u64; /// Auxiliary trait to extract BABE inherent data. @@ -117,6 +125,7 @@ impl ProvideInherentData for InherentDataProvider { pub trait Trait: timestamp::Trait { type EpochDuration: Get; type ExpectedBlockTime: Get; + type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; } /// The length of the BABE randomness @@ -208,6 +217,20 @@ decl_module! { return; } } + + fn report_equivocation(origin, equivocation: BabeEquivocation) { + let _who = ensure_signed(origin)?; + if let Some(identity) = equivocation.identity_proof() { + let _to_punish = ::KeyOwnerSystem::check_proof( + (key_types::SR25519, equivocation.identity().encode()), + identity.clone(), + ); + + if equivocation.is_valid() { + // TODO: Slash. + } + } + } } } diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index f3a8a549a610b..0c2c66a18abc9 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -17,7 +17,7 @@ //! An opt-in utility for tracking historical sessions in SRML-session. //! //! This is generally useful when implementing blockchains that require accountable -//! safety where validators from some amount f prior sessions must remain slashable. +//! safety where validators from some amount of prior sessions must remain slashable. //! //! Rather than store the full session data for any given session, we instead commit //! to the roots of merkle tries containing the session data. @@ -27,6 +27,8 @@ use rstd::prelude::*; use codec::{Encode, Decode}; +#[cfg(feature = "std")] +use serde::Serialize; use sr_primitives::KeyTypeId; use sr_primitives::traits::{Convert, OpaqueKeys, Hash as HashT}; use srml_support::{ @@ -271,6 +273,7 @@ impl ProvingTrie { } /// Proof of ownership of a specific key. +#[cfg_attr(feature = "std", derive(Serialize, Debug))] #[derive(Encode, Decode, Clone, PartialEq)] pub struct Proof { session: SessionIndex, From 0d3407657d6ff1318878d8593813c697c562b3ea Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 11:51:54 +0200 Subject: [PATCH 107/191] Add historical to babe --- node/runtime/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 5c1ba95598bd5..f7e5b1041d8bd 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -49,6 +49,7 @@ use primitives::OpaqueMetadata; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use im_online::{AuthorityId as ImOnlineId}; use finality_tracker::{DEFAULT_REPORT_LATENCY, DEFAULT_WINDOW_SIZE}; +use session::historical::{self, Proof}; #[cfg(any(feature = "std", test))] pub use sr_primitives::BuildStorage; @@ -136,6 +137,7 @@ parameter_types! { impl babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; + type KeyOwnerSystem = Historical; } impl indices::Trait for Runtime { @@ -432,6 +434,7 @@ construct_runtime!( Authorship: authorship::{Module, Call, Storage, Inherent}, Indices: indices, Balances: balances, + Historical: historical::{Module}, Staking: staking::{default, OfflineWorker}, Session: session::{Module, Call, Storage, Event, Config}, Democracy: democracy::{Module, Call, Storage, Config, Event}, From dd3f53398c277314a7e288c0d2acfcbc1e1d61ff Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 12:43:11 +0200 Subject: [PATCH 108/191] Move find_pre_digest to primitives --- core/consensus/babe/primitives/src/lib.rs | 46 +++++++-------------- core/consensus/babe/src/lib.rs | 17 -------- core/consensus/common/primitives/src/lib.rs | 6 +-- core/sr-primitives/src/traits.rs | 2 + srml/babe/src/lib.rs | 37 +++++++++++++++-- 5 files changed, 53 insertions(+), 55 deletions(-) diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 857670b3573c4..cfffb5754ca38 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -145,6 +145,22 @@ impl slots::SlotData for BabeConfiguration { const SLOT_KEY: &'static [u8] = b"babe_bootstrap_data"; } +/// Extract the BABE pre digest from the given header. Pre-runtime digests are +/// mandatory, the function will return `Err` if none is found. +pub fn find_pre_digest(header: &H) -> Result + where DigestItemForheader: CompatibleDigestItem, +{ + let mut pre_digest: Option<_> = None; + for log in header.digest().logs() { + match (log.as_babe_pre_digest(), pre_digest.is_some()) { + (Some(_), true) => Err("Multiple BABE pre-runtime digests, rejecting!")?, + (None, _) => {}, + (s, false) => pre_digest = s, + } + } + pre_digest.ok_or_else(|| "No BABE pre-runtime digest found") +} + /// Represents an Babe equivocation proof. #[derive(Debug, Clone, Encode, Decode, PartialEq)] pub struct BabeEquivocationProof { @@ -195,36 +211,6 @@ where self.slot } - /// Check the validity of the equivocation proof. - fn is_valid(&self) -> bool { - // let first_header = self.first_header(); - // let second_header = self.second_header(); - - // if first_header == second_header { - // return false - // } - - // let maybe_first_slot = get_slot::(first_header); - // let maybe_second_slot = get_slot::(second_header); - - // if maybe_first_slot.is_ok() && maybe_first_slot == maybe_second_slot { - // // TODO: Check that author matches slot author (improve HistoricalSession). - // let author = self.identity(); - - // if !self.first_signature().verify(first_header.hash().as_ref(), author) { - // return false - // } - - // if !self.second_signature().verify(second_header.hash().as_ref(), author) { - // return false - // } - - // return true; - // } - - false - } - /// Get the identity of the suspect of equivocating. fn identity(&self) -> &I { &self.identity diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index a2f4ed8abb18f..00dd0620ed1b9 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -422,23 +422,6 @@ macro_rules! babe_err { }; } -/// Extract the BABE pre digest from the given header. Pre-runtime digests are -/// mandatory, the function will return `Err` if none is found. -fn find_pre_digest(header: &B::Header) -> Result - where DigestItemFor: CompatibleDigestItem, -{ - let mut pre_digest: Option<_> = None; - for log in header.digest().logs() { - trace!(target: "babe", "Checking log {:?}, looking for pre runtime digest", log); - match (log.as_babe_pre_digest(), pre_digest.is_some()) { - (Some(_), true) => Err(babe_err!("Multiple BABE pre-runtime digests, rejecting!"))?, - (None, _) => trace!(target: "babe", "Ignoring digest not meant for us"), - (s, false) => pre_digest = s, - } - } - pre_digest.ok_or_else(|| babe_err!("No BABE pre-runtime digest found")) -} - /// Extract the BABE epoch change digest from the given header, if it exists. fn find_next_epoch_digest(header: &B::Header) -> Result, String> where DigestItemFor: CompatibleDigestItem, diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 82ae66d71af34..342de9755377c 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -21,7 +21,7 @@ use codec::Codec; use client::decl_runtime_apis; use rstd::vec::Vec; -use parity_codec::{Encode, Decode, Codec}; +use parity_codec::Codec; #[cfg(feature = "std")] use serde::Serialize; use sr_primitives::{traits::{Header, Verify}}; @@ -55,10 +55,6 @@ pub trait AuthorshipEquivocationProof { /// Get the slot where the equivocation happened. fn slot(&self) -> u64; - /// Check the validity of the equivocation. - /// Includes checking signatures, identity inclusion, same slot and distinct headers. - fn is_valid(&self) -> bool; - /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index 5fc0cb5c5761b..ec28c097ced3c 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -760,6 +760,8 @@ pub type NumberFor = <::Header as Header>::Number; pub type DigestFor = Digest<<::Header as Header>::Hash>; /// Extract the digest item type for a block. pub type DigestItemFor = DigestItem<<::Header as Header>::Hash>; +/// Extract the digest item type for a header. +pub type DigestItemForHeader = DigestItem<::Hash>; /// A "checkable" piece of information, used by the standard Substrate Executive in order to /// check the validity of a piece of extrinsic information, usually by verifying the signature. diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 8c1b593cb9f34..62f32057abafc 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -45,7 +45,10 @@ use inherents::{InherentDataProviders, ProvideInherentData}; use session::historical::Proof; use system::ensure_signed; use consensus_common_primitives::AuthorshipEquivocationProof; -use babe_primitives::{BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, BabeEquivocationProof}; +use babe_primitives::{ + BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, + BabeEquivocationProof, find_pre_digest +}; pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; /// The BABE inherent identifier. @@ -181,6 +184,32 @@ decl_storage! { } } +fn equivocation_is_valid(equivocation: BabeEquivocation) -> bool { + let first_header = equivocation.first_header(); + let second_header = equivocation.second_header(); + + if first_header == second_header { + return false + } + + let maybe_first_slot = get_slot::(first_header); + let maybe_second_slot = get_slot::(second_header); + + if maybe_first_slot.is_ok() && maybe_first_slot == maybe_second_slot { + let author = self.identity(); + + if !self.first_signature().verify(first_header.hash().as_ref(), author) { + return false + } + if !self.second_signature().verify(second_header.hash().as_ref(), author) { + return false + } + return true; + } + + false +} + decl_module! { /// The BABE SRML module pub struct Module for enum Call where origin: T::Origin { @@ -220,14 +249,16 @@ decl_module! { fn report_equivocation(origin, equivocation: BabeEquivocation) { let _who = ensure_signed(origin)?; + if let Some(identity) = equivocation.identity_proof() { + let _to_punish = ::KeyOwnerSystem::check_proof( (key_types::SR25519, equivocation.identity().encode()), identity.clone(), ); - if equivocation.is_valid() { - // TODO: Slash. + if equivocation_is_valid(equivocation) { + // TODO: Slash `to_punish` and reward `who`. } } } From cdc43f27a234eb31697191c355a42cbac34d4a2e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 16:08:07 +0200 Subject: [PATCH 109/191] Use get_slot --- core/consensus/babe/primitives/src/digest.rs | 51 ++++++++++++++------ core/consensus/babe/primitives/src/lib.rs | 20 +------- core/consensus/babe/src/lib.rs | 4 +- srml/babe/src/lib.rs | 28 +++++++---- 4 files changed, 58 insertions(+), 45 deletions(-) diff --git a/core/consensus/babe/primitives/src/digest.rs b/core/consensus/babe/primitives/src/digest.rs index 3b6e3221bd8a8..73cb8b8add41f 100644 --- a/core/consensus/babe/primitives/src/digest.rs +++ b/core/consensus/babe/primitives/src/digest.rs @@ -16,15 +16,13 @@ //! Private implementation details of BABE digests. -#[cfg(feature = "std")] -use super::AuthoritySignature; -#[cfg(feature = "std")] use super::{BABE_ENGINE_ID, Epoch}; #[cfg(not(feature = "std"))] use super::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}; use super::SlotNumber; -#[cfg(feature = "std")] use sr_primitives::{DigestItem, generic::OpaqueDigestItemId}; +use sr_primitives::traits::{Header, DigestItemForHeader, Verify}; +use parity_codec::{Decode, Encode, Codec}; #[cfg(feature = "std")] use std::fmt::Debug; use codec::{Decode, Encode}; @@ -50,6 +48,30 @@ pub struct BabePreDigest { pub slot_number: SlotNumber, } +/// Get the slot. +pub fn get_slot(header: &H) -> Result + where DigestItemForHeader: CompatibleDigestItem, +{ + find_pre_digest::(header) + .map(|raw_pre_digest| raw_pre_digest.slot_number) +} + +/// Extract the BABE pre digest from the given header. Pre-runtime digests are +/// mandatory, the function will return `Err` if none is found. +pub fn find_pre_digest(header: &H) -> Result + where DigestItemForHeader: CompatibleDigestItem, +{ + let mut pre_digest: Option<_> = None; + for log in header.digest().logs() { + match (log.as_babe_pre_digest(), pre_digest.is_some()) { + (Some(_), true) => Err("Multiple BABE pre-runtime digests, rejecting!")?, + (None, _) => {}, + (s, false) => pre_digest = s, + } + } + pre_digest.ok_or_else(|| "No BABE pre-runtime digest found") +} + /// The prefix used by BABE for its VRF keys. pub const BABE_VRF_PREFIX: &'static [u8] = b"substrate-babe-vrf"; @@ -102,41 +124,40 @@ impl Decode for BabePreDigest { } /// A digest item which is usable with BABE consensus. -#[cfg(feature = "std")] +// #[cfg(feature = "std")] pub trait CompatibleDigestItem: Sized { /// Construct a digest item which contains a BABE pre-digest. - fn babe_pre_digest(seal: BabePreDigest) -> Self; + fn babe_pre_digest(seal: D) -> Self; /// If this item is an BABE pre-digest, return it. - fn as_babe_pre_digest(&self) -> Option; + fn as_babe_pre_digest(&self) -> Option; /// Construct a digest item which contains a BABE seal. - fn babe_seal(signature: AuthoritySignature) -> Self; + fn babe_seal(signature: S) -> Self; /// If this item is a BABE signature, return the signature. - fn as_babe_seal(&self) -> Option; + fn as_babe_seal(&self) -> Option; /// If this item is a BABE epoch, return it. fn as_babe_epoch(&self) -> Option; } -#[cfg(feature = "std")] impl CompatibleDigestItem for DigestItem where - Hash: Debug + Send + Sync + Eq + Clone + Codec + 'static + Hash: Send + Sync + Eq + Clone + Codec + 'static { - fn babe_pre_digest(digest: BabePreDigest) -> Self { + fn babe_pre_digest(digest: D) -> Self { DigestItem::PreRuntime(BABE_ENGINE_ID, digest.encode()) } - fn as_babe_pre_digest(&self) -> Option { + fn as_babe_pre_digest(&self) -> Option { self.try_to(OpaqueDigestItemId::PreRuntime(&BABE_ENGINE_ID)) } - fn babe_seal(signature: AuthoritySignature) -> Self { + fn babe_seal(signature: S) -> Self { DigestItem::Seal(BABE_ENGINE_ID, signature.encode()) } - fn as_babe_seal(&self) -> Option { + fn as_babe_seal(&self) -> Option { self.try_to(OpaqueDigestItemId::Seal(&BABE_ENGINE_ID)) } diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index cfffb5754ca38..621f8de927efd 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -29,8 +29,8 @@ use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; #[cfg(feature = "std")] -pub use digest::{BabePreDigest, CompatibleDigestItem}; -pub use digest::{BABE_VRF_PREFIX, RawBabePreDigest}; +pub use digest::BabePreDigest; +pub use digest::{BABE_VRF_PREFIX, RawBabePreDigest, get_slot, CompatibleDigestItem, find_pre_digest}; mod app { use app_crypto::{app_crypto, key_types::BABE, sr25519}; @@ -145,22 +145,6 @@ impl slots::SlotData for BabeConfiguration { const SLOT_KEY: &'static [u8] = b"babe_bootstrap_data"; } -/// Extract the BABE pre digest from the given header. Pre-runtime digests are -/// mandatory, the function will return `Err` if none is found. -pub fn find_pre_digest(header: &H) -> Result - where DigestItemForheader: CompatibleDigestItem, -{ - let mut pre_digest: Option<_> = None; - for log in header.digest().logs() { - match (log.as_babe_pre_digest(), pre_digest.is_some()) { - (Some(_), true) => Err("Multiple BABE pre-runtime digests, rejecting!")?, - (None, _) => {}, - (s, false) => pre_digest = s, - } - } - pre_digest.ok_or_else(|| "No BABE pre-runtime digest found") -} - /// Represents an Babe equivocation proof. #[derive(Debug, Clone, Encode, Decode, PartialEq)] pub struct BabeEquivocationProof { diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 00dd0620ed1b9..f750bda0c329b 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -474,7 +474,7 @@ fn check_header( babe_err!("Header {:?} has a bad seal", hash) })?; - let pre_digest = find_pre_digest::(&header)?; + let pre_digest = find_pre_digest::(&header)?; let BabePreDigest { slot_number, authority_index, ref vrf_proof, ref vrf_output } = pre_digest; @@ -980,7 +980,7 @@ impl BlockImport for BabeBlockImport(&block.header) + let pre_digest = find_pre_digest::(&block.header) .expect("valid babe headers must contain a predigest; \ header has been already verified; qed"); let BabePreDigest { slot_number, .. } = pre_digest; diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 62f32057abafc..78d30cd32cf3b 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -31,7 +31,9 @@ use srml_support::{ }; use timestamp::{OnTimestampSet}; use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId}; -use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; +use sr_primitives::traits::{ + IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Verify, Header +}; use sr_staking_primitives::{ SessionIndex, offence::{Offence, TimeSlot, Kind}, @@ -46,8 +48,8 @@ use session::historical::Proof; use system::ensure_signed; use consensus_common_primitives::AuthorshipEquivocationProof; use babe_primitives::{ - BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, - BabeEquivocationProof, find_pre_digest + BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, + BabeEquivocationProof, get_slot }; pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; @@ -192,16 +194,22 @@ fn equivocation_is_valid(equivocation: BabeEquivocation) -> return false } - let maybe_first_slot = get_slot::(first_header); - let maybe_second_slot = get_slot::(second_header); + let maybe_first_slot = get_slot::(first_header); + let maybe_second_slot = get_slot::(second_header); + + if maybe_first_slot.is_err() || maybe_second_slot.is_err() { + return false + } + let first_slot = maybe_first_slot.expect("checked before; qed"); + let second_slot = maybe_second_slot.expect("checked before; qed"); - if maybe_first_slot.is_ok() && maybe_first_slot == maybe_second_slot { - let author = self.identity(); + if equivocation.slot() == first_slot && first_slot == second_slot { + let author = equivocation.identity(); - if !self.first_signature().verify(first_header.hash().as_ref(), author) { + if !equivocation.first_signature().verify(first_header.hash().as_ref(), author) { return false } - if !self.second_signature().verify(second_header.hash().as_ref(), author) { + if !equivocation.second_signature().verify(second_header.hash().as_ref(), author) { return false } return true; @@ -257,7 +265,7 @@ decl_module! { identity.clone(), ); - if equivocation_is_valid(equivocation) { + if equivocation_is_valid::(equivocation) { // TODO: Slash `to_punish` and reward `who`. } } From 106d2f047a39061c2f410e6c9b2471be82c369a8 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 16:41:01 +0200 Subject: [PATCH 110/191] Add tx pool to environment --- core/finality-grandpa/src/environment.rs | 13 +++++----- core/finality-grandpa/src/lib.rs | 31 +++++++++++++++++------- node/cli/src/service.rs | 1 + 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 5761093c5eb67..38cfda023855c 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -367,7 +367,7 @@ impl SharedVoterSetState { } /// The environment we run GRANDPA in. -pub(crate) struct Environment, RA, SC> { +pub(crate) struct Environment, RA, SC, T> { pub(crate) inner: Arc>, pub(crate) select_chain: SC, pub(crate) voters: Arc>, @@ -377,9 +377,10 @@ pub(crate) struct Environment, RA, SC> { pub(crate) network: crate::communication::NetworkBridge, pub(crate) set_id: u64, pub(crate) voter_set_state: SharedVoterSetState, + pub(crate) transaction_pool: Arc, } -impl, RA, SC> Environment { +impl, RA, SC, T> Environment { /// Updates the voter set state using the given closure. The write lock is /// held during evaluation of the closure and the environment's voter set /// state is set to its result if successful. @@ -395,9 +396,9 @@ impl, RA, SC> Environment, B, E, N, RA, SC> +impl, B, E, N, RA, SC, T> grandpa::Chain> -for Environment +for Environment where Block: 'static, B: Backend + 'static, @@ -523,9 +524,9 @@ pub(crate) fn ancestry, E, RA>( Ok(tree_route.retracted().iter().skip(1).map(|e| e.hash).collect()) } -impl, N, RA, SC> +impl, N, RA, SC, T> voter::Environment> -for Environment +for Environment where Block: 'static, B: Backend + 'static, diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 5c6835e3bb4df..cb1b2d2c147f3 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -58,6 +58,7 @@ use futures::sync::mpsc; use client::{ BlockchainEvents, CallExecutor, Client, backend::Backend, error::Error as ClientError, }; +use client::runtime_api::ConstructRuntimeApi; use client::blockchain::HeaderBackend; use codec::Encode; use sr_primitives::generic::BlockId; @@ -472,7 +473,7 @@ fn register_finality_tracker_inherent_data_provider, N, RA, SC, X> { +pub struct GrandpaParams, N, RA, SC, X, T> { /// Configuration for the GRANDPA service. pub config: Config, /// A link to the block import worker. @@ -485,23 +486,28 @@ pub struct GrandpaParams, N, RA, SC, X> { pub on_exit: X, /// If supplied, can be used to hook on telemetry connection established events. pub telemetry_on_connect: Option, + /// The transaction pool. + pub transaction_pool: Arc, } /// Run a GRANDPA voter as a task. Provide configuration and a link to a /// block import worker that has already been instantiated with `block_import`. -pub fn run_grandpa_voter, N, RA, SC, X>( - grandpa_params: GrandpaParams, +pub fn run_grandpa_voter, N, RA, SC, X, T>( + grandpa_params: GrandpaParams, ) -> client::error::Result + Send + 'static> where Block::Hash: Ord, B: Backend + 'static, - E: CallExecutor + Send + Sync + 'static, + E: CallExecutor + Send + Sync + Clone + 'static, N: Network + Send + Sync + 'static, N::In: Send + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, DigestFor: Encode, - RA: Send + Sync + 'static, X: Future + Clone + Send + 'static, + T: Send + Sync + 'static, + Client: HeaderBackend + ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: GrandpaApi, + RA: Send + Sync + 'static + ConstructRuntimeApi>, { let GrandpaParams { config, @@ -510,6 +516,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( inherent_data_providers, on_exit, telemetry_on_connect, + transaction_pool, } = grandpa_params; use futures::future::{self, Loop as FutureLoop}; @@ -566,6 +573,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( authority_set: authority_set.clone(), consensus_changes: consensus_changes.clone(), voter_set_state: set_state.clone(), + transaction_pool: transaction_pool.clone(), }); let initial_state = (initial_environment, voter_commands_rx.into_future()); @@ -614,6 +622,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( }); let client = client.clone(); + let transaction_pool = transaction_pool.clone(); let config = config.clone(); let network = network.clone(); let select_chain = select_chain.clone(); @@ -656,6 +665,7 @@ pub fn run_grandpa_voter, N, RA, SC, X>( authority_set, consensus_changes, voter_set_state: set_state, + transaction_pool: transaction_pool.clone(), }); Ok(FutureLoop::Continue((env, voter_commands_rx))) @@ -723,19 +733,22 @@ pub fn run_grandpa_voter, N, RA, SC, X>( } #[deprecated(since = "1.1", note = "Please switch to run_grandpa_voter.")] -pub fn run_grandpa, N, RA, SC, X>( - grandpa_params: GrandpaParams, +pub fn run_grandpa, N, RA, SC, X, T>( + grandpa_params: GrandpaParams, ) -> ::client::error::Result + Send + 'static> where Block::Hash: Ord, B: Backend + 'static, - E: CallExecutor + Send + Sync + 'static, + E: CallExecutor + Send + Sync + Clone + 'static, N: Network + Send + Sync + 'static, N::In: Send + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, DigestFor: Encode, - RA: Send + Sync + 'static, X: Future + Clone + Send + 'static, + T: Sync + Send + 'static, + Client: HeaderBackend + ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: GrandpaApi, + RA: Send + Sync + 'static + ConstructRuntimeApi>, { run_grandpa_voter(grandpa_params) } diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 90c76eda84cbe..33652a59064cd 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -189,6 +189,7 @@ construct_service_factory! { service.config().custom.inherent_data_providers.clone(), on_exit: service.on_exit(), telemetry_on_connect: Some(telemetry_on_connect), + transaction_pool: service.transaction_pool(), }; // the GRANDPA voter task is considered infallible, i.e. From c62f64c09335a7d5323b0c1c3bb38f4168d6764e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 17:28:31 +0200 Subject: [PATCH 111/191] Create grandpa equivocation --- Cargo.lock | 24 +++++++++ core/finality-grandpa/Cargo.toml | 6 ++- core/finality-grandpa/primitives/Cargo.toml | 2 + core/finality-grandpa/primitives/src/lib.rs | 29 ++++++++++- core/finality-grandpa/src/environment.rs | 57 +++++++++++++++++++-- 5 files changed, 111 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a98043aaf5084..73dc887c46fbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -846,14 +846,22 @@ dependencies = [ [[package]] name = "finality-grandpa" +<<<<<<< HEAD version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +======= +version = "0.8.1" +>>>>>>> Create grandpa equivocation dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Create grandpa equivocation "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4636,7 +4644,11 @@ name = "substrate-finality-grandpa" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "finality-grandpa 0.8.1", +>>>>>>> Create grandpa equivocation "fork-tree 2.0.0", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4669,11 +4681,20 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "2.0.0" dependencies = [ +<<<<<<< HEAD "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "finality-grandpa 0.8.1", + "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Create grandpa equivocation "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", +<<<<<<< HEAD "substrate-application-crypto 2.0.0", +======= + "srml-session 2.0.0", +>>>>>>> Create grandpa equivocation "substrate-client 2.0.0", ] @@ -6225,7 +6246,10 @@ dependencies = [ "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" +<<<<<<< HEAD "checksum finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9681c1f75941ea47584573dd2bc10558b2067d460612945887e00744e43393be" +======= +>>>>>>> Create grandpa equivocation "checksum fixed-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index 22237c5a0b5a0..43b18e5328e12 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -26,10 +26,12 @@ network = { package = "substrate-network", path = "../network" } service = { package = "substrate-service", path = "../service", optional = true } srml-finality-tracker = { path = "../../srml/finality-tracker" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } -grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec"] } +# grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec"] } [dev-dependencies] -grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec", "test-helpers"] } +# grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec", "test-helpers"] } network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } keyring = { package = "substrate-keyring", path = "../keyring" } test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client"} diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index ecbaf2e1ecc70..f56cb25590b01 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -11,6 +11,8 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sr-primitives = { path = "../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false } +session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] default = ["std"] diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index b92444e26295c..56a37c75518c2 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -24,9 +24,11 @@ extern crate alloc; #[cfg(feature = "std")] use serde::Serialize; use codec::{Encode, Decode, Codec}; -use sr_primitives::{ConsensusEngineId, traits::{DigestFor, NumberFor}}; +use sr_primitives::{ConsensusEngineId, traits::{DigestFor, NumberFor, Block as BlockT}}; use client::decl_runtime_apis; use rstd::vec::Vec; +use grandpa::Message; +use session::historical::Proof; mod app { use app_crypto::{app_crypto, key_types::GRANDPA, ed25519}; @@ -52,6 +54,31 @@ pub type AuthorityWeight = u64; /// The index of an authority. pub type AuthorityIndex = u64; +// #[cfg_attr(feature = "std", derive(Debug, Serialize))] +#[derive(Clone, PartialEq, Eq, Encode, Decode)] +pub struct GrandpaEquivocation { + /// The set id. + pub set_id: u64, + /// The round number equivocated in. + pub round_number: u64, + /// The identity of the equivocator. + pub identity: I, + /// The proof of identity inclusion. + pub identity_proof: Option

, + /// The first vote in the equivocation. + pub first: (Message, S), + /// The second vote in the equivocation. + pub second: (Message, S), +} + +pub type GrandpaEquivocationFrom = GrandpaEquivocation< + ::Hash, + NumberFor, + AuthoritySignature, + AuthorityId, + Proof, +>; + /// A scheduled change of authority set. #[cfg_attr(feature = "std", derive(Debug, Serialize))] #[derive(Clone, Eq, PartialEq, Encode, Decode)] diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 38cfda023855c..a51f3226a9226 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -31,7 +31,7 @@ use client::{ }; use grandpa::{ BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState, - voter, voter_set::VoterSet, + voter, voter_set::VoterSet, Message }; use primitives::{Blake2Hasher, H256, Pair}; use sr_primitives::generic::BlockId; @@ -51,7 +51,7 @@ use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; -use fg_primitives::{AuthorityId, AuthoritySignature}; +use fg_primitives::{AuthorityId, AuthoritySignature, GrandpaEquivocationFrom}; type HistoricalVotes = grandpa::HistoricalVotes< ::Hash, @@ -841,7 +841,39 @@ where equivocation: ::grandpa::Equivocation, Self::Signature> ) { warn!(target: "afg", "Detected prevote equivocation in the finality worker: {:?}", equivocation); - // nothing yet; this could craft misbehavior reports of some kind. + + let first_vote = Message::>::Prevote(equivocation.first.0); + let second_vote = Message::>::Prevote(equivocation.second.0); + let first_signature = equivocation.first.1; + let second_signature = equivocation.second.1; + + let grandpa_equivocation = GrandpaEquivocationFrom:: { + round_number: equivocation.round_number, + identity: equivocation.identity, + identity_proof: None, + first: (first_vote, first_signature), + second: (second_vote, second_signature), + set_id: self.set_id, + }; + + let block_id = BlockId::::number(self.inner.info().chain.best_number); + // let maybe_report_call = self.inner.runtime_api() + // .construct_equivocation_report_call(&block_id, grandpa_equivocation); + + // if let Ok(Some(report_call)) = maybe_report_call { + // if let Some(session_key) = self.config.local_key.clone() { + // self.transaction_pool.submit_report_call( + // self.inner.deref(), + // session_key.deref(), + // report_call.as_slice(), + // ); + // info!(target: "afg", "Equivocation report has been submitted"); + // } else { + // error!(target: "afg", "Failed to get local key for equivocation report") + // } + // } else { + // error!(target: "afg", "Failed to construct equivocation report call") + // } } fn precommit_equivocation( @@ -850,7 +882,24 @@ where equivocation: Equivocation, Self::Signature> ) { warn!(target: "afg", "Detected precommit equivocation in the finality worker: {:?}", equivocation); - // nothing yet + + let first_vote = Message::>::Precommit(equivocation.first.0); + let second_vote = Message::>::Precommit(equivocation.second.0); + let first_signature = equivocation.first.1; + let second_signature = equivocation.second.1; + + let grandpa_equivocation = GrandpaEquivocationFrom:: { + round_number: equivocation.round_number, + identity: equivocation.identity, + identity_proof: None, + first: (first_vote, first_signature), + second: (second_vote, second_signature), + set_id: self.set_id, + }; + + let block_id = BlockId::::number(self.inner.info().chain.best_number); + + } } From 98a7d527a06aa2832dd330c193dc903d2a28a623 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 18:17:40 +0200 Subject: [PATCH 112/191] Add report_equivocation to grandpa --- core/finality-grandpa/primitives/Cargo.toml | 2 +- core/finality-grandpa/primitives/src/lib.rs | 24 +++++--- .../finality-grandpa/src/communication/mod.rs | 6 +- node/runtime/src/lib.rs | 15 ++++- srml/grandpa/src/lib.rs | 61 ++++++++++++++++--- srml/session/src/historical.rs | 2 +- 6 files changed, 84 insertions(+), 26 deletions(-) diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index f56cb25590b01..4091b26dd09b3 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sr-primitives = { path = "../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 56a37c75518c2..3245f9def3818 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -54,29 +54,30 @@ pub type AuthorityWeight = u64; /// The index of an authority. pub type AuthorityIndex = u64; -// #[cfg_attr(feature = "std", derive(Debug, Serialize))] +pub fn localized_payload(round: u64, set_id: u64, message: &E) -> Vec { + (message, round, set_id).encode() +} + +#[cfg_attr(feature = "std", derive(Debug))] #[derive(Clone, PartialEq, Eq, Encode, Decode)] -pub struct GrandpaEquivocation { +pub struct GrandpaEquivocation { /// The set id. pub set_id: u64, /// The round number equivocated in. pub round_number: u64, /// The identity of the equivocator. - pub identity: I, + pub identity: AuthorityId, /// The proof of identity inclusion. - pub identity_proof: Option

, + pub identity_proof: Option, /// The first vote in the equivocation. - pub first: (Message, S), + pub first: (Message, AuthoritySignature), /// The second vote in the equivocation. - pub second: (Message, S), + pub second: (Message, AuthoritySignature), } pub type GrandpaEquivocationFrom = GrandpaEquivocation< ::Hash, NumberFor, - AuthoritySignature, - AuthorityId, - Proof, >; /// A scheduled change of authority set. @@ -230,5 +231,10 @@ decl_runtime_apis! { /// used to finalize descendants of this block (B+1, B+2, ...). The block B itself /// is finalized by the authorities from block B-1. fn grandpa_authorities() -> Vec<(AuthorityId, AuthorityWeight)>; + + /// Construct a call to report the equivocation. + fn construct_equivocation_report_call( + proof: GrandpaEquivocationFrom + ) -> Option>; } } diff --git a/core/finality-grandpa/src/communication/mod.rs b/core/finality-grandpa/src/communication/mod.rs index 2aa2618535948..3d6e530cf3acb 100644 --- a/core/finality-grandpa/src/communication/mod.rs +++ b/core/finality-grandpa/src/communication/mod.rs @@ -58,7 +58,7 @@ mod periodic; #[cfg(test)] mod tests; -pub use fg_primitives::GRANDPA_ENGINE_ID; +pub use fg_primitives::{GRANDPA_ENGINE_ID, localized_payload}; // cost scalars for reporting peers. mod cost { @@ -612,10 +612,6 @@ impl> Clone for NetworkBridge { } } -fn localized_payload(round: u64, set_id: u64, message: &E) -> Vec { - (message, round, set_id).encode() -} - /// Type-safe wrapper around u64 when indicating that it's a round number. #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Encode, Decode)] pub struct Round(pub u64); diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index f7e5b1041d8bd..990d2494a46f1 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -29,8 +29,9 @@ use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; +use parity_codec::{Encode, Decode, Codec}; use babe::{AuthorityId as BabeId}; -use grandpa::fg_primitives::{self, ScheduledChange}; +use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; use client::{ block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult}, runtime_api as client_api, impl_runtime_apis @@ -55,6 +56,7 @@ use session::historical::{self, Proof}; pub use sr_primitives::BuildStorage; pub use timestamp::Call as TimestampCall; pub use balances::Call as BalancesCall; +pub use grandpa::Call as GrandpaCall; pub use contracts::Gas; pub use sr_primitives::{Permill, Perbill}; pub use support::StorageValue; @@ -548,6 +550,17 @@ impl_runtime_apis! { fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { Grandpa::grandpa_authorities() } + + fn construct_equivocation_report_call( + equivocation: GrandpaEquivocationFrom + ) -> Option> { + // let proof = Historical::prove((key_types::ED25519, equivocation.identity.encode()))?; + // let mut proved_equivocation = equivocation.clone(); + // proved_equivocation.identity_proof = Some(proof); + let grandpa_call = GrandpaCall::report_equivocation(equivocation); + let call = Call::Grandpa(grandpa_call); + Some(call.encode()) + } } impl babe_primitives::BabeApi for Runtime { diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 0698e322d4464..462202e1bd494 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -31,19 +31,18 @@ pub use substrate_finality_grandpa_primitives as fg_primitives; use rstd::prelude::*; -use codec::{self as codec, Encode, Decode, Error}; +use codec::{self as codec, Encode, Decode, Error, Codec}; use srml_support::{ decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue }; use sr_primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, - Perbill, + generic::{DigestItem, OpaqueDigestItemId}, traits::{Zero, Verify}, Perbill }; -use sr_staking_primitives::{ - SessionIndex, - offence::{TimeSlot, Offence, Kind}, +use sr_staking_primitives::{SessionIndex, offence::{TimeSlot, Offence, Kind}}; +use fg_primitives::{ + ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, + localized_payload }; -use fg_primitives::{ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID}; pub use fg_primitives::{AuthorityId, AuthorityWeight}; use system::{ensure_signed, DigestOf}; @@ -154,13 +153,57 @@ decl_storage! { } } +fn equivocation_is_valid( + equivocation: GrandpaEquivocation +) -> bool { + let first_vote = &equivocation.first.0; + let first_signature = &equivocation.first.1; + + let second_vote = &equivocation.second.0; + let second_signature = &equivocation.second.1; + + if first_vote != second_vote { + let first_payload = localized_payload( + equivocation.round_number, + equivocation.set_id, + &first_vote, + ); + + if !first_signature.verify(first_payload.as_slice(), &equivocation.identity) { + return false + } + + let second_payload = localized_payload( + equivocation.round_number, + equivocation.set_id, + &second_vote, + ); + + if !second_signature.verify(second_payload.as_slice(), &equivocation.identity) { + return false + } + + return true + } + + false +} + decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; /// Report some misbehavior. - fn report_misbehavior(origin, _report: Vec) { - ensure_signed(origin)?; + fn report_equivocation( + origin, + equivocation: GrandpaEquivocation + ) { + let _who = ensure_signed(origin)?; + + if equivocation_is_valid(equivocation) { + // slash + } + // FIXME: https://github.com/paritytech/substrate/issues/1112 } diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index 0c2c66a18abc9..c9c3240514162 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -274,7 +274,7 @@ impl ProvingTrie { /// Proof of ownership of a specific key. #[cfg_attr(feature = "std", derive(Serialize, Debug))] -#[derive(Encode, Decode, Clone, PartialEq)] +#[derive(Encode, Decode, Clone, PartialEq, Eq)] pub struct Proof { session: SessionIndex, trie_nodes: Vec>, From 9c6e3230cd42d8386772d91439b9b4c1ef6cd98d Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 19:01:32 +0200 Subject: [PATCH 113/191] Add proof to construct_report --- core/finality-grandpa/primitives/src/lib.rs | 3 ++- node/runtime/src/lib.rs | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 3245f9def3818..0efcea5cac053 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -234,7 +234,8 @@ decl_runtime_apis! { /// Construct a call to report the equivocation. fn construct_equivocation_report_call( - proof: GrandpaEquivocationFrom + equivocation: GrandpaEquivocationFrom, + proof: Proof ) -> Option>; } } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 990d2494a46f1..0c2628b054080 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -552,11 +552,10 @@ impl_runtime_apis! { } fn construct_equivocation_report_call( - equivocation: GrandpaEquivocationFrom + equivocation: GrandpaEquivocationFrom, + proof: Proof, ) -> Option> { - // let proof = Historical::prove((key_types::ED25519, equivocation.identity.encode()))?; - // let mut proved_equivocation = equivocation.clone(); - // proved_equivocation.identity_proof = Some(proof); + // TODO: Check proof. let grandpa_call = GrandpaCall::report_equivocation(equivocation); let call = Call::Grandpa(grandpa_call); Some(call.encode()) From 4a8e88b014fa6a34e1b516f79eac4959d4b72e08 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 22:50:51 +0200 Subject: [PATCH 114/191] add construct report to babe --- Cargo.lock | 5 + core/consensus/babe/primitives/Cargo.toml | 1 + .../babe/primitives/src/equivocation.rs | 102 ++++++++++++++++++ core/consensus/babe/primitives/src/lib.rs | 49 ++++----- core/consensus/babe/src/lib.rs | 3 +- core/consensus/common/primitives/src/lib.rs | 5 - core/consensus/slots/src/aux_schema.rs | 2 - core/finality-grandpa/Cargo.toml | 1 + core/finality-grandpa/primitives/src/lib.rs | 2 +- core/finality-grandpa/src/environment.rs | 5 +- node/runtime/src/lib.rs | 12 +++ srml/babe/src/lib.rs | 18 +--- srml/session/src/historical.rs | 2 +- 13 files changed, 153 insertions(+), 54 deletions(-) create mode 100644 core/consensus/babe/primitives/src/equivocation.rs diff --git a/Cargo.lock b/Cargo.lock index 73dc887c46fbf..db4b8aacfbb34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4514,7 +4514,11 @@ dependencies = [ "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", +<<<<<<< HEAD "substrate-application-crypto 2.0.0", +======= + "srml-session 2.0.0", +>>>>>>> add construct report to babe "substrate-client 2.0.0", "substrate-consensus-common-primitives 2.0.0", "substrate-consensus-slots 2.0.0", @@ -4659,6 +4663,7 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "srml-finality-tracker 2.0.0", + "srml-session 2.0.0", "substrate-client 2.0.0", "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common 2.0.0", diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 3133e914daf7b..d638811f38c2a 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -14,6 +14,7 @@ slots = { package = "substrate-consensus-slots", path = "../../slots", optional schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../../common/primitives", default-features = false } +srml-session = { path = "../../../../srml/session", default-features = false } [features] default = ["std"] diff --git a/core/consensus/babe/primitives/src/equivocation.rs b/core/consensus/babe/primitives/src/equivocation.rs new file mode 100644 index 0000000000000..dfdcb946532c2 --- /dev/null +++ b/core/consensus/babe/primitives/src/equivocation.rs @@ -0,0 +1,102 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Primitives for BABE equivocations. + +use parity_codec::{Encode, Decode, Codec}; +use sr_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header, Verify}}; +use safety_primitives::AuthorshipEquivocationProof; +use srml_session::historical::Proof; +use crate::digest::find_pre_digest; + +/// Represents a Babe equivocation proof. +#[cfg_attr(feature = "std", derive(Serialize, Debug))] +#[derive(Clone, Encode, Decode, PartialEq, Eq)] +pub struct BabeEquivocationProof { + identity: AuthorityId, + slot: u64, + identity_proof: Proof, + first_header: H, + second_header: H, + first_signature: AuthoritySignature, + second_signature: AuthoritySignature, +} + +impl AuthorshipEquivocationProof for BabeEquivocationProof +where + H: Header, +{ + type Header = H; + type Signature = AuthoritySignature; + type Identity = AuthorityId; + type InclusionProof = Proof; + + /// Create a new Babe equivocation proof. + fn new( + identity: AuthorityId, + identity_proof: Proof, + slot: u64, + first_header: H, + second_header: H, + first_signature: AuthoritySignature, + second_signature: AuthoritySignature, + ) -> Self { + BabeEquivocationProof { + identity, + identity_proof, + slot, + first_header, + second_header, + first_signature, + second_signature, + } + } + + /// Return the slot where the equivocation happened. + fn slot(&self) -> u64 { + self.slot + } + + /// Get the identity of the suspect of equivocating. + fn identity(&self) -> &I { + &self.identity + } + + /// Get the identity proof. + fn identity_proof(&self) -> Option<&P> { + self.identity_proof.as_ref() + } + + /// Get the first header involved in the equivocation. + fn first_header(&self) -> &H { + &self.first_header + } + + /// Get the second header involved in the equivocation. + fn second_header(&self) -> &H { + &self.second_header + } + + /// Get the first signature involved in the equivocation. + fn first_signature(&self) -> &S { + &self.first_signature + } + + /// Get the second signature involved in the equivocation. + fn second_signature(&self) -> &S { + &self.second_signature + } +} \ No newline at end of file diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 621f8de927efd..538d87f548998 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -23,10 +23,11 @@ mod digest; use codec::{Encode, Decode, Codec}; use rstd::vec::Vec; -use sr_primitives::{ConsensusEngineId, traits::{Verify, Header}}; +use sr_primitives::{ConsensusEngineId, traits::Header}; use primitives::sr25519; use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; +use srml_session::historical::Proof; #[cfg(feature = "std")] pub use digest::BabePreDigest; @@ -146,42 +147,35 @@ impl slots::SlotData for BabeConfiguration { } /// Represents an Babe equivocation proof. -#[derive(Debug, Clone, Encode, Decode, PartialEq)] -pub struct BabeEquivocationProof { - identity: I, - identity_proof: Option

, +#[derive(Clone, Encode, Decode, PartialEq)] +pub struct BabeEquivocationProof { + identity: AuthorityId, slot: u64, first_header: H, second_header: H, - first_signature: S, - second_signature: S, + first_signature: AuthoritySignature, + second_signature: AuthoritySignature, } -impl AuthorshipEquivocationProof for BabeEquivocationProof +impl AuthorshipEquivocationProof for BabeEquivocationProof where H: Header, - S: Verify + Codec, - I: Codec, - P: Codec, { type Header = H; - type Signature = S; - type Identity = I; - type InclusionProof = P; + type Signature = AuthoritySignature; + type Identity = AuthorityId; /// Create a new Babe equivocation proof. fn new( - identity: I, - identity_proof: Option

, + identity: Self::Identity, slot: u64, first_header: H, second_header: H, - first_signature: S, - second_signature: S, + first_signature: Self::Signature, + second_signature: Self::Signature, ) -> Self { BabeEquivocationProof { identity, - identity_proof, slot, first_header, second_header, @@ -196,15 +190,10 @@ where } /// Get the identity of the suspect of equivocating. - fn identity(&self) -> &I { + fn identity(&self) -> &Self::Identity { &self.identity } - /// Get the identity proof. - fn identity_proof(&self) -> Option<&P> { - self.identity_proof.as_ref() - } - /// Get the first header involved in the equivocation. fn first_header(&self) -> &H { &self.first_header @@ -215,11 +204,11 @@ where &self.second_header } - fn first_signature(&self) -> &S { + fn first_signature(&self) -> &Self::Signature { &self.first_signature } - fn second_signature(&self) -> &S { + fn second_signature(&self) -> &Self::Signature { &self.second_signature } } @@ -236,5 +225,11 @@ decl_runtime_apis! { /// Get the current epoch data for Babe. fn epoch() -> Epoch; + + /// Construct a call to report the equivocation. + fn construct_equivocation_report_call( + equivocation: BabeEquivocationProof, + proof: Proof + ) -> Option>; } } diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index f750bda0c329b..79272461cd92b 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -76,7 +76,6 @@ use futures::{prelude::*, future}; use futures01::Stream as _; use futures_timer::Delay; use log::{error, warn, debug, info, trace}; -use srml_session::historical::Proof; use consensus_common_primitives::AuthorshipEquivocationProof; use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, SignedDuration}; @@ -508,7 +507,7 @@ fn check_header( } if let Some(equivocation_proof) = check_equivocation::< - _, _, BabeEquivocationProof, _, _ + _, _, BabeEquivocationProof, _, _ >( client, slot_now, diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 342de9755377c..74f374ac1aeb0 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -39,12 +39,10 @@ pub trait AuthorshipEquivocationProof { type Header: Header; type Signature: Verify; type Identity: Codec; - type InclusionProof: Codec; /// Create an equivocation proof for AuRa or Babe. fn new( identity: Self::Identity, - identity_proof: Option, slot: u64, first_header: Self::Header, second_header: Self::Header, @@ -58,9 +56,6 @@ pub trait AuthorshipEquivocationProof { /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; - /// Get the proof of inclusion of the identity in the validator set. - fn identity_proof(&self) -> Option<&Self::InclusionProof>; - /// Get the first header involved in the equivocation. fn first_header(&self) -> &Self::Header; diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index e7780fec72c94..e3396751d5ca8 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -75,7 +75,6 @@ pub fn check_equivocation( Header=H, Signature=V, Identity=::Signer, - InclusionProof=P >, { // We don't check equivocations for old headers out of our capacity. @@ -107,7 +106,6 @@ pub fn check_equivocation( if header.hash() != prev_header.hash() { return Ok(Some(AuthorshipEquivocationProof::new( signer.clone(), - None, slot, prev_header.clone(), header.clone(), diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index 43b18e5328e12..0206be86e688b 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -25,6 +25,7 @@ inherents = { package = "substrate-inherents", path = "../../core/inherents" } network = { package = "substrate-network", path = "../network" } service = { package = "substrate-service", path = "../service", optional = true } srml-finality-tracker = { path = "../../srml/finality-tracker" } +srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec"] } # grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec"] } diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 0efcea5cac053..7310a9234fdd5 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -68,7 +68,7 @@ pub struct GrandpaEquivocation { /// The identity of the equivocator. pub identity: AuthorityId, /// The proof of identity inclusion. - pub identity_proof: Option, + pub identity_proof: Proof, /// The first vote in the equivocation. pub first: (Message, AuthoritySignature), /// The second vote in the equivocation. diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index a51f3226a9226..8fcf2d2b1f59c 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -46,6 +46,7 @@ use crate::{ }; use consensus_common::SelectChain; +use srml_session::historical::Proof; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; @@ -850,7 +851,7 @@ where let grandpa_equivocation = GrandpaEquivocationFrom:: { round_number: equivocation.round_number, identity: equivocation.identity, - identity_proof: None, + identity_proof: Proof::default(), first: (first_vote, first_signature), second: (second_vote, second_signature), set_id: self.set_id, @@ -891,7 +892,7 @@ where let grandpa_equivocation = GrandpaEquivocationFrom:: { round_number: equivocation.round_number, identity: equivocation.identity, - identity_proof: None, + identity_proof: Proof::default(), first: (first_vote, first_signature), second: (second_vote, second_signature), set_id: self.set_id, diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 0c2628b054080..10ae009943b3d 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -31,6 +31,7 @@ use node_primitives::{ }; use parity_codec::{Encode, Decode, Codec}; use babe::{AuthorityId as BabeId}; +use babe_primitives::BabeEquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; use client::{ block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult}, @@ -56,6 +57,7 @@ use session::historical::{self, Proof}; pub use sr_primitives::BuildStorage; pub use timestamp::Call as TimestampCall; pub use balances::Call as BalancesCall; +pub use babe::Call as BabeCall; pub use grandpa::Call as GrandpaCall; pub use contracts::Gas; pub use sr_primitives::{Permill, Perbill}; @@ -585,6 +587,16 @@ impl_runtime_apis! { duration: EpochDuration::get(), } } + + fn construct_equivocation_report_call( + equivocation: BabeEquivocationProof<::Header>, + proof: Proof, + ) -> Option> { + // TODO: Check proof. + let babe_call = BabeCall::report_equivocation(equivocation); + let call = Call::Babe(babe_call); + Some(call.encode()) + } } impl consensus_primitives::ConsensusApi for Runtime { diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 78d30cd32cf3b..87e359fcefb33 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -56,8 +56,6 @@ pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PU /// The BABE inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot"; -/// The type of the BABE equivocation. -pub type BabeEquivocation

= BabeEquivocationProof; /// The type of the BABE inherent. pub type InherentType = u64; /// Auxiliary trait to extract BABE inherent data. @@ -186,7 +184,7 @@ decl_storage! { } } -fn equivocation_is_valid(equivocation: BabeEquivocation) -> bool { +fn equivocation_is_valid(equivocation: BabeEquivocationProof) -> bool { let first_header = equivocation.first_header(); let second_header = equivocation.second_header(); @@ -255,19 +253,11 @@ decl_module! { } } - fn report_equivocation(origin, equivocation: BabeEquivocation) { + fn report_equivocation(origin, equivocation: BabeEquivocationProof) { let _who = ensure_signed(origin)?; - if let Some(identity) = equivocation.identity_proof() { - - let _to_punish = ::KeyOwnerSystem::check_proof( - (key_types::SR25519, equivocation.identity().encode()), - identity.clone(), - ); - - if equivocation_is_valid::(equivocation) { - // TODO: Slash `to_punish` and reward `who`. - } + if equivocation_is_valid::(equivocation) { + // TODO: Slash `to_punish` and reward `who`. } } } diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index c9c3240514162..50591a861390c 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -274,7 +274,7 @@ impl ProvingTrie { /// Proof of ownership of a specific key. #[cfg_attr(feature = "std", derive(Serialize, Debug))] -#[derive(Encode, Decode, Clone, PartialEq, Eq)] +#[derive(Encode, Decode, Clone, PartialEq, Eq, Default)] pub struct Proof { session: SessionIndex, trie_nodes: Vec>, From 7b2dcde7f430ed8cad49377083d27dee0430f179 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 23:56:09 +0200 Subject: [PATCH 115/191] Fix signature and public tmp --- Cargo.lock | 2 + .../babe/primitives/src/equivocation.rs | 102 ------------------ core/consensus/babe/primitives/src/lib.rs | 10 +- core/consensus/babe/src/lib.rs | 2 +- core/consensus/common/primitives/Cargo.toml | 1 + core/consensus/common/primitives/src/lib.rs | 6 +- core/consensus/slots/Cargo.toml | 3 +- core/consensus/slots/src/aux_schema.rs | 7 +- core/primitives/src/sr25519.rs | 14 +++ srml/babe/src/lib.rs | 5 +- srml/session/src/historical.rs | 4 +- 11 files changed, 44 insertions(+), 112 deletions(-) delete mode 100644 core/consensus/babe/primitives/src/equivocation.rs diff --git a/Cargo.lock b/Cargo.lock index db4b8aacfbb34..e674b535fef78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4555,6 +4555,7 @@ dependencies = [ >>>>>>> Add AuthorshipEquivocation trait "sr-primitives 2.0.0", "sr-std 2.0.0", + "srml-session 2.0.0", "substrate-client 2.0.0", "substrate-primitives 2.0.0", ] @@ -4593,6 +4594,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "srml-session 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", "substrate-consensus-common-primitives 2.0.0", diff --git a/core/consensus/babe/primitives/src/equivocation.rs b/core/consensus/babe/primitives/src/equivocation.rs deleted file mode 100644 index dfdcb946532c2..0000000000000 --- a/core/consensus/babe/primitives/src/equivocation.rs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Primitives for BABE equivocations. - -use parity_codec::{Encode, Decode, Codec}; -use sr_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header, Verify}}; -use safety_primitives::AuthorshipEquivocationProof; -use srml_session::historical::Proof; -use crate::digest::find_pre_digest; - -/// Represents a Babe equivocation proof. -#[cfg_attr(feature = "std", derive(Serialize, Debug))] -#[derive(Clone, Encode, Decode, PartialEq, Eq)] -pub struct BabeEquivocationProof { - identity: AuthorityId, - slot: u64, - identity_proof: Proof, - first_header: H, - second_header: H, - first_signature: AuthoritySignature, - second_signature: AuthoritySignature, -} - -impl AuthorshipEquivocationProof for BabeEquivocationProof -where - H: Header, -{ - type Header = H; - type Signature = AuthoritySignature; - type Identity = AuthorityId; - type InclusionProof = Proof; - - /// Create a new Babe equivocation proof. - fn new( - identity: AuthorityId, - identity_proof: Proof, - slot: u64, - first_header: H, - second_header: H, - first_signature: AuthoritySignature, - second_signature: AuthoritySignature, - ) -> Self { - BabeEquivocationProof { - identity, - identity_proof, - slot, - first_header, - second_header, - first_signature, - second_signature, - } - } - - /// Return the slot where the equivocation happened. - fn slot(&self) -> u64 { - self.slot - } - - /// Get the identity of the suspect of equivocating. - fn identity(&self) -> &I { - &self.identity - } - - /// Get the identity proof. - fn identity_proof(&self) -> Option<&P> { - self.identity_proof.as_ref() - } - - /// Get the first header involved in the equivocation. - fn first_header(&self) -> &H { - &self.first_header - } - - /// Get the second header involved in the equivocation. - fn second_header(&self) -> &H { - &self.second_header - } - - /// Get the first signature involved in the equivocation. - fn first_signature(&self) -> &S { - &self.first_signature - } - - /// Get the second signature involved in the equivocation. - fn second_signature(&self) -> &S { - &self.second_signature - } -} \ No newline at end of file diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 538d87f548998..7799cd92ca8ff 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -147,9 +147,10 @@ impl slots::SlotData for BabeConfiguration { } /// Represents an Babe equivocation proof. -#[derive(Clone, Encode, Decode, PartialEq)] +#[derive(Debug, Clone, Encode, Decode, PartialEq)] pub struct BabeEquivocationProof { identity: AuthorityId, + identity_proof: Proof, slot: u64, first_header: H, second_header: H, @@ -168,6 +169,7 @@ where /// Create a new Babe equivocation proof. fn new( identity: Self::Identity, + identity_proof: Proof, slot: u64, first_header: H, second_header: H, @@ -176,6 +178,7 @@ where ) -> Self { BabeEquivocationProof { identity, + identity_proof, slot, first_header, second_header, @@ -194,6 +197,11 @@ where &self.identity } + /// Get the identity of the suspect of equivocating. + fn identity_proof(&self) -> &Proof { + &self.identity_proof + } + /// Get the first header involved in the equivocation. fn first_header(&self) -> &H { &self.first_header diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 79272461cd92b..807f44f5e9780 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -507,7 +507,7 @@ fn check_header( } if let Some(equivocation_proof) = check_equivocation::< - _, _, BabeEquivocationProof, _, _ + _, _, BabeEquivocationProof, _ >( client, slot_now, diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index f3b2e7180a3c3..9b72a292796f6 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -12,6 +12,7 @@ sr-primitives = { path = "../../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } +srml-session = { path = "../../../../srml/session", default-features = false } [features] default = ["std"] diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 74f374ac1aeb0..54a906b0fb340 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -25,7 +25,7 @@ use parity_codec::Codec; #[cfg(feature = "std")] use serde::Serialize; use sr_primitives::{traits::{Header, Verify}}; - +use srml_session::historical::Proof; decl_runtime_apis! { /// Common consensus runtime api. @@ -43,6 +43,7 @@ pub trait AuthorshipEquivocationProof { /// Create an equivocation proof for AuRa or Babe. fn new( identity: Self::Identity, + identity_proof: Proof, slot: u64, first_header: Self::Header, second_header: Self::Header, @@ -53,6 +54,9 @@ pub trait AuthorshipEquivocationProof { /// Get the slot where the equivocation happened. fn slot(&self) -> u64; + /// Get the identity proof of the suspect of equivocating. + fn identity_proof(&self) -> &Proof; + /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index 6801ff622c14d..e50576a159968 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -13,7 +13,8 @@ sr-primitives = { path = "../../sr-primitives" } consensus_common = { package = "substrate-consensus-common", path = "../common" } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } inherents = { package = "substrate-inherents", path = "../../inherents" } -futures-preview = "=0.3.0-alpha.17" +srml-session = { path = "../../../srml/session", default-features = false } +futures-preview = "0.3.0-alpha.17" futures-timer = "0.2.1" parking_lot = "0.9.0" log = "0.4" diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index e3396751d5ca8..18782103e1fd5 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -16,12 +16,13 @@ //! Schema for slots in the aux-db. +use std::ops::Deref; use codec::{Encode, Decode, Codec}; use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::{Header, Verify}; use consensus_common_primitives::AuthorshipEquivocationProof; -use std::ops::Deref; +use srml_session::historical::Proof; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; @@ -57,7 +58,7 @@ pub struct EquivocationProof { /// Checks if the header is an equivocation and returns the proof in that case. /// /// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY. -pub fn check_equivocation( +pub fn check_equivocation( backend: &C, slot_now: u64, slot: u64, @@ -68,7 +69,6 @@ pub fn check_equivocation( where H: Header, C: AuxStore, - P: Clone + Encode + Decode + PartialEq, V: Verify + Codec + Clone, ::Signer: Clone + Codec + PartialEq, E: AuthorshipEquivocationProof< @@ -106,6 +106,7 @@ pub fn check_equivocation( if header.hash() != prev_header.hash() { return Ok(Some(AuthorshipEquivocationProof::new( signer.clone(), + Proof::default(), slot, prev_header.clone(), header.clone(), diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 0e573f49ce34c..38c23c1c6b708 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -136,6 +136,20 @@ impl std::fmt::Debug for Public { } } +#[cfg(not(feature = "std"))] +impl ::core::fmt::Debug for Public { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + write!(f, "") + } +} + +#[cfg(not(feature = "std"))] +impl ::core::fmt::Debug for Signature { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + write!(f, "") + } +} + #[cfg(feature = "std")] impl Serialize for Public { fn serialize(&self, serializer: S) -> Result where S: Serializer { diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 87e359fcefb33..676845f1ff2a8 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -253,7 +253,10 @@ decl_module! { } } - fn report_equivocation(origin, equivocation: BabeEquivocationProof) { + fn report_equivocation( + origin, + equivocation: BabeEquivocationProof + ) { let _who = ensure_signed(origin)?; if equivocation_is_valid::(equivocation) { diff --git a/srml/session/src/historical.rs b/srml/session/src/historical.rs index 50591a861390c..9e0647b78ecf9 100644 --- a/srml/session/src/historical.rs +++ b/srml/session/src/historical.rs @@ -273,8 +273,8 @@ impl ProvingTrie { } /// Proof of ownership of a specific key. -#[cfg_attr(feature = "std", derive(Serialize, Debug))] -#[derive(Encode, Decode, Clone, PartialEq, Eq, Default)] +#[cfg_attr(feature = "std", derive(Serialize))] +#[derive(Encode, Decode, Clone, PartialEq, Eq, Default, Debug)] pub struct Proof { session: SessionIndex, trie_nodes: Vec>, From a7e959e47c368b4187e54e30a4d9e89e5de8d443 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 09:26:45 +0200 Subject: [PATCH 116/191] Add SessionIndex --- core/consensus/babe/primitives/src/lib.rs | 10 +++++++++- core/consensus/common/primitives/src/lib.rs | 12 ++++++++---- core/consensus/slots/src/aux_schema.rs | 5 +++-- core/finality-grandpa/primitives/src/lib.rs | 4 +++- core/finality-grandpa/src/environment.rs | 6 ++++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 7799cd92ca8ff..8c4ede88c2182 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -27,7 +27,7 @@ use sr_primitives::{ConsensusEngineId, traits::Header}; use primitives::sr25519; use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; -use srml_session::historical::Proof; +use srml_session::{historical::Proof, SessionIndex}; #[cfg(feature = "std")] pub use digest::BabePreDigest; @@ -152,6 +152,7 @@ pub struct BabeEquivocationProof { identity: AuthorityId, identity_proof: Proof, slot: u64, + session_index: SessionIndex, first_header: H, second_header: H, first_signature: AuthoritySignature, @@ -171,6 +172,7 @@ where identity: Self::Identity, identity_proof: Proof, slot: u64, + session_index: SessionIndex, first_header: H, second_header: H, first_signature: Self::Signature, @@ -180,6 +182,7 @@ where identity, identity_proof, slot, + session_index, first_header, second_header, first_signature, @@ -192,6 +195,11 @@ where self.slot } + /// Get the session index where the equivocation happened. + fn session_index(&self) -> &SessionIndex { + &self.session_index + } + /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity { &self.identity diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 54a906b0fb340..f6b222bd941b6 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -25,7 +25,7 @@ use parity_codec::Codec; #[cfg(feature = "std")] use serde::Serialize; use sr_primitives::{traits::{Header, Verify}}; -use srml_session::historical::Proof; +use srml_session::{historical::Proof, SessionIndex}; decl_runtime_apis! { /// Common consensus runtime api. @@ -45,21 +45,25 @@ pub trait AuthorshipEquivocationProof { identity: Self::Identity, identity_proof: Proof, slot: u64, + session_index: SessionIndex, first_header: Self::Header, second_header: Self::Header, first_signature: Self::Signature, second_signature: Self::Signature, ) -> Self; + /// Get the session index where the equivocation happened. + fn session_index(&self) -> &SessionIndex; + /// Get the slot where the equivocation happened. fn slot(&self) -> u64; - /// Get the identity proof of the suspect of equivocating. - fn identity_proof(&self) -> &Proof; - /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; + /// Get the identity proof of the suspect of equivocating. + fn identity_proof(&self) -> &Proof; + /// Get the first header involved in the equivocation. fn first_header(&self) -> &Self::Header; diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 18782103e1fd5..d38d566102cae 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -22,7 +22,7 @@ use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::{Header, Verify}; use consensus_common_primitives::AuthorshipEquivocationProof; -use srml_session::historical::Proof; +use srml_session::{historical::Proof, SessionIndex}; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; @@ -106,8 +106,9 @@ pub fn check_equivocation( if header.hash() != prev_header.hash() { return Ok(Some(AuthorshipEquivocationProof::new( signer.clone(), - Proof::default(), + Proof::default(), // TODO: add the proof. slot, + SessionIndex::default(), // TODO: add session index. prev_header.clone(), header.clone(), prev_signature.clone(), diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 7310a9234fdd5..a1f205b04d5fe 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -28,7 +28,7 @@ use sr_primitives::{ConsensusEngineId, traits::{DigestFor, NumberFor, Block as B use client::decl_runtime_apis; use rstd::vec::Vec; use grandpa::Message; -use session::historical::Proof; +use session::{historical::Proof, SessionIndex}; mod app { use app_crypto::{app_crypto, key_types::GRANDPA, ed25519}; @@ -63,6 +63,8 @@ pub fn localized_payload(round: u64, set_id: u64, message: &E) -> Vec pub struct GrandpaEquivocation { /// The set id. pub set_id: u64, + /// The session id. + pub session_index: SessionIndex, /// The round number equivocated in. pub round_number: u64, /// The identity of the equivocator. diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 8fcf2d2b1f59c..cc95e28d77a07 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -46,7 +46,7 @@ use crate::{ }; use consensus_common::SelectChain; -use srml_session::historical::Proof; +use srml_session::{historical::Proof, SessionIndex}; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; @@ -850,6 +850,7 @@ where let grandpa_equivocation = GrandpaEquivocationFrom:: { round_number: equivocation.round_number, + session_index: SessionIndex::default(), // TODO: add session index. identity: equivocation.identity, identity_proof: Proof::default(), first: (first_vote, first_signature), @@ -891,8 +892,9 @@ where let grandpa_equivocation = GrandpaEquivocationFrom:: { round_number: equivocation.round_number, + session_index: SessionIndex::default(), // TODO: add session index. identity: equivocation.identity, - identity_proof: Proof::default(), + identity_proof: Proof::default(), // TODO: add proof. first: (first_vote, first_signature), second: (second_vote, second_signature), set_id: self.set_id, From f0108ac9a3a91b9a4a947a38955ae6e79186fde2 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 6 Aug 2019 23:56:09 +0200 Subject: [PATCH 117/191] Fix signature and public tmp --- core/consensus/common/primitives/src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index f6b222bd941b6..92729a10fb5c8 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -58,6 +58,9 @@ pub trait AuthorshipEquivocationProof { /// Get the slot where the equivocation happened. fn slot(&self) -> u64; + /// Get the identity proof of the suspect of equivocating. + fn identity_proof(&self) -> &Proof; + /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; From 1b01ad41356e39c66fedf8bc6dab906756a4c864 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 10:18:41 +0200 Subject: [PATCH 118/191] Fix merge; update grandpa --- Cargo.lock | 623 ++++++++++--------- core/consensus/babe/primitives/src/digest.rs | 7 +- core/consensus/babe/primitives/src/lib.rs | 2 +- core/consensus/common/primitives/Cargo.toml | 2 +- core/consensus/common/primitives/src/lib.rs | 6 - core/finality-grandpa/Cargo.toml | 6 +- core/finality-grandpa/primitives/Cargo.toml | 2 +- node/runtime/src/lib.rs | 2 +- 8 files changed, 326 insertions(+), 324 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e674b535fef78..c4320dc9434fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -32,13 +32,13 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aho-corasick" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -50,7 +50,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -132,7 +132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.33" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -161,7 +161,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -194,11 +194,11 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -230,7 +230,7 @@ dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -291,7 +291,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -363,8 +363,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -510,8 +510,8 @@ dependencies = [ "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -620,7 +620,7 @@ dependencies = [ "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -669,14 +669,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -749,7 +749,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -775,8 +775,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -790,7 +790,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -798,7 +798,7 @@ name = "error-chain" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -816,7 +816,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -846,22 +846,14 @@ dependencies = [ [[package]] name = "finality-grandpa" -<<<<<<< HEAD version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -======= -version = "0.8.1" ->>>>>>> Create grandpa equivocation dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Create grandpa equivocation "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1088,10 +1080,10 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1110,11 +1102,11 @@ name = "globset" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "bstr 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1126,9 +1118,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1230,7 +1222,7 @@ dependencies = [ [[package]] name = "http" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1245,7 +1237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1289,12 +1281,12 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1333,7 +1325,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1341,7 +1333,7 @@ name = "impl-serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1396,16 +1388,16 @@ dependencies = [ [[package]] name = "jsonrpc-client-transports" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1413,27 +1405,27 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-core-client" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-client-transports 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-derive" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1444,13 +1436,13 @@ dependencies = [ [[package]] name = "jsonrpc-http-server" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1458,25 +1450,25 @@ dependencies = [ [[package]] name = "jsonrpc-pubsub" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-server-utils" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1485,12 +1477,12 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" -version = "12.1.0" +version = "12.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1547,10 +1539,10 @@ dependencies = [ "fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1563,9 +1555,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "lazycell" @@ -1638,7 +1627,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1656,7 +1645,7 @@ dependencies = [ "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1686,7 +1675,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1717,7 +1706,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1741,7 +1730,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1765,7 +1754,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1786,7 +1775,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1799,18 +1788,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1822,7 +1811,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1849,7 +1838,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1867,7 +1856,7 @@ dependencies = [ "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1905,7 +1894,7 @@ dependencies = [ "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1918,7 +1907,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1944,7 +1933,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "soketto 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1961,7 +1950,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2044,12 +2033,12 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2117,7 +2106,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2166,7 +2155,7 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2179,7 +2168,7 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2212,7 +2201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2234,7 +2223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2274,7 +2263,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", @@ -2347,8 +2336,13 @@ name = "node-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2362,8 +2356,8 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "substrate-rpc 2.0.0", ] @@ -2377,7 +2371,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", @@ -2421,7 +2415,7 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-template-runtime 2.0.0", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2449,7 +2443,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2553,7 +2547,7 @@ dependencies = [ [[package]] name = "opaque-debug" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2617,12 +2611,13 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "4.1.3" +version = "4.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "bitvec 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-slice-cast 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2637,7 +2632,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2665,7 +2660,7 @@ dependencies = [ "bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec-derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2927,7 +2922,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2947,9 +2942,9 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3001,7 +2996,7 @@ dependencies = [ "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3016,7 +3011,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3046,12 +3041,12 @@ name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3059,7 +3054,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3092,7 +3087,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3104,7 +3099,7 @@ dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3115,7 +3110,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3177,14 +3172,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3197,11 +3191,8 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "remove_dir_all" @@ -3218,7 +3209,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3278,7 +3269,7 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3310,7 +3301,7 @@ dependencies = [ [[package]] name = "safemem" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3335,14 +3326,24 @@ name = "schnorrkel" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ +<<<<<<< HEAD "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa ] [[package]] @@ -3397,7 +3398,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3412,15 +3413,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3435,7 +3436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3446,7 +3447,7 @@ dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3474,7 +3475,7 @@ dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3486,7 +3487,7 @@ dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3529,7 +3530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3568,12 +3569,12 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3585,9 +3586,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3623,7 +3624,7 @@ dependencies = [ "substrate-state-machine 2.0.0", "substrate-test-runtime-client 2.0.0", "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", - "trybuild 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3648,13 +3649,17 @@ name = "sr-primitives" version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", @@ -3697,7 +3702,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -3707,7 +3712,7 @@ name = "srml-assets" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3722,8 +3727,13 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3758,8 +3768,13 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3781,7 +3796,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3798,7 +3813,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3818,7 +3833,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-sandbox 2.0.0", @@ -3838,7 +3853,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3855,7 +3870,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3870,7 +3885,7 @@ name = "srml-example" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "srml-balances 2.0.0", @@ -3885,7 +3900,7 @@ version = "2.0.0" dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3901,7 +3916,7 @@ name = "srml-finality-tracker" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3916,7 +3931,7 @@ name = "srml-generic-asset" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3930,7 +3945,7 @@ name = "srml-grandpa" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3948,7 +3963,7 @@ name = "srml-im-online" version = "0.1.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3967,7 +3982,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3996,7 +4011,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -4024,7 +4039,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -4044,7 +4059,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -4064,7 +4079,7 @@ name = "srml-sudo" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4083,7 +4098,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4131,12 +4146,12 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "srml-support 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "trybuild 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4146,7 +4161,7 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4159,7 +4174,7 @@ name = "srml-timestamp" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4174,7 +4189,7 @@ name = "srml-treasury" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4304,7 +4319,7 @@ name = "substrate-basic-authorship" version = "2.0.0" dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -4342,9 +4357,9 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4374,7 +4389,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", @@ -4402,7 +4417,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4425,7 +4440,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4471,7 +4486,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4532,7 +4547,7 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4547,12 +4562,8 @@ dependencies = [ name = "substrate-consensus-common-primitives" version = "2.0.0" dependencies = [ -<<<<<<< HEAD "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Add AuthorshipEquivocation trait + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", @@ -4567,7 +4578,7 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4590,7 +4601,7 @@ version = "2.0.0" dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4626,7 +4637,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4650,15 +4661,11 @@ name = "substrate-finality-grandpa" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "finality-grandpa 0.8.1", ->>>>>>> Create grandpa equivocation "fork-tree 2.0.0", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4688,13 +4695,9 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "2.0.0" dependencies = [ -<<<<<<< HEAD + "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "finality-grandpa 0.8.1", - "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Create grandpa equivocation - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", <<<<<<< HEAD @@ -4737,7 +4740,7 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-application-crypto 2.0.0", "substrate-primitives 2.0.0", - "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4759,14 +4762,14 @@ dependencies = [ "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4786,7 +4789,7 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4794,8 +4797,13 @@ name = "substrate-offchain" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4821,8 +4829,8 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4832,7 +4840,7 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4859,18 +4867,23 @@ dependencies = [ "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-serializer 2.0.0", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4881,15 +4894,15 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4910,11 +4923,11 @@ dependencies = [ name = "substrate-rpc-servers" version = "2.0.0" dependencies = [ - "jsonrpc-http-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-rpc 2.0.0", ] @@ -4934,7 +4947,7 @@ dependencies = [ name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4947,14 +4960,19 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4976,7 +4994,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", - "sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4989,7 +5007,7 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -5015,7 +5033,7 @@ name = "substrate-state-db" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", @@ -5027,7 +5045,7 @@ version = "2.0.0" dependencies = [ "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5047,10 +5065,15 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5081,10 +5104,10 @@ name = "substrate-test-runtime" version = "2.0.0" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5130,10 +5153,15 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", +>>>>>>> Fix merge; update grandpa "sr-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime 2.0.0", @@ -5145,7 +5173,7 @@ version = "2.0.0" dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -5202,7 +5230,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -5228,7 +5256,7 @@ dependencies = [ [[package]] name = "sysinfo" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5331,7 +5359,7 @@ name = "tinytemplate" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5341,7 +5369,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5435,7 +5463,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5446,7 +5474,7 @@ dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5500,7 +5528,7 @@ dependencies = [ "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5535,7 +5563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5551,7 +5579,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5564,7 +5592,7 @@ name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5576,7 +5604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "transaction-factory" version = "0.0.1" dependencies = [ - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-cli 2.0.0", @@ -5609,7 +5637,7 @@ dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5637,12 +5665,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trybuild" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5655,15 +5683,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "twox-hash" -version = "1.4.2" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5676,11 +5704,6 @@ name = "typenum" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "ucd-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "uint" version = "0.8.0" @@ -5762,11 +5785,6 @@ dependencies = [ "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "utf8-ranges" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "vcpkg" version = "0.2.7" @@ -5782,8 +5800,8 @@ name = "vecarray" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 4.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5812,8 +5830,8 @@ name = "wabt" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5844,7 +5862,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5863,7 +5881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5913,7 +5931,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6080,7 +6098,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6104,7 +6122,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6125,7 +6143,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6136,15 +6154,15 @@ dependencies = [ [[package]] name = "zeroize" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "zeroize_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zeroize_derive" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6158,7 +6176,7 @@ dependencies = [ "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f10b352bc3fc08ae24dc5d2d3ddcac153678533986122dc283d747b12071000" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" @@ -6170,7 +6188,7 @@ dependencies = [ "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" -"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" +"checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -6232,7 +6250,7 @@ dependencies = [ "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5d4b820e8711c211745880150f5fac78ab07d6e3851d8ce9f5a02cedc199174c" +"checksum curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "019779982f8518304cfbabd515e77ad6372a9a28a57d22d39478164c5e2b32ee" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" @@ -6253,10 +6271,7 @@ dependencies = [ "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" -<<<<<<< HEAD "checksum finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9681c1f75941ea47584573dd2bc10558b2067d460612945887e00744e43393be" -======= ->>>>>>> Create grandpa equivocation "checksum fixed-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" @@ -6282,7 +6297,7 @@ dependencies = [ "checksum generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fceb69994e330afed50c93524be68c42fa898c2d9fd4ee8da03bd7363acd26f2" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" -"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" +"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" @@ -6299,7 +6314,7 @@ dependencies = [ "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" -"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" +"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" @@ -6317,14 +6332,14 @@ dependencies = [ "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "da3ea71161651a4cd97d999b2da139109c537b15ab33abc8ae4ead38deac8a03" -"checksum jsonrpc-client-transports 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6be24a8de4ced80f6fd8b6ace54aa610823a7642976a0e8e00e3bb2f4d8c33f0" -"checksum jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0216cf4c95fb373d89c63572672097b8aa74cfcdd77054accbf545d840be5bd7" -"checksum jsonrpc-core-client 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1603b6cc05060de7794c2962edd705e1ad2698bd2b0d2ddd4489f8c85df122b7" -"checksum jsonrpc-derive 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8afff172177878850d133ccdcd93cad794e85d7779ab334998d669ef80e13180" -"checksum jsonrpc-http-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a24e140242e0d2e9a694cf8db513a2bd739d24c392e0ad15e0d6d7ee8851e3a2" -"checksum jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c45f7cdb1bb28a3bfb3a0a5184bf99669c9ffe8cf8d7b8a582f2a52bf9944a" -"checksum jsonrpc-server-utils 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7aac8e0029d19582b68c9fd498d18bdcf0846612c968acc93b6e5ae67eea4e0" -"checksum jsonrpc-ws-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "698fee4fcaf09a5927b7e39dd8a8136a102b343cebacaa351fc4def01a050a5b" +"checksum jsonrpc-client-transports 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "903004abf8bfea78499516b80736783ad8d2d2112e3a3dfb389ff2fbb1fa3ab6" +"checksum jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8df63798dccd2fc909485cc7a8979ab79f398a7cf788e552e17537e06f85d8e" +"checksum jsonrpc-core-client 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f07193b79d586728f14e52832bfd7650b68c8340a71c6088e346cf42161136f" +"checksum jsonrpc-derive 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9dd82265c34ad1be0d87239b24404160f04ae58c3ad335395822a860c8fe8153" +"checksum jsonrpc-http-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "99c3f43b5f7d2eb010f56354b0dbfb2427491dadc11d1abaf0c4baa329abc507" +"checksum jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3062b654749ce3a58b765297a4836d2710fc667877c47b5269d5a92afb9a191" +"checksum jsonrpc-server-utils 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6820ccc63886731f5cca989082f7ed4238e6e124e1143a477bbc9b58e4b4aa" +"checksum jsonrpc-ws-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45bf96f95892eac61c15280c07e380a9fd24bef6c5e3e87b7764208b74585e77" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bf18164fd7ce989041f8fc4a1ae72a8bd1bec3575f2aeaf1d4968fc053aabef" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -6366,7 +6381,7 @@ dependencies = [ "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" "checksum malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "35adee9ed962cf7d07d62cb58bc45029f3227f5b5b86246caa8632f06c187bc3" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" @@ -6398,7 +6413,7 @@ dependencies = [ "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" +"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)" = "8152bb5a9b5b721538462336e3bef9a539f892715e5037fda0f984577311af15" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)" = "b5ba300217253bcc5dc68bed23d782affa45000193866e025329aa8a7a9f05b8" @@ -6406,7 +6421,7 @@ dependencies = [ "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" -"checksum parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2900f06356edf90de66a2922db622b36178dca71e85625eae58d0d9cc6cff2ac" +"checksum parity-codec 4.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7c1a0e8c54ce49245caa93c1a4e11dc4da1d1e9cc8649ff30e57aa177d4abd55" "checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" "checksum parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "00fd14ff806ad82cea9a8f909bb116443d92efda7c9acd4502690af64741ad81" @@ -6451,7 +6466,7 @@ dependencies = [ "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" @@ -6466,9 +6481,9 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d813022b2e00774a48eaf43caaa3c20b45f040ba8cbf398e2e8911a06668dbe6" -"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" +"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" +"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36542aafc2429a4c010fafa079a20dee953b663cb2427f51d86cf1d436846b4d" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" @@ -6481,7 +6496,7 @@ dependencies = [ "checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" +"checksum safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e133ccc4f4d1cd4f89cc8a7ff618287d56dc7f638b8e38fc32c5fdcadc339dd5" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "77e8d6a92f49a53f21b71c090a5559bf45c469071ebe556aebaf2dca3abc5cb5" @@ -6494,8 +6509,8 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" -"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" +"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" +"checksum serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "01e69e1b8a631f245467ee275b8c757b818653c6d704cdbcaeb56b56767b529c" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" @@ -6527,10 +6542,10 @@ dependencies = [ "checksum substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" "checksum substrate-wasm-builder-runner 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f52ecbff6cc3d6e5c6401828e15937b680f459d6803ce238f01fe615bc40d071" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" +"checksum subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01f40907d9ffc762709e4ff3eb4a6f6b41b650375a3f09ac92b641942b7fb082" "checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3e2cab189e59f72710e3dd5e1e0d5be0f6c5c999c326f2fdcdf3bf4483ec9fd" +"checksum sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7d12b854e48e680bf4b10856a7867e843845158fa8226e6c2f6cc38539cb01" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" @@ -6567,12 +6582,11 @@ dependencies = [ "checksum trie-root 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b0eaa64e50d686c89e6d4817ed33cb18cfa249e9071b7918b18ecfacc7867" "checksum trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "64fda153c00484d640bc91334624be22ead0e5baca917d9fd53ff29bdebcf9b2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" -"checksum trybuild 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f2e8e773ac21d176ee05243456b9f1a942cd1a586dab188ced05b8e8d58dc635" +"checksum trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c718030bb5c88b65994c4200d929d10628d653c7798a35012f8ff4c4211624a8" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twox-hash 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7834480552ffc48e1930ceddd701f47d2234319d80b7bcbbe2fe7202933c101" +"checksum twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" -"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum uint 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5375d2c574f89adad4108ad525c93e39669853a602560bf5ed4ca9943b10799" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" @@ -6584,7 +6598,6 @@ dependencies = [ "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d68a73b7d7d950c6558b6009e9fba229fb67562bda9fd02198f614f4ecf83f" @@ -6624,5 +6637,5 @@ dependencies = [ "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" -"checksum zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4177936c03b5a349c1b8e4509c46add268e66bc66fe92663729fa0570fe4f213" -"checksum zeroize_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afd1469e4bbca3b96606d26ba6e9bd6d3aed3b1299c82b92ec94377d22d78dbc" +"checksum zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" +"checksum zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e" diff --git a/core/consensus/babe/primitives/src/digest.rs b/core/consensus/babe/primitives/src/digest.rs index 73cb8b8add41f..ffa4a695ebcf4 100644 --- a/core/consensus/babe/primitives/src/digest.rs +++ b/core/consensus/babe/primitives/src/digest.rs @@ -22,12 +22,9 @@ use super::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}; use super::SlotNumber; use sr_primitives::{DigestItem, generic::OpaqueDigestItemId}; use sr_primitives::traits::{Header, DigestItemForHeader, Verify}; -use parity_codec::{Decode, Encode, Codec}; +use codec::{Decode, Encode, Codec}; #[cfg(feature = "std")] -use std::fmt::Debug; -use codec::{Decode, Encode}; -#[cfg(feature = "std")] -use codec::{Codec, Input, Error}; +use codec::{Input, Error}; #[cfg(feature = "std")] use schnorrkel::{ SignatureError, errors::MultiSignatureStage, diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 8c4ede88c2182..b125bdd396b71 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -21,7 +21,7 @@ mod digest; -use codec::{Encode, Decode, Codec}; +use codec::{Encode, Decode}; use rstd::vec::Vec; use sr_primitives::{ConsensusEngineId, traits::Header}; use primitives::sr25519; diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index 9b72a292796f6..c5997d286ea87 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -20,7 +20,7 @@ std = [ "rstd/std", "client/std", "codec/std", - "sr-primitives/std" + "sr-primitives/std", "primitives/std", "serde" ] diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 92729a10fb5c8..5e10b85e86896 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -21,9 +21,6 @@ use codec::Codec; use client::decl_runtime_apis; use rstd::vec::Vec; -use parity_codec::Codec; -#[cfg(feature = "std")] -use serde::Serialize; use sr_primitives::{traits::{Header, Verify}}; use srml_session::{historical::Proof, SessionIndex}; @@ -58,9 +55,6 @@ pub trait AuthorshipEquivocationProof { /// Get the slot where the equivocation happened. fn slot(&self) -> u64; - /// Get the identity proof of the suspect of equivocating. - fn identity_proof(&self) -> &Proof; - /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index 0206be86e688b..d7537082caf2b 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -27,12 +27,10 @@ service = { package = "substrate-service", path = "../service", optional = true srml-finality-tracker = { path = "../../srml/finality-tracker" } srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec"] } -# grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } [dev-dependencies] -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec", "test-helpers"] } -# grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec", "test-helpers"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] } network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } keyring = { package = "substrate-keyring", path = "../keyring" } test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client"} diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 4091b26dd09b3..7e9e5fad5bf5a 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sr-primitives = { path = "../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", default-features = false, features = ["derive-codec"] } session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 10ae009943b3d..27f6d82819a3f 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -29,7 +29,7 @@ use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; -use parity_codec::{Encode, Decode, Codec}; +use codec::{Encode, Decode, Codec}; use babe::{AuthorityId as BabeId}; use babe_primitives::BabeEquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; From 916af40d3fc1a8ef5a6c414764d5e7c4222cbb86 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 12:22:08 +0200 Subject: [PATCH 119/191] Add small trait to transaction pool --- core/offchain/src/api.rs | 2 +- core/rpc/src/author/mod.rs | 1 + core/service/src/lib.rs | 3 ++- core/transaction-pool/graph/src/lib.rs | 2 +- core/transaction-pool/graph/src/pool.rs | 28 ++++++++++++++++++++----- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/core/offchain/src/api.rs b/core/offchain/src/api.rs index 225e7c3f725a4..aa97986f82542 100644 --- a/core/offchain/src/api.rs +++ b/core/offchain/src/api.rs @@ -32,7 +32,7 @@ use primitives::offchain::{ OpaqueNetworkState, OpaquePeerId, OpaqueMultiaddr, StorageKind, }; use sr_primitives::{generic::BlockId, traits::{self, Extrinsic}}; -use transaction_pool::txpool::{Pool, ChainApi}; +use transaction_pool::txpool::{Pool, ChainApi, SubmitExtrinsic}; /// A message between the offchain extension and the processing thread. enum ExtMessage { diff --git a/core/rpc/src/author/mod.rs b/core/rpc/src/author/mod.rs index d797e87da5776..4a1d47dee4557 100644 --- a/core/rpc/src/author/mod.rs +++ b/core/rpc/src/author/mod.rs @@ -45,6 +45,7 @@ use transaction_pool::{ IntoPoolError, Pool, watcher::Status, + SubmitExtrinsic, }, }; use session::SessionKeys; diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index dc34a488535e5..01b3aec233e9d 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -51,7 +51,8 @@ pub use self::error::Error; pub use config::{Configuration, Roles, PruningMode}; pub use chain_spec::{ChainSpec, Properties}; pub use transaction_pool::txpool::{ - self, Pool as TransactionPool, Options as TransactionPoolOptions, ChainApi, IntoPoolError + self, Pool as TransactionPool, Options as TransactionPoolOptions, ChainApi, + IntoPoolError, SubmitExtrinsic }; pub use client::FinalityNotifications; diff --git a/core/transaction-pool/graph/src/lib.rs b/core/transaction-pool/graph/src/lib.rs index ea890a5cd0f21..a66733ee42f9f 100644 --- a/core/transaction-pool/graph/src/lib.rs +++ b/core/transaction-pool/graph/src/lib.rs @@ -36,4 +36,4 @@ pub mod watcher; pub use self::error::IntoPoolError; pub use self::base_pool::{Transaction, Status}; -pub use self::pool::{Pool, Options, ChainApi, EventStream, ExtrinsicFor, BlockHash, ExHash, NumberFor, TransactionFor}; +pub use self::pool::{Pool, SubmitExtrinsic, Options, ChainApi, EventStream, ExtrinsicFor, BlockHash, ExHash, NumberFor, TransactionFor}; diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 6eec0d222f1a3..38bebdbd8d13e 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -112,6 +112,29 @@ pub struct Pool { rotator: PoolRotator>, } +/// Something that can submit an extrinsic. +pub trait SubmitExtrinsic { + /// Concrete extrinsic validation and query logic. + type Api: ChainApi; + + /// Imports one unverified extrinsic to the pool + fn submit_one( + &self, + at: &BlockId<::Block>, + xt: ExtrinsicFor, + ) -> Result, ::Error>; +} + +impl SubmitExtrinsic for Pool { + type Api = B; + + fn submit_one(&self, at: &BlockId, xt: ExtrinsicFor) -> Result, B::Error> { + Ok(self.submit_at(at, ::std::iter::once(xt))? + .pop() + .expect("One extrinsic passed; one result returned; qed")?) + } +} + impl Pool { /// Imports a bunch of unverified extrinsics to the pool pub fn submit_at(&self, at: &BlockId, xts: T) -> Result, B::Error>>, B::Error> where @@ -204,11 +227,6 @@ impl Pool { } } - /// Imports one unverified extrinsic to the pool - pub fn submit_one(&self, at: &BlockId, xt: ExtrinsicFor) -> Result, B::Error> { - Ok(self.submit_at(at, ::std::iter::once(xt))?.pop().expect("One extrinsic passed; one result returned; qed")?) - } - /// Import a single extrinsic and starts to watch their progress in the pool. pub fn submit_and_watch(&self, at: &BlockId, xt: ExtrinsicFor) -> Result, BlockHash>, B::Error> { let hash = self.api.hash_and_length(&xt).0; From 1bbd70073065412e528abff47be8400a437c93d2 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 13:16:17 +0200 Subject: [PATCH 120/191] Submit to tx pool from grandpa --- Cargo.lock | 4 ++ core/consensus/babe/primitives/src/lib.rs | 3 +- core/finality-grandpa/Cargo.toml | 1 + core/finality-grandpa/primitives/src/lib.rs | 1 - core/finality-grandpa/src/environment.rs | 62 ++++++++++++--------- core/finality-grandpa/src/lib.rs | 5 ++ node/runtime/src/lib.rs | 4 +- 7 files changed, 48 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4320dc9434fd..6700c7407eea8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4685,7 +4685,11 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", +<<<<<<< HEAD "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "substrate-transaction-pool 2.0.0", +>>>>>>> Submit to tx pool from grandpa "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index b125bdd396b71..4f85e6546963b 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -244,8 +244,7 @@ decl_runtime_apis! { /// Construct a call to report the equivocation. fn construct_equivocation_report_call( - equivocation: BabeEquivocationProof, - proof: Proof + equivocation: BabeEquivocationProof ) -> Option>; } } diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index d7537082caf2b..eee3b3e94774a 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -28,6 +28,7 @@ srml-finality-tracker = { path = "../../srml/finality-tracker" } srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } +transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } [dev-dependencies] grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] } diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index a1f205b04d5fe..94b3e4bbcd740 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -237,7 +237,6 @@ decl_runtime_apis! { /// Construct a call to report the equivocation. fn construct_equivocation_report_call( equivocation: GrandpaEquivocationFrom, - proof: Proof ) -> Option>; } } diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index cc95e28d77a07..b0386babfd35c 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -19,7 +19,7 @@ use std::iter::FromIterator; use std::sync::Arc; use std::time::{Duration, Instant}; -use log::{debug, warn, info}; +use log::{debug, warn, info, error}; use codec::{Decode, Encode}; use futures::prelude::*; use tokio_timer::Delay; @@ -27,7 +27,7 @@ use parking_lot::RwLock; use client::{ backend::Backend, BlockchainEvents, CallExecutor, Client, error::Error as ClientError, - utils::is_descendent_of, + utils::is_descendent_of, blockchain::HeaderBackend }; use grandpa::{ BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState, @@ -36,7 +36,7 @@ use grandpa::{ use primitives::{Blake2Hasher, H256, Pair}; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ - Block as BlockT, Header as HeaderT, NumberFor, One, Zero, + Block as BlockT, Header as HeaderT, NumberFor, One, Zero, ProvideRuntimeApi }; use substrate_telemetry::{telemetry, CONSENSUS_INFO}; @@ -47,12 +47,13 @@ use crate::{ use consensus_common::SelectChain; use srml_session::{historical::Proof, SessionIndex}; +use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; -use fg_primitives::{AuthorityId, AuthoritySignature, GrandpaEquivocationFrom}; +use fg_primitives::{AuthorityId, AuthoritySignature, GrandpaEquivocationFrom, GrandpaApi}; type HistoricalVotes = grandpa::HistoricalVotes< ::Hash, @@ -537,6 +538,10 @@ where RA: 'static + Send + Sync, SC: SelectChain + 'static, NumberFor: BlockNumberOps, + T: SubmitExtrinsic, + ::Api: ChainApi, + Client: HeaderBackend + ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: GrandpaApi, { type Timer = Box + Send>; type Id = AuthorityId; @@ -797,8 +802,6 @@ where } fn finalize_block(&self, hash: Block::Hash, number: NumberFor, round: u64, commit: Commit) -> Result<(), Self::Error> { - use client::blockchain::HeaderBackend; - #[allow(deprecated)] let blockchain = self.inner.backend().blockchain(); let status = blockchain.info(); @@ -852,30 +855,26 @@ where round_number: equivocation.round_number, session_index: SessionIndex::default(), // TODO: add session index. identity: equivocation.identity, - identity_proof: Proof::default(), + identity_proof: Proof::default(), // TODO: add proof. first: (first_vote, first_signature), second: (second_vote, second_signature), set_id: self.set_id, }; let block_id = BlockId::::number(self.inner.info().chain.best_number); - // let maybe_report_call = self.inner.runtime_api() - // .construct_equivocation_report_call(&block_id, grandpa_equivocation); - - // if let Ok(Some(report_call)) = maybe_report_call { - // if let Some(session_key) = self.config.local_key.clone() { - // self.transaction_pool.submit_report_call( - // self.inner.deref(), - // session_key.deref(), - // report_call.as_slice(), - // ); - // info!(target: "afg", "Equivocation report has been submitted"); - // } else { - // error!(target: "afg", "Failed to get local key for equivocation report") - // } - // } else { - // error!(target: "afg", "Failed to construct equivocation report call") - // } + let maybe_report_call = self.inner.runtime_api() + .construct_equivocation_report_call(&block_id, grandpa_equivocation); + + if let Ok(Some(report_call)) = maybe_report_call { + let uxt = Decode::decode(&mut report_call.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + match self.transaction_pool.submit_one(&block_id, uxt) { + Err(e) => warn!("Error importing misbehavior report: {:?}", e), + Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), + } + } else { + error!(target: "afg", "Failed to construct equivocation report call") + } } fn precommit_equivocation( @@ -901,8 +900,19 @@ where }; let block_id = BlockId::::number(self.inner.info().chain.best_number); - - + let maybe_report_call = self.inner.runtime_api() + .construct_equivocation_report_call(&block_id, grandpa_equivocation); + + if let Ok(Some(report_call)) = maybe_report_call { + let uxt = Decode::decode(&mut report_call.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + match self.transaction_pool.submit_one(&block_id, uxt) { + Err(e) => warn!("Error importing misbehavior report: {:?}", e), + Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), + } + } else { + error!(target: "afg", "Failed to construct equivocation report call") + } } } diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index cb1b2d2c147f3..149e3a694203d 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -72,6 +72,7 @@ use consensus_common::SelectChain; use primitives::{H256, Blake2Hasher}; use substrate_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN}; use serde_json; +use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; use srml_finality_tracker; @@ -508,6 +509,8 @@ pub fn run_grandpa_voter, N, RA, SC, X, T>( Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, RA: Send + Sync + 'static + ConstructRuntimeApi>, + T: SubmitExtrinsic, + ::Api: ChainApi, { let GrandpaParams { config, @@ -749,6 +752,8 @@ pub fn run_grandpa, N, RA, SC, X, T>( Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, RA: Send + Sync + 'static + ConstructRuntimeApi>, + T: SubmitExtrinsic, + ::Api: ChainApi, { run_grandpa_voter(grandpa_params) } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 27f6d82819a3f..510b46ce0cc87 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -554,8 +554,7 @@ impl_runtime_apis! { } fn construct_equivocation_report_call( - equivocation: GrandpaEquivocationFrom, - proof: Proof, + equivocation: GrandpaEquivocationFrom ) -> Option> { // TODO: Check proof. let grandpa_call = GrandpaCall::report_equivocation(equivocation); @@ -590,7 +589,6 @@ impl_runtime_apis! { fn construct_equivocation_report_call( equivocation: BabeEquivocationProof<::Header>, - proof: Proof, ) -> Option> { // TODO: Check proof. let babe_call = BabeCall::report_equivocation(equivocation); From 26efab0a6a6cdecc93097d5281919ea483301b17 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 13:50:50 +0200 Subject: [PATCH 121/191] Submit call from Babe --- Cargo.lock | 4 ++++ core/consensus/babe/Cargo.toml | 1 + core/consensus/babe/src/lib.rs | 35 ++++++++++++++++++++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6700c7407eea8..9ed794d17595d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4462,7 +4462,11 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", +<<<<<<< HEAD "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +======= + "substrate-transaction-pool 2.0.0", +>>>>>>> Submit call from Babe "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 9d0d557dc8fb1..413aaea3460e2 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -21,6 +21,7 @@ substrate-telemetry = { path = "../../telemetry" } keystore = { package = "substrate-keystore", path = "../../keystore" } srml-babe = { path = "../../../srml/babe" } srml-session = { path = "../../../srml/session" } +transaction_pool = { package = "substrate-transaction-pool", path = "../../transaction-pool" } client = { package = "substrate-client", path = "../../client" } uncles = { package = "substrate-consensus-uncles", path = "../uncles" } diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 807f44f5e9780..b8dedc0098d9e 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -70,6 +70,7 @@ use client::{ ProvideUncles, utils::is_descendent_of, }; +use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; use fork_tree::ForkTree; use slots::{CheckedHeader, check_equivocation}; use futures::{prelude::*, future}; @@ -458,10 +459,13 @@ fn check_header( randomness: [u8; 32], epoch_index: u64, c: (u64, u64), - _transaction_pool: Option<&T>, + transaction_pool: Option<&T>, ) -> Result, DigestItemFor)>, String> where DigestItemFor: CompatibleDigestItem, - T: Send + Sync + 'static, + C: ProvideRuntimeApi + HeaderBackend, + C::Api: BabeApi, + T: SubmitExtrinsic + Send + Sync + 'static, + ::Api: ChainApi, { trace!(target: "babe", "Checking header"); let seal = match header.digest_mut().pop() { @@ -523,6 +527,23 @@ fn check_header( equivocation_proof.first_header().hash(), equivocation_proof.second_header().hash(), ); + + // Submit a transaction reporting the equivocation. + let block_id = BlockId::number(client.info().best_number); + + let maybe_report_call = client + .runtime_api() + .construct_equivocation_report_call(&block_id, equivocation_proof); + if let Ok(Some(report_call)) = maybe_report_call { + transaction_pool.as_ref().map(|txpool| { + let uxt = Decode::decode(&mut report_call.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + txpool.submit_one(&block_id, uxt) + }); + info!(target: "afg", "Equivocation report has been submitted") + } else { + error!(target: "afg", "Error constructing equivocation report") + } } let pre_digest = CompatibleDigestItem::babe_pre_digest(pre_digest); @@ -617,9 +638,10 @@ fn median_algorithm( } impl Verifier for BabeVerifier where - C: ProvideRuntimeApi + Send + Sync + AuxStore + ProvideCache, + C: ProvideRuntimeApi + HeaderBackend + Send + Sync + AuxStore + ProvideCache, C::Api: BlockBuilderApi + BabeApi, - T: Send + Sync + 'static, + T: SubmitExtrinsic + Send + Sync + 'static, + ::Api: ChainApi, { fn verify( &mut self, @@ -1142,9 +1164,10 @@ pub fn import_queue, I, RA, PRA, T>( I::Error: Into, E: CallExecutor + Clone + Send + Sync + 'static, RA: Send + Sync + 'static, - PRA: ProvideRuntimeApi + ProvideCache + Send + Sync + AuxStore + 'static, + PRA: ProvideRuntimeApi + HeaderBackend + ProvideCache + Send + Sync + AuxStore + 'static, PRA::Api: BlockBuilderApi + BabeApi, - T: Send + Sync + 'static, + T: SubmitExtrinsic + Send + Sync + 'static, + ::Api: ChainApi, { register_babe_inherent_data_provider(&inherent_data_providers, config.get())?; initialize_authorities_cache(&*api)?; From d5ae058ecca74cf760c8449049cf3ab2ff15f583 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 19:06:01 +0200 Subject: [PATCH 122/191] Rename construct methods --- core/consensus/babe/primitives/src/lib.rs | 4 ++-- core/consensus/babe/src/lib.rs | 2 +- core/finality-grandpa/primitives/src/lib.rs | 4 ++-- core/finality-grandpa/src/environment.rs | 4 ++-- node/runtime/src/lib.rs | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 4f85e6546963b..fabc988fee725 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -242,8 +242,8 @@ decl_runtime_apis! { /// Get the current epoch data for Babe. fn epoch() -> Epoch; - /// Construct a call to report the equivocation. - fn construct_equivocation_report_call( + /// Construct a transaction to report the equivocation. + fn construct_equivocation_transaction( equivocation: BabeEquivocationProof ) -> Option>; } diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index b8dedc0098d9e..771c1e5902778 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -533,7 +533,7 @@ fn check_header( let maybe_report_call = client .runtime_api() - .construct_equivocation_report_call(&block_id, equivocation_proof); + .construct_equivocation_transaction(&block_id, equivocation_proof); if let Ok(Some(report_call)) = maybe_report_call { transaction_pool.as_ref().map(|txpool| { let uxt = Decode::decode(&mut report_call.as_slice()) diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 94b3e4bbcd740..93874516cca46 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -234,8 +234,8 @@ decl_runtime_apis! { /// is finalized by the authorities from block B-1. fn grandpa_authorities() -> Vec<(AuthorityId, AuthorityWeight)>; - /// Construct a call to report the equivocation. - fn construct_equivocation_report_call( + /// Construct a transaction to report the equivocation. + fn construct_equivocation_transaction( equivocation: GrandpaEquivocationFrom, ) -> Option>; } diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index b0386babfd35c..494bb7017f21e 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -863,7 +863,7 @@ where let block_id = BlockId::::number(self.inner.info().chain.best_number); let maybe_report_call = self.inner.runtime_api() - .construct_equivocation_report_call(&block_id, grandpa_equivocation); + .construct_equivocation_transaction(&block_id, grandpa_equivocation); if let Ok(Some(report_call)) = maybe_report_call { let uxt = Decode::decode(&mut report_call.as_slice()) @@ -901,7 +901,7 @@ where let block_id = BlockId::::number(self.inner.info().chain.best_number); let maybe_report_call = self.inner.runtime_api() - .construct_equivocation_report_call(&block_id, grandpa_equivocation); + .construct_equivocation_transaction(&block_id, grandpa_equivocation); if let Ok(Some(report_call)) = maybe_report_call { let uxt = Decode::decode(&mut report_call.as_slice()) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 510b46ce0cc87..48d36e7649940 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -553,10 +553,10 @@ impl_runtime_apis! { Grandpa::grandpa_authorities() } - fn construct_equivocation_report_call( + fn construct_equivocation_transaction( equivocation: GrandpaEquivocationFrom ) -> Option> { - // TODO: Check proof. + // TODO: Check proof and create transaction. let grandpa_call = GrandpaCall::report_equivocation(equivocation); let call = Call::Grandpa(grandpa_call); Some(call.encode()) @@ -587,10 +587,10 @@ impl_runtime_apis! { } } - fn construct_equivocation_report_call( + fn construct_equivocation_transaction( equivocation: BabeEquivocationProof<::Header>, ) -> Option> { - // TODO: Check proof. + // TODO: Check proof and construct transaction. let babe_call = BabeCall::report_equivocation(equivocation); let call = Call::Babe(babe_call); Some(call.encode()) From 405f995f31123518082eeb64dd5a276c6dcd22b4 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 7 Aug 2019 19:13:53 +0200 Subject: [PATCH 123/191] add prove --- node/runtime/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 48d36e7649940..36efdba2207c9 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -22,7 +22,10 @@ use rstd::prelude::*; use support::{ - construct_runtime, parameter_types, traits::{SplitTwoWays, Currency} + construct_runtime, parameter_types, + traits::{ + SplitTwoWays, Currency, KeyOwnerProofSystem + } }; use primitives::u32_trait::{_1, _2, _3, _4}; use node_primitives::{ @@ -30,6 +33,7 @@ use node_primitives::{ Moment, Signature, }; use codec::{Encode, Decode, Codec}; +use consensus_primitives::AuthorshipEquivocationProof; use babe::{AuthorityId as BabeId}; use babe_primitives::BabeEquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; @@ -557,6 +561,7 @@ impl_runtime_apis! { equivocation: GrandpaEquivocationFrom ) -> Option> { // TODO: Check proof and create transaction. + let proof = Historical::prove((key_types::SR25519, equivocation.identity.encode()))?; let grandpa_call = GrandpaCall::report_equivocation(equivocation); let call = Call::Grandpa(grandpa_call); Some(call.encode()) @@ -591,6 +596,7 @@ impl_runtime_apis! { equivocation: BabeEquivocationProof<::Header>, ) -> Option> { // TODO: Check proof and construct transaction. + let proof = Historical::prove((key_types::SR25519, equivocation.identity().encode()))?; let babe_call = BabeCall::report_equivocation(equivocation); let call = Call::Babe(babe_call); Some(call.encode()) From 231d1bde4d17d77da4a48fe424898045229ba634 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 8 Aug 2019 00:37:48 +0200 Subject: [PATCH 124/191] Merge master --- Cargo.lock | 153 +++++++------------ core/consensus/babe/primitives/src/digest.rs | 10 +- core/consensus/babe/primitives/src/lib.rs | 9 +- core/consensus/common/primitives/Cargo.toml | 1 + core/consensus/common/primitives/src/lib.rs | 7 +- core/consensus/slots/Cargo.toml | 1 + core/consensus/slots/src/aux_schema.rs | 25 ++- core/primitives/src/sr25519.rs | 14 -- srml/babe/Cargo.toml | 1 + srml/babe/src/lib.rs | 7 +- srml/grandpa/Cargo.toml | 1 + srml/grandpa/src/lib.rs | 7 +- 12 files changed, 88 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9ed794d17595d..abc2eba4bc641 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,7 +108,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -637,7 +637,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -669,7 +669,7 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -692,7 +692,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -703,9 +703,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -749,7 +749,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -827,7 +827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1431,7 +1431,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1654,7 +1654,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1788,7 +1788,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2058,7 +2058,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2672,7 +2672,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2826,7 +2826,7 @@ dependencies = [ "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2900,7 +2900,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3221,7 +3221,7 @@ dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3326,24 +3326,14 @@ name = "schnorrkel" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ -<<<<<<< HEAD - "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD - "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3426,7 +3416,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3552,7 +3542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3603,7 +3593,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "spin" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3623,7 +3613,7 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-test-runtime-client 2.0.0", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3654,12 +3644,8 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", @@ -3727,13 +3713,8 @@ version = "2.0.0" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3768,13 +3749,8 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3784,6 +3760,7 @@ dependencies = [ "srml-support 2.0.0", "srml-system 2.0.0", "srml-timestamp 2.0.0", + "substrate-application-crypto 2.0.0", "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common-primitives 2.0.0", "substrate-inherents 2.0.0", @@ -3954,6 +3931,7 @@ dependencies = [ "srml-session 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", + "substrate-application-crypto 2.0.0", "substrate-finality-grandpa-primitives 2.0.0", "substrate-primitives 2.0.0", ] @@ -3997,7 +3975,7 @@ name = "srml-membership" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4117,7 +4095,7 @@ dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4128,7 +4106,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4137,7 +4115,7 @@ version = "2.0.0" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4252,7 +4230,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4268,7 +4246,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4306,7 +4284,7 @@ name = "substrate-application-crypto" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4521,6 +4499,10 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", +<<<<<<< HEAD +======= + "substrate-transaction-pool 2.0.0", +>>>>>>> Merge master "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4533,11 +4515,8 @@ dependencies = [ "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", -<<<<<<< HEAD - "substrate-application-crypto 2.0.0", -======= "srml-session 2.0.0", ->>>>>>> add construct report to babe + "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common-primitives 2.0.0", "substrate-consensus-slots 2.0.0", @@ -4571,6 +4550,7 @@ dependencies = [ "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", + "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-primitives 2.0.0", ] @@ -4610,6 +4590,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "srml-session 2.0.0", + "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", "substrate-consensus-common-primitives 2.0.0", @@ -4689,11 +4670,8 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", -<<<<<<< HEAD - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -======= "substrate-transaction-pool 2.0.0", ->>>>>>> Submit to tx pool from grandpa + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4708,11 +4686,8 @@ dependencies = [ "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", -<<<<<<< HEAD - "substrate-application-crypto 2.0.0", -======= "srml-session 2.0.0", ->>>>>>> Create grandpa equivocation + "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", ] @@ -4877,13 +4852,8 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4974,13 +4944,8 @@ dependencies = [ "node-runtime 2.0.0", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -5073,13 +5038,8 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD - "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -======= "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5163,13 +5123,8 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "sr-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime 2.0.0", @@ -5243,7 +5198,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.42" +version = "0.15.43" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5258,7 +5213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5850,7 +5805,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", - "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5892,7 +5847,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5922,7 +5877,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5942,7 +5897,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6130,7 +6085,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6175,7 +6130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6235,7 +6190,7 @@ dependencies = [ "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" +"checksum cmake 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "3c84c596dcf125d6781f58e3f4254677ec2a6d8aa56e8501ac277100990b3229" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" @@ -6258,7 +6213,7 @@ dependencies = [ "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "019779982f8518304cfbabd515e77ad6372a9a28a57d22d39478164c5e2b32ee" +"checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" @@ -6536,7 +6491,7 @@ dependencies = [ "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" "checksum soketto 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db2383e992ba8ba8205cd1169cac2efdf325d3a0da465dc35f63a2074598347e" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" -"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" +"checksum spin 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbdb51a221842709c2dd65b62ad4b78289fc3e706a02c17a26104528b6aa7837" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" @@ -6551,7 +6506,7 @@ dependencies = [ "checksum substrate-wasm-builder-runner 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f52ecbff6cc3d6e5c6401828e15937b680f459d6803ce238f01fe615bc40d071" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01f40907d9ffc762709e4ff3eb4a6f6b41b650375a3f09ac92b641942b7fb082" -"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" +"checksum syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ee06ea4b620ab59a2267c6b48be16244a3389f8bfa0986bdd15c35b890b00af3" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7d12b854e48e680bf4b10856a7867e843845158fa8226e6c2f6cc38539cb01" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" diff --git a/core/consensus/babe/primitives/src/digest.rs b/core/consensus/babe/primitives/src/digest.rs index ffa4a695ebcf4..72b1e59f14119 100644 --- a/core/consensus/babe/primitives/src/digest.rs +++ b/core/consensus/babe/primitives/src/digest.rs @@ -21,7 +21,7 @@ use super::{BABE_ENGINE_ID, Epoch}; use super::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}; use super::SlotNumber; use sr_primitives::{DigestItem, generic::OpaqueDigestItemId}; -use sr_primitives::traits::{Header, DigestItemForHeader, Verify}; +use sr_primitives::traits::{Header, DigestItemForHeader}; use codec::{Decode, Encode, Codec}; #[cfg(feature = "std")] use codec::{Input, Error}; @@ -130,10 +130,10 @@ pub trait CompatibleDigestItem: Sized { fn as_babe_pre_digest(&self) -> Option; /// Construct a digest item which contains a BABE seal. - fn babe_seal(signature: S) -> Self; + fn babe_seal(signature: S) -> Self; /// If this item is a BABE signature, return the signature. - fn as_babe_seal(&self) -> Option; + fn as_babe_seal(&self) -> Option; /// If this item is a BABE epoch, return it. fn as_babe_epoch(&self) -> Option; @@ -150,11 +150,11 @@ impl CompatibleDigestItem for DigestItem where self.try_to(OpaqueDigestItemId::PreRuntime(&BABE_ENGINE_ID)) } - fn babe_seal(signature: S) -> Self { + fn babe_seal(signature: S) -> Self { DigestItem::Seal(BABE_ENGINE_ID, signature.encode()) } - fn as_babe_seal(&self) -> Option { + fn as_babe_seal(&self) -> Option { self.try_to(OpaqueDigestItemId::Seal(&BABE_ENGINE_ID)) } diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index fabc988fee725..26960baf45952 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -24,7 +24,6 @@ mod digest; use codec::{Encode, Decode}; use rstd::vec::Vec; use sr_primitives::{ConsensusEngineId, traits::Header}; -use primitives::sr25519; use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; use srml_session::{historical::Proof, SessionIndex}; @@ -50,9 +49,6 @@ pub type AuthoritySignature = app::Signature; /// the main Babe module. If that ever changes, then this must, too. pub type AuthorityId = app::Public; -/// A Babe authority signature. -pub type AuthoritySignature = sr25519::Signature; - /// The `ConsensusEngineId` of BABE. pub const BABE_ENGINE_ID: ConsensusEngineId = *b"BABE"; @@ -147,7 +143,8 @@ impl slots::SlotData for BabeConfiguration { } /// Represents an Babe equivocation proof. -#[derive(Debug, Clone, Encode, Decode, PartialEq)] +#[derive(Clone, Encode, Decode, PartialEq)] +#[cfg_attr(any(feature = "std", test), derive(Debug))] pub struct BabeEquivocationProof { identity: AuthorityId, identity_proof: Proof, @@ -164,8 +161,8 @@ where H: Header, { type Header = H; - type Signature = AuthoritySignature; type Identity = AuthorityId; + type Signature = AuthoritySignature; /// Create a new Babe equivocation proof. fn new( diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index c5997d286ea87..fc33f59d57682 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -13,6 +13,7 @@ rstd = { package = "sr-std", path = "../../../sr-std", default-features = false serde = { version = "1.0", optional = true, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } srml-session = { path = "../../../../srml/session", default-features = false } +app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } [features] default = ["std"] diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 5e10b85e86896..d8949a16531f7 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -21,8 +21,9 @@ use codec::Codec; use client::decl_runtime_apis; use rstd::vec::Vec; -use sr_primitives::{traits::{Header, Verify}}; +use sr_primitives::{traits::Header}; use srml_session::{historical::Proof, SessionIndex}; +use app_crypto::RuntimeAppPublic; decl_runtime_apis! { /// Common consensus runtime api. @@ -34,8 +35,8 @@ decl_runtime_apis! { pub trait AuthorshipEquivocationProof { type Header: Header; - type Signature: Verify; - type Identity: Codec; + type Signature: Codec; + type Identity: Codec + RuntimeAppPublic; /// Create an equivocation proof for AuRa or Babe. fn new( diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index e50576a159968..9755d151badd0 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -12,6 +12,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives" } sr-primitives = { path = "../../sr-primitives" } consensus_common = { package = "substrate-consensus-common", path = "../common" } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } +app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } inherents = { package = "substrate-inherents", path = "../../inherents" } srml-session = { path = "../../../srml/session", default-features = false } futures-preview = "0.3.0-alpha.17" diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index d38d566102cae..877445cf49488 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -20,7 +20,8 @@ use std::ops::Deref; use codec::{Encode, Decode, Codec}; use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; -use sr_primitives::traits::{Header, Verify}; +use sr_primitives::traits::Header; +use app_crypto::RuntimeAppPublic; use consensus_common_primitives::AuthorshipEquivocationProof; use srml_session::{historical::Proof, SessionIndex}; @@ -47,14 +48,6 @@ fn load_decode(backend: &C, key: &[u8]) -> ClientResult> } } -/// Represents an equivocation proof. -#[derive(Debug, Clone)] -pub struct EquivocationProof { - slot: u64, - fst_header: H, - snd_header: H, -} - /// Checks if the header is an equivocation and returns the proof in that case. /// /// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY. @@ -63,18 +56,18 @@ pub fn check_equivocation( slot_now: u64, slot: u64, header: &H, - signature: V, - signer: &V::Signer, + signature: V::Signature, + signer: &V, ) -> ClientResult> where H: Header, C: AuxStore, - V: Verify + Codec + Clone, - ::Signer: Clone + Codec + PartialEq, + V: RuntimeAppPublic + Codec + Clone + PartialEq, + ::Signature: Clone + Codec, E: AuthorshipEquivocationProof< Header=H, - Signature=V, - Identity=::Signer, + Signature=::Signature, + Identity=V, >, { // We don't check equivocations for old headers out of our capacity. @@ -87,7 +80,7 @@ pub fn check_equivocation( slot.using_encoded(|s| current_slot_key.extend(s)); // Get headers of this slot. - let mut headers_with_signature = load_decode::<_, Vec<(H, V, V::Signer)>>( + let mut headers_with_signature = load_decode::<_, Vec<(H, V::Signature, V)>>( backend.deref(), ¤t_slot_key[..], )? diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 38c23c1c6b708..0e573f49ce34c 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -136,20 +136,6 @@ impl std::fmt::Debug for Public { } } -#[cfg(not(feature = "std"))] -impl ::core::fmt::Debug for Public { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - write!(f, "") - } -} - -#[cfg(not(feature = "std"))] -impl ::core::fmt::Debug for Signature { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - write!(f, "") - } -} - #[cfg(feature = "std")] impl Serialize for Public { fn serialize(&self, serializer: S) -> Result where S: Serializer { diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index 253068c609073..2a033806336df 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -20,6 +20,7 @@ session = { package = "srml-session", path = "../session", default-features = fa consensus-common-primitives = { package = "substrate-consensus-common-primitives", path = "../../core/consensus/common/primitives", default-features = false } babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } +app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } [dev-dependencies] lazy_static = "1.3.0" diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 676845f1ff2a8..ad7898e0cb7f1 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -32,7 +32,7 @@ use srml_support::{ use timestamp::{OnTimestampSet}; use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId}; use sr_primitives::traits::{ - IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Verify, Header + IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header }; use sr_staking_primitives::{ SessionIndex, @@ -51,6 +51,7 @@ use babe_primitives::{ BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, BabeEquivocationProof, get_slot }; +use app_crypto::RuntimeAppPublic; pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; /// The BABE inherent identifier. @@ -204,10 +205,10 @@ fn equivocation_is_valid(equivocation: BabeEquivocationProof( let second_vote = &equivocation.second.0; let second_signature = &equivocation.second.1; + let identity = equivocation.identity; + if first_vote != second_vote { let first_payload = localized_payload( equivocation.round_number, @@ -169,7 +172,7 @@ fn equivocation_is_valid( &first_vote, ); - if !first_signature.verify(first_payload.as_slice(), &equivocation.identity) { + if !identity.verify(&first_payload, &first_signature) { return false } @@ -179,7 +182,7 @@ fn equivocation_is_valid( &second_vote, ); - if !second_signature.verify(second_payload.as_slice(), &equivocation.identity) { + if !identity.verify(&second_payload, &second_signature) { return false } From 41bd05ab1dabd7fc5c1b7be3b88a9b5cec489b6e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 8 Aug 2019 01:11:43 +0200 Subject: [PATCH 125/191] Get key for grandpa --- core/consensus/babe/primitives/src/lib.rs | 8 ++ core/consensus/common/primitives/src/lib.rs | 4 + core/consensus/slots/src/aux_schema.rs | 1 + core/finality-grandpa/primitives/src/lib.rs | 2 + core/finality-grandpa/src/environment.rs | 89 ++++++++++++--------- 5 files changed, 64 insertions(+), 40 deletions(-) diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 26960baf45952..6055abe2f5f40 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -146,6 +146,7 @@ impl slots::SlotData for BabeConfiguration { #[derive(Clone, Encode, Decode, PartialEq)] #[cfg_attr(any(feature = "std", test), derive(Debug))] pub struct BabeEquivocationProof { + reporter: AuthorityId, identity: AuthorityId, identity_proof: Proof, slot: u64, @@ -166,6 +167,7 @@ where /// Create a new Babe equivocation proof. fn new( + reporter: Self::Identity, identity: Self::Identity, identity_proof: Proof, slot: u64, @@ -176,6 +178,7 @@ where second_signature: Self::Signature, ) -> Self { BabeEquivocationProof { + reporter, identity, identity_proof, slot, @@ -187,6 +190,11 @@ where } } + /// Get the reporter of the equivocation. + fn reporter(&self) -> &Self::Identity { + &self.reporter + } + /// Get the slot where the equivocation happened. fn slot(&self) -> u64 { self.slot diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index d8949a16531f7..19d899f3e2532 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -40,6 +40,7 @@ pub trait AuthorshipEquivocationProof { /// Create an equivocation proof for AuRa or Babe. fn new( + reporter: Self::Identity, identity: Self::Identity, identity_proof: Proof, slot: u64, @@ -50,6 +51,9 @@ pub trait AuthorshipEquivocationProof { second_signature: Self::Signature, ) -> Self; + /// Get the reporter of the equivocation. + fn reporter(&self) -> &Self::Identity; + /// Get the session index where the equivocation happened. fn session_index(&self) -> &SessionIndex; diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 877445cf49488..25506c8852fba 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -98,6 +98,7 @@ pub fn check_equivocation( // 2) with different hash if header.hash() != prev_header.hash() { return Ok(Some(AuthorshipEquivocationProof::new( + signer.clone(), // TODO: this should be the reporter. signer.clone(), Proof::default(), // TODO: add the proof. slot, diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 93874516cca46..2ebd1780ebb9c 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -61,6 +61,8 @@ pub fn localized_payload(round: u64, set_id: u64, message: &E) -> Vec #[cfg_attr(feature = "std", derive(Debug))] #[derive(Clone, PartialEq, Eq, Encode, Decode)] pub struct GrandpaEquivocation { + /// Reporter of the equivocation. + pub reporter: AuthorityId, /// The set id. pub set_id: u64, /// The session id. diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 494bb7017f21e..e0af730826016 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -851,29 +851,34 @@ where let first_signature = equivocation.first.1; let second_signature = equivocation.second.1; - let grandpa_equivocation = GrandpaEquivocationFrom:: { - round_number: equivocation.round_number, - session_index: SessionIndex::default(), // TODO: add session index. - identity: equivocation.identity, - identity_proof: Proof::default(), // TODO: add proof. - first: (first_vote, first_signature), - second: (second_vote, second_signature), - set_id: self.set_id, - }; + if let Some(local_key) = crate::is_voter(&self.voters, &self.config.keystore) { + let reporter = local_key.public(); + + let grandpa_equivocation = GrandpaEquivocationFrom:: { + reporter, + round_number: equivocation.round_number, + session_index: SessionIndex::default(), // TODO: add session index. + identity: equivocation.identity, + identity_proof: Proof::default(), // TODO: add proof. + first: (first_vote, first_signature), + second: (second_vote, second_signature), + set_id: self.set_id, + }; - let block_id = BlockId::::number(self.inner.info().chain.best_number); - let maybe_report_call = self.inner.runtime_api() - .construct_equivocation_transaction(&block_id, grandpa_equivocation); + let block_id = BlockId::::number(self.inner.info().chain.best_number); + let maybe_report_call = self.inner.runtime_api() + .construct_equivocation_transaction(&block_id, grandpa_equivocation); - if let Ok(Some(report_call)) = maybe_report_call { - let uxt = Decode::decode(&mut report_call.as_slice()) - .expect("Encoded extrinsic is valid; qed"); - match self.transaction_pool.submit_one(&block_id, uxt) { - Err(e) => warn!("Error importing misbehavior report: {:?}", e), - Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), + if let Ok(Some(report_call)) = maybe_report_call { + let uxt = Decode::decode(&mut report_call.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + match self.transaction_pool.submit_one(&block_id, uxt) { + Err(e) => warn!("Error importing misbehavior report: {:?}", e), + Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), + } + } else { + error!(target: "afg", "Failed to construct equivocation report call") } - } else { - error!(target: "afg", "Failed to construct equivocation report call") } } @@ -889,29 +894,33 @@ where let first_signature = equivocation.first.1; let second_signature = equivocation.second.1; - let grandpa_equivocation = GrandpaEquivocationFrom:: { - round_number: equivocation.round_number, - session_index: SessionIndex::default(), // TODO: add session index. - identity: equivocation.identity, - identity_proof: Proof::default(), // TODO: add proof. - first: (first_vote, first_signature), - second: (second_vote, second_signature), - set_id: self.set_id, - }; + if let Some(local_key) = crate::is_voter(&self.voters, &self.config.keystore) { + let reporter = local_key.public(); + let grandpa_equivocation = GrandpaEquivocationFrom:: { + reporter, + round_number: equivocation.round_number, + session_index: SessionIndex::default(), // TODO: add session index. + identity: equivocation.identity, + identity_proof: Proof::default(), // TODO: add proof. + first: (first_vote, first_signature), + second: (second_vote, second_signature), + set_id: self.set_id, + }; - let block_id = BlockId::::number(self.inner.info().chain.best_number); - let maybe_report_call = self.inner.runtime_api() - .construct_equivocation_transaction(&block_id, grandpa_equivocation); + let block_id = BlockId::::number(self.inner.info().chain.best_number); + let maybe_report_call = self.inner.runtime_api() + .construct_equivocation_transaction(&block_id, grandpa_equivocation); - if let Ok(Some(report_call)) = maybe_report_call { - let uxt = Decode::decode(&mut report_call.as_slice()) - .expect("Encoded extrinsic is valid; qed"); - match self.transaction_pool.submit_one(&block_id, uxt) { - Err(e) => warn!("Error importing misbehavior report: {:?}", e), - Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), + if let Ok(Some(report_call)) = maybe_report_call { + let uxt = Decode::decode(&mut report_call.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + match self.transaction_pool.submit_one(&block_id, uxt) { + Err(e) => warn!("Error importing misbehavior report: {:?}", e), + Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), + } + } else { + error!(target: "afg", "Failed to construct equivocation report call") } - } else { - error!(target: "afg", "Failed to construct equivocation report call") } } } From e753bc6d732e3a00ce8cb958713f5303f297a0d8 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 8 Aug 2019 01:14:12 +0200 Subject: [PATCH 126/191] Remove proof from grandpa equi --- core/finality-grandpa/primitives/src/lib.rs | 2 -- core/finality-grandpa/src/environment.rs | 2 -- 2 files changed, 4 deletions(-) diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 2ebd1780ebb9c..199c7b0008170 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -71,8 +71,6 @@ pub struct GrandpaEquivocation { pub round_number: u64, /// The identity of the equivocator. pub identity: AuthorityId, - /// The proof of identity inclusion. - pub identity_proof: Proof, /// The first vote in the equivocation. pub first: (Message, AuthoritySignature), /// The second vote in the equivocation. diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index e0af730826016..ec887df702c3c 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -859,7 +859,6 @@ where round_number: equivocation.round_number, session_index: SessionIndex::default(), // TODO: add session index. identity: equivocation.identity, - identity_proof: Proof::default(), // TODO: add proof. first: (first_vote, first_signature), second: (second_vote, second_signature), set_id: self.set_id, @@ -901,7 +900,6 @@ where round_number: equivocation.round_number, session_index: SessionIndex::default(), // TODO: add session index. identity: equivocation.identity, - identity_proof: Proof::default(), // TODO: add proof. first: (first_vote, first_signature), second: (second_vote, second_signature), set_id: self.set_id, From b28d05c6ad67f902e17c14da7b2af487c7544626 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 8 Aug 2019 01:23:02 +0200 Subject: [PATCH 127/191] Add proof to report --- node/runtime/src/lib.rs | 4 ++-- srml/babe/src/lib.rs | 3 ++- srml/grandpa/src/lib.rs | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 36efdba2207c9..cd7b611bcaa51 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -562,7 +562,7 @@ impl_runtime_apis! { ) -> Option> { // TODO: Check proof and create transaction. let proof = Historical::prove((key_types::SR25519, equivocation.identity.encode()))?; - let grandpa_call = GrandpaCall::report_equivocation(equivocation); + let grandpa_call = GrandpaCall::report_equivocation(equivocation, proof); let call = Call::Grandpa(grandpa_call); Some(call.encode()) } @@ -597,7 +597,7 @@ impl_runtime_apis! { ) -> Option> { // TODO: Check proof and construct transaction. let proof = Historical::prove((key_types::SR25519, equivocation.identity().encode()))?; - let babe_call = BabeCall::report_equivocation(equivocation); + let babe_call = BabeCall::report_equivocation(equivocation, proof); let call = Call::Babe(babe_call); Some(call.encode()) } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index ad7898e0cb7f1..5731cf7596abd 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -256,7 +256,8 @@ decl_module! { fn report_equivocation( origin, - equivocation: BabeEquivocationProof + equivocation: BabeEquivocationProof, + _proof: Proof ) { let _who = ensure_signed(origin)?; diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 2eeddc21c60da..08db8f2be54ba 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -44,6 +44,7 @@ use fg_primitives::{ ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, localized_payload }; +use session::historical::Proof; pub use fg_primitives::{AuthorityId, AuthorityWeight}; use system::{ensure_signed, DigestOf}; @@ -199,7 +200,8 @@ decl_module! { /// Report some misbehavior. fn report_equivocation( origin, - equivocation: GrandpaEquivocation + equivocation: GrandpaEquivocation, + _proof: Proof ) { let _who = ensure_signed(origin)?; From 96a9ffefc9cc2143a72614dcda711771346c9751 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 10 Aug 2019 11:43:50 +0200 Subject: [PATCH 128/191] fix cargo.lock --- Cargo.lock | 644 +++++++++++++++++++++++++++-------------------------- 1 file changed, 326 insertions(+), 318 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abc2eba4bc641..4962bc498dbe2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -32,13 +32,13 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "stream-cipher 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "aho-corasick" -version = "0.7.6" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -50,7 +50,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -108,7 +108,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -132,7 +132,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "backtrace" -version = "0.3.34" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -161,7 +161,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -194,11 +194,11 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -230,7 +230,7 @@ dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -291,7 +291,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -363,8 +363,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -458,7 +458,7 @@ dependencies = [ [[package]] name = "cmake" -version = "0.1.41" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -510,8 +510,8 @@ dependencies = [ "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -620,7 +620,7 @@ dependencies = [ "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -637,7 +637,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -669,14 +669,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "1.2.3" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -692,7 +692,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -703,9 +703,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -749,7 +749,7 @@ version = "1.0.0-pre.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -775,8 +775,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -790,7 +790,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -798,7 +798,7 @@ name = "error-chain" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -816,7 +816,7 @@ name = "failure" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -827,7 +827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -851,7 +851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1080,10 +1080,10 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.1.8" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1102,11 +1102,11 @@ name = "globset" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "bstr 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1118,9 +1118,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1222,7 +1222,7 @@ dependencies = [ [[package]] name = "http" -version = "0.1.18" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1237,7 +1237,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1281,12 +1281,12 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1325,7 +1325,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1333,7 +1333,7 @@ name = "impl-serde" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1388,16 +1388,16 @@ dependencies = [ [[package]] name = "jsonrpc-client-transports" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.22.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1405,44 +1405,44 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-core-client" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-client-transports 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-derive" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-http-server" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1450,25 +1450,25 @@ dependencies = [ [[package]] name = "jsonrpc-pubsub" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-server-utils" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1477,12 +1477,12 @@ dependencies = [ [[package]] name = "jsonrpc-ws-server" -version = "12.2.0" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1539,10 +1539,10 @@ dependencies = [ "fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1555,6 +1555,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "lazycell" @@ -1627,7 +1630,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1645,7 +1648,7 @@ dependencies = [ "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1654,7 +1657,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1675,7 +1678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1706,7 +1709,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1730,7 +1733,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1754,7 +1757,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1775,7 +1778,7 @@ dependencies = [ "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1788,18 +1791,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1811,7 +1814,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1838,7 +1841,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1856,7 +1859,7 @@ dependencies = [ "js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1894,7 +1897,7 @@ dependencies = [ "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "tk-listen 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1907,7 +1910,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1933,7 +1936,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "soketto 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1950,7 +1953,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2033,12 +2036,12 @@ name = "log" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.8" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2058,7 +2061,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2106,7 +2109,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2155,7 +2158,7 @@ dependencies = [ "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2168,7 +2171,7 @@ version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2201,7 +2204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2223,7 +2226,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2263,7 +2266,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", @@ -2336,13 +2339,8 @@ name = "node-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -2356,8 +2354,8 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "substrate-rpc 2.0.0", ] @@ -2371,7 +2369,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", @@ -2415,7 +2413,7 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "node-template-runtime 2.0.0", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2443,7 +2441,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -2547,7 +2545,7 @@ dependencies = [ [[package]] name = "opaque-debug" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2611,13 +2609,12 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "4.1.4" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "bitvec 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-slice-cast 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2632,7 +2629,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2660,7 +2657,7 @@ dependencies = [ "bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec-derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2672,7 +2669,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2826,7 +2823,7 @@ dependencies = [ "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2900,7 +2897,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2922,7 +2919,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2942,9 +2939,9 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2996,7 +2993,7 @@ dependencies = [ "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3011,7 +3008,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3041,12 +3038,12 @@ name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.4.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3054,7 +3051,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3087,7 +3084,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3099,7 +3096,7 @@ dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3110,7 +3107,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3172,13 +3169,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.2.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3191,8 +3189,11 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.11" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "remove_dir_all" @@ -3209,7 +3210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3221,7 +3222,7 @@ dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "spin 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3269,7 +3270,7 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3301,7 +3302,7 @@ dependencies = [ [[package]] name = "safemem" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3326,14 +3327,14 @@ name = "schnorrkel" version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519-dalek 1.0.0-pre.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3388,7 +3389,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3403,20 +3404,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.98" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.98" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3426,7 +3427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3437,7 +3438,7 @@ dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3465,7 +3466,7 @@ dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3477,7 +3478,7 @@ dependencies = [ "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3520,7 +3521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3542,7 +3543,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3559,12 +3560,12 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3576,9 +3577,9 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3593,7 +3594,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "spin" -version = "0.5.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3613,8 +3614,8 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-test-runtime-client 2.0.0", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", - "trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3639,13 +3640,13 @@ name = "sr-primitives" version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", @@ -3688,7 +3689,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -3698,7 +3699,7 @@ name = "srml-assets" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3714,7 +3715,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3750,7 +3751,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3773,7 +3774,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3790,7 +3791,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3810,7 +3811,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-sandbox 2.0.0", @@ -3830,7 +3831,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3847,7 +3848,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3862,7 +3863,7 @@ name = "srml-example" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "srml-balances 2.0.0", @@ -3877,7 +3878,7 @@ version = "2.0.0" dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3893,7 +3894,7 @@ name = "srml-finality-tracker" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3908,7 +3909,7 @@ name = "srml-generic-asset" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3922,7 +3923,7 @@ name = "srml-grandpa" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3941,7 +3942,7 @@ name = "srml-im-online" version = "0.1.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3960,7 +3961,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3975,7 +3976,7 @@ name = "srml-membership" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3989,7 +3990,7 @@ name = "srml-metadata" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -4017,7 +4018,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -4037,7 +4038,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -4057,7 +4058,7 @@ name = "srml-sudo" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4076,7 +4077,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4095,7 +4096,7 @@ dependencies = [ "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", "srml-support-procedural-tools 2.0.0", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4106,7 +4107,7 @@ dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "srml-support-procedural-tools-derive 2.0.0", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4115,7 +4116,7 @@ version = "2.0.0" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4124,12 +4125,12 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "srml-support 2.0.0", "substrate-inherents 2.0.0", "substrate-primitives 2.0.0", - "trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4139,7 +4140,7 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4152,7 +4153,7 @@ name = "srml-timestamp" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4167,7 +4168,7 @@ name = "srml-treasury" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4230,7 +4231,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4246,7 +4247,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4284,7 +4285,7 @@ name = "substrate-application-crypto" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -4297,7 +4298,7 @@ name = "substrate-basic-authorship" version = "2.0.0" dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -4335,9 +4336,9 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4367,7 +4368,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 2.0.0", @@ -4395,7 +4396,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4418,7 +4419,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4468,7 +4469,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "merlin 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4530,7 +4531,7 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4546,7 +4547,7 @@ name = "substrate-consensus-common-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", @@ -4562,7 +4563,7 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4585,7 +4586,7 @@ version = "2.0.0" dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4622,7 +4623,7 @@ dependencies = [ "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4650,7 +4651,7 @@ dependencies = [ "fork-tree 2.0.0", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4683,7 +4684,7 @@ version = "2.0.0" dependencies = [ "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", @@ -4723,7 +4724,7 @@ dependencies = [ "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-application-crypto 2.0.0", "substrate-primitives 2.0.0", - "subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4745,14 +4746,14 @@ dependencies = [ "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4772,7 +4773,7 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4780,13 +4781,8 @@ name = "substrate-offchain" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -<<<<<<< HEAD "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ->>>>>>> Fix merge; update grandpa "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -4812,8 +4808,8 @@ dependencies = [ name = "substrate-panic-handler" version = "2.0.0" dependencies = [ - "backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4823,7 +4819,7 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4850,18 +4846,18 @@ dependencies = [ "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-serializer 2.0.0", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4872,15 +4868,15 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4901,11 +4897,11 @@ dependencies = [ name = "substrate-rpc-servers" version = "2.0.0" dependencies = [ - "jsonrpc-http-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-rpc 2.0.0", ] @@ -4925,7 +4921,7 @@ dependencies = [ name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4938,14 +4934,14 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -4967,7 +4963,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", - "sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4980,7 +4976,7 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -5006,7 +5002,7 @@ name = "substrate-state-db" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", @@ -5018,7 +5014,7 @@ version = "2.0.0" dependencies = [ "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5038,10 +5034,10 @@ dependencies = [ "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5072,10 +5068,10 @@ name = "substrate-test-runtime" version = "2.0.0" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5121,10 +5117,10 @@ dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime 2.0.0", @@ -5136,7 +5132,7 @@ version = "2.0.0" dependencies = [ "derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -5193,12 +5189,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.1.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" -version = "0.15.43" +version = "0.15.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5213,13 +5209,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sysinfo" -version = "0.9.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5322,7 +5318,7 @@ name = "tinytemplate" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5332,7 +5328,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5426,7 +5422,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5437,7 +5433,7 @@ dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5491,7 +5487,7 @@ dependencies = [ "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5526,7 +5522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5542,7 +5538,7 @@ dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5555,7 +5551,7 @@ name = "toml" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5567,7 +5563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "transaction-factory" version = "0.0.1" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-cli 2.0.0", @@ -5600,7 +5596,7 @@ dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5628,12 +5624,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trybuild" -version = "1.0.11" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5646,15 +5642,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "twox-hash" -version = "1.5.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5667,6 +5663,11 @@ name = "typenum" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ucd-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "uint" version = "0.8.0" @@ -5748,6 +5749,11 @@ dependencies = [ "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "utf8-ranges" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "vcpkg" version = "0.2.7" @@ -5763,8 +5769,8 @@ name = "vecarray" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 4.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5793,8 +5799,8 @@ name = "wabt" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5805,7 +5811,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", - "cmake 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5825,7 +5831,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5844,10 +5850,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5877,7 +5883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5894,10 +5900,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6061,7 +6067,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6085,7 +6091,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6106,7 +6112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "nohash-hasher 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6117,20 +6123,20 @@ dependencies = [ [[package]] name = "zeroize" -version = "0.9.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zeroize_derive" -version = "0.9.3" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6139,7 +6145,7 @@ dependencies = [ "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +"checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" "checksum aio-limited 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f10b352bc3fc08ae24dc5d2d3ddcac153678533986122dc283d747b12071000" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" @@ -6151,7 +6157,7 @@ dependencies = [ "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" -"checksum backtrace 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)" = "b5164d292487f037ece34ec0de2fcede2faa162f085dd96d2385ab81b12765ba" +"checksum backtrace 0.3.33 (registry+https://github.com/rust-lang/crates.io-index)" = "88fb679bc9af8fa639198790a77f52d345fe13656c08b43afa9424c206b731c6" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" @@ -6190,7 +6196,7 @@ dependencies = [ "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum cmake 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "3c84c596dcf125d6781f58e3f4254677ec2a6d8aa56e8501ac277100990b3229" +"checksum cmake 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "2ca4386c8954b76a8415b63959337d940d724b336cabd3afe189c2b51a7e1ff0" "checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e" "checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" @@ -6213,7 +6219,7 @@ dependencies = [ "checksum ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" "checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" -"checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +"checksum curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5d4b820e8711c211745880150f5fac78ab07d6e3851d8ce9f5a02cedc199174c" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d944ac6003ed268757ef1ee686753b57efc5fcf0ebe7b64c9fc81e7e32ff839" "checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" @@ -6260,7 +6266,7 @@ dependencies = [ "checksum generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fceb69994e330afed50c93524be68c42fa898c2d9fd4ee8da03bd7363acd26f2" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" "checksum get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0d04f9fb746cf36b191c00f3ede8bde9c8e64f9f4b05ae2694a9ccf5e3f5ab48" -"checksum getrandom 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "34f33de6f0ae7c9cb5e574502a562e2b512799e32abb801cd1e79ad952b62b49" +"checksum getrandom 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e65cce4e5084b14874c4e7097f38cab54f47ee554f9194673456ea379dcc4c55" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" @@ -6277,7 +6283,7 @@ dependencies = [ "checksum hmac 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a13f4163aa0c5ca1be584aace0e2212b2e41be5478218d4f657f5f778b2ae2a" "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum hmac-drbg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4fe727d41d2eec0a6574d887914347e5ff96a3b87177817e2a9820c5c87fecc2" -"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4" +"checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca7e5f2e110db35f93b837c81797f3714500b81d517bf20c431b16d3ca4f114" @@ -6295,14 +6301,14 @@ dependencies = [ "checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum js-sys 0.3.25 (registry+https://github.com/rust-lang/crates.io-index)" = "da3ea71161651a4cd97d999b2da139109c537b15ab33abc8ae4ead38deac8a03" -"checksum jsonrpc-client-transports 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "903004abf8bfea78499516b80736783ad8d2d2112e3a3dfb389ff2fbb1fa3ab6" -"checksum jsonrpc-core 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8df63798dccd2fc909485cc7a8979ab79f398a7cf788e552e17537e06f85d8e" -"checksum jsonrpc-core-client 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f07193b79d586728f14e52832bfd7650b68c8340a71c6088e346cf42161136f" -"checksum jsonrpc-derive 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9dd82265c34ad1be0d87239b24404160f04ae58c3ad335395822a860c8fe8153" -"checksum jsonrpc-http-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "99c3f43b5f7d2eb010f56354b0dbfb2427491dadc11d1abaf0c4baa329abc507" -"checksum jsonrpc-pubsub 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3062b654749ce3a58b765297a4836d2710fc667877c47b5269d5a92afb9a191" -"checksum jsonrpc-server-utils 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d6820ccc63886731f5cca989082f7ed4238e6e124e1143a477bbc9b58e4b4aa" -"checksum jsonrpc-ws-server 12.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45bf96f95892eac61c15280c07e380a9fd24bef6c5e3e87b7764208b74585e77" +"checksum jsonrpc-client-transports 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6be24a8de4ced80f6fd8b6ace54aa610823a7642976a0e8e00e3bb2f4d8c33f0" +"checksum jsonrpc-core 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0216cf4c95fb373d89c63572672097b8aa74cfcdd77054accbf545d840be5bd7" +"checksum jsonrpc-core-client 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1603b6cc05060de7794c2962edd705e1ad2698bd2b0d2ddd4489f8c85df122b7" +"checksum jsonrpc-derive 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8afff172177878850d133ccdcd93cad794e85d7779ab334998d669ef80e13180" +"checksum jsonrpc-http-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a24e140242e0d2e9a694cf8db513a2bd739d24c392e0ad15e0d6d7ee8851e3a2" +"checksum jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c45f7cdb1bb28a3bfb3a0a5184bf99669c9ffe8cf8d7b8a582f2a52bf9944a" +"checksum jsonrpc-server-utils 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7aac8e0029d19582b68c9fd498d18bdcf0846612c968acc93b6e5ae67eea4e0" +"checksum jsonrpc-ws-server 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "698fee4fcaf09a5927b7e39dd8a8136a102b343cebacaa351fc4def01a050a5b" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bf18164fd7ce989041f8fc4a1ae72a8bd1bec3575f2aeaf1d4968fc053aabef" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -6344,7 +6350,7 @@ dependencies = [ "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" "checksum malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "35adee9ed962cf7d07d62cb58bc45029f3227f5b5b86246caa8632f06c187bc3" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" @@ -6376,7 +6382,7 @@ dependencies = [ "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" -"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum opaque-debug 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "93f5bb2e8e8dec81642920ccff6b61f1eb94fa3020c5a325c9851ff604152409" "checksum openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)" = "8152bb5a9b5b721538462336e3bef9a539f892715e5037fda0f984577311af15" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" "checksum openssl-sys 0.9.48 (registry+https://github.com/rust-lang/crates.io-index)" = "b5ba300217253bcc5dc68bed23d782affa45000193866e025329aa8a7a9f05b8" @@ -6384,7 +6390,7 @@ dependencies = [ "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" -"checksum parity-codec 4.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7c1a0e8c54ce49245caa93c1a4e11dc4da1d1e9cc8649ff30e57aa177d4abd55" +"checksum parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2900f06356edf90de66a2922db622b36178dca71e85625eae58d0d9cc6cff2ac" "checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" "checksum parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "00fd14ff806ad82cea9a8f909bb116443d92efda7c9acd4502690af64741ad81" @@ -6429,7 +6435,7 @@ dependencies = [ "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" "checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" "checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" "checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" "checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" "checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" @@ -6444,9 +6450,9 @@ dependencies = [ "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d813022b2e00774a48eaf43caaa3c20b45f040ba8cbf398e2e8911a06668dbe6" -"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" +"checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" -"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" +"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36542aafc2429a4c010fafa079a20dee953b663cb2427f51d86cf1d436846b4d" "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" @@ -6459,7 +6465,7 @@ dependencies = [ "checksum rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9cbe61c20455d3015b2bb7be39e1872310283b8e5a52f5b242b0ac7581fe78" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum safemem 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e133ccc4f4d1cd4f89cc8a7ff618287d56dc7f638b8e38fc32c5fdcadc339dd5" +"checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" "checksum schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "77e8d6a92f49a53f21b71c090a5559bf45c469071ebe556aebaf2dca3abc5cb5" @@ -6472,8 +6478,8 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "7fe5626ac617da2f2d9c48af5515a21d5a480dbd151e01bb1c355e26a3e68113" -"checksum serde_derive 1.0.98 (registry+https://github.com/rust-lang/crates.io-index)" = "01e69e1b8a631f245467ee275b8c757b818653c6d704cdbcaeb56b56767b529c" +"checksum serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "d46b3dfedb19360a74316866cef04687cd4d6a70df8e6a506c63512790769b72" +"checksum serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)" = "c22a0820adfe2f257b098714323563dd06426502abbbce4f51b72ef544c5027f" "checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" @@ -6491,7 +6497,7 @@ dependencies = [ "checksum snow 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5a64f02fd208ef15bd2d1a65861df4707e416151e1272d02c8faafad1c138100" "checksum soketto 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db2383e992ba8ba8205cd1169cac2efdf325d3a0da465dc35f63a2074598347e" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" -"checksum spin 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbdb51a221842709c2dd65b62ad4b78289fc3e706a02c17a26104528b6aa7837" +"checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum static_slice 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "92a7e0c5e3dfb52e8fbe0e63a1b947bbb17b4036408b151353c4491374931362" @@ -6505,10 +6511,10 @@ dependencies = [ "checksum substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" "checksum substrate-wasm-builder-runner 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f52ecbff6cc3d6e5c6401828e15937b680f459d6803ce238f01fe615bc40d071" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01f40907d9ffc762709e4ff3eb4a6f6b41b650375a3f09ac92b641942b7fb082" -"checksum syn 0.15.43 (registry+https://github.com/rust-lang/crates.io-index)" = "ee06ea4b620ab59a2267c6b48be16244a3389f8bfa0986bdd15c35b890b00af3" +"checksum subtle 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "01dca13cf6c3b179864ab3292bd794e757618d35a7766b7c46050c614ba00829" +"checksum syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)" = "eadc09306ca51a40555dd6fc2b415538e9e18bc9f870e47b1a524a79fe2dcf5e" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" -"checksum sysinfo 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7d12b854e48e680bf4b10856a7867e843845158fa8226e6c2f6cc38539cb01" +"checksum sysinfo 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c3e2cab189e59f72710e3dd5e1e0d5be0f6c5c999c326f2fdcdf3bf4483ec9fd" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" @@ -6545,11 +6551,12 @@ dependencies = [ "checksum trie-root 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b0eaa64e50d686c89e6d4817ed33cb18cfa249e9071b7918b18ecfacc7867" "checksum trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "64fda153c00484d640bc91334624be22ead0e5baca917d9fd53ff29bdebcf9b2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" -"checksum trybuild 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c718030bb5c88b65994c4200d929d10628d653c7798a35012f8ff4c4211624a8" +"checksum trybuild 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f2e8e773ac21d176ee05243456b9f1a942cd1a586dab188ced05b8e8d58dc635" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" -"checksum twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" +"checksum twox-hash 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7834480552ffc48e1930ceddd701f47d2234319d80b7bcbbe2fe7202933c101" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum uint 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5375d2c574f89adad4108ad525c93e39669853a602560bf5ed4ca9943b10799" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a84e5511b2a947f3ae965dcb29b13b7b1691b6e7332cf5dbc1744138d5acb7f6" @@ -6561,6 +6568,7 @@ dependencies = [ "checksum unsigned-varint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2c64cdf40b4a9645534a943668681bcb219faf51874d4b65d2e0abda1b10a2ab" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +"checksum utf8-ranges 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d50aa7650df78abf942826607c62468ce18d9019673d4a2ebe1865dbb96ffde" "checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d68a73b7d7d950c6558b6009e9fba229fb67562bda9fd02198f614f4ecf83f" @@ -6600,5 +6608,5 @@ dependencies = [ "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992" "checksum yamux 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "01bd67889938c48f0049fc60a77341039e6c3eaf16cb7693e6ead7c0ba701295" -"checksum zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" -"checksum zeroize_derive 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "080616bd0e31f36095288bb0acdf1f78ef02c2fa15527d7e993f2a6c7591643e" +"checksum zeroize 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4177936c03b5a349c1b8e4509c46add268e66bc66fe92663729fa0570fe4f213" +"checksum zeroize_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "afd1469e4bbca3b96606d26ba6e9bd6d3aed3b1299c82b92ec94377d22d78dbc" From a51ef4b36716533c14ba0f925e856dcd398e8a5a Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 12 Aug 2019 11:04:43 +0200 Subject: [PATCH 129/191] Add ValidateUnsigned to babe --- srml/babe/src/lib.rs | 48 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 5731cf7596abd..eb53259adbfd3 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -27,12 +27,16 @@ pub use timestamp; use rstd::{result, prelude::*}; use srml_support::{ decl_storage, decl_module, StorageValue, StorageMap, - traits::{FindAuthor, Get, KeyOwnerProofSystem} + traits::{FindAuthor, Get, KeyOwnerProofSystem}, }; use timestamp::{OnTimestampSet}; -use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId}; +use sr_primitives::{ + generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId, + transaction_validity::{TransactionValidity, ValidTransaction}, +}; use sr_primitives::traits::{ - IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header + IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header, + ValidateUnsigned }; use sr_staking_primitives::{ SessionIndex, @@ -185,7 +189,32 @@ decl_storage! { } } -fn equivocation_is_valid(equivocation: BabeEquivocationProof) -> bool { +impl ValidateUnsigned for Module where T: Trait +{ + type Call = Call; + + fn validate_unsigned(call: &Self::Call) -> TransactionValidity { + match call { + Call::report_equivocation(equivocation, _proof) + if equivocation_is_valid::(equivocation) => { + return TransactionValidity::Valid( + ValidTransaction { + priority: 0, + requires: vec![], + provides: vec![], + longevity: 18446744073709551615, + propagate: true, + } + ) + }, + _ => TransactionValidity::Invalid(0), + } + } +} + +fn equivocation_is_valid( + equivocation: &BabeEquivocationProof, +) -> bool { let first_header = equivocation.first_header(); let second_header = equivocation.second_header(); @@ -257,12 +286,15 @@ decl_module! { fn report_equivocation( origin, equivocation: BabeEquivocationProof, - _proof: Proof + proof: Proof ) { let _who = ensure_signed(origin)?; - - if equivocation_is_valid::(equivocation) { - // TODO: Slash `to_punish` and reward `who`. + let to_punish = ::KeyOwnerSystem::check_proof( + (key_types::SR25519, equivocation.identity().encode()), + proof.clone(), + ); + if to_punish.is_some() { + // TODO: Slash. } } } From 5a2efb987343cb430c4cc00d3f3281881c4934f7 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 12 Aug 2019 11:37:44 +0200 Subject: [PATCH 130/191] Sign babe tx --- Cargo.lock | 1 + node/runtime/Cargo.toml | 1 + node/runtime/src/lib.rs | 9 +++++++-- srml/babe/src/lib.rs | 20 +++++++++++++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4962bc498dbe2..dc027b27d8492 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2395,6 +2395,7 @@ dependencies = [ "srml-system 2.0.0", "srml-timestamp 2.0.0", "srml-treasury 2.0.0", + "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common-primitives 2.0.0", diff --git a/node/runtime/Cargo.toml b/node/runtime/Cargo.toml index 188d0c6f97180..1a26d63ed50f2 100644 --- a/node/runtime/Cargo.toml +++ b/node/runtime/Cargo.toml @@ -44,6 +44,7 @@ rustc-hex = { version = "2.0", optional = true } serde = { version = "1.0", optional = true } substrate-keyring = { path = "../../core/keyring", optional = true } substrate-session = { path = "../../core/session", default-features = false } +app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.2", path = "../../core/utils/wasm-builder-runner" } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index cd7b611bcaa51..9a844655573fb 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -28,6 +28,7 @@ use support::{ } }; use primitives::u32_trait::{_1, _2, _3, _4}; +use app_crypto::RuntimeAppPublic; use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, @@ -597,9 +598,13 @@ impl_runtime_apis! { ) -> Option> { // TODO: Check proof and construct transaction. let proof = Historical::prove((key_types::SR25519, equivocation.identity().encode()))?; - let babe_call = BabeCall::report_equivocation(equivocation, proof); + let reporter = equivocation.reporter(); + let signature = reporter.sign(&(equivocation.clone(), proof.clone()).encode()) + .expect("FIXME"); + let babe_call = BabeCall::report_equivocation(equivocation, proof, signature); let call = Call::Babe(babe_call); - Some(call.encode()) + let ex = UncheckedExtrinsic::new_unsigned(call.into()); + Some(ex.encode()) } } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index eb53259adbfd3..274d4b76ba7ed 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -195,8 +195,8 @@ impl ValidateUnsigned for Module where T: Trait fn validate_unsigned(call: &Self::Call) -> TransactionValidity { match call { - Call::report_equivocation(equivocation, _proof) - if equivocation_is_valid::(equivocation) => { + Call::report_equivocation(equivocation, proof, signature) + if equivocation_is_valid::(equivocation, proof, signature) => { return TransactionValidity::Valid( ValidTransaction { priority: 0, @@ -214,7 +214,20 @@ impl ValidateUnsigned for Module where T: Trait fn equivocation_is_valid( equivocation: &BabeEquivocationProof, + proof: &Proof, + signature: &AuthoritySignature, ) -> bool { + let signed = (equivocation, proof); + let reporter = equivocation.reporter(); + + let signature_valid = signed.using_encoded(|signed| { + reporter.verify(&signed, &signature) + }); + + if !signature_valid { + return false + } + let first_header = equivocation.first_header(); let second_header = equivocation.second_header(); @@ -286,7 +299,8 @@ decl_module! { fn report_equivocation( origin, equivocation: BabeEquivocationProof, - proof: Proof + proof: Proof, + _signature: AuthoritySignature ) { let _who = ensure_signed(origin)?; let to_punish = ::KeyOwnerSystem::check_proof( From fa9573030839c9135118b2523854cbbf745c2c6d Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 12 Aug 2019 11:56:49 +0200 Subject: [PATCH 131/191] Sign grandpa tx, grandpa unsigned --- node/runtime/src/lib.rs | 15 ++++++---- srml/grandpa/src/lib.rs | 65 ++++++++++++++++++++++++++++++++++------- 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 9a844655573fb..d525e96b5b5da 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -33,7 +33,7 @@ use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; -use codec::{Encode, Decode, Codec}; +use codec::{Encode}; use consensus_primitives::AuthorshipEquivocationProof; use babe::{AuthorityId as BabeId}; use babe_primitives::BabeEquivocationProof; @@ -56,7 +56,7 @@ use primitives::OpaqueMetadata; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use im_online::{AuthorityId as ImOnlineId}; use finality_tracker::{DEFAULT_REPORT_LATENCY, DEFAULT_WINDOW_SIZE}; -use session::historical::{self, Proof}; +use session::historical; #[cfg(any(feature = "std", test))] pub use sr_primitives::BuildStorage; @@ -418,6 +418,7 @@ impl offences::Trait for Runtime { impl grandpa::Trait for Runtime { type Event = Event; + type KeyOwnerSystem = Historical; } parameter_types! { @@ -561,11 +562,14 @@ impl_runtime_apis! { fn construct_equivocation_transaction( equivocation: GrandpaEquivocationFrom ) -> Option> { - // TODO: Check proof and create transaction. let proof = Historical::prove((key_types::SR25519, equivocation.identity.encode()))?; - let grandpa_call = GrandpaCall::report_equivocation(equivocation, proof); + let signing = (equivocation.clone(), proof.clone()); + let reporter = &equivocation.reporter; + let signature = reporter.sign(&signing.encode()).expect("FIXME"); + let grandpa_call = GrandpaCall::report_equivocation(equivocation, proof, signature); let call = Call::Grandpa(grandpa_call); - Some(call.encode()) + let ex = UncheckedExtrinsic::new_unsigned(call.into()); + Some(ex.encode()) } } @@ -596,7 +600,6 @@ impl_runtime_apis! { fn construct_equivocation_transaction( equivocation: BabeEquivocationProof<::Header>, ) -> Option> { - // TODO: Check proof and construct transaction. let proof = Historical::prove((key_types::SR25519, equivocation.identity().encode()))?; let reporter = equivocation.reporter(); let signature = reporter.sign(&(equivocation.clone(), proof.clone()).encode()) diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 08db8f2be54ba..d45f6f3226aee 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -33,11 +33,14 @@ pub use substrate_finality_grandpa_primitives as fg_primitives; use rstd::prelude::*; use codec::{self as codec, Encode, Decode, Error, Codec}; use srml_support::{ - decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue + decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue, + traits::KeyOwnerProofSystem }; use app_crypto::RuntimeAppPublic; use sr_primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, traits::{Zero, Verify}, Perbill + generic::{DigestItem, OpaqueDigestItemId}, Perbill, key_types, KeyTypeId, + transaction_validity::{TransactionValidity, ValidTransaction}, + traits::{Zero, ValidateUnsigned} }; use sr_staking_primitives::{SessionIndex, offence::{TimeSlot, Offence, Kind}}; use fg_primitives::{ @@ -45,7 +48,7 @@ use fg_primitives::{ localized_payload }; use session::historical::Proof; -pub use fg_primitives::{AuthorityId, AuthorityWeight}; +pub use fg_primitives::{AuthorityId, AuthorityWeight, AuthoritySignature}; use system::{ensure_signed, DigestOf}; mod mock; @@ -54,6 +57,7 @@ mod tests; pub trait Trait: system::Trait { /// The event type of this module. type Event: From + Into<::Event>; + type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; } /// A stored pending change, old format. @@ -155,16 +159,53 @@ decl_storage! { } } +impl ValidateUnsigned for Module where T: Trait +{ + type Call = Call; + + fn validate_unsigned(call: &Self::Call) -> TransactionValidity { + match call { + Call::report_equivocation(equivocation, proof, signature) + if equivocation_is_valid::(equivocation, proof, signature) => { + return TransactionValidity::Valid( + ValidTransaction { + priority: 0, + requires: vec![], + provides: vec![], + longevity: 18446744073709551615, + propagate: true, + } + ) + }, + _ => TransactionValidity::Invalid(0), + } + } +} + fn equivocation_is_valid( - equivocation: GrandpaEquivocation + equivocation: &GrandpaEquivocation, + proof: &Proof, + signature: &AuthoritySignature ) -> bool { + + let signed = (equivocation, proof); + let reporter = &equivocation.reporter; + + let signature_valid = signed.using_encoded(|signed| { + reporter.verify(&signed, &signature) + }); + + if !signature_valid { + return false + } + let first_vote = &equivocation.first.0; let first_signature = &equivocation.first.1; let second_vote = &equivocation.second.0; let second_signature = &equivocation.second.1; - let identity = equivocation.identity; + let identity = &equivocation.identity; if first_vote != second_vote { let first_payload = localized_payload( @@ -201,15 +242,17 @@ decl_module! { fn report_equivocation( origin, equivocation: GrandpaEquivocation, - _proof: Proof + proof: Proof, + _signature: AuthoritySignature ) { let _who = ensure_signed(origin)?; - - if equivocation_is_valid(equivocation) { - // slash + let to_punish = ::KeyOwnerSystem::check_proof( + (key_types::SR25519, equivocation.identity.encode()), + proof.clone(), + ); + if to_punish.is_some() { + // TODO: Slash. } - - // FIXME: https://github.com/paritytech/substrate/issues/1112 } fn on_finalize(block_number: T::BlockNumber) { From f29ddec0b784581dc85601d208e938da68329412 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 12 Aug 2019 16:40:15 +0200 Subject: [PATCH 132/191] submit tx works --- Cargo.lock | 6 +- core/consensus/babe/src/lib.rs | 10 +- core/consensus/slots/src/aux_schema.rs | 112 ++++++++++---------- core/consensus/slots/src/lib.rs | 4 +- core/finality-grandpa/Cargo.toml | 4 +- core/finality-grandpa/primitives/Cargo.toml | 2 +- core/finality-grandpa/src/environment.rs | 2 +- node/runtime/src/lib.rs | 32 ++++-- srml/babe/src/lib.rs | 27 ++--- srml/grandpa/src/lib.rs | 30 +++--- 10 files changed, 123 insertions(+), 106 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc027b27d8492..9acc7fd7d74fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -847,7 +847,6 @@ dependencies = [ [[package]] name = "finality-grandpa" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4648,7 +4647,7 @@ name = "substrate-finality-grandpa" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "finality-grandpa 0.9.0", "fork-tree 2.0.0", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4683,7 +4682,7 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "2.0.0" dependencies = [ - "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "finality-grandpa 0.9.0", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -6241,7 +6240,6 @@ dependencies = [ "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" -"checksum finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9681c1f75941ea47584573dd2bc10558b2067d460612945887e00744e43393be" "checksum fixed-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 771c1e5902778..33ddb9edf6fac 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -531,18 +531,18 @@ fn check_header( // Submit a transaction reporting the equivocation. let block_id = BlockId::number(client.info().best_number); - let maybe_report_call = client + let maybe_report_tx = client .runtime_api() .construct_equivocation_transaction(&block_id, equivocation_proof); - if let Ok(Some(report_call)) = maybe_report_call { + if let Ok(Some(report_tx)) = maybe_report_tx { transaction_pool.as_ref().map(|txpool| { - let uxt = Decode::decode(&mut report_call.as_slice()) + let uxt = Decode::decode(&mut report_tx.as_slice()) .expect("Encoded extrinsic is valid; qed"); txpool.submit_one(&block_id, uxt) }); - info!(target: "afg", "Equivocation report has been submitted") + info!(target: "afg", "Babe equivocation report has been submitted") } else { - error!(target: "afg", "Error constructing equivocation report") + error!(target: "afg", "Error constructing Babe equivocation report") } } diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 25506c8852fba..490e1b341c0b6 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -71,75 +71,75 @@ pub fn check_equivocation( >, { // We don't check equivocations for old headers out of our capacity. - if slot_now - slot > MAX_SLOT_CAPACITY { - return Ok(None) - } + // if slot_now - slot > MAX_SLOT_CAPACITY { + // return Ok(None) + // } // Key for this slot. - let mut current_slot_key = SLOT_HEADER_MAP_KEY.to_vec(); - slot.using_encoded(|s| current_slot_key.extend(s)); + // let mut current_slot_key = SLOT_HEADER_MAP_KEY.to_vec(); + // slot.using_encoded(|s| current_slot_key.extend(s)); // Get headers of this slot. - let mut headers_with_signature = load_decode::<_, Vec<(H, V::Signature, V)>>( - backend.deref(), - ¤t_slot_key[..], - )? - .unwrap_or_else(Vec::new); + // let mut headers_with_signature = load_decode::<_, Vec<(H, V::Signature, V)>>( + // backend.deref(), + // ¤t_slot_key[..], + // )? + // .unwrap_or_else(Vec::new); // Get first slot saved. - let slot_header_start = SLOT_HEADER_START.to_vec(); - let first_saved_slot = load_decode::<_, u64>(backend, &slot_header_start[..])? - .unwrap_or(slot); + // let slot_header_start = SLOT_HEADER_START.to_vec(); + // let first_saved_slot = load_decode::<_, u64>(backend, &slot_header_start[..])? + // .unwrap_or(slot); - for (prev_header, prev_signature, prev_signer) in headers_with_signature.iter() { + // for (prev_header, prev_signature, prev_signer) in headers_with_signature.iter() { // A proof of equivocation consists of two headers: // 1) signed by the same voter, - if prev_signer == signer { + // if prev_signer == signer { // 2) with different hash - if header.hash() != prev_header.hash() { - return Ok(Some(AuthorshipEquivocationProof::new( - signer.clone(), // TODO: this should be the reporter. - signer.clone(), - Proof::default(), // TODO: add the proof. - slot, - SessionIndex::default(), // TODO: add session index. - prev_header.clone(), - header.clone(), - prev_signature.clone(), - signature.clone(), - ))); - } else { + // if header.hash() != prev_header.hash() { + // return Ok(Some(AuthorshipEquivocationProof::new( + // signer.clone(), // TODO: this should be the reporter. + // signer.clone(), + // Proof::default(), // TODO: add the proof. + // slot, + // SessionIndex::default(), // TODO: add session index. + // header.clone(), + // header.clone(), + // signature.clone(), + // signature.clone(), + // ))); + // } else { // We don't need to continue in case of duplicated header, // since it's already saved and a possible equivocation // would have been detected before. - return Ok(None) - } - } - } - - let mut keys_to_delete = vec![]; - let mut new_first_saved_slot = first_saved_slot; - - if slot_now - first_saved_slot >= PRUNING_BOUND { - let prefix = SLOT_HEADER_MAP_KEY.to_vec(); - new_first_saved_slot = slot_now.saturating_sub(MAX_SLOT_CAPACITY); - - for s in first_saved_slot..new_first_saved_slot { - let mut p = prefix.clone(); - s.using_encoded(|s| p.extend(s)); - keys_to_delete.push(p); - } - } - - headers_with_signature.push((header.clone(), signature.clone(), signer.clone())); - - backend.insert_aux( - &[ - (¤t_slot_key[..], headers_with_signature.encode().as_slice()), - (&slot_header_start[..], new_first_saved_slot.encode().as_slice()), - ], - &keys_to_delete.iter().map(|k| &k[..]).collect::>()[..], - )?; + // return Ok(None) + // } + // } + // } + + // let mut keys_to_delete = vec![]; + // let mut new_first_saved_slot = first_saved_slot; + + // if slot_now - first_saved_slot >= PRUNING_BOUND { + // let prefix = SLOT_HEADER_MAP_KEY.to_vec(); + // new_first_saved_slot = slot_now.saturating_sub(MAX_SLOT_CAPACITY); + + // for s in first_saved_slot..new_first_saved_slot { + // let mut p = prefix.clone(); + // s.using_encoded(|s| p.extend(s)); + // keys_to_delete.push(p); + // } + // } + + // headers_with_signature.push((header.clone(), signature.clone(), signer.clone())); + + // backend.insert_aux( + // &[ + // (¤t_slot_key[..], headers_with_signature.encode().as_slice()), + // (&slot_header_start[..], new_first_saved_slot.encode().as_slice()), + // ], + // &keys_to_delete.iter().map(|k| &k[..]).collect::>()[..], + // )?; Ok(None) } diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index fc0134f746af7..6a1f474e39957 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -20,8 +20,8 @@ //! time during which certain events can and/or must occur. This crate //! provides generic functionality for slots. -#![deny(warnings)] -#![forbid(unsafe_code, missing_docs)] +// #![deny(warnings)] +// #![forbid(unsafe_code, missing_docs)] mod slots; mod aux_schema; diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index eee3b3e94774a..81361e52928c4 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -27,11 +27,11 @@ service = { package = "substrate-service", path = "../service", optional = true srml-finality-tracker = { path = "../../srml/finality-tracker" } srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } -grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec"] } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } [dev-dependencies] -grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec", "test-helpers"] } network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } keyring = { package = "substrate-keyring", path = "../keyring" } test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client"} diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 7e9e5fad5bf5a..4091b26dd09b3 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sr-primitives = { path = "../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", version = "0.9.0", default-features = false, features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index ec887df702c3c..92f71b45e095f 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -530,7 +530,7 @@ impl, N, RA, SC, T> voter::Environment> for Environment where - Block: 'static, + Block: 'static + Encode + Decode, B: Backend + 'static, E: CallExecutor + 'static + Send + Sync, N: Network + 'static + Send, diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index d525e96b5b5da..b410aa849d9d2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -52,7 +52,7 @@ use version::RuntimeVersion; use elections::VoteIndex; #[cfg(any(feature = "std", test))] use version::NativeVersion; -use primitives::OpaqueMetadata; +use primitives::{OpaqueMetadata, blake2_256}; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use im_online::{AuthorityId as ImOnlineId}; use finality_tracker::{DEFAULT_REPORT_LATENCY, DEFAULT_WINDOW_SIZE}; @@ -439,7 +439,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Storage, Config, Event}, - Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, + Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp), ValidateUnsigned}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, Authorship: authorship::{Module, Call, Storage, Inherent}, Indices: indices, @@ -453,7 +453,7 @@ construct_runtime!( Elections: elections::{Module, Call, Storage, Event, Config}, TechnicalMembership: membership::::{Module, Call, Storage, Event, Config}, FinalityTracker: finality_tracker::{Module, Call, Inherent}, - Grandpa: grandpa::{Module, Call, Storage, Config, Event}, + Grandpa: grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned}, Treasury: treasury::{Module, Call, Storage, Event}, Contracts: contracts, Sudo: sudo, @@ -562,13 +562,20 @@ impl_runtime_apis! { fn construct_equivocation_transaction( equivocation: GrandpaEquivocationFrom ) -> Option> { - let proof = Historical::prove((key_types::SR25519, equivocation.identity.encode()))?; - let signing = (equivocation.clone(), proof.clone()); + let proof = Historical::prove((key_types::GRANDPA, equivocation.identity.encode()))?; let reporter = &equivocation.reporter; - let signature = reporter.sign(&signing.encode()).expect("FIXME"); + let to_sign = (equivocation.clone(), proof.clone()); + + let signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + reporter.sign(&blake2_256(payload)) + } else { + reporter.sign(&payload) + }).expect("FIXME"); + let grandpa_call = GrandpaCall::report_equivocation(equivocation, proof, signature); let call = Call::Grandpa(grandpa_call); let ex = UncheckedExtrinsic::new_unsigned(call.into()); + Some(ex.encode()) } } @@ -600,13 +607,20 @@ impl_runtime_apis! { fn construct_equivocation_transaction( equivocation: BabeEquivocationProof<::Header>, ) -> Option> { - let proof = Historical::prove((key_types::SR25519, equivocation.identity().encode()))?; + let proof = Historical::prove((key_types::BABE, equivocation.identity().encode()))?; let reporter = equivocation.reporter(); - let signature = reporter.sign(&(equivocation.clone(), proof.clone()).encode()) - .expect("FIXME"); + let to_sign = (equivocation.clone(), proof.clone()); + + let signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + reporter.sign(&blake2_256(payload)) + } else { + reporter.sign(&payload) + }).expect("FIXME"); + let babe_call = BabeCall::report_equivocation(equivocation, proof, signature); let call = Call::Babe(babe_call); let ex = UncheckedExtrinsic::new_unsigned(call.into()); + Some(ex.encode()) } } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 274d4b76ba7ed..41b9dd042b1fa 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -25,6 +25,7 @@ pub use timestamp; use rstd::{result, prelude::*}; +use runtime_io::blake2_256; use srml_support::{ decl_storage, decl_module, StorageValue, StorageMap, traits::{FindAuthor, Get, KeyOwnerProofSystem}, @@ -220,7 +221,9 @@ fn equivocation_is_valid( let signed = (equivocation, proof); let reporter = equivocation.reporter(); - let signature_valid = signed.using_encoded(|signed| { + let signature_valid = signed.using_encoded(|signed| if signed.len() > 256 { + reporter.verify(&blake2_256(signed), &signature) + } else { reporter.verify(&signed, &signature) }); @@ -297,19 +300,19 @@ decl_module! { } fn report_equivocation( - origin, - equivocation: BabeEquivocationProof, - proof: Proof, + _origin, + _equivocation: BabeEquivocationProof, + _proof: Proof, _signature: AuthoritySignature ) { - let _who = ensure_signed(origin)?; - let to_punish = ::KeyOwnerSystem::check_proof( - (key_types::SR25519, equivocation.identity().encode()), - proof.clone(), - ); - if to_punish.is_some() { - // TODO: Slash. - } + // let _who = ensure_signed(origin)?; + // let to_punish = ::KeyOwnerSystem::check_proof( + // (key_types::SR25519, equivocation.identity().encode()), + // proof.clone(), + // ); + // if to_punish.is_some() { + // // TODO: Slash. + // } } } } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index d45f6f3226aee..05645cd593bf9 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -36,6 +36,7 @@ use srml_support::{ decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue, traits::KeyOwnerProofSystem }; +use primitives::blake2_256; use app_crypto::RuntimeAppPublic; use sr_primitives::{ generic::{DigestItem, OpaqueDigestItemId}, Perbill, key_types, KeyTypeId, @@ -187,11 +188,12 @@ fn equivocation_is_valid( proof: &Proof, signature: &AuthoritySignature ) -> bool { - let signed = (equivocation, proof); let reporter = &equivocation.reporter; - let signature_valid = signed.using_encoded(|signed| { + let signature_valid = signed.using_encoded(|signed| if signed.len() > 256 { + reporter.verify(&blake2_256(signed), &signature) + } else { reporter.verify(&signed, &signature) }); @@ -207,7 +209,7 @@ fn equivocation_is_valid( let identity = &equivocation.identity; - if first_vote != second_vote { + if first_vote == second_vote { // TODO: fix equality before merging let first_payload = localized_payload( equivocation.round_number, equivocation.set_id, @@ -240,19 +242,19 @@ decl_module! { /// Report some misbehavior. fn report_equivocation( - origin, - equivocation: GrandpaEquivocation, - proof: Proof, + _origin, + _equivocation: GrandpaEquivocation, + _proof: Proof, _signature: AuthoritySignature ) { - let _who = ensure_signed(origin)?; - let to_punish = ::KeyOwnerSystem::check_proof( - (key_types::SR25519, equivocation.identity.encode()), - proof.clone(), - ); - if to_punish.is_some() { - // TODO: Slash. - } + // let _who = ensure_signed(origin)?; + // let to_punish = ::KeyOwnerSystem::check_proof( + // (key_types::SR25519, equivocation.identity.encode()), + // proof.clone(), + // ); + // if to_punish.is_some() { + // // TODO: Slash. + // } } fn on_finalize(block_number: T::BlockNumber) { From b5084fce0cbef0d8a8c70c2b52d1b76626d67bb2 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 12 Aug 2019 23:39:57 +0200 Subject: [PATCH 133/191] merge retreat-slashing --- Cargo.lock | 12 +++++------- core/consensus/babe/primitives/Cargo.toml | 1 + core/consensus/babe/primitives/src/lib.rs | 3 ++- core/consensus/common/primitives/Cargo.toml | 1 + core/consensus/common/primitives/src/lib.rs | 5 +++-- core/consensus/slots/src/aux_schema.rs | 2 +- core/finality-grandpa/Cargo.toml | 1 + core/finality-grandpa/primitives/Cargo.toml | 1 + core/finality-grandpa/primitives/src/lib.rs | 2 +- core/finality-grandpa/src/environment.rs | 2 +- node/runtime/Cargo.toml | 1 + node/runtime/src/lib.rs | 3 ++- srml/grandpa/Cargo.toml | 1 + srml/grandpa/src/lib.rs | 2 +- 14 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9acc7fd7d74fa..e9be996d45e18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2369,6 +2369,7 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", @@ -4441,11 +4442,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", -<<<<<<< HEAD "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -======= - "substrate-transaction-pool 2.0.0", ->>>>>>> Submit call from Babe "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4500,10 +4497,7 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", -<<<<<<< HEAD -======= "substrate-transaction-pool 2.0.0", ->>>>>>> Merge master "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4515,6 +4509,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", "substrate-application-crypto 2.0.0", @@ -4549,6 +4544,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", "substrate-application-crypto 2.0.0", @@ -4657,6 +4653,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "srml-finality-tracker 2.0.0", "srml-session 2.0.0", "substrate-client 2.0.0", @@ -4686,6 +4683,7 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "sr-std 2.0.0", "srml-session 2.0.0", "substrate-application-crypto 2.0.0", diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index d638811f38c2a..42263da095f36 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -9,6 +9,7 @@ edition = "2018" substrate-client = { path = "../../../client", default-features = false } rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } sr-primitives = { path = "../../../sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 6055abe2f5f40..ea9c9ae5fbd57 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -26,7 +26,8 @@ use rstd::vec::Vec; use sr_primitives::{ConsensusEngineId, traits::Header}; use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; -use srml_session::{historical::Proof, SessionIndex}; +use srml_session::historical::Proof; +use sr_staking_primitives::SessionIndex; #[cfg(feature = "std")] pub use digest::BabePreDigest; diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index fc33f59d57682..4636fe085ade1 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -13,6 +13,7 @@ rstd = { package = "sr-std", path = "../../../sr-std", default-features = false serde = { version = "1.0", optional = true, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } srml-session = { path = "../../../../srml/session", default-features = false } +sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } [features] diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 19d899f3e2532..58d488e956967 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -21,8 +21,9 @@ use codec::Codec; use client::decl_runtime_apis; use rstd::vec::Vec; -use sr_primitives::{traits::Header}; -use srml_session::{historical::Proof, SessionIndex}; +use sr_primitives::traits::Header; +use sr_staking_primitives::SessionIndex; +use srml_session::historical::Proof; use app_crypto::RuntimeAppPublic; decl_runtime_apis! { diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 490e1b341c0b6..0ed7c410c0d24 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -23,7 +23,7 @@ use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Header; use app_crypto::RuntimeAppPublic; use consensus_common_primitives::AuthorshipEquivocationProof; -use srml_session::{historical::Proof, SessionIndex}; +use srml_session::historical::Proof; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index 81361e52928c4..e66ce20dae05f 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -29,6 +29,7 @@ srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec"] } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } +sr-staking-primitives = { path = "../sr-staking-primitives", default-features = false } [dev-dependencies] grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec", "test-helpers"] } diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 4091b26dd09b3..072a32ad67e35 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -9,6 +9,7 @@ client = { package = "substrate-client", path = "../../client", default-features app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sr-primitives = { path = "../../sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index 199c7b0008170..a4c4945a7ccc9 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -28,7 +28,7 @@ use sr_primitives::{ConsensusEngineId, traits::{DigestFor, NumberFor, Block as B use client::decl_runtime_apis; use rstd::vec::Vec; use grandpa::Message; -use session::{historical::Proof, SessionIndex}; +use sr_staking_primitives::SessionIndex; mod app { use app_crypto::{app_crypto, key_types::GRANDPA, ed25519}; diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 92f71b45e095f..bd194471e0154 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -46,8 +46,8 @@ use crate::{ }; use consensus_common::SelectChain; -use srml_session::{historical::Proof, SessionIndex}; use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; +use sr_staking_primitives::SessionIndex; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; diff --git a/node/runtime/Cargo.toml b/node/runtime/Cargo.toml index 1a26d63ed50f2..cd58b21ca8a9b 100644 --- a/node/runtime/Cargo.toml +++ b/node/runtime/Cargo.toml @@ -45,6 +45,7 @@ serde = { version = "1.0", optional = true } substrate-keyring = { path = "../../core/keyring", optional = true } substrate-session = { path = "../../core/session", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.2", path = "../../core/utils/wasm-builder-runner" } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index b410aa849d9d2..a56a9cd17f1db 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -52,7 +52,8 @@ use version::RuntimeVersion; use elections::VoteIndex; #[cfg(any(feature = "std", test))] use version::NativeVersion; -use primitives::{OpaqueMetadata, blake2_256}; +use primitives::OpaqueMetadata; +use runtime_io::blake2_256; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use im_online::{AuthorityId as ImOnlineId}; use finality_tracker::{DEFAULT_REPORT_LATENCY, DEFAULT_WINDOW_SIZE}; diff --git a/srml/grandpa/Cargo.toml b/srml/grandpa/Cargo.toml index 0b3d19f04e9f4..f27efb24a1ea9 100644 --- a/srml/grandpa/Cargo.toml +++ b/srml/grandpa/Cargo.toml @@ -17,6 +17,7 @@ system = { package = "srml-system", path = "../system", default-features = false session = { package = "srml-session", path = "../session", default-features = false } finality-tracker = { package = "srml-finality-tracker", path = "../finality-tracker", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } [dev-dependencies] runtime_io = { package = "sr-io", path = "../../core/sr-io" } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 05645cd593bf9..90c2b5f210014 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -36,13 +36,13 @@ use srml_support::{ decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue, traits::KeyOwnerProofSystem }; -use primitives::blake2_256; use app_crypto::RuntimeAppPublic; use sr_primitives::{ generic::{DigestItem, OpaqueDigestItemId}, Perbill, key_types, KeyTypeId, transaction_validity::{TransactionValidity, ValidTransaction}, traits::{Zero, ValidateUnsigned} }; +use runtime_io::blake2_256; use sr_staking_primitives::{SessionIndex, offence::{TimeSlot, Offence, Kind}}; use fg_primitives::{ ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, From 9919e29c7a59e796a16484f7584ec8f610fec85e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 13 Aug 2019 02:09:35 +0200 Subject: [PATCH 134/191] Add ReportEquivocation type to Babe --- node/runtime/src/lib.rs | 1 + srml/babe/src/lib.rs | 47 +++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index a56a9cd17f1db..11f32904ebdd9 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -148,6 +148,7 @@ impl babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; type KeyOwnerSystem = Historical; + type ReportEquivocation = Offences; } impl indices::Trait for Runtime { diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 41b9dd042b1fa..ca01acd708976 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -41,7 +41,7 @@ use sr_primitives::traits::{ }; use sr_staking_primitives::{ SessionIndex, - offence::{Offence, TimeSlot, Kind}, + offence::{ReportOffence, Offence, TimeSlot, Kind}, }; #[cfg(feature = "std")] use timestamp::TimestampInherentData; @@ -49,7 +49,7 @@ use codec::{Encode, Decode}; use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; -use session::historical::Proof; +use session::historical::{Proof, IdentificationTuple}; use system::ensure_signed; use consensus_common_primitives::AuthorshipEquivocationProof; use babe_primitives::{ @@ -131,10 +131,19 @@ impl ProvideInherentData for InherentDataProvider { } } -pub trait Trait: timestamp::Trait { +pub trait Trait: timestamp::Trait + session::historical::Trait { type EpochDuration: Get; type ExpectedBlockTime: Get; - type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; + type KeyOwnerSystem: KeyOwnerProofSystem< + (KeyTypeId, Vec), + Proof=Proof, + IdentificationTuple=IdentificationTuple + >; + type ReportEquivocation: ReportOffence< + Self::AccountId, + IdentificationTuple, + BabeEquivocationOffence>, + >; } /// The length of the BABE randomness @@ -300,19 +309,25 @@ decl_module! { } fn report_equivocation( - _origin, - _equivocation: BabeEquivocationProof, - _proof: Proof, + origin, + equivocation: BabeEquivocationProof, + proof: Proof, _signature: AuthoritySignature ) { - // let _who = ensure_signed(origin)?; - // let to_punish = ::KeyOwnerSystem::check_proof( - // (key_types::SR25519, equivocation.identity().encode()), - // proof.clone(), - // ); - // if to_punish.is_some() { - // // TODO: Slash. - // } + let who = ensure_signed(origin)?; + let to_punish = ::KeyOwnerSystem::check_proof( + (key_types::BABE, equivocation.identity().encode()), + proof.clone(), + ); + if let Some(to_punish) = to_punish { + let offence = BabeEquivocationOffence { + slot: equivocation.slot(), + session_index: equivocation.session_index().clone(), + validators_count: 0, + offender: to_punish, + }; + T::ReportEquivocation::report_offence(Some(who), offence); + } } } } @@ -359,7 +374,7 @@ impl session::ShouldEndSession for Module { /// /// When a validator released two or more blocks at the same slot. #[allow(dead_code)] -struct BabeEquivocationOffence { +pub struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. slot: u64, /// The session index in which the incident happened. From 95a01d6d526c5678772e442f0405abcc265d951d Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 13 Aug 2019 11:09:23 +0200 Subject: [PATCH 135/191] Remove dup function --- srml/contracts/src/wasm/runtime.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/srml/contracts/src/wasm/runtime.rs b/srml/contracts/src/wasm/runtime.rs index 511c2941313c5..ecc4dfc7fb592 100644 --- a/srml/contracts/src/wasm/runtime.rs +++ b/srml/contracts/src/wasm/runtime.rs @@ -269,24 +269,6 @@ fn read_sandbox_memory_as( D::decode(&mut &buf[..]).map_err(|_| sandbox::HostError) } -/// Read designated chunk from the sandbox memory, consuming an appropriate amount of -/// gas, and attempt to decode into the specified type. -/// -/// Returns `Err` if one of the following conditions occurs: -/// -/// - calculating the gas cost resulted in overflow. -/// - out of gas -/// - requested buffer is not within the bounds of the sandbox memory. -/// - the buffer contents cannot be decoded as the required type. -fn read_sandbox_memory_as( - ctx: &mut Runtime, - ptr: u32, - len: u32, -) -> Result { - let buf = read_sandbox_memory(ctx, ptr, len)?; - D::decode(&mut &buf[..]).map_err(|_| sandbox::HostError) -} - /// Write the given buffer to the designated location in the sandbox memory, consuming /// an appropriate amount of gas. /// From 6158fdbc1a998d5a61026f999ef94108c478e1b1 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 13 Aug 2019 11:57:41 +0200 Subject: [PATCH 136/191] Add keystore --- core/consensus/babe/src/lib.rs | 46 ++++++++++++++++++++++------------ core/service/src/chain_ops.rs | 1 + core/service/src/components.rs | 6 ++++- core/service/src/lib.rs | 6 +++-- node/cli/Cargo.toml | 1 + node/cli/src/service.rs | 3 +++ 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 33ddb9edf6fac..83f2501036ed4 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -37,7 +37,7 @@ use keystore::KeyStorePtr; use runtime_support::serde::{Serialize, Deserialize}; use codec::{Decode, Encode}; use parking_lot::{Mutex, MutexGuard}; -use primitives::{Blake2Hasher, H256, Pair, Public}; +use primitives::{Blake2Hasher, H256, Pair, Public, traits::BareCryptoStorePtr}; use merlin::Transcript; use inherents::{InherentDataProviders, InherentData}; use substrate_telemetry::{ @@ -460,6 +460,7 @@ fn check_header( epoch_index: u64, c: (u64, u64), transaction_pool: Option<&T>, + keystore: Option<&KeyStorePtr>, ) -> Result, DigestItemFor)>, String> where DigestItemFor: CompatibleDigestItem, C: ProvideRuntimeApi + HeaderBackend, @@ -528,21 +529,30 @@ fn check_header( equivocation_proof.second_header().hash(), ); - // Submit a transaction reporting the equivocation. - let block_id = BlockId::number(client.info().best_number); - - let maybe_report_tx = client - .runtime_api() - .construct_equivocation_transaction(&block_id, equivocation_proof); - if let Ok(Some(report_tx)) = maybe_report_tx { - transaction_pool.as_ref().map(|txpool| { - let uxt = Decode::decode(&mut report_tx.as_slice()) - .expect("Encoded extrinsic is valid; qed"); - txpool.submit_one(&block_id, uxt) - }); - info!(target: "afg", "Babe equivocation report has been submitted") - } else { - error!(target: "afg", "Error constructing Babe equivocation report") + let keystore = keystore.expect("FIXME"); + let keystore = keystore.read(); + if let Some((key_pair, authority_index)) = authorities.iter() + .enumerate() + .find_map(|(i, a)| { + keystore.key_pair::(&a.0).ok().map(|kp| (kp, i)) + }) { + + // Submit a transaction reporting the equivocation. + let block_id = BlockId::number(client.info().best_number); + + let maybe_report_tx = client + .runtime_api() + .construct_equivocation_transaction(&block_id, equivocation_proof); + if let Ok(Some(report_tx)) = maybe_report_tx { + transaction_pool.as_ref().map(|txpool| { + let uxt = Decode::decode(&mut report_tx.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + txpool.submit_one(&block_id, uxt) + }); + info!(target: "afg", "Babe equivocation report has been submitted") + } else { + error!(target: "afg", "Error constructing Babe equivocation report") + } } } @@ -565,6 +575,7 @@ pub struct BabeVerifier { config: Config, time_source: BabeLink, transaction_pool: Option>, + keystore: Option, } impl BabeVerifier { @@ -686,6 +697,7 @@ impl Verifier for BabeVerifier where epoch_index, self.config.c(), self.transaction_pool.as_ref().map(|x| &**x), + self.keystore.as_ref(), )?; match checked_header { @@ -1153,6 +1165,7 @@ pub fn import_queue, I, RA, PRA, T>( api: Arc, inherent_data_providers: InherentDataProviders, transaction_pool: Option>, + keystore: Option, ) -> ClientResult<( BabeImportQueue, BabeLink, @@ -1178,6 +1191,7 @@ pub fn import_queue, I, RA, PRA, T>( time_source: Default::default(), config, transaction_pool, + keystore, }; #[allow(deprecated)] diff --git a/core/service/src/chain_ops.rs b/core/service/src/chain_ops.rs index c801b81186f18..20da48d212916 100644 --- a/core/service/src/chain_ops.rs +++ b/core/service/src/chain_ops.rs @@ -148,6 +148,7 @@ pub fn import_blocks( client.clone(), select_chain, None, + None, )?; let (exit_send, exit_recv) = std::sync::mpsc::channel(); diff --git a/core/service/src/components.rs b/core/service/src/components.rs index b88abd4a98b03..fce9d977294cc 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -382,6 +382,7 @@ pub trait ServiceFactory: 'static + Sized { _client: Arc>, _select_chain: Self::SelectChain, _transaction_pool: Option>>, + _keystore: Option, ) -> Result { if let Some(name) = config.chain_spec.consensus_engine() { match name { @@ -456,6 +457,7 @@ pub trait Components: Sized + 'static { client: Arc>, select_chain: Option, _transaction_pool: Option>>, + _keystore: Option, ) -> Result<(Self::ImportQueue, Option>>), error::Error>; /// Finality proof provider for serving network requests. @@ -575,10 +577,11 @@ impl Components for FullComponents { client: Arc>, select_chain: Option, transaction_pool: Option>>, + keystore: Option, ) -> Result<(Self::ImportQueue, Option>>), error::Error> { let select_chain = select_chain .ok_or(error::Error::SelectChainRequired)?; - Factory::build_full_import_queue(config, client, select_chain, transaction_pool) + Factory::build_full_import_queue(config, client, select_chain, transaction_pool, keystore) .map(|queue| (queue, None)) } @@ -699,6 +702,7 @@ impl Components for LightComponents { client: Arc>, _select_chain: Option, _transaction_pool: Option>>, + _keystore: Option, ) -> Result<(Self::ImportQueue, Option>>), error::Error> { Factory::build_light_import_queue(config, client) .map(|(queue, builder)| (queue, Some(builder))) diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 01b3aec233e9d..99bac546d63cc 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -37,7 +37,7 @@ use client::{BlockchainEvents, backend::Backend, runtime_api::BlockT}; use exit_future::Signal; use futures::prelude::*; use futures03::stream::{StreamExt as _, TryStreamExt as _}; -use keystore::Store as Keystore; +use keystore::{Store as Keystore, KeyStorePtr}; use network::{NetworkState, NetworkStateInfo}; use log::{log, info, warn, debug, error, Level}; use codec::{Encode, Decode}; @@ -189,6 +189,7 @@ impl Service { client.clone(), select_chain.clone(), Some(transaction_pool.clone()), + Some(keystore.clone()), )?; let import_queue = Box::new(import_queue); let finality_proof_provider = Components::build_finality_proof_provider(client.clone())?; @@ -1070,8 +1071,9 @@ macro_rules! construct_service_factory { client: $crate::Arc<$crate::FullClient>, select_chain: Self::SelectChain, transaction_pool: Option>>, + keystore: Option, ) -> $crate::Result { - ( $( $full_import_queue_init )* ) (config, client, select_chain, transaction_pool) + ( $( $full_import_queue_init )* ) (config, client, select_chain, transaction_pool, keystore) } fn build_light_import_queue( diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index c266427439d78..3b770b40867b2 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -43,6 +43,7 @@ system = { package = "srml-system", path = "../../srml/system" } balances = { package = "srml-balances", path = "../../srml/balances" } support = { package = "srml-support", path = "../../srml/support", default-features = false } im_online = { package = "srml-im-online", path = "../../srml/im-online", default-features = false } +keystore = { package = "substrate-keystore", path = "../../core/keystore", default-features = false } [dev-dependencies] keystore = { package = "substrate-keystore", path = "../../core/keystore" } diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 33652a59064cd..adb87e65b5141 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -38,6 +38,7 @@ use inherents::InherentDataProviders; use network::construct_simple_protocol; use substrate_service::construct_service_factory; use substrate_service::TelemetryOnConnect; +use keystore::KeyStorePtr; construct_simple_protocol! { /// Demo protocol attachment for substrate. @@ -234,6 +235,7 @@ construct_service_factory! { client, config.custom.inherent_data_providers.clone(), transaction_pool, + keystore, )?; config.custom.import_setup = Some((babe_block_import.clone(), link_half, babe_link)); @@ -266,6 +268,7 @@ construct_service_factory! { client, config.custom.inherent_data_providers.clone(), None, + None, )?; Ok((import_queue, finality_proof_request_builder)) From 35c2e87dd25eb6f1f764d21ab9c6b7c55d1309e0 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 13:50:35 +0200 Subject: [PATCH 137/191] Use construct_with_context to get keys --- Cargo.lock | 2 + core/consensus/babe/primitives/src/lib.rs | 30 +++++--------- core/consensus/babe/src/lib.rs | 45 +++++++++------------ core/consensus/common/primitives/src/lib.rs | 11 +---- core/consensus/slots/Cargo.toml | 2 + core/consensus/slots/src/aux_schema.rs | 24 +++++------ core/finality-grandpa/primitives/src/lib.rs | 2 +- core/finality-grandpa/src/environment.rs | 14 +++++-- node/runtime/src/lib.rs | 34 +++------------- srml/babe/Cargo.toml | 4 +- srml/babe/src/lib.rs | 42 ++++++++++++++++--- srml/grandpa/src/lib.rs | 32 ++++++++++++++- 12 files changed, 134 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9be996d45e18..e86c0f5c41e85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4586,12 +4586,14 @@ dependencies = [ "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", + "sr-staking-primitives 2.0.0", "srml-session 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", "substrate-consensus-common-primitives 2.0.0", "substrate-inherents 2.0.0", + "substrate-keystore 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", ] diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index ea9c9ae5fbd57..7821c123dcc1d 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -26,14 +26,14 @@ use rstd::vec::Vec; use sr_primitives::{ConsensusEngineId, traits::Header}; use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; -use srml_session::historical::Proof; use sr_staking_primitives::SessionIndex; #[cfg(feature = "std")] pub use digest::BabePreDigest; pub use digest::{BABE_VRF_PREFIX, RawBabePreDigest, get_slot, CompatibleDigestItem, find_pre_digest}; -mod app { +/// Crypto App module for Babe. +pub mod app { use app_crypto::{app_crypto, key_types::BABE, sr25519}; app_crypto!(sr25519, BABE); } @@ -147,11 +147,10 @@ impl slots::SlotData for BabeConfiguration { #[derive(Clone, Encode, Decode, PartialEq)] #[cfg_attr(any(feature = "std", test), derive(Debug))] pub struct BabeEquivocationProof { - reporter: AuthorityId, + reporter: Option, identity: AuthorityId, - identity_proof: Proof, slot: u64, - session_index: SessionIndex, + session_index: Option, first_header: H, second_header: H, first_signature: AuthoritySignature, @@ -168,22 +167,18 @@ where /// Create a new Babe equivocation proof. fn new( - reporter: Self::Identity, identity: Self::Identity, - identity_proof: Proof, slot: u64, - session_index: SessionIndex, first_header: H, second_header: H, first_signature: Self::Signature, second_signature: Self::Signature, ) -> Self { BabeEquivocationProof { - reporter, + reporter: None, identity, - identity_proof, slot, - session_index, + session_index: None, first_header, second_header, first_signature, @@ -192,8 +187,8 @@ where } /// Get the reporter of the equivocation. - fn reporter(&self) -> &Self::Identity { - &self.reporter + fn reporter(&self) -> Option<&Self::Identity> { + self.reporter.as_ref() } /// Get the slot where the equivocation happened. @@ -202,8 +197,8 @@ where } /// Get the session index where the equivocation happened. - fn session_index(&self) -> &SessionIndex { - &self.session_index + fn session_index(&self) -> Option<&SessionIndex> { + self.session_index.as_ref() } /// Get the identity of the suspect of equivocating. @@ -211,11 +206,6 @@ where &self.identity } - /// Get the identity of the suspect of equivocating. - fn identity_proof(&self) -> &Proof { - &self.identity_proof - } - /// Get the first header involved in the equivocation. fn first_header(&self) -> &H { &self.first_header diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 83f2501036ed4..4edba3736dd13 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -37,7 +37,7 @@ use keystore::KeyStorePtr; use runtime_support::serde::{Serialize, Deserialize}; use codec::{Decode, Encode}; use parking_lot::{Mutex, MutexGuard}; -use primitives::{Blake2Hasher, H256, Pair, Public, traits::BareCryptoStorePtr}; +use primitives::{Blake2Hasher, H256, Pair, Public, ExecutionContext}; use merlin::Transcript; use inherents::{InherentDataProviders, InherentData}; use substrate_telemetry::{ @@ -529,30 +529,25 @@ fn check_header( equivocation_proof.second_header().hash(), ); - let keystore = keystore.expect("FIXME"); - let keystore = keystore.read(); - if let Some((key_pair, authority_index)) = authorities.iter() - .enumerate() - .find_map(|(i, a)| { - keystore.key_pair::(&a.0).ok().map(|kp| (kp, i)) - }) { - - // Submit a transaction reporting the equivocation. - let block_id = BlockId::number(client.info().best_number); - - let maybe_report_tx = client - .runtime_api() - .construct_equivocation_transaction(&block_id, equivocation_proof); - if let Ok(Some(report_tx)) = maybe_report_tx { - transaction_pool.as_ref().map(|txpool| { - let uxt = Decode::decode(&mut report_tx.as_slice()) - .expect("Encoded extrinsic is valid; qed"); - txpool.submit_one(&block_id, uxt) - }); - info!(target: "afg", "Babe equivocation report has been submitted") - } else { - error!(target: "afg", "Error constructing Babe equivocation report") - } + // Submit a transaction reporting the equivocation. + let block_id = BlockId::number(client.info().best_number); + let maybe_report_tx = client + .runtime_api() + .construct_equivocation_transaction_with_context( + &block_id, + ExecutionContext::Other, + equivocation_proof, + ); + + if let Ok(Some(report_tx)) = maybe_report_tx { + transaction_pool.as_ref().map(|txpool| { + let uxt = Decode::decode(&mut report_tx.as_slice()) + .expect("Encoded extrinsic is valid; qed"); + txpool.submit_one(&block_id, uxt) + }); + info!(target: "afg", "Babe equivocation report has been submitted") + } else { + error!(target: "afg", "Error constructing Babe equivocation report") } } diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 58d488e956967..708e801d7824b 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -23,7 +23,6 @@ use client::decl_runtime_apis; use rstd::vec::Vec; use sr_primitives::traits::Header; use sr_staking_primitives::SessionIndex; -use srml_session::historical::Proof; use app_crypto::RuntimeAppPublic; decl_runtime_apis! { @@ -41,11 +40,8 @@ pub trait AuthorshipEquivocationProof { /// Create an equivocation proof for AuRa or Babe. fn new( - reporter: Self::Identity, identity: Self::Identity, - identity_proof: Proof, slot: u64, - session_index: SessionIndex, first_header: Self::Header, second_header: Self::Header, first_signature: Self::Signature, @@ -53,10 +49,10 @@ pub trait AuthorshipEquivocationProof { ) -> Self; /// Get the reporter of the equivocation. - fn reporter(&self) -> &Self::Identity; + fn reporter(&self) -> Option<&Self::Identity>; /// Get the session index where the equivocation happened. - fn session_index(&self) -> &SessionIndex; + fn session_index(&self) -> Option<&SessionIndex>; /// Get the slot where the equivocation happened. fn slot(&self) -> u64; @@ -64,9 +60,6 @@ pub trait AuthorshipEquivocationProof { /// Get the identity of the suspect of equivocating. fn identity(&self) -> &Self::Identity; - /// Get the identity proof of the suspect of equivocating. - fn identity_proof(&self) -> &Proof; - /// Get the first header involved in the equivocation. fn first_header(&self) -> &Self::Header; diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index 9755d151badd0..e01263ebd1b4e 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -10,10 +10,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } client = { package = "substrate-client", path = "../../client" } primitives = { package = "substrate-primitives", path = "../../primitives" } sr-primitives = { path = "../../sr-primitives" } +sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } consensus_common = { package = "substrate-consensus-common", path = "../common" } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } inherents = { package = "substrate-inherents", path = "../../inherents" } +keystore = { package = "substrate-keystore", path = "../../../core/keystore" } srml-session = { path = "../../../srml/session", default-features = false } futures-preview = "0.3.0-alpha.17" futures-timer = "0.2.1" diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 0ed7c410c0d24..f2b225c2ba899 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -24,6 +24,8 @@ use sr_primitives::traits::Header; use app_crypto::RuntimeAppPublic; use consensus_common_primitives::AuthorshipEquivocationProof; use srml_session::historical::Proof; +use keystore::KeyStorePtr; +use sr_staking_primitives::SessionIndex; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; @@ -62,7 +64,7 @@ pub fn check_equivocation( where H: Header, C: AuxStore, - V: RuntimeAppPublic + Codec + Clone + PartialEq, + V: RuntimeAppPublic + Codec + Clone + PartialEq, ::Signature: Clone + Codec, E: AuthorshipEquivocationProof< Header=H, @@ -97,17 +99,15 @@ pub fn check_equivocation( // if prev_signer == signer { // 2) with different hash // if header.hash() != prev_header.hash() { - // return Ok(Some(AuthorshipEquivocationProof::new( - // signer.clone(), // TODO: this should be the reporter. - // signer.clone(), - // Proof::default(), // TODO: add the proof. - // slot, - // SessionIndex::default(), // TODO: add session index. - // header.clone(), - // header.clone(), - // signature.clone(), - // signature.clone(), - // ))); + + return Ok(Some(AuthorshipEquivocationProof::new( + signer.clone(), + slot, + header.clone(), + header.clone(), + signature.clone(), + signature.clone(), + ))); // } else { // We don't need to continue in case of duplicated header, // since it's already saved and a possible equivocation diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index a4c4945a7ccc9..d7f19f8e540c1 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -30,7 +30,7 @@ use rstd::vec::Vec; use grandpa::Message; use sr_staking_primitives::SessionIndex; -mod app { +pub mod app { use app_crypto::{app_crypto, key_types::GRANDPA, ed25519}; app_crypto!(ed25519, GRANDPA); } diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index bd194471e0154..98bc82d366cdb 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -33,7 +33,7 @@ use grandpa::{ BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState, voter, voter_set::VoterSet, Message }; -use primitives::{Blake2Hasher, H256, Pair}; +use primitives::{Blake2Hasher, H256, Pair, ExecutionContext}; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ Block as BlockT, Header as HeaderT, NumberFor, One, Zero, ProvideRuntimeApi @@ -866,7 +866,11 @@ where let block_id = BlockId::::number(self.inner.info().chain.best_number); let maybe_report_call = self.inner.runtime_api() - .construct_equivocation_transaction(&block_id, grandpa_equivocation); + .construct_equivocation_transaction_with_context( + &block_id, + ExecutionContext::Other, + grandpa_equivocation, + ); if let Ok(Some(report_call)) = maybe_report_call { let uxt = Decode::decode(&mut report_call.as_slice()) @@ -907,7 +911,11 @@ where let block_id = BlockId::::number(self.inner.info().chain.best_number); let maybe_report_call = self.inner.runtime_api() - .construct_equivocation_transaction(&block_id, grandpa_equivocation); + .construct_equivocation_transaction_with_context( + &block_id, + ExecutionContext::Other, + grandpa_equivocation, + ); if let Ok(Some(report_call)) = maybe_report_call { let uxt = Decode::decode(&mut report_call.as_slice()) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 11f32904ebdd9..13499b1ec0ac0 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -149,6 +149,8 @@ impl babe::Trait for Runtime { type ExpectedBlockTime = ExpectedBlockTime; type KeyOwnerSystem = Historical; type ReportEquivocation = Offences; + type Call = Call; + type UncheckedExtrinsic = UncheckedExtrinsic; } impl indices::Trait for Runtime { @@ -419,6 +421,8 @@ impl offences::Trait for Runtime { } impl grandpa::Trait for Runtime { + type Call = Call; + type UncheckedExtrinsic = UncheckedExtrinsic; type Event = Event; type KeyOwnerSystem = Historical; } @@ -565,20 +569,7 @@ impl_runtime_apis! { equivocation: GrandpaEquivocationFrom ) -> Option> { let proof = Historical::prove((key_types::GRANDPA, equivocation.identity.encode()))?; - let reporter = &equivocation.reporter; - let to_sign = (equivocation.clone(), proof.clone()); - - let signature = to_sign.using_encoded(|payload| if payload.len() > 256 { - reporter.sign(&blake2_256(payload)) - } else { - reporter.sign(&payload) - }).expect("FIXME"); - - let grandpa_call = GrandpaCall::report_equivocation(equivocation, proof, signature); - let call = Call::Grandpa(grandpa_call); - let ex = UncheckedExtrinsic::new_unsigned(call.into()); - - Some(ex.encode()) + Grandpa::construct_equivocation_transaction(equivocation, proof) } } @@ -610,20 +601,7 @@ impl_runtime_apis! { equivocation: BabeEquivocationProof<::Header>, ) -> Option> { let proof = Historical::prove((key_types::BABE, equivocation.identity().encode()))?; - let reporter = equivocation.reporter(); - let to_sign = (equivocation.clone(), proof.clone()); - - let signature = to_sign.using_encoded(|payload| if payload.len() > 256 { - reporter.sign(&blake2_256(payload)) - } else { - reporter.sign(&payload) - }).expect("FIXME"); - - let babe_call = BabeCall::report_equivocation(equivocation, proof, signature); - let call = Call::Babe(babe_call); - let ex = UncheckedExtrinsic::new_unsigned(call.into()); - - Some(ex.encode()) + Babe::construct_equivocation_transaction(equivocation, proof) } } diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index 2a033806336df..2f5cb7ff55186 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -19,7 +19,7 @@ timestamp = { package = "srml-timestamp", path = "../timestamp", default-feature session = { package = "srml-session", path = "../session", default-features = false } consensus-common-primitives = { package = "substrate-consensus-common-primitives", path = "../../core/consensus/common/primitives", default-features = false } babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false } -runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } +sr-io = { path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } [dev-dependencies] @@ -41,6 +41,6 @@ std = [ "inherents/std", "babe-primitives/std", "session/std", - "runtime_io/std", + "sr-io/std", "staking/std", ] diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index ca01acd708976..4237d26a8971b 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -25,7 +25,7 @@ pub use timestamp; use rstd::{result, prelude::*}; -use runtime_io::blake2_256; +use sr_io::blake2_256; use srml_support::{ decl_storage, decl_module, StorageValue, StorageMap, traits::{FindAuthor, Get, KeyOwnerProofSystem}, @@ -37,7 +37,7 @@ use sr_primitives::{ }; use sr_primitives::traits::{ IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header, - ValidateUnsigned + ValidateUnsigned, Extrinsic as ExtrinsicT }; use sr_staking_primitives::{ SessionIndex, @@ -57,7 +57,7 @@ use babe_primitives::{ BabeEquivocationProof, get_slot }; use app_crypto::RuntimeAppPublic; -pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; +pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH, app}; /// The BABE inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot"; @@ -134,6 +134,10 @@ impl ProvideInherentData for InherentDataProvider { pub trait Trait: timestamp::Trait + session::historical::Trait { type EpochDuration: Get; type ExpectedBlockTime: Get; + + type Call: From>; + type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; + type KeyOwnerSystem: KeyOwnerProofSystem< (KeyTypeId, Vec), Proof=Proof, @@ -228,7 +232,7 @@ fn equivocation_is_valid( signature: &AuthoritySignature, ) -> bool { let signed = (equivocation, proof); - let reporter = equivocation.reporter(); + let reporter = equivocation.reporter().expect("FIXME"); let signature_valid = signed.using_encoded(|signed| if signed.len() > 256 { reporter.verify(&blake2_256(signed), &signature) @@ -322,7 +326,7 @@ decl_module! { if let Some(to_punish) = to_punish { let offence = BabeEquivocationOffence { slot: equivocation.slot(), - session_index: equivocation.session_index().clone(), + session_index: equivocation.session_index().expect("FIXME").clone(), validators_count: 0, offender: to_punish, }; @@ -423,6 +427,32 @@ impl Module { ::MinimumPeriod::get().saturating_mul(2.into()) } + pub fn construct_equivocation_transaction( + equivocation: BabeEquivocationProof, + proof: Proof, + ) -> Option> { + let mut local_keys = app::Public::all(); + + if local_keys.len() > 0 { + let reporter = &local_keys[0]; + let to_sign = (equivocation.clone(), proof.clone()); + + let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + reporter.sign(&blake2_256(payload)) + } else { + reporter.sign(&payload) + }); + + if let Some(signature) = maybe_signature { + let call = Call::report_equivocation(equivocation, proof, signature.into()); + let ex = T::UncheckedExtrinsic::new_unsigned(call.into()); + return Some(ex.encode()) + } + } + + None + } + fn deposit_consensus(new: U) { let log: DigestItem = DigestItem::Consensus(BABE_ENGINE_ID, new.encode()); >::deposit_log(log.into()) @@ -564,7 +594,7 @@ fn compute_randomness( s.extend_from_slice(&vrf_output[..]); } - runtime_io::blake2_256(&s) + sr_io::blake2_256(&s) } impl ProvideInherent for Module { diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 90c2b5f210014..99f62c411a38c 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -40,13 +40,13 @@ use app_crypto::RuntimeAppPublic; use sr_primitives::{ generic::{DigestItem, OpaqueDigestItemId}, Perbill, key_types, KeyTypeId, transaction_validity::{TransactionValidity, ValidTransaction}, - traits::{Zero, ValidateUnsigned} + traits::{Zero, ValidateUnsigned, Extrinsic as ExtrinsicT} }; use runtime_io::blake2_256; use sr_staking_primitives::{SessionIndex, offence::{TimeSlot, Offence, Kind}}; use fg_primitives::{ ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, - localized_payload + localized_payload, app }; use session::historical::Proof; pub use fg_primitives::{AuthorityId, AuthorityWeight, AuthoritySignature}; @@ -59,6 +59,8 @@ pub trait Trait: system::Trait { /// The event type of this module. type Event: From + Into<::Event>; type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; + type Call: From>; + type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; } /// A stored pending change, old format. @@ -403,6 +405,32 @@ impl Module { } } + pub fn construct_equivocation_transaction( + equivocation: GrandpaEquivocation, + proof: Proof, + ) -> Option> { + let mut local_keys = app::Public::all(); + + if local_keys.len() > 0 { + let reporter = &local_keys[0]; + let to_sign = (equivocation.clone(), proof.clone()); + + let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + reporter.sign(&blake2_256(payload)) + } else { + reporter.sign(&payload) + }); + + if let Some(signature) = maybe_signature { + let call = Call::report_equivocation(equivocation, proof, signature.into()); + let ex = T::UncheckedExtrinsic::new_unsigned(call.into()); + return Some(ex.encode()) + } + } + + None + } + /// Deposit one of this module's logs. fn deposit_log(log: ConsensusLog) { let log: DigestItem = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); From efc7248d3ca0a056c59e63efa7d360e80061db90 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 14:43:24 +0200 Subject: [PATCH 138/191] Cleaning --- core/consensus/babe/primitives/src/digest.rs | 1 - core/consensus/babe/src/lib.rs | 5 ----- core/service/src/lib.rs | 2 +- node/cli/src/service.rs | 2 -- node/runtime/src/lib.rs | 2 -- srml/babe/src/lib.rs | 7 ++----- 6 files changed, 3 insertions(+), 16 deletions(-) diff --git a/core/consensus/babe/primitives/src/digest.rs b/core/consensus/babe/primitives/src/digest.rs index 72b1e59f14119..187e155ba877d 100644 --- a/core/consensus/babe/primitives/src/digest.rs +++ b/core/consensus/babe/primitives/src/digest.rs @@ -121,7 +121,6 @@ impl Decode for BabePreDigest { } /// A digest item which is usable with BABE consensus. -// #[cfg(feature = "std")] pub trait CompatibleDigestItem: Sized { /// Construct a digest item which contains a BABE pre-digest. fn babe_pre_digest(seal: D) -> Self; diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 4edba3736dd13..81cb19443a314 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -460,7 +460,6 @@ fn check_header( epoch_index: u64, c: (u64, u64), transaction_pool: Option<&T>, - keystore: Option<&KeyStorePtr>, ) -> Result, DigestItemFor)>, String> where DigestItemFor: CompatibleDigestItem, C: ProvideRuntimeApi + HeaderBackend, @@ -570,7 +569,6 @@ pub struct BabeVerifier { config: Config, time_source: BabeLink, transaction_pool: Option>, - keystore: Option, } impl BabeVerifier { @@ -692,7 +690,6 @@ impl Verifier for BabeVerifier where epoch_index, self.config.c(), self.transaction_pool.as_ref().map(|x| &**x), - self.keystore.as_ref(), )?; match checked_header { @@ -1160,7 +1157,6 @@ pub fn import_queue, I, RA, PRA, T>( api: Arc, inherent_data_providers: InherentDataProviders, transaction_pool: Option>, - keystore: Option, ) -> ClientResult<( BabeImportQueue, BabeLink, @@ -1186,7 +1182,6 @@ pub fn import_queue, I, RA, PRA, T>( time_source: Default::default(), config, transaction_pool, - keystore, }; #[allow(deprecated)] diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 99bac546d63cc..fd549bbb05f24 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -37,7 +37,7 @@ use client::{BlockchainEvents, backend::Backend, runtime_api::BlockT}; use exit_future::Signal; use futures::prelude::*; use futures03::stream::{StreamExt as _, TryStreamExt as _}; -use keystore::{Store as Keystore, KeyStorePtr}; +use keystore::Store as Keystore; use network::{NetworkState, NetworkStateInfo}; use log::{log, info, warn, debug, error, Level}; use codec::{Encode, Decode}; diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index adb87e65b5141..b74e0695651dd 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -235,7 +235,6 @@ construct_service_factory! { client, config.custom.inherent_data_providers.clone(), transaction_pool, - keystore, )?; config.custom.import_setup = Some((babe_block_import.clone(), link_half, babe_link)); @@ -268,7 +267,6 @@ construct_service_factory! { client, config.custom.inherent_data_providers.clone(), None, - None, )?; Ok((import_queue, finality_proof_request_builder)) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 13499b1ec0ac0..36f2ecd486a53 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -28,7 +28,6 @@ use support::{ } }; use primitives::u32_trait::{_1, _2, _3, _4}; -use app_crypto::RuntimeAppPublic; use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, @@ -53,7 +52,6 @@ use elections::VoteIndex; #[cfg(any(feature = "std", test))] use version::NativeVersion; use primitives::OpaqueMetadata; -use runtime_io::blake2_256; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use im_online::{AuthorityId as ImOnlineId}; use finality_tracker::{DEFAULT_REPORT_LATENCY, DEFAULT_WINDOW_SIZE}; diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 4237d26a8971b..5f4690440dcf9 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -19,8 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![forbid(unused_must_use, unsafe_code, unused_variables)] -// TODO: @marcio uncomment this when BabeEquivocation is integrated. -// #![forbid(dead_code)] +#![forbid(dead_code)] pub use timestamp; @@ -373,11 +372,9 @@ impl session::ShouldEndSession for Module { } } -// TODO [slashing]: @marcio use this, remove the dead_code annotation. /// A BABE equivocation offence report. /// /// When a validator released two or more blocks at the same slot. -#[allow(dead_code)] pub struct BabeEquivocationOffence { /// A babe slot number in which this incident happened. slot: u64, @@ -431,7 +428,7 @@ impl Module { equivocation: BabeEquivocationProof, proof: Proof, ) -> Option> { - let mut local_keys = app::Public::all(); + let local_keys = app::Public::all(); if local_keys.len() > 0 { let reporter = &local_keys[0]; From 870a7bd76896d0ba1b4510d96a30032ef0554716 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 16:41:17 +0200 Subject: [PATCH 139/191] Fix decode error --- core/consensus/babe/src/lib.rs | 6 +++--- core/finality-grandpa/src/environment.rs | 6 +++--- srml/babe/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 81cb19443a314..b9321df491d00 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -530,7 +530,7 @@ fn check_header( // Submit a transaction reporting the equivocation. let block_id = BlockId::number(client.info().best_number); - let maybe_report_tx = client + let maybe_report_transaction = client .runtime_api() .construct_equivocation_transaction_with_context( &block_id, @@ -538,9 +538,9 @@ fn check_header( equivocation_proof, ); - if let Ok(Some(report_tx)) = maybe_report_tx { + if let Ok(Some(report_transaction)) = maybe_report_transaction { transaction_pool.as_ref().map(|txpool| { - let uxt = Decode::decode(&mut report_tx.as_slice()) + let uxt = Decode::decode(&mut report_transaction.as_slice()) .expect("Encoded extrinsic is valid; qed"); txpool.submit_one(&block_id, uxt) }); diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 98bc82d366cdb..139d8d9a81fc8 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -865,15 +865,15 @@ where }; let block_id = BlockId::::number(self.inner.info().chain.best_number); - let maybe_report_call = self.inner.runtime_api() + let maybe_report_transaction = self.inner.runtime_api() .construct_equivocation_transaction_with_context( &block_id, ExecutionContext::Other, grandpa_equivocation, ); - if let Ok(Some(report_call)) = maybe_report_call { - let uxt = Decode::decode(&mut report_call.as_slice()) + if let Ok(Some(report_transaction)) = maybe_report_transaction { + let uxt = Decode::decode(&mut report_transaction.as_slice()) .expect("Encoded extrinsic is valid; qed"); match self.transaction_pool.submit_one(&block_id, uxt) { Err(e) => warn!("Error importing misbehavior report: {:?}", e), diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 5f4690440dcf9..f8a246dda391a 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -442,7 +442,7 @@ impl Module { if let Some(signature) = maybe_signature { let call = Call::report_equivocation(equivocation, proof, signature.into()); - let ex = T::UncheckedExtrinsic::new_unsigned(call.into()); + let ex = T::UncheckedExtrinsic::new_unsigned(call.into())?; return Some(ex.encode()) } } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 99f62c411a38c..d7b7b9ace5dfc 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -244,12 +244,12 @@ decl_module! { /// Report some misbehavior. fn report_equivocation( - _origin, + origin, _equivocation: GrandpaEquivocation, _proof: Proof, _signature: AuthoritySignature ) { - // let _who = ensure_signed(origin)?; + ensure_signed(origin)?; // let to_punish = ::KeyOwnerSystem::check_proof( // (key_types::SR25519, equivocation.identity.encode()), // proof.clone(), @@ -409,7 +409,7 @@ impl Module { equivocation: GrandpaEquivocation, proof: Proof, ) -> Option> { - let mut local_keys = app::Public::all(); + let local_keys = app::Public::all(); if local_keys.len() > 0 { let reporter = &local_keys[0]; @@ -423,7 +423,7 @@ impl Module { if let Some(signature) = maybe_signature { let call = Call::report_equivocation(equivocation, proof, signature.into()); - let ex = T::UncheckedExtrinsic::new_unsigned(call.into()); + let ex = T::UncheckedExtrinsic::new_unsigned(call.into())?; return Some(ex.encode()) } } From ad3797f6536029e70aded9834144f732d095aa6c Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 18:45:43 +0200 Subject: [PATCH 140/191] Add test extrinsic --- srml/grandpa/Cargo.toml | 1 + srml/grandpa/src/mock.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/srml/grandpa/Cargo.toml b/srml/grandpa/Cargo.toml index f27efb24a1ea9..4c20d1f02ec00 100644 --- a/srml/grandpa/Cargo.toml +++ b/srml/grandpa/Cargo.toml @@ -21,6 +21,7 @@ runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = [dev-dependencies] runtime_io = { package = "sr-io", path = "../../core/sr-io" } +test_runtime = { package = "substrate-test-runtime", path = "../../core/test-runtime" } [features] default = ["std"] diff --git a/srml/grandpa/src/mock.rs b/srml/grandpa/src/mock.rs index e3c53510deae4..aca7bbb8eefc0 100644 --- a/srml/grandpa/src/mock.rs +++ b/srml/grandpa/src/mock.rs @@ -25,6 +25,7 @@ use primitives::{H256, Blake2Hasher}; use codec::{Encode, Decode}; use crate::{AuthorityId, GenesisConfig, Trait, Module, ConsensusLog}; use substrate_finality_grandpa_primitives::GRANDPA_ENGINE_ID; +use test_runtime::Extrinsic; impl_outer_origin!{ pub enum Origin for Test {} @@ -39,7 +40,9 @@ pub fn grandpa_log(log: ConsensusLog) -> DigestItem { pub struct Test; impl Trait for Test { type Event = TestEvent; - + type KeyOwnerSystem = (); + type Call = (); + type UncheckedExtrinsic = Extrinsic; } parameter_types! { pub const BlockHashCount: u64 = 250; From 0f998dd1722007334112df4849c24b113508a184 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 18:48:49 +0200 Subject: [PATCH 141/191] fix delimiter --- core/consensus/aura/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 2ffbb7ba4406a..4a3f7d00f3b91 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -810,7 +810,7 @@ mod tests { transaction_pool: Default::default(), phantom: Default::default(), transaction_pool: Default::default(), - }) + } }, PeersClient::Light(_) => unreachable!("No (yet) tests for light client + Aura"), } From 6c5e5d981d079aa2c0f8ba81895b231e6ace8873 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 18:50:44 +0200 Subject: [PATCH 142/191] add signature to aura --- core/consensus/aura/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 4a3f7d00f3b91..f6a9599e2b9ff 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -433,6 +433,7 @@ fn check_header( slot_now, slot_num, &header, + sig, expected_author, ).map_err(|e| e.to_string())? { info!( From 4d59551df064afb832c0ef6affa72550f31b04f3 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 14 Aug 2019 18:59:30 +0200 Subject: [PATCH 143/191] Uncomment check_equivocation in Aura temporarily --- core/consensus/aura/src/lib.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index f6a9599e2b9ff..e3f5d9a578fe5 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -428,21 +428,21 @@ fn check_header( let pre_hash = header.hash(); if P::verify(&sig, pre_hash.as_ref(), expected_author) { - if let Some(equivocation_proof) = check_equivocation( - client, - slot_now, - slot_num, - &header, - sig, - expected_author, - ).map_err(|e| e.to_string())? { - info!( - "Slot author is equivocating at slot {} with headers {:?} and {:?}", - slot_num, - equivocation_proof.fst_header().hash(), - equivocation_proof.snd_header().hash(), - ); - } + // if let Some(equivocation_proof) = check_equivocation( + // client, + // slot_now, + // slot_num, + // &header, + // sig, + // expected_author, + // ).map_err(|e| e.to_string())? { + // info!( + // "Slot author is equivocating at slot {} with headers {:?} and {:?}", + // slot_num, + // equivocation_proof.fst_header().hash(), + // equivocation_proof.snd_header().hash(), + // ); + // } Ok(CheckedHeader::Checked(header, (slot_num, seal))) } else { From fc927d1e4cef96365782490af71d427b0c579f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 22:36:48 +0200 Subject: [PATCH 144/191] Fix staking tests. --- srml/staking/src/tests.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 90cc0432dccb8..141c833fdf46e 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -594,7 +594,6 @@ fn nominators_also_get_slashed() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(5)], @@ -2016,7 +2015,6 @@ fn offence_forces_new_era() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(5)], @@ -2044,7 +2042,6 @@ fn slashing_performed_according_exposure() { others: vec![], }, ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(50)], @@ -2069,7 +2066,6 @@ fn reporters_receive_their_slice() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![1, 2], }], &[Perbill::from_percent(50)], @@ -2095,12 +2091,10 @@ fn invulnerables_are_not_slashed() { &[ OffenceDetails { offender: (11, Staking::stakers(&11)), - count: 1, reporters: vec![], }, OffenceDetails { offender: (21, Staking::stakers(&21)), - count: 1, reporters: vec![], }, ], @@ -2126,7 +2120,6 @@ fn dont_slash_if_fraction_is_zero() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(0)], From f3a2d6806ada702ba28d908da7db1788a4e99726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 14 Aug 2019 23:09:21 +0200 Subject: [PATCH 145/191] Update srml/im-online/src/lib.rs Co-Authored-By: Logan Saether --- srml/im-online/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 021a7f58d2443..1eb845fffe0c6 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -478,7 +478,7 @@ impl srml_support::unsigned::ValidateUnsigned for Module { } } -/// An offense that is filed if a validator didn't send a heartbeat message. +/// An offence that is filed if a validator didn't send a heartbeat message. pub struct UnresponsivenessOffence { /// The current session index in which we report the unresponsive validators. /// From f8236f5acf218f3a53781aaddd4cfa717dcf82d8 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 05:56:41 +0200 Subject: [PATCH 146/191] Finish removing keystore --- Cargo.lock | 1 + core/service/src/chain_ops.rs | 1 - core/service/src/components.rs | 8 ++------ core/service/src/lib.rs | 4 +--- core/test-runtime/src/lib.rs | 2 ++ node/cli/src/service.rs | 1 - srml/babe/src/lib.rs | 4 ++-- srml/grandpa/src/lib.rs | 2 +- 8 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e86c0f5c41e85..37ad20f1ebb8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3936,6 +3936,7 @@ dependencies = [ "substrate-application-crypto 2.0.0", "substrate-finality-grandpa-primitives 2.0.0", "substrate-primitives 2.0.0", + "substrate-test-runtime 2.0.0", ] [[package]] diff --git a/core/service/src/chain_ops.rs b/core/service/src/chain_ops.rs index 20da48d212916..c801b81186f18 100644 --- a/core/service/src/chain_ops.rs +++ b/core/service/src/chain_ops.rs @@ -148,7 +148,6 @@ pub fn import_blocks( client.clone(), select_chain, None, - None, )?; let (exit_send, exit_recv) = std::sync::mpsc::channel(); diff --git a/core/service/src/components.rs b/core/service/src/components.rs index fce9d977294cc..486c6a07aa6ba 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -382,8 +382,7 @@ pub trait ServiceFactory: 'static + Sized { _client: Arc>, _select_chain: Self::SelectChain, _transaction_pool: Option>>, - _keystore: Option, - ) -> Result { + ) -> Result { if let Some(name) = config.chain_spec.consensus_engine() { match name { _ => Err(format!("Chain Specification defines unknown consensus engine '{}'", name).into()) @@ -457,7 +456,6 @@ pub trait Components: Sized + 'static { client: Arc>, select_chain: Option, _transaction_pool: Option>>, - _keystore: Option, ) -> Result<(Self::ImportQueue, Option>>), error::Error>; /// Finality proof provider for serving network requests. @@ -577,11 +575,10 @@ impl Components for FullComponents { client: Arc>, select_chain: Option, transaction_pool: Option>>, - keystore: Option, ) -> Result<(Self::ImportQueue, Option>>), error::Error> { let select_chain = select_chain .ok_or(error::Error::SelectChainRequired)?; - Factory::build_full_import_queue(config, client, select_chain, transaction_pool, keystore) + Factory::build_full_import_queue(config, client, select_chain, transaction_pool) .map(|queue| (queue, None)) } @@ -702,7 +699,6 @@ impl Components for LightComponents { client: Arc>, _select_chain: Option, _transaction_pool: Option>>, - _keystore: Option, ) -> Result<(Self::ImportQueue, Option>>), error::Error> { Factory::build_light_import_queue(config, client) .map(|(queue, builder)| (queue, Some(builder))) diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index fd549bbb05f24..01b3aec233e9d 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -189,7 +189,6 @@ impl Service { client.clone(), select_chain.clone(), Some(transaction_pool.clone()), - Some(keystore.clone()), )?; let import_queue = Box::new(import_queue); let finality_proof_provider = Components::build_finality_proof_provider(client.clone())?; @@ -1071,9 +1070,8 @@ macro_rules! construct_service_factory { client: $crate::Arc<$crate::FullClient>, select_chain: Self::SelectChain, transaction_pool: Option>>, - keystore: Option, ) -> $crate::Result { - ( $( $full_import_queue_init )* ) (config, client, select_chain, transaction_pool, keystore) + ( $( $full_import_queue_init )* ) (config, client, select_chain, transaction_pool) } fn build_light_import_queue( diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index 54c922c2169f8..e261fd45adae0 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -390,6 +390,8 @@ impl srml_babe::Trait for Runtime { type ExpectedBlockTime = ExpectedBlockTime; } + + /// Adds one to the given input and returns the final result. #[inline(never)] fn benchmark_add_one(i: u64) -> u64 { diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index b74e0695651dd..33652a59064cd 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -38,7 +38,6 @@ use inherents::InherentDataProviders; use network::construct_simple_protocol; use substrate_service::construct_service_factory; use substrate_service::TelemetryOnConnect; -use keystore::KeyStorePtr; construct_simple_protocol! { /// Demo protocol attachment for substrate. diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index f8a246dda391a..92f7ebb376ff7 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -326,10 +326,10 @@ decl_module! { let offence = BabeEquivocationOffence { slot: equivocation.slot(), session_index: equivocation.session_index().expect("FIXME").clone(), - validators_count: 0, + validator_set_count: 0, offender: to_punish, }; - T::ReportEquivocation::report_offence(Some(who), offence); + T::ReportEquivocation::report_offence(vec![who], offence); } } } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index d7b7b9ace5dfc..eff2a1b0af08b 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -38,7 +38,7 @@ use srml_support::{ }; use app_crypto::RuntimeAppPublic; use sr_primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, Perbill, key_types, KeyTypeId, + generic::{DigestItem, OpaqueDigestItemId}, Perbill, KeyTypeId, transaction_validity::{TransactionValidity, ValidTransaction}, traits::{Zero, ValidateUnsigned, Extrinsic as ExtrinsicT} }; From 46015f8c8af3031b7ab2b4978dd566478c7bba1b Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 06:56:40 +0200 Subject: [PATCH 147/191] Fix test-runtime --- core/consensus/aura/src/lib.rs | 1 - core/test-runtime/src/lib.rs | 38 +++++++++++++++++++++++++--------- srml/staking/src/tests.rs | 7 ------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index e3f5d9a578fe5..5ddfc506f625b 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -710,7 +710,6 @@ pub fn import_queue( inherent_data_providers, transaction_pool, phantom: PhantomData, - transaction_pool, }; Ok(BasicQueue::new( verifier, diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index e261fd45adae0..e5780803cfc4b 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -385,10 +385,10 @@ parameter_types! { pub const ExpectedBlockTime: u64 = 10_000; } -impl srml_babe::Trait for Runtime { - type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; -} +// impl srml_babe::Trait for Runtime { +// type EpochDuration = EpochDuration; +// type ExpectedBlockTime = ExpectedBlockTime; +// } @@ -608,13 +608,22 @@ cfg_if! { let authorities: Vec<_> = authorities.into_iter().map(|x|(x, 1)).collect(); babe_primitives::Epoch { - start_slot: >::epoch_start_slot(), + // start_slot: >::epoch_start_slot(), + start_slot: 0, authorities, - randomness: >::randomness(), - epoch_index: >::epoch_index(), + // randomness: >::randomness(), + randomness: [0; 32], + // epoch_index: >::epoch_index(), + epoch_index: 0, duration: EpochDuration::get(), } } + + fn construct_equivocation_transaction( + equivocation: babe_primitives::BabeEquivocationProof<::Header>, + ) -> Option> { + Some(vec![]) + } } impl offchain_primitives::OffchainWorkerApi for Runtime { @@ -818,13 +827,22 @@ cfg_if! { let authorities: Vec<_> = authorities.into_iter().map(|x|(x, 1)).collect(); babe_primitives::Epoch { - start_slot: >::epoch_start_slot(), + // start_slot: >::epoch_start_slot(), + start_slot: 0, authorities, - randomness: >::randomness(), - epoch_index: >::epoch_index(), + // randomness: >::randomness(), + randomness: [0; 32], + // epoch_index: >::epoch_index(), + epoch_index: 0, duration: EpochDuration::get(), } } + + fn construct_equivocation_transaction( + equivocation: babe_primitives::BabeEquivocationProof<::Header>, + ) -> Option> { + Some(vec![]) + } } impl offchain_primitives::OffchainWorkerApi for Runtime { diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 90cc0432dccb8..141c833fdf46e 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -594,7 +594,6 @@ fn nominators_also_get_slashed() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(5)], @@ -2016,7 +2015,6 @@ fn offence_forces_new_era() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(5)], @@ -2044,7 +2042,6 @@ fn slashing_performed_according_exposure() { others: vec![], }, ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(50)], @@ -2069,7 +2066,6 @@ fn reporters_receive_their_slice() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![1, 2], }], &[Perbill::from_percent(50)], @@ -2095,12 +2091,10 @@ fn invulnerables_are_not_slashed() { &[ OffenceDetails { offender: (11, Staking::stakers(&11)), - count: 1, reporters: vec![], }, OffenceDetails { offender: (21, Staking::stakers(&21)), - count: 1, reporters: vec![], }, ], @@ -2126,7 +2120,6 @@ fn dont_slash_if_fraction_is_zero() { 11, Staking::stakers(&11), ), - count: 1, reporters: vec![], }], &[Perbill::from_percent(0)], From 97bde5b861fbc9303c6c9e5c0192e17458b42a8b Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:07:36 +0200 Subject: [PATCH 148/191] Add extrinsic to mock grandpa --- srml/grandpa/src/mock.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/srml/grandpa/src/mock.rs b/srml/grandpa/src/mock.rs index aca7bbb8eefc0..04aaef67ba75b 100644 --- a/srml/grandpa/src/mock.rs +++ b/srml/grandpa/src/mock.rs @@ -20,7 +20,7 @@ use sr_primitives::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; use runtime_io; -use srml_support::{impl_outer_origin, impl_outer_event, parameter_types}; +use srml_support::{impl_outer_origin, impl_outer_dispatch, impl_outer_event, parameter_types}; use primitives::{H256, Blake2Hasher}; use codec::{Encode, Decode}; use crate::{AuthorityId, GenesisConfig, Trait, Module, ConsensusLog}; @@ -31,6 +31,11 @@ impl_outer_origin!{ pub enum Origin for Test {} } +impl_outer_dispatch! { + pub enum Call for Test where origin: Origin { + } +} + pub fn grandpa_log(log: ConsensusLog) -> DigestItem { DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()) } @@ -41,7 +46,7 @@ pub struct Test; impl Trait for Test { type Event = TestEvent; type KeyOwnerSystem = (); - type Call = (); + type Call = Extrinsic; type UncheckedExtrinsic = Extrinsic; } parameter_types! { From 782e46d1eb9084d5c1a1ade59fdf5ed51b3d66cf Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:09:43 +0200 Subject: [PATCH 149/191] Fix tx pool test --- core/transaction-pool/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/transaction-pool/src/tests.rs b/core/transaction-pool/src/tests.rs index 71ed988e5e7b3..c54e6f6cb9e7f 100644 --- a/core/transaction-pool/src/tests.rs +++ b/core/transaction-pool/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use codec::Encode; -use txpool::{self, Pool}; +use txpool::{self, Pool, SubmitExtrinsic}; use test_client::{runtime::{AccountId, Block, Hash, Index, Extrinsic, Transfer}, AccountKeyring::{self, *}}; use sr_primitives::{ generic::{self, BlockId}, From ab32ead93c3da0cbe242f0db7bfd2bacbdd0657e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:43:05 +0200 Subject: [PATCH 150/191] move construct back to node --- node/runtime/src/lib.rs | 26 ++++++++++++++++++++++---- srml/grandpa/src/lib.rs | 32 ++------------------------------ srml/grandpa/src/mock.rs | 9 +-------- 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 36f2ecd486a53..b2a029025f6d2 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -419,10 +419,8 @@ impl offences::Trait for Runtime { } impl grandpa::Trait for Runtime { - type Call = Call; - type UncheckedExtrinsic = UncheckedExtrinsic; type Event = Event; - type KeyOwnerSystem = Historical; + // type KeyOwnerSystem = Historical; } parameter_types! { @@ -567,7 +565,27 @@ impl_runtime_apis! { equivocation: GrandpaEquivocationFrom ) -> Option> { let proof = Historical::prove((key_types::GRANDPA, equivocation.identity.encode()))?; - Grandpa::construct_equivocation_transaction(equivocation, proof) + let local_keys = runtime_io::ed25519_public_keys(key_types::GRANDPA); + + if local_keys.len() > 0 { + let reporter = &local_keys[0]; + let to_sign = (equivocation.clone(), proof.clone()); + + let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + runtime_io::ed25519_sign(key_types::GRANDPA, reporter, &runtime_io::blake2_256(payload)) + } else { + runtime_io::ed25519_sign(key_types::GRANDPA, reporter, &payload) + }); + + if let Some(signature) = maybe_signature { + let call = GrandpaCall::report_equivocation(equivocation, proof, signature.into()); + let grandpa_call = Call::Grandpa(call); + let ex = UncheckedExtrinsic::new_unsigned(grandpa_call); + return Some(ex.encode()) + } + } + + None } } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index eff2a1b0af08b..c08e7c1d59022 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -40,7 +40,7 @@ use app_crypto::RuntimeAppPublic; use sr_primitives::{ generic::{DigestItem, OpaqueDigestItemId}, Perbill, KeyTypeId, transaction_validity::{TransactionValidity, ValidTransaction}, - traits::{Zero, ValidateUnsigned, Extrinsic as ExtrinsicT} + traits::{Zero, ValidateUnsigned} }; use runtime_io::blake2_256; use sr_staking_primitives::{SessionIndex, offence::{TimeSlot, Offence, Kind}}; @@ -58,9 +58,7 @@ mod tests; pub trait Trait: system::Trait { /// The event type of this module. type Event: From + Into<::Event>; - type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; - type Call: From>; - type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; + // type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; } /// A stored pending change, old format. @@ -405,32 +403,6 @@ impl Module { } } - pub fn construct_equivocation_transaction( - equivocation: GrandpaEquivocation, - proof: Proof, - ) -> Option> { - let local_keys = app::Public::all(); - - if local_keys.len() > 0 { - let reporter = &local_keys[0]; - let to_sign = (equivocation.clone(), proof.clone()); - - let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { - reporter.sign(&blake2_256(payload)) - } else { - reporter.sign(&payload) - }); - - if let Some(signature) = maybe_signature { - let call = Call::report_equivocation(equivocation, proof, signature.into()); - let ex = T::UncheckedExtrinsic::new_unsigned(call.into())?; - return Some(ex.encode()) - } - } - - None - } - /// Deposit one of this module's logs. fn deposit_log(log: ConsensusLog) { let log: DigestItem = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); diff --git a/srml/grandpa/src/mock.rs b/srml/grandpa/src/mock.rs index 04aaef67ba75b..403f15d838ad7 100644 --- a/srml/grandpa/src/mock.rs +++ b/srml/grandpa/src/mock.rs @@ -31,11 +31,6 @@ impl_outer_origin!{ pub enum Origin for Test {} } -impl_outer_dispatch! { - pub enum Call for Test where origin: Origin { - } -} - pub fn grandpa_log(log: ConsensusLog) -> DigestItem { DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()) } @@ -45,9 +40,7 @@ pub fn grandpa_log(log: ConsensusLog) -> DigestItem { pub struct Test; impl Trait for Test { type Event = TestEvent; - type KeyOwnerSystem = (); - type Call = Extrinsic; - type UncheckedExtrinsic = Extrinsic; + // type KeyOwnerSystem = (); } parameter_types! { pub const BlockHashCount: u64 = 250; From de9fccc2703faa4ff302b2eab01778f2b5790519 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:47:21 +0200 Subject: [PATCH 151/191] simplify slots --- core/consensus/slots/src/aux_schema.rs | 67 +++++++++++++++++--------- core/consensus/slots/src/lib.rs | 4 +- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index f2b225c2ba899..97a93e9fe5b56 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -22,7 +22,6 @@ use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Header; use app_crypto::RuntimeAppPublic; -use consensus_common_primitives::AuthorshipEquivocationProof; use srml_session::historical::Proof; use keystore::KeyStorePtr; use sr_staking_primitives::SessionIndex; @@ -50,27 +49,35 @@ fn load_decode(backend: &C, key: &[u8]) -> ClientResult> } } +/// Represents an Babe equivocation proof. +#[derive(Clone, Encode, Decode, PartialEq, Debug)] +// #[cfg_attr(any(feature = "std", test), derive(Debug))] +pub struct EquivocationProof { + pub reporter: P, + pub identity: P, + pub slot: u64, + pub first_header: H, + pub second_header: H, + pub first_signature: S, + pub second_signature: S, +} + /// Checks if the header is an equivocation and returns the proof in that case. /// /// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY. -pub fn check_equivocation( +pub fn check_equivocation( backend: &C, slot_now: u64, slot: u64, header: &H, signature: V::Signature, signer: &V, -) -> ClientResult> +) -> ClientResult::Signature>>> where H: Header, C: AuxStore, V: RuntimeAppPublic + Codec + Clone + PartialEq, ::Signature: Clone + Codec, - E: AuthorshipEquivocationProof< - Header=H, - Signature=::Signature, - Identity=V, - >, { // We don't check equivocations for old headers out of our capacity. // if slot_now - slot > MAX_SLOT_CAPACITY { @@ -100,14 +107,15 @@ pub fn check_equivocation( // 2) with different hash // if header.hash() != prev_header.hash() { - return Ok(Some(AuthorshipEquivocationProof::new( - signer.clone(), + return Ok(Some(EquivocationProof { + reporter: signer.clone(), + identity: signer.clone(), slot, - header.clone(), - header.clone(), - signature.clone(), - signature.clone(), - ))); + first_header: header.clone(), + second_header: header.clone(), + first_signature: signature.clone(), + second_signature: signature.clone(), + })); // } else { // We don't need to continue in case of duplicated header, // since it's already saved and a possible equivocation @@ -146,11 +154,13 @@ pub fn check_equivocation( #[cfg(test)] mod test { + use super::*; use primitives::{sr25519, Pair}; use primitives::hash::H256; use sr_primitives::testing::{Header as HeaderTest, Digest as DigestTest}; - use test_client; - + use test_client::{ + runtime::app_crypto::ed25519::{AppPair, AppPublic, AppSignature }, + }; use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation}; fn create_header(number: u64) -> HeaderTest { @@ -171,7 +181,7 @@ mod test { #[test] fn check_equivocation_works() { let client = test_client::new(); - let (pair, _seed) = sr25519::Pair::generate(); + let (pair, _seed) = AppPair::generate(); let public = pair.public(); let header1 = create_header(1); // @ slot 2 @@ -181,6 +191,8 @@ mod test { let header5 = create_header(4); // @ slot MAX_SLOT_CAPACITY + 4 let header6 = create_header(3); // @ slot 4 + let signature1: AppSignature = pair.sign(header1.encode().as_slice()); + // It's ok to sign same headers. assert!( check_equivocation( @@ -188,6 +200,7 @@ mod test { 2, 2, &header1, + signature1, &public, ).unwrap().is_none(), ); @@ -198,7 +211,8 @@ mod test { 3, 2, &header1, - &public, + signature1, + &public.into(), ).unwrap().is_none(), ); @@ -209,7 +223,8 @@ mod test { 4, 2, &header2, - &public, + signature1, + &public.into(), ).unwrap().is_some(), ); @@ -220,7 +235,8 @@ mod test { 5, 4, &header3, - &public, + signature1, + &public.into(), ).unwrap().is_none(), ); @@ -231,7 +247,8 @@ mod test { PRUNING_BOUND + 2, MAX_SLOT_CAPACITY + 4, &header4, - &public, + signature1, + &public.into(), ).unwrap().is_none(), ); @@ -242,7 +259,8 @@ mod test { PRUNING_BOUND + 3, MAX_SLOT_CAPACITY + 4, &header5, - &public, + signature1, + &public.into(), ).unwrap().is_some(), ); @@ -253,7 +271,8 @@ mod test { PRUNING_BOUND + 4, 4, &header6, - &public, + signature1, + &public.into(), ).unwrap().is_none(), ); } diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index 6a1f474e39957..a94e4ff14ffbd 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -28,7 +28,9 @@ mod aux_schema; pub use slots::{SignedDuration, SlotInfo}; use slots::Slots; -pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND}; +pub use aux_schema::{ + check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND, EquivocationProof +}; use codec::{Decode, Encode}; use consensus_common::{SyncOracle, SelectChain}; From 10741ec0e40c8b8ca80f52fc36008f4fe32508ec Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:48:47 +0200 Subject: [PATCH 152/191] update babe --- srml/babe/src/lib.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 92f7ebb376ff7..7617061e0f627 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -53,7 +53,7 @@ use system::ensure_signed; use consensus_common_primitives::AuthorshipEquivocationProof; use babe_primitives::{ BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, - BabeEquivocationProof, get_slot + EquivocationProof, get_slot }; use app_crypto::RuntimeAppPublic; pub use babe_primitives::{AuthorityId, AuthoritySignature, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH, app}; @@ -226,12 +226,12 @@ impl ValidateUnsigned for Module where T: Trait } fn equivocation_is_valid( - equivocation: &BabeEquivocationProof, + equivocation: &EquivocationProof, proof: &Proof, signature: &AuthoritySignature, ) -> bool { let signed = (equivocation, proof); - let reporter = equivocation.reporter().expect("FIXME"); + let reporter = &equivocation.reporter; let signature_valid = signed.using_encoded(|signed| if signed.len() > 256 { reporter.verify(&blake2_256(signed), &signature) @@ -243,15 +243,15 @@ fn equivocation_is_valid( return false } - let first_header = equivocation.first_header(); - let second_header = equivocation.second_header(); + let first_header = &equivocation.first_header; + let second_header = &equivocation.second_header; if first_header == second_header { return false } - let maybe_first_slot = get_slot::(first_header); - let maybe_second_slot = get_slot::(second_header); + let maybe_first_slot = get_slot::(&first_header); + let maybe_second_slot = get_slot::(&second_header); if maybe_first_slot.is_err() || maybe_second_slot.is_err() { return false @@ -259,13 +259,13 @@ fn equivocation_is_valid( let first_slot = maybe_first_slot.expect("checked before; qed"); let second_slot = maybe_second_slot.expect("checked before; qed"); - if equivocation.slot() == first_slot && first_slot == second_slot { - let author = equivocation.identity(); + if equivocation.slot == first_slot && first_slot == second_slot { + let author = &equivocation.identity; - if !author.verify(&first_header.hash(), equivocation.first_signature()) { + if !author.verify(&first_header.hash(), &equivocation.first_signature) { return false } - if !author.verify(&second_header.hash(), equivocation.second_signature()) { + if !author.verify(&second_header.hash(), &equivocation.second_signature) { return false } return true; @@ -313,19 +313,19 @@ decl_module! { fn report_equivocation( origin, - equivocation: BabeEquivocationProof, + equivocation: EquivocationProof, proof: Proof, _signature: AuthoritySignature ) { let who = ensure_signed(origin)?; let to_punish = ::KeyOwnerSystem::check_proof( - (key_types::BABE, equivocation.identity().encode()), + (key_types::BABE, equivocation.identity.encode()), proof.clone(), ); if let Some(to_punish) = to_punish { let offence = BabeEquivocationOffence { - slot: equivocation.slot(), - session_index: equivocation.session_index().expect("FIXME").clone(), + slot: equivocation.slot, + session_index: SessionIndex::default(), validator_set_count: 0, offender: to_punish, }; @@ -425,7 +425,7 @@ impl Module { } pub fn construct_equivocation_transaction( - equivocation: BabeEquivocationProof, + equivocation: EquivocationProof, proof: Proof, ) -> Option> { let local_keys = app::Public::all(); From 9f822969ae30c127ef35ccf7d3e2bdf08f13dd7b Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:49:15 +0200 Subject: [PATCH 153/191] update node --- node/runtime/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index b2a029025f6d2..e4e4d1605cece 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -35,7 +35,7 @@ use node_primitives::{ use codec::{Encode}; use consensus_primitives::AuthorshipEquivocationProof; use babe::{AuthorityId as BabeId}; -use babe_primitives::BabeEquivocationProof; +use babe_primitives::EquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; use client::{ block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult}, @@ -614,7 +614,7 @@ impl_runtime_apis! { } fn construct_equivocation_transaction( - equivocation: BabeEquivocationProof<::Header>, + equivocation: EquivocationProof<::Header, babe_primitives::AuthorityId, babe_primitives::AuthoritySignature>, ) -> Option> { let proof = Historical::prove((key_types::BABE, equivocation.identity().encode()))?; Babe::construct_equivocation_transaction(equivocation, proof) From 940bef679f5efdf5a46d018daaf6d22ea87bd5b9 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 10:50:16 +0200 Subject: [PATCH 154/191] Update consensus --- core/consensus/babe/primitives/Cargo.toml | 3 +- core/consensus/babe/primitives/src/lib.rs | 154 ++++++++++------------ core/consensus/babe/src/lib.rs | 4 +- 3 files changed, 74 insertions(+), 87 deletions(-) diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 42263da095f36..72e1fd1bb9222 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -11,7 +11,7 @@ rstd = { package = "sr-std", path = "../../../sr-std", default-features = false sr-primitives = { path = "../../../sr-primitives", default-features = false } sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } -slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } +slots = { package = "substrate-consensus-slots", path = "../../slots" } schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../../common/primitives", default-features = false } @@ -25,7 +25,6 @@ std = [ "substrate-client/std", "codec/std", "schnorrkel", - "slots", "app-crypto/std", "consensus_common_primitives/std", ] diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 7821c123dcc1d..d640383535d75 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -15,8 +15,8 @@ // along with Substrate. If not, see . //! Primitives for BABE. -#![deny(warnings)] -#![forbid(unsafe_code, missing_docs, unused_variables, unused_imports)] +// #![deny(warnings)] +// #![forbid(unsafe_code, missing_docs, unused_variables, unused_imports)] #![cfg_attr(not(feature = "std"), no_std)] mod digest; @@ -27,6 +27,7 @@ use sr_primitives::{ConsensusEngineId, traits::Header}; use substrate_client::decl_runtime_apis; use consensus_common_primitives::AuthorshipEquivocationProof; use sr_staking_primitives::SessionIndex; +pub use slots::EquivocationProof; #[cfg(feature = "std")] pub use digest::BabePreDigest; @@ -143,87 +144,74 @@ impl slots::SlotData for BabeConfiguration { const SLOT_KEY: &'static [u8] = b"babe_bootstrap_data"; } -/// Represents an Babe equivocation proof. -#[derive(Clone, Encode, Decode, PartialEq)] -#[cfg_attr(any(feature = "std", test), derive(Debug))] -pub struct BabeEquivocationProof { - reporter: Option, - identity: AuthorityId, - slot: u64, - session_index: Option, - first_header: H, - second_header: H, - first_signature: AuthoritySignature, - second_signature: AuthoritySignature, -} - -impl AuthorshipEquivocationProof for BabeEquivocationProof -where - H: Header, -{ - type Header = H; - type Identity = AuthorityId; - type Signature = AuthoritySignature; - - /// Create a new Babe equivocation proof. - fn new( - identity: Self::Identity, - slot: u64, - first_header: H, - second_header: H, - first_signature: Self::Signature, - second_signature: Self::Signature, - ) -> Self { - BabeEquivocationProof { - reporter: None, - identity, - slot, - session_index: None, - first_header, - second_header, - first_signature, - second_signature, - } - } - - /// Get the reporter of the equivocation. - fn reporter(&self) -> Option<&Self::Identity> { - self.reporter.as_ref() - } - - /// Get the slot where the equivocation happened. - fn slot(&self) -> u64 { - self.slot - } - - /// Get the session index where the equivocation happened. - fn session_index(&self) -> Option<&SessionIndex> { - self.session_index.as_ref() - } - /// Get the identity of the suspect of equivocating. - fn identity(&self) -> &Self::Identity { - &self.identity - } - - /// Get the first header involved in the equivocation. - fn first_header(&self) -> &H { - &self.first_header - } - - /// Get the second header involved in the equivocation. - fn second_header(&self) -> &H { - &self.second_header - } - - fn first_signature(&self) -> &Self::Signature { - &self.first_signature - } - - fn second_signature(&self) -> &Self::Signature { - &self.second_signature - } -} +// impl AuthorshipEquivocationProof for BabeEquivocationProof +// where +// H: Header, +// { +// type Header = H; +// type Identity = AuthorityId; +// type Signature = AuthoritySignature; + +// /// Create a new Babe equivocation proof. +// fn new( +// identity: Self::Identity, +// slot: u64, +// first_header: H, +// second_header: H, +// first_signature: Self::Signature, +// second_signature: Self::Signature, +// ) -> Self { +// BabeEquivocationProof { +// reporter: None, +// identity, +// slot, +// session_index: None, +// first_header, +// second_header, +// first_signature, +// second_signature, +// } +// } + +// /// Get the reporter of the equivocation. +// fn reporter(&self) -> Option<&Self::Identity> { +// self.reporter.as_ref() +// } + +// /// Get the slot where the equivocation happened. +// fn slot(&self) -> u64 { +// self.slot +// } + +// /// Get the session index where the equivocation happened. +// fn session_index(&self) -> Option<&SessionIndex> { +// self.session_index.as_ref() +// } + +// /// Get the identity of the suspect of equivocating. +// fn identity(&self) -> &Self::Identity { +// &self.identity +// } + +// /// Get the first header involved in the equivocation. +// fn first_header(&self) -> &H { +// &self.first_header +// } + +// /// Get the second header involved in the equivocation. +// fn second_header(&self) -> &H { +// &self.second_header +// } + +// fn first_signature(&self) -> &Self::Signature { +// &self.first_signature +// } + +// fn second_signature(&self) -> &Self::Signature { +// &self.second_signature +// } +// } decl_runtime_apis! { @@ -240,7 +228,7 @@ decl_runtime_apis! { /// Construct a transaction to report the equivocation. fn construct_equivocation_transaction( - equivocation: BabeEquivocationProof + equivocation: EquivocationProof ) -> Option>; } } diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index b9321df491d00..1e01e18273ce3 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -84,7 +84,7 @@ use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, SignedDuration}; mod aux_schema; #[cfg(test)] mod tests; -pub use babe_primitives::{AuthorityId, AuthorityPair, AuthoritySignature, BabeEquivocationProof}; +pub use babe_primitives::{AuthorityId, AuthorityPair, AuthoritySignature, EquivocationProof}; /// A slot duration. Create with `get_or_compute`. // FIXME: Once Rust has higher-kinded types, the duplication between this @@ -511,7 +511,7 @@ fn check_header( } if let Some(equivocation_proof) = check_equivocation::< - _, _, BabeEquivocationProof, _ + _, _, EquivocationProof, _ >( client, slot_now, From f9b82dbcf000ab459ed98c393ddc603cde6543e6 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 11:07:36 +0200 Subject: [PATCH 155/191] fix test --- core/consensus/babe/src/lib.rs | 9 +++------ core/finality-grandpa/primitives/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 1e01e18273ce3..d0f98eb4bd77a 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -77,7 +77,6 @@ use futures::{prelude::*, future}; use futures01::Stream as _; use futures_timer::Delay; use log::{error, warn, debug, info, trace}; -use consensus_common_primitives::AuthorshipEquivocationProof; use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, SignedDuration}; @@ -510,9 +509,7 @@ fn check_header( threshold {} exceeded", author, threshold)); } - if let Some(equivocation_proof) = check_equivocation::< - _, _, EquivocationProof, _ - >( + if let Some(equivocation_proof) = check_equivocation( client, slot_now, slot_number, @@ -524,8 +521,8 @@ fn check_header( "Slot author {:?} is equivocating at slot {} with headers {:?} and {:?}", author, slot_number, - equivocation_proof.first_header().hash(), - equivocation_proof.second_header().hash(), + equivocation_proof.first_header.hash(), + equivocation_proof.second_header.hash(), ); // Submit a transaction reporting the equivocation. diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 072a32ad67e35..0459ddbcf2d8c 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -12,7 +12,7 @@ sr-primitives = { path = "../../sr-primitives", default-features = false } sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false } session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] From b7f44fc3c5ce9240273b6ed9c50c576a5ab226e0 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 15 Aug 2019 18:27:33 +0200 Subject: [PATCH 156/191] Fix doc on time_slot --- core/sr-staking-primitives/src/offence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index 11604af942722..c9c6bcfe5de05 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -75,7 +75,7 @@ pub trait Offence { /// both `session_index` and `time_slot` are equal. /// /// As an example, for GRANDPA timescale could be a round number and for BABE it could be a slot - /// number. Note that for BABE the round number is reset each epoch. + /// number. Note that for GRANDPA the round number is reset each epoch. fn time_slot(&self) -> TimeSlot; /// A slash fraction of the total exposure that should be slashed for this From dcf04c9cdbc9bbe3294e3c4875abca384463c3c8 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Thu, 15 Aug 2019 12:50:01 +0200 Subject: [PATCH 157/191] fix stuff --- Cargo.lock | 1 + core/consensus/aura/src/lib.rs | 1 - core/consensus/babe/primitives/Cargo.toml | 3 +- core/consensus/babe/primitives/src/lib.rs | 3 +- core/consensus/babe/src/tests.rs | 13 ++++- core/consensus/common/primitives/Cargo.toml | 2 +- core/consensus/common/primitives/src/lib.rs | 59 ++++++--------------- core/consensus/slots/src/aux_schema.rs | 42 ++++++--------- core/consensus/slots/src/lib.rs | 5 +- core/finality-grandpa/primitives/Cargo.toml | 2 +- core/finality-grandpa/src/tests.rs | 1 + core/service/src/components.rs | 4 +- core/service/test/Cargo.toml | 1 + core/service/test/src/lib.rs | 1 + core/test-runtime/src/lib.rs | 14 +++-- node/runtime/src/lib.rs | 29 +++++++--- srml/babe/src/lib.rs | 33 +----------- 17 files changed, 91 insertions(+), 123 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37ad20f1ebb8c..83cbcace812d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4984,6 +4984,7 @@ dependencies = [ "substrate-network 2.0.0", "substrate-primitives 2.0.0", "substrate-service 2.0.0", + "substrate-transaction-pool 2.0.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 5ddfc506f625b..8a611c3c532ce 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -809,7 +809,6 @@ mod tests { inherent_data_providers, transaction_pool: Default::default(), phantom: Default::default(), - transaction_pool: Default::default(), } }, PeersClient::Light(_) => unreachable!("No (yet) tests for light client + Aura"), diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 72e1fd1bb9222..cb21dd91fdb01 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -11,7 +11,7 @@ rstd = { package = "sr-std", path = "../../../sr-std", default-features = false sr-primitives = { path = "../../../sr-primitives", default-features = false } sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } -slots = { package = "substrate-consensus-slots", path = "../../slots" } +slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../../common/primitives", default-features = false } @@ -26,5 +26,6 @@ std = [ "codec/std", "schnorrkel", "app-crypto/std", + "slots", "consensus_common_primitives/std", ] diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index d640383535d75..5c352fcfaae95 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -25,9 +25,8 @@ use codec::{Encode, Decode}; use rstd::vec::Vec; use sr_primitives::{ConsensusEngineId, traits::Header}; use substrate_client::decl_runtime_apis; -use consensus_common_primitives::AuthorshipEquivocationProof; use sr_staking_primitives::SessionIndex; -pub use slots::EquivocationProof; +pub use consensus_common_primitives::EquivocationProof; #[cfg(feature = "std")] pub use digest::BabePreDigest; diff --git a/core/consensus/babe/src/tests.rs b/core/consensus/babe/src/tests.rs index 01e0acb96402a..fc3bc148ad933 100644 --- a/core/consensus/babe/src/tests.rs +++ b/core/consensus/babe/src/tests.rs @@ -35,6 +35,8 @@ use client::BlockchainEvents; use test_client; use log::debug; use std::{time::Duration, borrow::Borrow, cell::RefCell}; +use transaction_pool::txpool::SubmitExtrinsic; + type Item = generic::DigestItem; type Error = client::error::Error; @@ -87,8 +89,17 @@ pub struct BabeTestNet { type TestHeader = ::Header; type TestExtrinsic = ::Extrinsic; +#[derive(Debug, Encode, Decode, Clone)] +pub struct TestPool; + +impl SubmitExtrinsic for TestPool +{ + fn submit_one(&self, _client: &C, _extrinsic: &[u8]) { + } +} + pub struct TestVerifier { - inner: BabeVerifier, + inner: BabeVerifier, mutator: Mutator, } diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index 4636fe085ade1..70e8aba4612b7 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -6,7 +6,7 @@ description = "Common consensus primitives" edition = "2018" [dependencies] -codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } client = { package = "substrate-client", path = "../../../client", default-features = false } sr-primitives = { path = "../../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index 708e801d7824b..f700607eb2c19 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -18,12 +18,23 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::Codec; +use codec::{Encode, Decode, Codec}; use client::decl_runtime_apis; use rstd::vec::Vec; use sr_primitives::traits::Header; -use sr_staking_primitives::SessionIndex; -use app_crypto::RuntimeAppPublic; + +/// Represents an Babe equivocation proof. +#[cfg_attr(feature = "std", derive(Debug))] +#[derive(Clone, PartialEq, Eq, Decode, Encode)] +pub struct EquivocationProof { + pub reporter: P, + pub identity: P, + pub slot: u64, + pub first_header: H, + pub second_header: H, + pub first_signature: S, + pub second_signature: S, +} decl_runtime_apis! { /// Common consensus runtime api. @@ -31,44 +42,4 @@ decl_runtime_apis! { /// Returns the set of authorities of the currently active consensus mechanism. fn authorities() -> Vec; } -} - -pub trait AuthorshipEquivocationProof { - type Header: Header; - type Signature: Codec; - type Identity: Codec + RuntimeAppPublic; - - /// Create an equivocation proof for AuRa or Babe. - fn new( - identity: Self::Identity, - slot: u64, - first_header: Self::Header, - second_header: Self::Header, - first_signature: Self::Signature, - second_signature: Self::Signature, - ) -> Self; - - /// Get the reporter of the equivocation. - fn reporter(&self) -> Option<&Self::Identity>; - - /// Get the session index where the equivocation happened. - fn session_index(&self) -> Option<&SessionIndex>; - - /// Get the slot where the equivocation happened. - fn slot(&self) -> u64; - - /// Get the identity of the suspect of equivocating. - fn identity(&self) -> &Self::Identity; - - /// Get the first header involved in the equivocation. - fn first_header(&self) -> &Self::Header; - - /// Get the second header involved in the equivocation. - fn second_header(&self) -> &Self::Header; - - /// Get signature for the first header involved in the equivocation. - fn first_signature(&self) -> &Self::Signature; - - /// Get signature for the second header involved in the equivocation. - fn second_signature(&self) -> &Self::Signature; -} +} \ No newline at end of file diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 97a93e9fe5b56..f3ea70fb1b5e7 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -25,6 +25,7 @@ use app_crypto::RuntimeAppPublic; use srml_session::historical::Proof; use keystore::KeyStorePtr; use sr_staking_primitives::SessionIndex; +use consensus_common_primitives::EquivocationProof; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; @@ -49,19 +50,6 @@ fn load_decode(backend: &C, key: &[u8]) -> ClientResult> } } -/// Represents an Babe equivocation proof. -#[derive(Clone, Encode, Decode, PartialEq, Debug)] -// #[cfg_attr(any(feature = "std", test), derive(Debug))] -pub struct EquivocationProof { - pub reporter: P, - pub identity: P, - pub slot: u64, - pub first_header: H, - pub second_header: H, - pub first_signature: S, - pub second_signature: S, -} - /// Checks if the header is an equivocation and returns the proof in that case. /// /// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY. @@ -191,7 +179,7 @@ mod test { let header5 = create_header(4); // @ slot MAX_SLOT_CAPACITY + 4 let header6 = create_header(3); // @ slot 4 - let signature1: AppSignature = pair.sign(header1.encode().as_slice()); + let signature: AppSignature = pair.sign(header1.encode().as_slice()); // It's ok to sign same headers. assert!( @@ -200,7 +188,7 @@ mod test { 2, 2, &header1, - signature1, + signature.clone(), &public, ).unwrap().is_none(), ); @@ -211,8 +199,8 @@ mod test { 3, 2, &header1, - signature1, - &public.into(), + signature.clone(), + &public, ).unwrap().is_none(), ); @@ -223,8 +211,8 @@ mod test { 4, 2, &header2, - signature1, - &public.into(), + signature.clone(), + &public, ).unwrap().is_some(), ); @@ -235,8 +223,8 @@ mod test { 5, 4, &header3, - signature1, - &public.into(), + signature.clone(), + &public, ).unwrap().is_none(), ); @@ -247,8 +235,8 @@ mod test { PRUNING_BOUND + 2, MAX_SLOT_CAPACITY + 4, &header4, - signature1, - &public.into(), + signature.clone(), + &public, ).unwrap().is_none(), ); @@ -259,8 +247,8 @@ mod test { PRUNING_BOUND + 3, MAX_SLOT_CAPACITY + 4, &header5, - signature1, - &public.into(), + signature.clone(), + &public, ).unwrap().is_some(), ); @@ -271,8 +259,8 @@ mod test { PRUNING_BOUND + 4, 4, &header6, - signature1, - &public.into(), + signature.clone(), + &public, ).unwrap().is_none(), ); } diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index a94e4ff14ffbd..d5d6691e557f3 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -28,12 +28,11 @@ mod aux_schema; pub use slots::{SignedDuration, SlotInfo}; use slots::Slots; -pub use aux_schema::{ - check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND, EquivocationProof -}; +pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND}; use codec::{Decode, Encode}; use consensus_common::{SyncOracle, SelectChain}; +use consensus_common_primitives::EquivocationProof; use futures::{prelude::*, future::{self, Either}}; use inherents::{InherentData, InherentDataProviders}; use log::{debug, error, info, warn}; diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 0459ddbcf2d8c..072a32ad67e35 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -12,7 +12,7 @@ sr-primitives = { path = "../../sr-primitives", default-features = false } sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false } +grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index bbaae1e9b7e01..4a3d12c4d7a41 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -422,6 +422,7 @@ fn run_to_completion_with( inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, + transaction_pool: Arc::new(()), }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 486c6a07aa6ba..6512ef9f1e0ca 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -28,7 +28,9 @@ use network::{ self, OnDemand, FinalityProofProvider, NetworkStateInfo, config::BoxFinalityProofRequestBuilder }; use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; -use transaction_pool::txpool::{self, Options as TransactionPoolOptions, Pool as TransactionPool}; +use transaction_pool::txpool::{ + self, Options as TransactionPoolOptions, Pool as TransactionPool, SubmitExtrinsic +}; use sr_primitives::{ BuildStorage, traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}, generic::BlockId }; diff --git a/core/service/test/Cargo.toml b/core/service/test/Cargo.toml index aa3dddfc1851e..0f7aeae7b2792 100644 --- a/core/service/test/Cargo.toml +++ b/core/service/test/Cargo.toml @@ -17,3 +17,4 @@ consensus = { package = "substrate-consensus-common", path = "../../../core/cons client = { package = "substrate-client", path = "../../../core/client" } sr-primitives = { path = "../../../core/sr-primitives" } primitives = { package = "substrate-primitives", path = "../../../core/primitives" } +transaction_pool = { package = "substrate-transaction-pool", path = "../../../core/transaction-pool" } diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index 1b3c43dae74bb..475b93ee30f86 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -38,6 +38,7 @@ use network::{multiaddr, Multiaddr}; use network::config::{NetworkConfiguration, TransportConfig, NodeKeyConfig, Secret, NonReservedPeerMode}; use sr_primitives::generic::BlockId; use consensus::{BlockImportParams, BlockImport}; +use transaction_pool::txpool::SubmitExtrinsic; /// Maximum duration of single wait call. const MAX_WAIT_TIME: Duration = Duration::from_secs(60 * 3); diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index e5780803cfc4b..7f2ac4c4d4d10 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -53,7 +53,7 @@ use inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; // Ensure Babe and Aura use the same crypto to simplify things a bit. -pub use babe_primitives::AuthorityId; +pub use babe_primitives::{AuthorityId, AuthoritySignature}; pub type AuraId = aura_primitives::sr25519::AuthorityId; // Inlucde the WASM binary @@ -620,7 +620,11 @@ cfg_if! { } fn construct_equivocation_transaction( - equivocation: babe_primitives::BabeEquivocationProof<::Header>, + equivocation: babe_primitives::EquivocationProof< + ::Header, + AuthorityId, + AuthoritySignature + >, ) -> Option> { Some(vec![]) } @@ -839,7 +843,11 @@ cfg_if! { } fn construct_equivocation_transaction( - equivocation: babe_primitives::BabeEquivocationProof<::Header>, + equivocation: babe_primitives::EquivocationProof< + ::Header, + AuthorityId, + AuthoritySignature + >, ) -> Option> { Some(vec![]) } diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index e4e4d1605cece..433624f9c403e 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -32,8 +32,7 @@ use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; -use codec::{Encode}; -use consensus_primitives::AuthorshipEquivocationProof; +use codec::{Encode, Decode}; use babe::{AuthorityId as BabeId}; use babe_primitives::EquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; @@ -147,8 +146,6 @@ impl babe::Trait for Runtime { type ExpectedBlockTime = ExpectedBlockTime; type KeyOwnerSystem = Historical; type ReportEquivocation = Offences; - type Call = Call; - type UncheckedExtrinsic = UncheckedExtrinsic; } impl indices::Trait for Runtime { @@ -616,8 +613,28 @@ impl_runtime_apis! { fn construct_equivocation_transaction( equivocation: EquivocationProof<::Header, babe_primitives::AuthorityId, babe_primitives::AuthoritySignature>, ) -> Option> { - let proof = Historical::prove((key_types::BABE, equivocation.identity().encode()))?; - Babe::construct_equivocation_transaction(equivocation, proof) + let proof = Historical::prove((key_types::BABE, equivocation.identity.encode()))?; + let local_keys = runtime_io::sr25519_public_keys(key_types::GRANDPA); + + if local_keys.len() > 0 { + let reporter = &local_keys[0]; + let to_sign = (equivocation.clone(), proof.clone()); + + let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + runtime_io::sr25519_sign(key_types::BABE, reporter, &runtime_io::blake2_256(payload)) + } else { + runtime_io::sr25519_sign(key_types::BABE, reporter, &payload) + }); + + if let Some(signature) = maybe_signature { + let call = BabeCall::report_equivocation(equivocation, proof, signature.into()); + let babe_call = Call::Babe(call); + let ex = UncheckedExtrinsic::new_unsigned(babe_call); + return Some(ex.encode()) + } + } + + None } } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 7617061e0f627..6cc156f190388 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -35,8 +35,7 @@ use sr_primitives::{ transaction_validity::{TransactionValidity, ValidTransaction}, }; use sr_primitives::traits::{ - IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header, - ValidateUnsigned, Extrinsic as ExtrinsicT + IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header, ValidateUnsigned, }; use sr_staking_primitives::{ SessionIndex, @@ -50,7 +49,6 @@ use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent use inherents::{InherentDataProviders, ProvideInherentData}; use session::historical::{Proof, IdentificationTuple}; use system::ensure_signed; -use consensus_common_primitives::AuthorshipEquivocationProof; use babe_primitives::{ BABE_ENGINE_ID, ConsensusLog, BabeWeight, Epoch, RawBabePreDigest, EquivocationProof, get_slot @@ -134,9 +132,6 @@ pub trait Trait: timestamp::Trait + session::historical::Trait { type EpochDuration: Get; type ExpectedBlockTime: Get; - type Call: From>; - type UncheckedExtrinsic: ExtrinsicT::Call> + Encode + Decode; - type KeyOwnerSystem: KeyOwnerProofSystem< (KeyTypeId, Vec), Proof=Proof, @@ -424,32 +419,6 @@ impl Module { ::MinimumPeriod::get().saturating_mul(2.into()) } - pub fn construct_equivocation_transaction( - equivocation: EquivocationProof, - proof: Proof, - ) -> Option> { - let local_keys = app::Public::all(); - - if local_keys.len() > 0 { - let reporter = &local_keys[0]; - let to_sign = (equivocation.clone(), proof.clone()); - - let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { - reporter.sign(&blake2_256(payload)) - } else { - reporter.sign(&payload) - }); - - if let Some(signature) = maybe_signature { - let call = Call::report_equivocation(equivocation, proof, signature.into()); - let ex = T::UncheckedExtrinsic::new_unsigned(call.into())?; - return Some(ex.encode()) - } - } - - None - } - fn deposit_consensus(new: U) { let log: DigestItem = DigestItem::Consensus(BABE_ENGINE_ID, new.encode()); >::deposit_log(log.into()) From ce31bf1b76fe1749821f77f44bf0e267ba03423b Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Fri, 16 Aug 2019 09:53:09 +0200 Subject: [PATCH 158/191] Add new SubmitExtrinsic trait --- core/consensus/babe/src/lib.rs | 14 +++---- core/consensus/babe/src/tests.rs | 21 ++++++---- core/finality-grandpa/src/environment.rs | 15 ++++--- core/finality-grandpa/src/lib.rs | 9 ++--- core/offchain/src/api.rs | 2 +- core/rpc/src/author/mod.rs | 1 - core/service/src/components.rs | 2 +- core/service/src/lib.rs | 2 +- core/sr-primitives/src/traits.rs | 17 ++++++++ core/transaction-pool/graph/src/lib.rs | 2 +- core/transaction-pool/graph/src/pool.rs | 50 ++++++++++++------------ 11 files changed, 76 insertions(+), 59 deletions(-) diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index d0f98eb4bd77a..d5767690b2414 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -31,7 +31,7 @@ use consensus_common::well_known_cache_keys::Id as CacheKeyId; use sr_primitives::{generic, generic::{BlockId, OpaqueDigestItemId}, Justification}; use sr_primitives::traits::{ Block as BlockT, Header, DigestItemFor, NumberFor, ProvideRuntimeApi, - SimpleBitOps, Zero, + SimpleBitOps, Zero, SubmitExtrinsic }; use keystore::KeyStorePtr; use runtime_support::serde::{Serialize, Deserialize}; @@ -70,7 +70,6 @@ use client::{ ProvideUncles, utils::is_descendent_of, }; -use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; use fork_tree::ForkTree; use slots::{CheckedHeader, check_equivocation}; use futures::{prelude::*, future}; @@ -463,8 +462,7 @@ fn check_header( DigestItemFor: CompatibleDigestItem, C: ProvideRuntimeApi + HeaderBackend, C::Api: BabeApi, - T: SubmitExtrinsic + Send + Sync + 'static, - ::Api: ChainApi, + T: SubmitExtrinsic> + Send + Sync + 'static, { trace!(target: "babe", "Checking header"); let seal = match header.digest_mut().pop() { @@ -539,7 +537,7 @@ fn check_header( transaction_pool.as_ref().map(|txpool| { let uxt = Decode::decode(&mut report_transaction.as_slice()) .expect("Encoded extrinsic is valid; qed"); - txpool.submit_one(&block_id, uxt) + txpool.submit_extrinsic(&block_id, uxt) }); info!(target: "afg", "Babe equivocation report has been submitted") } else { @@ -641,8 +639,7 @@ fn median_algorithm( impl Verifier for BabeVerifier where C: ProvideRuntimeApi + HeaderBackend + Send + Sync + AuxStore + ProvideCache, C::Api: BlockBuilderApi + BabeApi, - T: SubmitExtrinsic + Send + Sync + 'static, - ::Api: ChainApi, + T: SubmitExtrinsic> + Send + Sync + 'static, { fn verify( &mut self, @@ -1167,8 +1164,7 @@ pub fn import_queue, I, RA, PRA, T>( RA: Send + Sync + 'static, PRA: ProvideRuntimeApi + HeaderBackend + ProvideCache + Send + Sync + AuxStore + 'static, PRA::Api: BlockBuilderApi + BabeApi, - T: SubmitExtrinsic + Send + Sync + 'static, - ::Api: ChainApi, + T: SubmitExtrinsic> + Send + Sync + 'static, { register_babe_inherent_data_provider(&inherent_data_providers, config.get())?; initialize_authorities_cache(&*api)?; diff --git a/core/consensus/babe/src/tests.rs b/core/consensus/babe/src/tests.rs index fc3bc148ad933..5f5d24eb83e70 100644 --- a/core/consensus/babe/src/tests.rs +++ b/core/consensus/babe/src/tests.rs @@ -89,17 +89,24 @@ pub struct BabeTestNet { type TestHeader = ::Header; type TestExtrinsic = ::Extrinsic; -#[derive(Debug, Encode, Decode, Clone)] -pub struct TestPool; - -impl SubmitExtrinsic for TestPool -{ - fn submit_one(&self, _client: &C, _extrinsic: &[u8]) { +struct TransactionPool; + +impl SubmitExtrinsic for TransactionPool { + type BlockId = (); + type Extrinsic = (); + type Error = (); + + fn submit_extrinsic( + &self, + at: &Self::BlockId, + xt: Self::Extrinsic, + ) -> Result<(), Self::Error> { + Ok(()) } } pub struct TestVerifier { - inner: BabeVerifier, + inner: BabeVerifier, mutator: Mutator, } diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 139d8d9a81fc8..859944845f881 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -36,7 +36,8 @@ use grandpa::{ use primitives::{Blake2Hasher, H256, Pair, ExecutionContext}; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ - Block as BlockT, Header as HeaderT, NumberFor, One, Zero, ProvideRuntimeApi + Block as BlockT, Header as HeaderT, NumberFor, One, Zero, ProvideRuntimeApi, + SubmitExtrinsic }; use substrate_telemetry::{telemetry, CONSENSUS_INFO}; @@ -46,7 +47,6 @@ use crate::{ }; use consensus_common::SelectChain; -use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; use sr_staking_primitives::SessionIndex; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; @@ -538,8 +538,7 @@ where RA: 'static + Send + Sync, SC: SelectChain + 'static, NumberFor: BlockNumberOps, - T: SubmitExtrinsic, - ::Api: ChainApi, + T: SubmitExtrinsic>, Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, { @@ -875,8 +874,8 @@ where if let Ok(Some(report_transaction)) = maybe_report_transaction { let uxt = Decode::decode(&mut report_transaction.as_slice()) .expect("Encoded extrinsic is valid; qed"); - match self.transaction_pool.submit_one(&block_id, uxt) { - Err(e) => warn!("Error importing misbehavior report: {:?}", e), + match self.transaction_pool.submit_extrinsic(&block_id, uxt) { + Err(e) => warn!("Error importing misbehavior report: {}", e), Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), } } else { @@ -920,8 +919,8 @@ where if let Ok(Some(report_call)) = maybe_report_call { let uxt = Decode::decode(&mut report_call.as_slice()) .expect("Encoded extrinsic is valid; qed"); - match self.transaction_pool.submit_one(&block_id, uxt) { - Err(e) => warn!("Error importing misbehavior report: {:?}", e), + match self.transaction_pool.submit_extrinsic(&block_id, uxt) { + Err(e) => warn!("Error importing misbehavior report: {}", e), Ok(hash) => info!("Misbehavior report imported to transaction pool: {:?}", hash), } } else { diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 149e3a694203d..bc1891ffef8dc 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -63,7 +63,7 @@ use client::blockchain::HeaderBackend; use codec::Encode; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ - NumberFor, Block as BlockT, DigestFor, ProvideRuntimeApi + NumberFor, Block as BlockT, DigestFor, ProvideRuntimeApi, SubmitExtrinsic }; use fg_primitives::{GrandpaApi, AuthorityPair}; use keystore::KeyStorePtr; @@ -72,7 +72,6 @@ use consensus_common::SelectChain; use primitives::{H256, Blake2Hasher}; use substrate_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN}; use serde_json; -use transaction_pool::txpool::{SubmitExtrinsic, ChainApi}; use srml_finality_tracker; @@ -509,8 +508,7 @@ pub fn run_grandpa_voter, N, RA, SC, X, T>( Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, RA: Send + Sync + 'static + ConstructRuntimeApi>, - T: SubmitExtrinsic, - ::Api: ChainApi, + T: SubmitExtrinsic>, { let GrandpaParams { config, @@ -752,8 +750,7 @@ pub fn run_grandpa, N, RA, SC, X, T>( Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, RA: Send + Sync + 'static + ConstructRuntimeApi>, - T: SubmitExtrinsic, - ::Api: ChainApi, + T: SubmitExtrinsic>, { run_grandpa_voter(grandpa_params) } diff --git a/core/offchain/src/api.rs b/core/offchain/src/api.rs index aa97986f82542..225e7c3f725a4 100644 --- a/core/offchain/src/api.rs +++ b/core/offchain/src/api.rs @@ -32,7 +32,7 @@ use primitives::offchain::{ OpaqueNetworkState, OpaquePeerId, OpaqueMultiaddr, StorageKind, }; use sr_primitives::{generic::BlockId, traits::{self, Extrinsic}}; -use transaction_pool::txpool::{Pool, ChainApi, SubmitExtrinsic}; +use transaction_pool::txpool::{Pool, ChainApi}; /// A message between the offchain extension and the processing thread. enum ExtMessage { diff --git a/core/rpc/src/author/mod.rs b/core/rpc/src/author/mod.rs index 4a1d47dee4557..d797e87da5776 100644 --- a/core/rpc/src/author/mod.rs +++ b/core/rpc/src/author/mod.rs @@ -45,7 +45,6 @@ use transaction_pool::{ IntoPoolError, Pool, watcher::Status, - SubmitExtrinsic, }, }; use session::SessionKeys; diff --git a/core/service/src/components.rs b/core/service/src/components.rs index 6512ef9f1e0ca..2ba6855948c33 100644 --- a/core/service/src/components.rs +++ b/core/service/src/components.rs @@ -29,7 +29,7 @@ use network::{ }; use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; use transaction_pool::txpool::{ - self, Options as TransactionPoolOptions, Pool as TransactionPool, SubmitExtrinsic + self, Options as TransactionPoolOptions, Pool as TransactionPool }; use sr_primitives::{ BuildStorage, traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}, generic::BlockId diff --git a/core/service/src/lib.rs b/core/service/src/lib.rs index 01b3aec233e9d..3c093cebc06e4 100644 --- a/core/service/src/lib.rs +++ b/core/service/src/lib.rs @@ -52,7 +52,7 @@ pub use config::{Configuration, Roles, PruningMode}; pub use chain_spec::{ChainSpec, Properties}; pub use transaction_pool::txpool::{ self, Pool as TransactionPool, Options as TransactionPoolOptions, ChainApi, - IntoPoolError, SubmitExtrinsic + IntoPoolError }; pub use client::FinalityNotifications; diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index ec28c097ced3c..10cd754cd2ec0 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -1203,6 +1203,23 @@ impl AccountIdConver } } +/// Something that can submit an extrinsic. +pub trait SubmitExtrinsic { + /// Id of the block where the extrinsic is submitted. + type BlockId; + /// The extrinsic submitted. + type Extrinsic: Codec; + /// Error type in case of failed submission. + type Error: core::fmt::Display; + + /// Imports one unverified extrinsic to the pool + fn submit_extrinsic( + &self, + at: &Self::BlockId, + xt: Self::Extrinsic, + ) -> Result<(), Self::Error>; +} + #[cfg(test)] mod tests { use super::AccountIdConversion; diff --git a/core/transaction-pool/graph/src/lib.rs b/core/transaction-pool/graph/src/lib.rs index a66733ee42f9f..ea890a5cd0f21 100644 --- a/core/transaction-pool/graph/src/lib.rs +++ b/core/transaction-pool/graph/src/lib.rs @@ -36,4 +36,4 @@ pub mod watcher; pub use self::error::IntoPoolError; pub use self::base_pool::{Transaction, Status}; -pub use self::pool::{Pool, SubmitExtrinsic, Options, ChainApi, EventStream, ExtrinsicFor, BlockHash, ExHash, NumberFor, TransactionFor}; +pub use self::pool::{Pool, Options, ChainApi, EventStream, ExtrinsicFor, BlockHash, ExHash, NumberFor, TransactionFor}; diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index 38bebdbd8d13e..50dc6c781613c 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -33,7 +33,7 @@ use futures::sync::mpsc; use parking_lot::{Mutex, RwLock}; use sr_primitives::{ generic::BlockId, - traits::{self, SaturatedConversion}, + traits::{self, SaturatedConversion, SubmitExtrinsic}, transaction_validity::{TransactionValidity, TransactionTag as Tag}, }; @@ -99,6 +99,24 @@ impl Default for Options { } } +/// Something that can submit an extrinsic. +impl SubmitExtrinsic for Pool { + type BlockId = BlockId; + type Extrinsic = ExtrinsicFor; + type Error = String; + + /// Imports one unverified extrinsic to the pool + fn submit_extrinsic( + &self, + at: &Self::BlockId, + xt: Self::Extrinsic, + ) -> Result<(), Self::Error> { + self.submit_one(at, xt) + .map_err(|e| format!("{}", e)) + .map(|_| ()) + } +} + /// Extrinsics pool. pub struct Pool { api: B, @@ -112,29 +130,6 @@ pub struct Pool { rotator: PoolRotator>, } -/// Something that can submit an extrinsic. -pub trait SubmitExtrinsic { - /// Concrete extrinsic validation and query logic. - type Api: ChainApi; - - /// Imports one unverified extrinsic to the pool - fn submit_one( - &self, - at: &BlockId<::Block>, - xt: ExtrinsicFor, - ) -> Result, ::Error>; -} - -impl SubmitExtrinsic for Pool { - type Api = B; - - fn submit_one(&self, at: &BlockId, xt: ExtrinsicFor) -> Result, B::Error> { - Ok(self.submit_at(at, ::std::iter::once(xt))? - .pop() - .expect("One extrinsic passed; one result returned; qed")?) - } -} - impl Pool { /// Imports a bunch of unverified extrinsics to the pool pub fn submit_at(&self, at: &BlockId, xts: T) -> Result, B::Error>>, B::Error> where @@ -197,6 +192,13 @@ impl Pool { }).collect()) } + /// Imports one unverified extrinsic to the pool + pub fn submit_one(&self, at: &BlockId, xt: ExtrinsicFor) -> Result, B::Error> { + Ok(self.submit_at(at, ::std::iter::once(xt))? + .pop() + .expect("One extrinsic passed; one result returned; qed")?) + } + fn enforce_limits(&self) -> HashSet> { let status = self.pool.read().status(); let ready_limit = &self.options.ready; From 50da947a5aaa9f0d72cc8e1abae6be61c3545196 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Fri, 16 Aug 2019 11:48:00 +0200 Subject: [PATCH 159/191] last changes --- core/consensus/babe/src/tests.rs | 23 +++++++++---------- core/finality-grandpa/src/tests.rs | 36 +++++++++++++++++++++++++++--- core/service/test/src/lib.rs | 1 - core/transaction-pool/src/tests.rs | 2 +- node/cli/src/service.rs | 2 +- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/core/consensus/babe/src/tests.rs b/core/consensus/babe/src/tests.rs index 5f5d24eb83e70..c784b6316f326 100644 --- a/core/consensus/babe/src/tests.rs +++ b/core/consensus/babe/src/tests.rs @@ -27,7 +27,7 @@ use client::{LongestChain, block_builder::BlockBuilder}; use consensus_common::NoNetwork as DummyOracle; use network::test::*; use network::test::{Block as TestBlock, PeersClient}; -use sr_primitives::traits::{Block as BlockT, DigestFor}; +use sr_primitives::traits::{Block as BlockT, DigestFor, SubmitExtrinsic}; use network::config::ProtocolConfig; use tokio::runtime::current_thread; use keyring::sr25519::Keyring; @@ -35,7 +35,6 @@ use client::BlockchainEvents; use test_client; use log::debug; use std::{time::Duration, borrow::Borrow, cell::RefCell}; -use transaction_pool::txpool::SubmitExtrinsic; type Item = generic::DigestItem; @@ -92,9 +91,9 @@ type TestExtrinsic = ::Extrinsic; struct TransactionPool; impl SubmitExtrinsic for TransactionPool { - type BlockId = (); - type Extrinsic = (); - type Error = (); + type BlockId = BlockId; + type Extrinsic = TestExtrinsic; + type Error = String; fn submit_extrinsic( &self, @@ -268,7 +267,7 @@ fn rejects_missing_inherent_digest() { MUTATOR.with(|s| *s.borrow_mut() = Arc::new(move |header: &mut TestHeader| { let v = std::mem::replace(&mut header.digest_mut().logs, vec![]); header.digest_mut().logs = v.into_iter() - .filter(|v| v.as_babe_pre_digest().is_none()) + .filter(|v| v.as_babe_pre_digest::<()>().is_none()) .collect() })); run_one_test() @@ -280,7 +279,7 @@ fn rejects_missing_seals() { MUTATOR.with(|s| *s.borrow_mut() = Arc::new(move |header: &mut TestHeader| { let v = std::mem::replace(&mut header.digest_mut().logs, vec![]); header.digest_mut().logs = v.into_iter() - .filter(|v| v.as_babe_seal().is_none()) + .filter(|v| v.as_babe_seal::<()>().is_none()) .collect() })); run_one_test() @@ -306,15 +305,15 @@ fn wrong_consensus_engine_id_rejected() { let _ = env_logger::try_init(); let sig = AuthorityPair::generate().0.sign(b""); let bad_seal: Item = DigestItem::Seal([0; 4], sig.to_vec()); - assert!(bad_seal.as_babe_pre_digest().is_none()); - assert!(bad_seal.as_babe_seal().is_none()) + assert!(bad_seal.as_babe_pre_digest::<()>().is_none()); + assert!(bad_seal.as_babe_seal::<()>().is_none()) } #[test] fn malformed_pre_digest_rejected() { let _ = env_logger::try_init(); let bad_seal: Item = DigestItem::Seal(BABE_ENGINE_ID, [0; 64].to_vec()); - assert!(bad_seal.as_babe_pre_digest().is_none()); + assert!(bad_seal.as_babe_pre_digest::<()>().is_none()); } #[test] @@ -322,8 +321,8 @@ fn sig_is_not_pre_digest() { let _ = env_logger::try_init(); let sig = AuthorityPair::generate().0.sign(b""); let bad_seal: Item = DigestItem::Seal(BABE_ENGINE_ID, sig.to_vec()); - assert!(bad_seal.as_babe_pre_digest().is_none()); - assert!(bad_seal.as_babe_seal().is_some()) + assert!(bad_seal.as_babe_pre_digest::<()>().is_none()); + assert!(bad_seal.as_babe_seal::<()>().is_some()) } #[test] diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 4a3d12c4d7a41..6f6557a3dc9e7 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -36,10 +36,10 @@ use consensus_common::import_queue::{BoxBlockImport, BoxJustificationImport, Box use std::collections::{HashMap, HashSet}; use std::result; use codec::Decode; -use sr_primitives::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT}; +use sr_primitives::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT, SubmitExtrinsic}; use sr_primitives::generic::BlockId; use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public}; -use fg_primitives::AuthorityId; +use fg_primitives::{AuthorityId, GrandpaEquivocationFrom}; use authorities::AuthoritySet; use finality_proof::{FinalityProofProvider, AuthoritySetForFinalityProver, AuthoritySetForFinalityChecker}; @@ -310,6 +310,16 @@ impl GrandpaApi for RuntimeApi { // extrinsics. Ok(self.inner.forced_changes.lock().get(&parent_hash).map(|c| c.clone())).map(NativeOrEncoded::Native) } + + fn GrandpaApi_construct_equivocation_transaction_runtime_api_impl( + &self, + at: &BlockId, + _: ExecutionContext, + _: Option<(GrandpaEquivocationFrom)>, + _: Vec, + ) -> Result>>> { + Ok(NativeOrEncoded::Native(Some(vec![]))) + } } impl AuthoritySetForFinalityProver for TestApi { @@ -354,6 +364,22 @@ fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir (keystore, keystore_path) } +struct TransactionPool; + +impl SubmitExtrinsic for TransactionPool { + type BlockId = BlockId; + type Extrinsic = (); + type Error = String; + + fn submit_extrinsic( + &self, + at: &Self::BlockId, + xt: Self::Extrinsic, + ) -> std::result::Result<(), Self::Error> { + Ok(()) + } +} + // run the voters to completion. provide a closure to be invoked after // the voters are spawned but before blocking on them. fn run_to_completion_with( @@ -422,7 +448,7 @@ fn run_to_completion_with( inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, - transaction_pool: Arc::new(()), + transaction_pool: Arc::new(TransactionPool), }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -536,6 +562,7 @@ fn finalize_3_voters_1_full_observer() { inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, + transaction_pool: Arc::new(TransactionPool), }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -707,6 +734,7 @@ fn transition_3_voters_twice_1_full_observer() { inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, + transaction_pool: Arc::new(TransactionPool), }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -1133,6 +1161,7 @@ fn voter_persists_its_votes() { inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, + transaction_pool: Arc::new(TransactionPool), }; let voter = run_grandpa_voter(grandpa_params) @@ -1463,6 +1492,7 @@ fn voter_catches_up_to_latest_round_when_behind() { inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, + transaction_pool: Arc::new(TransactionPool), }; Box::new(run_grandpa_voter(grandpa_params).expect("all in order with client and network")) diff --git a/core/service/test/src/lib.rs b/core/service/test/src/lib.rs index 475b93ee30f86..1b3c43dae74bb 100644 --- a/core/service/test/src/lib.rs +++ b/core/service/test/src/lib.rs @@ -38,7 +38,6 @@ use network::{multiaddr, Multiaddr}; use network::config::{NetworkConfiguration, TransportConfig, NodeKeyConfig, Secret, NonReservedPeerMode}; use sr_primitives::generic::BlockId; use consensus::{BlockImportParams, BlockImport}; -use transaction_pool::txpool::SubmitExtrinsic; /// Maximum duration of single wait call. const MAX_WAIT_TIME: Duration = Duration::from_secs(60 * 3); diff --git a/core/transaction-pool/src/tests.rs b/core/transaction-pool/src/tests.rs index c54e6f6cb9e7f..71ed988e5e7b3 100644 --- a/core/transaction-pool/src/tests.rs +++ b/core/transaction-pool/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use codec::Encode; -use txpool::{self, Pool, SubmitExtrinsic}; +use txpool::{self, Pool}; use test_client::{runtime::{AccountId, Block, Hash, Index, Extrinsic, Transfer}, AccountKeyring::{self, *}}; use sr_primitives::{ generic::{self, BlockId}, diff --git a/node/cli/src/service.rs b/node/cli/src/service.rs index 33652a59064cd..386822d7c8128 100644 --- a/node/cli/src/service.rs +++ b/node/cli/src/service.rs @@ -429,7 +429,7 @@ mod tests { // add it to a digest item. let to_sign = pre_hash.encode(); let signature = alice.sign(&to_sign[..]); - let item = ::babe_seal( + let item = ::babe_seal::( signature.into(), ); slot_num += 1; From 369f8f468f017ef76476c379c1f8cf966b611447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 13:32:57 +0200 Subject: [PATCH 160/191] post-merge fixes. --- Cargo.lock | 7 ++++--- core/consensus/babe/primitives/Cargo.toml | 1 + core/consensus/common/primitives/Cargo.toml | 23 +++++++++++---------- core/finality-grandpa/Cargo.toml | 4 ++-- core/finality-grandpa/primitives/Cargo.toml | 2 +- srml/aura/Cargo.toml | 1 + srml/babe/Cargo.toml | 1 - srml/grandpa/Cargo.toml | 22 ++++++++++---------- srml/session/Cargo.toml | 17 ++++++++------- 9 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44b1fa7592324..113977c11850d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -833,6 +833,7 @@ dependencies = [ [[package]] name = "finality-grandpa" version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4531,7 +4532,6 @@ dependencies = [ "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", - "srml-session 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-primitives 2.0.0", @@ -4631,7 +4631,7 @@ name = "substrate-finality-grandpa" version = "2.0.0" dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "finality-grandpa 0.9.0", + "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4667,7 +4667,7 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "2.0.0" dependencies = [ - "finality-grandpa 0.9.0", + "finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -6213,6 +6213,7 @@ dependencies = [ "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" +"checksum finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9681c1f75941ea47584573dd2bc10558b2067d460612945887e00744e43393be" "checksum fixed-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e" "checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index cb21dd91fdb01..52892b3f19081 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -22,6 +22,7 @@ default = ["std"] std = [ "rstd/std", "sr-primitives/std", + "sr-staking-primitives/std", "substrate-client/std", "codec/std", "schnorrkel", diff --git a/core/consensus/common/primitives/Cargo.toml b/core/consensus/common/primitives/Cargo.toml index 70e8aba4612b7..9f9288ccd3eb3 100644 --- a/core/consensus/common/primitives/Cargo.toml +++ b/core/consensus/common/primitives/Cargo.toml @@ -6,23 +6,24 @@ description = "Common consensus primitives" edition = "2018" [dependencies] -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } client = { package = "substrate-client", path = "../../../client", default-features = false } -sr-primitives = { path = "../../../sr-primitives", default-features = false } +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } -srml-session = { path = "../../../../srml/session", default-features = false } +sr-primitives = { path = "../../../sr-primitives", default-features = false } sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } -app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } [features] default = ["std"] std = [ - "rstd/std", - "client/std", - "codec/std", - "sr-primitives/std", - "primitives/std", - "serde" + "app-crypto/std", + "client/std", + "codec/std", + "primitives/std", + "rstd/std", + "serde", + "sr-primitives/std", + "sr-staking-primitives/std", ] diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index e66ce20dae05f..98ceb34ad5cf3 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -27,12 +27,12 @@ service = { package = "substrate-service", path = "../service", optional = true srml-finality-tracker = { path = "../../srml/finality-tracker" } srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } sr-staking-primitives = { path = "../sr-staking-primitives", default-features = false } [dev-dependencies] -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", features = ["derive-codec", "test-helpers"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] } network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } keyring = { package = "substrate-keyring", path = "../keyring" } test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client"} diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 072a32ad67e35..f74bc37f9329b 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -12,7 +12,7 @@ sr-primitives = { path = "../../sr-primitives", default-features = false } sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", path = "/home/marcio/repos/finality-grandpa", default-features = false, features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } session = { package = "srml-session", path = "../../../srml/session", default-features = false } [features] diff --git a/srml/aura/Cargo.toml b/srml/aura/Cargo.toml index 9a5bee6276760..afc1b90adacac 100644 --- a/srml/aura/Cargo.toml +++ b/srml/aura/Cargo.toml @@ -32,6 +32,7 @@ std = [ "primitives/std", "rstd/std", "serde", + "session/std", "sr-primitives/std", "srml-support/std", "substrate-consensus-aura-primitives/std", diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index a43a37568511e..02a491e2846f2 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -33,7 +33,6 @@ std = [ "codec/std", "inherents/std", "rstd/std", - "runtime_io/std", "serde", "session/std", "sr-io/std", diff --git a/srml/grandpa/Cargo.toml b/srml/grandpa/Cargo.toml index 4d0ea5ed0db72..f514ecca68610 100644 --- a/srml/grandpa/Cargo.toml +++ b/srml/grandpa/Cargo.toml @@ -5,20 +5,19 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -serde = { version = "1.0", optional = true, features = ["derive"] } +app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +finality-tracker = { package = "srml-finality-tracker", path = "../finality-tracker", default-features = false } primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } -substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } +serde = { version = "1.0", optional = true, features = ["derive"] } +session = { package = "srml-session", path = "../session", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } srml-support = { path = "../support", default-features = false } +substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } -session = { package = "srml-session", path = "../session", default-features = false } -finality-tracker = { package = "srml-finality-tracker", path = "../finality-tracker", default-features = false } -app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } -runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } [dev-dependencies] runtime_io = { package = "sr-io", path = "../../core/sr-io" } @@ -27,15 +26,16 @@ test_runtime = { package = "substrate-test-runtime", path = "../../core/test-run [features] default = ["std"] std = [ - "serde", "codec/std", + "finality-tracker/std", "primitives/std", - "substrate-finality-grandpa-primitives/std", "rstd/std", - "srml-support/std", + "runtime_io/std", + "serde", + "session/std", "sr-primitives/std", "sr-staking-primitives/std", + "srml-support/std", + "substrate-finality-grandpa-primitives/std", "system/std", - "session/std", - "finality-tracker/std", ] diff --git a/srml/session/Cargo.toml b/srml/session/Cargo.toml index d0166997656ed..58978b25c60ad 100644 --- a/srml/session/Cargo.toml +++ b/srml/session/Cargo.toml @@ -5,17 +5,17 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -serde = { version = "1.0", optional = true } -safe-mix = { version = "1.0", default-features = false} codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } +safe-mix = { version = "1.0", default-features = false} +serde = { version = "1.0", optional = true } sr-primitives = { path = "../../core/sr-primitives", default-features = false } sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } srml-support = { path = "../support", default-features = false } +substrate-trie = { path = "../../core/trie", default-features = false, optional = true } system = { package = "srml-system", path = "../system", default-features = false } timestamp = { package = "srml-timestamp", path = "../timestamp", default-features = false } -substrate-trie = { path = "../../core/trie", default-features = false, optional = true } -runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } [dev-dependencies] primitives = { package = "substrate-primitives", path = "../../core/primitives" } @@ -26,13 +26,14 @@ lazy_static = "1.0" default = ["std", "historical"] historical = ["substrate-trie"] std = [ - "serde", - "safe-mix/std", "codec/std", "rstd/std", - "srml-support/std", + "runtime_io/std", + "safe-mix/std", + "serde", "sr-primitives/std", "sr-staking-primitives/std", + "srml-support/std", + "substrate-trie/std", "timestamp/std", - "substrate-trie/std" ] From 2d0fe687ec4c99d60dad4025fde37cc2ca089395 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 16 Aug 2019 14:02:48 +0200 Subject: [PATCH 161/191] Allow slashing only on current era (#3411) * only slash in current era * prune journal for last era * comment own_slash * emit an event when old slashing events are discarded --- srml/staking/src/lib.rs | 78 +++++++++++++++++++++++++++++++++++++-- srml/staking/src/tests.rs | 2 +- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/srml/staking/src/lib.rs b/srml/staking/src/lib.rs index d10e2939c73cc..ade5bcdac2d81 100644 --- a/srml/staking/src/lib.rs +++ b/srml/staking/src/lib.rs @@ -280,7 +280,7 @@ use sr_primitives::traits::{ }; use sr_staking_primitives::{ SessionIndex, CurrentElectedSet, - offence::{OnOffenceHandler, OffenceDetails}, + offence::{OnOffenceHandler, OffenceDetails, Offence, ReportOffence}, }; #[cfg(feature = "std")] use sr_primitives::{Serialize, Deserialize}; @@ -441,6 +441,15 @@ pub struct Exposure { pub others: Vec>, } +/// A slashing event occurred, slashing a validator for a given amount of balance. +#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default)] +#[cfg_attr(feature = "std", derive(Debug))] +pub struct SlashJournalEntry { + who: AccountId, + amount: Balance, + own_slash: Balance, // the amount of `who`'s own exposure that was slashed +} + pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; type PositiveImbalanceOf = @@ -614,6 +623,10 @@ decl_storage! { /// A mapping from still-bonded eras to the first session index of that era. BondedEras: Vec<(EraIndex, SessionIndex)>; + + /// All slashes that have occurred in a given era. + EraSlashJournal get(era_slash_journal): + map EraIndex => Vec>>; } add_extra_genesis { config(stakers): @@ -659,6 +672,9 @@ decl_event!( Reward(Balance), /// One validator (and its nominators) has been slashed by the given amount. Slash(AccountId, Balance), + /// An old slashing report from a prior era was discarded because it could + /// not be processed. + OldSlashingReportDiscarded(SessionIndex), } ); @@ -1030,17 +1046,33 @@ impl Module { /// Removes the slash from the validator's balance by preference, /// and reduces the nominators' balance if needed. /// - /// Returns the resulting `NegativeImbalance` to allow distributing the slashed amount. + /// Returns the resulting `NegativeImbalance` to allow distributing the slashed amount and + /// pushes an entry onto the slash journal. fn slash_validator( stash: &T::AccountId, slash: BalanceOf, exposure: &Exposure>, + journal: &mut Vec>>, ) -> NegativeImbalanceOf { // The amount we are actually going to slash (can't be bigger than the validator's total // exposure) let slash = slash.min(exposure.total); + + // limit what we'll slash of the stash's own to only what's in + // the exposure. + // + // note: this is fine only because we limit reports of the current era. + // otherwise, these funds may have already been slashed due to something + // reported from a prior era. + let already_slashed_own = journal.iter() + .filter(|entry| &entry.who == stash) + .map(|entry| entry.own_slash) + .fold(>::zero(), |a, c| a.saturating_add(c)); + + let own_remaining = exposure.own.saturating_sub(already_slashed_own); + // The amount we'll slash from the validator's stash directly. - let own_slash = exposure.own.min(slash); + let own_slash = own_remaining.min(slash); let (mut imbalance, missing) = T::Currency::slash(stash, own_slash); let own_slash = own_slash - missing; // The amount remaining that we can't slash from the validator, @@ -1058,6 +1090,12 @@ impl Module { } } + journal.push(SlashJournalEntry { + who: stash.clone(), + own_slash: own_slash.clone(), + amount: slash, + }); + // trigger the event Self::deposit_event( RawEvent::Slash(stash.clone(), slash) @@ -1178,6 +1216,10 @@ impl Module { // Increment current era. let current_era = CurrentEra::mutate(|s| { *s += 1; *s }); + + // prune journal for last era. + >::remove(current_era - 1); + CurrentEraStartSessionIndex::mutate(|v| { *v = start_session_index; }); @@ -1471,6 +1513,7 @@ impl SelectInitialValidators for Module { } } +/// This is intended to be used with `FilterHistoricalOffences`. impl OnOffenceHandler> for Module where T: session::Trait::AccountId>, T: session::historical::Trait< @@ -1489,6 +1532,8 @@ impl OnOffenceHandler>::zero(); let slash_reward_fraction = SlashRewardFraction::get(); + let era_now = Self::current_era(); + let mut journal = Self::era_slash_journal(era_now); for (details, slash_fraction) in offenders.iter().zip(slash_fraction) { let stash = &details.offender.0; let exposure = &details.offender.1; @@ -1512,7 +1557,7 @@ impl OnOffenceHandler OnOffenceHandler>::insert(era_now, journal); // Handle the rest of imbalances T::Slash::on_unbalanced(remaining_imbalance); } } +/// Filter historical offences out and only allow those from the current era. +pub struct FilterHistoricalOffences { + _inner: rstd::marker::PhantomData<(T, R)>, +} + +impl ReportOffence + for FilterHistoricalOffences, R> where + T: Trait, + R: ReportOffence, + O: Offence, +{ + fn report_offence(reporters: Vec, offence: O) { + // disallow any slashing from before the current era. + let offence_session = offence.session_index(); + if offence_session >= >::current_era_start_session_index() { + R::report_offence(reporters, offence) + } else { + >::deposit_event( + RawEvent::OldSlashingReportDiscarded(offence_session).into() + ) + } + } +} + /// Returns the currently elected validator set represented by their stash accounts. pub struct CurrentElectedStashAccounts(rstd::marker::PhantomData); diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 141c833fdf46e..55cebd3eb0766 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -1910,7 +1910,7 @@ fn reward_validator_slashing_validator_doesnt_overflow() { ]}); // Check slashing - let _ = Staking::slash_validator(&11, reward_slash, &Staking::stakers(&11)); + let _ = Staking::slash_validator(&11, reward_slash, &Staking::stakers(&11), &mut Vec::new()); assert_eq!(Balances::total_balance(&11), stake - 1); assert_eq!(Balances::total_balance(&2), 1); }) From 7fd484d9a46a9a2dedd13b4c5204fe5a6d4b9297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 14:10:49 +0200 Subject: [PATCH 162/191] Fix some more stuff. --- Cargo.lock | 2 -- core/consensus/babe/Cargo.toml | 1 - core/consensus/babe/primitives/Cargo.toml | 23 ++++++++++----------- core/consensus/slots/Cargo.toml | 2 -- core/consensus/slots/src/aux_schema.rs | 5 ++--- core/finality-grandpa/primitives/Cargo.toml | 14 ++++++------- 6 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 113977c11850d..b19901335226c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4497,7 +4497,6 @@ dependencies = [ "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", - "srml-session 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common-primitives 2.0.0", @@ -4673,7 +4672,6 @@ dependencies = [ "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", - "srml-session 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", ] diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 413aaea3460e2..a44f4caeec655 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -20,7 +20,6 @@ inherents = { package = "substrate-inherents", path = "../../inherents" } substrate-telemetry = { path = "../../telemetry" } keystore = { package = "substrate-keystore", path = "../../keystore" } srml-babe = { path = "../../../srml/babe" } -srml-session = { path = "../../../srml/session" } transaction_pool = { package = "substrate-transaction-pool", path = "../../transaction-pool" } client = { package = "substrate-client", path = "../../client" } diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 52892b3f19081..7163143083a5f 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -6,27 +6,26 @@ description = "Primitives for BABE consensus" edition = "2018" [dependencies] -substrate-client = { path = "../../../client", default-features = false } -rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } -sr-primitives = { path = "../../../sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false } -slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } -schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../../common/primitives", default-features = false } -srml-session = { path = "../../../../srml/session", default-features = false } +rstd = { package = "sr-std", path = "../../../sr-std", default-features = false } +schnorrkel = { version = "0.8.4", features = ["preaudit_deprecated"], optional = true } +slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } +sr-primitives = { path = "../../../sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../../sr-staking-primitives", default-features = false } +substrate-client = { path = "../../../client", default-features = false } [features] default = ["std"] std = [ + "app-crypto/std", + "codec/std", + "consensus_common_primitives/std", "rstd/std", + "schnorrkel", + "slots", "sr-primitives/std", "sr-staking-primitives/std", "substrate-client/std", - "codec/std", - "schnorrkel", - "app-crypto/std", - "slots", - "consensus_common_primitives/std", ] diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index 4812a4f6b4301..fdb17305072cb 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -16,8 +16,6 @@ consensus_common = { package = "substrate-consensus-common", path = "../common" consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } inherents = { package = "substrate-inherents", path = "../../inherents" } -keystore = { package = "substrate-keystore", path = "../../../core/keystore" } -srml-session = { path = "../../../srml/session", default-features = false } futures-preview = "0.3.0-alpha.17" futures-timer = "0.2.1" parking_lot = "0.9.0" diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index f3ea70fb1b5e7..e9903e2693071 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -1,4 +1,4 @@ -// Copyright 2019 Parity Technologies (UK) Ltd. +/ Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -23,7 +23,6 @@ use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Header; use app_crypto::RuntimeAppPublic; use srml_session::historical::Proof; -use keystore::KeyStorePtr; use sr_staking_primitives::SessionIndex; use consensus_common_primitives::EquivocationProof; @@ -94,7 +93,7 @@ pub fn check_equivocation( // if prev_signer == signer { // 2) with different hash // if header.hash() != prev_header.hash() { - + return Ok(Some(EquivocationProof { reporter: signer.clone(), identity: signer.clone(), diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index f74bc37f9329b..4207668632932 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -5,23 +5,23 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "substrate-client", path = "../../client", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } +client = { package = "substrate-client", path = "../../client", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sr-primitives = { path = "../../sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } -grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } -session = { package = "srml-session", path = "../../../srml/session", default-features = false } +sr-primitives = { path = "../../sr-primitives", default-features = false } +sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } [features] default = ["std"] std = [ + "app-crypto/std", "client/std", "codec/std", - "sr-primitives/std", "rstd/std", "serde", - "app-crypto/std", + "sr-primitives/std", + "sr-staking-primitives/std", ] From 6d2b7f8d2c6962966e556d89e6b5dc8ed1c8a33c Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 15 Aug 2019 19:09:10 +0200 Subject: [PATCH 163/191] Pave the way for pruning --- core/sr-staking-primitives/src/offence.rs | 16 +- srml/babe/src/lib.rs | 7 +- srml/grandpa/src/lib.rs | 19 +- srml/grandpa/src/tests.rs | 28 +++ srml/im-online/src/lib.rs | 7 +- srml/offences/src/lib.rs | 201 ++++++++++++++++------ srml/offences/src/mock.rs | 32 +++- srml/offences/src/tests.rs | 40 ++--- 8 files changed, 246 insertions(+), 104 deletions(-) diff --git a/core/sr-staking-primitives/src/offence.rs b/core/sr-staking-primitives/src/offence.rs index c9c6bcfe5de05..c076103c18332 100644 --- a/core/sr-staking-primitives/src/offence.rs +++ b/core/sr-staking-primitives/src/offence.rs @@ -38,12 +38,6 @@ pub type Kind = [u8; 16]; /// so that we can slash it accordingly. pub type OffenceCount = u32; -/// A type that represents a point in time on an abstract timescale. -/// -/// See `Offence::time_slot` for details. The only requirement is that such timescale could be -/// represented by a single `u128` value. -pub type TimeSlot = u128; - /// A trait implemented by an offence report. /// /// This trait assumes that the offence is legitimate and was validated already. @@ -53,6 +47,12 @@ pub trait Offence { /// Identifier which is unique for this kind of an offence. const ID: Kind; + /// A type that represents a point in time on an abstract timescale. + /// + /// See `Offence::time_slot` for details. The only requirement is that such timescale could be + /// represented by a single `u128` value. + type TimeSlot: Clone + codec::Codec + Ord; + /// The list of all offenders involved in this incident. /// /// The list has no duplicates, so it is rather a set. @@ -60,6 +60,8 @@ pub trait Offence { /// The session index that is used for querying the validator set for the `slash_fraction` /// function. + /// + /// This is used for filtering historical sessions. fn session_index(&self) -> SessionIndex; /// Return a validator set count at the time when the offence took place. @@ -76,7 +78,7 @@ pub trait Offence { /// /// As an example, for GRANDPA timescale could be a round number and for BABE it could be a slot /// number. Note that for GRANDPA the round number is reset each epoch. - fn time_slot(&self) -> TimeSlot; + fn time_slot(&self) -> Self::TimeSlot; /// A slash fraction of the total exposure that should be slashed for this /// particular offence kind for the given parameters that happened at a singular `TimeSlot`. diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 8ae370849c7c7..ff800d292d4d0 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -31,7 +31,7 @@ use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill}; use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert}; use sr_staking_primitives::{ SessionIndex, - offence::{Offence, TimeSlot, Kind}, + offence::{Offence, Kind}, }; #[cfg(feature = "std")] use timestamp::TimestampInherentData; @@ -266,6 +266,7 @@ struct BabeEquivocationOffence { impl Offence for BabeEquivocationOffence { const ID: Kind = *b"babe:equivocatio"; + type TimeSlot = u64; fn offenders(&self) -> Vec { vec![self.offender.clone()] @@ -279,8 +280,8 @@ impl Offence for BabeEquivocation self.validator_set_count } - fn time_slot(&self) -> TimeSlot { - self.slot as TimeSlot + fn time_slot(&self) -> u64 { + self.slot } fn slash_fraction( diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 0698e322d4464..5df6c2a32b88d 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -41,7 +41,7 @@ use sr_primitives::{ }; use sr_staking_primitives::{ SessionIndex, - offence::{TimeSlot, Offence, Kind}, + offence::{Offence, Kind}, }; use fg_primitives::{ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID}; pub use fg_primitives::{AuthorityId, AuthorityWeight}; @@ -382,12 +382,20 @@ impl finality_tracker::OnFinalizationStalled for Modul } } +/// A round number and set id which point on the time of an offence. +#[derive(Copy, Clone, PartialOrd, Ord, Eq, PartialEq, Encode, Decode)] +struct GrandpaTimeSlot { + // The order of these matters for `derive(Ord)`. + set_id: u64, + round: u64, +} + // TODO [slashing]: Integrate this. /// A grandpa equivocation offence report. #[allow(dead_code)] struct GrandpaEquivocationOffence { - /// A round in which the incident happened. - round: u64, + /// Time slot at which this incident happened. + time_slot: GrandpaTimeSlot, /// The session index in which the incident happened. session_index: SessionIndex, /// The size of the validator set at the time of the offence. @@ -398,6 +406,7 @@ struct GrandpaEquivocationOffence { impl Offence for GrandpaEquivocationOffence { const ID: Kind = *b"grandpa:equivoca"; + type TimeSlot = GrandpaTimeSlot; fn offenders(&self) -> Vec { vec![self.offender.clone()] @@ -411,8 +420,8 @@ impl Offence for GrandpaEquivocat self.validator_set_count } - fn time_slot(&self) -> TimeSlot { - self.round as TimeSlot + fn time_slot(&self) -> GrandpaTimeSlot { + self.time_slot } fn slash_fraction( diff --git a/srml/grandpa/src/tests.rs b/srml/grandpa/src/tests.rs index adef602ce6f18..41229a5136165 100644 --- a/srml/grandpa/src/tests.rs +++ b/srml/grandpa/src/tests.rs @@ -282,3 +282,31 @@ fn schedule_resume_only_when_paused() { ); }); } + +#[test] +fn time_slot_have_sane_ord() { + // Ensure that `Ord` implementation is sane. + const FIXTURE: &[GrandpaTimeSlot] = &[ + GrandpaTimeSlot { + set_id: 0, + round: 0, + }, + GrandpaTimeSlot { + set_id: 0, + round: 1, + }, + GrandpaTimeSlot { + set_id: 1, + round: 0, + }, + GrandpaTimeSlot { + set_id: 1, + round: 1, + }, + GrandpaTimeSlot { + set_id: 1, + round: 2, + } + ]; + assert!(FIXTURE.windows(2).all(|f| f[0] < f[1])); +} diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index 1eb845fffe0c6..3283c09616d44 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -80,7 +80,7 @@ use sr_primitives::{ }; use sr_staking_primitives::{ SessionIndex, CurrentElectedSet, - offence::{ReportOffence, Offence, TimeSlot, Kind}, + offence::{ReportOffence, Offence, Kind}, }; use srml_support::{ StorageValue, decl_module, decl_event, decl_storage, StorageDoubleMap, print, @@ -493,6 +493,7 @@ pub struct UnresponsivenessOffence { impl Offence for UnresponsivenessOffence { const ID: Kind = *b"im-online:offlin"; + type TimeSlot = SessionIndex; fn offenders(&self) -> Vec { self.offenders.clone() @@ -506,8 +507,8 @@ impl Offence for UnresponsivenessOffence { self.validator_set_count } - fn time_slot(&self) -> TimeSlot { - self.session_index as TimeSlot + fn time_slot(&self) -> SessionIndex { + self.session_index as SessionIndex } fn slash_fraction(offenders: u32, validator_set_count: u32) -> Perbill { diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 3a014c133b064..6c12aabf1b4e3 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -25,17 +25,26 @@ mod mock; mod tests; use rstd::{ - collections::btree_set::BTreeSet, vec::Vec, + collections::btree_set::BTreeSet, }; use support::{ - StorageDoubleMap, decl_module, decl_event, decl_storage, Parameter, + StorageMap, StorageDoubleMap, decl_module, decl_event, decl_storage, Parameter, +}; +use sr_primitives::{ + Perbill, + traits::Hash, }; -use sr_primitives::Perbill; use sr_staking_primitives::{ - SessionIndex, - offence::{Offence, ReportOffence, TimeSlot, Kind, OnOffenceHandler, OffenceDetails}, + offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails}, }; +use codec::{Encode, Decode}; + +/// A binary blob which represents a SCALE codec-encoded `O::TimeSlot`. +type OpaqueTimeSlot = Vec; + +/// A type alias for a report identifier. +type ReportIdOf = ::Hash; /// Offences trait pub trait Trait: system::Trait { @@ -49,14 +58,19 @@ pub trait Trait: system::Trait { decl_storage! { trait Store for Module as Offences { - /// A mapping between unique `TimeSlots` within a particular session and the offence `Kind` into - /// a vector of offending authorities. + /// The primary structure that holds all offence records keyed by report identifiers. + Reports get(reports): map ReportIdOf => Option>; + + /// A vector of reports of the same kind that happened at the same time slot. + ConcurrentReportsIndex: double_map Kind, blake2_256(OpaqueTimeSlot) => Vec>; + + /// Enumerates all reports of a kind along with the time they happened. + /// + /// All reports are sorted by the time of offence. /// - /// It's important that we store all authorities reported for an offence for any kind and - /// timeslot since the slashing will increase based on the length of this vec. - OffenceReports get(offence_reports): - double_map Kind, blake2_256((SessionIndex, TimeSlot)) - => Vec>; + /// Note that the actual type of this mapping is `Vec`, this is because values of + /// different types are not supported at the moment so we are doing the manual serialization. + ReportsByKindIndex: map Kind => Vec; // (O::TimeSlot, ReportIdOf) } } @@ -64,7 +78,7 @@ decl_event!( pub enum Event { /// There is an offence reported of the given `kind` happened at the `session_index` and /// (kind-specific) time slot. This event is not deposited for duplicate slashes. - Offence(Kind, SessionIndex, TimeSlot), + Offence(Kind, OpaqueTimeSlot), } ); @@ -75,57 +89,45 @@ decl_module! { } } -impl> ReportOffence - for Module where +impl> + ReportOffence for Module +where T::IdentificationTuple: Clone, { fn report_offence(reporters: Vec, offence: O) { let offenders = offence.offenders(); let time_slot = offence.time_slot(); - let session = offence.session_index(); let validator_set_count = offence.validator_set_count(); - // Check if an offence is already reported for the offender authorities - // and otherwise stores that report. - let mut new_offenders = BTreeSet::new(); - let all_offenders = { - // We have to return the modified list of offending authorities. If we were to use - // `mutate` we would have to clone the whole list in order to return it. - let mut offending_authorities = >::get(&O::ID, &(session, time_slot)); - - for offender in offenders { - // TODO [slashing] This prevents slashing for multiple reports of the same kind at the same slot, - // note however that we might do that in the future if the reports are not exactly the same (dups). - // De-duplication of reports is tricky though, we need a canonical form of the report - // (for instance babe equivocation can have headers swapped). - if !offending_authorities.iter().any(|details| details.offender == offender) { - new_offenders.insert(offender.clone()); - offending_authorities.push(OffenceDetails { - offender, - reporters: reporters.clone().into_iter().collect(), - }); - } - } + let mut cache = ReportIndexCache::load(&time_slot); - offending_authorities - }; + // Go through all offenders in the report and record unique reports. + let new_offenders = + Self::collect_unique_reports::(reporters, &time_slot, offenders, &mut cache); if new_offenders.is_empty() { // The report contained only duplicates, so there is no need to slash again. - return + return; } - // We pushed new items in the offending_authorities, so update it. - >::insert(&O::ID, &(session, time_slot), &all_offenders); + // Deposit the event. + Self::deposit_event(Event::Offence(O::ID, time_slot.encode())); - let offenders_count = all_offenders.len() as u32; - let previous_offenders_count = offenders_count - new_offenders.len() as u32; + // Load report details for the all reports happened at the same time. + let concurrent_offenders = cache + .concurrent_reports + .iter() + .filter_map(|report_id| { + >::get(report_id) + }) + .collect::>(); - // The report is not a duplicate. Deposit an event. - Self::deposit_event(Event::Offence(O::ID, session, time_slot)); + let offenders_count = concurrent_offenders.len() as u32; + let previous_offenders_count = offenders_count - new_offenders.len() as u32; // The amount new offenders are slashed let new_fraction = O::slash_fraction(offenders_count, validator_set_count); + // The amount previous offenders are slashed additionally. // // Since they were slashed in the past, we slash by: @@ -149,7 +151,7 @@ impl> ReportOffence 0 && new_offenders.contains(&details.offender) { new_fraction.clone() @@ -159,8 +161,111 @@ impl> ReportOffence>(); T::OnOffenceHandler::on_offence( - &all_offenders, + &concurrent_offenders, &slash_perbill, ); + + cache.save() + } +} + +impl Module { + /// Compute the ID for the given report properties. + /// + /// The report id depends on the offence kind, time slot and the id of offender. + fn report_id>( + time_slot: &O::TimeSlot, + offender: &T::IdentificationTuple, + ) -> ReportIdOf { + (O::ID, time_slot.encode(), offender).using_encoded(T::Hashing::hash) + } + + /// Goes through all offenders in a report and record each unique offence updating indexes. + /// + /// Returns `true` if there were unique reports. + fn collect_unique_reports>( + reporters: Vec, + time_slot: &O::TimeSlot, + offenders: Vec, + index_cache: &mut ReportIndexCache, + ) -> BTreeSet { + let mut new_offenders = BTreeSet::new(); + + for offender in offenders { + let report_id = Self::report_id::(time_slot, &offender); + + if !>::exists(&report_id) { + new_offenders.insert(offender.clone()); + >::insert( + &report_id, + OffenceDetails { + offender, + reporters: reporters.clone(), + }, + ); + + index_cache.insert(time_slot, report_id); + } + } + + new_offenders + } +} + +/// An auxilary struct for dealing with caches of report indexes localized for a specific offence +/// kind. +/// +/// It is expected that access to the indexes will be only performed through this struct while it +/// exists. +struct ReportIndexCache> { + opaque_time_slot: OpaqueTimeSlot, + concurrent_reports: Vec>, + same_kind_reports: Vec<(O::TimeSlot, ReportIdOf)>, +} + +impl> ReportIndexCache { + /// Preload indexes from the cache for the specific `time_slot` and the kind of the offence. + fn load(time_slot: &O::TimeSlot) -> Self { + let opaque_time_slot = time_slot.encode(); + + let same_kind_reports = ::get(&O::ID); + let same_kind_reports = + Vec::<(O::TimeSlot, ReportIdOf)>::decode(&mut &same_kind_reports[..]) + .unwrap_or_default(); + + let concurrent_reports = >::get(&O::ID, &opaque_time_slot); + + Self { + opaque_time_slot, + concurrent_reports, + same_kind_reports, + } + } + + /// Insert a new report to the index cache. + fn insert(&mut self, time_slot: &O::TimeSlot, report_id: ReportIdOf) { + // Update the list of concurrent reports. + self.concurrent_reports.push(report_id); + + // Insert the report id into the list while maintaining the ordering by the time + // slot. + let idx = match self + .same_kind_reports + .binary_search_by_key(&time_slot, |&(ref when, _)| when) + { + Ok(idx) => idx, + Err(idx) => idx, + }; + self.same_kind_reports.insert(idx, (time_slot.clone(), report_id)); + } + + /// Dump the indexes to the storage. + fn save(self) { + ::insert(&O::ID, self.same_kind_reports.encode()); + >::insert( + &O::ID, + &self.opaque_time_slot, + &self.concurrent_reports, + ); } } diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index 3c47192d00e9c..b518b95d16512 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -20,12 +20,16 @@ use std::cell::RefCell; use crate::{Module, Trait}; +use codec::Encode; use sr_primitives::Perbill; -use sr_staking_primitives::offence::{self, OffenceDetails, TimeSlot}; +use sr_staking_primitives::{ + SessionIndex, + offence::{self, Kind, OffenceDetails}, +}; use sr_primitives::testing::Header; use sr_primitives::traits::{IdentityLookup, BlakeTwo256}; use substrate_primitives::{H256, Blake2Hasher}; -use support::{impl_outer_origin, impl_outer_event, parameter_types}; +use support::{impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap}; use {runtime_io, system}; impl_outer_origin!{ @@ -109,33 +113,43 @@ pub type System = system::Module; pub const KIND: [u8; 16] = *b"test_report_1234"; +/// Returns all offence details for the specific `kind` happened at the specific time slot. +pub fn offence_reports(kind: Kind, time_slot: u128) -> Vec> { + >::get(&kind, &time_slot.encode()) + .into_iter() + .map(|report_id| >::get(&report_id).unwrap()) + .collect() +} + #[derive(Clone)] pub struct Offence { pub validator_set_count: u32, - pub session_index: u32, pub offenders: Vec, - pub time_slot: TimeSlot, + pub time_slot: u128, } impl offence::Offence for Offence { const ID: offence::Kind = KIND; + type TimeSlot = u128; fn offenders(&self) -> Vec { self.offenders.clone() } - fn session_index(&self) -> u32 { - self.session_index - } - fn validator_set_count(&self) -> u32 { self.validator_set_count } - fn time_slot(&self) -> TimeSlot { + fn time_slot(&self) -> u128 { self.time_slot } + fn session_index(&self) -> SessionIndex { + // session index is not used by the srml-offences directly, but rather it exists only for + // filtering historical reports. + unimplemented!() + } + fn slash_fraction( offenders_count: u32, validator_set_count: u32, diff --git a/srml/offences/src/tests.rs b/srml/offences/src/tests.rs index 2cc320387cc72..17f933b8e8d12 100644 --- a/srml/offences/src/tests.rs +++ b/srml/offences/src/tests.rs @@ -21,6 +21,7 @@ use super::*; use crate::mock::{ Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_fractions, + offence_reports, }; use system::{EventRecord, Phase}; use runtime_io::with_externalities; @@ -29,13 +30,11 @@ use runtime_io::with_externalities; fn should_report_an_authority_and_trigger_on_offence() { with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let offence = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; @@ -54,18 +53,15 @@ fn should_report_an_authority_and_trigger_on_offence() { fn should_calculate_the_fraction_correctly() { with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let offence1 = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; let offence2 = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![4], }; @@ -89,13 +85,11 @@ fn should_calculate_the_fraction_correctly() { fn should_not_report_the_same_authority_twice_in_the_same_slot() { with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let offence = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; @@ -121,13 +115,11 @@ fn should_not_report_the_same_authority_twice_in_the_same_slot() { fn should_report_in_different_time_slot() { with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let mut offence = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; @@ -153,16 +145,11 @@ fn should_report_in_different_time_slot() { fn should_deposit_event() { with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!( - Offences::offence_reports(&KIND, &(session_index, time_slot)), - vec![] - ); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let offence = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; @@ -175,7 +162,7 @@ fn should_deposit_event() { System::events(), vec![EventRecord { phase: Phase::ApplyExtrinsic(0), - event: TestEvent::offences(crate::Event::Offence(KIND, session_index, time_slot)), + event: TestEvent::offences(crate::Event::Offence(KIND, time_slot.encode())), topics: vec![], }] ); @@ -186,13 +173,11 @@ fn should_deposit_event() { fn doesnt_deposit_event_for_dups() { with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let offence = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; @@ -212,7 +197,7 @@ fn doesnt_deposit_event_for_dups() { System::events(), vec![EventRecord { phase: Phase::ApplyExtrinsic(0), - event: TestEvent::offences(crate::Event::Offence(KIND, session_index, time_slot)), + event: TestEvent::offences(crate::Event::Offence(KIND, time_slot.encode())), topics: vec![], }] ); @@ -225,19 +210,16 @@ fn should_properly_count_offences() { // should have `count` equal 2 and the count of the 2nd one should be equal to 1. with_externalities(&mut new_test_ext(), || { // given - let session_index = 5; let time_slot = 42; - assert_eq!(Offences::offence_reports(&KIND, &(session_index, time_slot)), vec![]); + assert_eq!(offence_reports(KIND, time_slot), vec![]); let offence1 = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![5], }; let offence2 = Offence { validator_set_count: 5, - session_index, time_slot, offenders: vec![4], }; @@ -254,7 +236,7 @@ fn should_properly_count_offences() { // then // the 1st authority should have count 2 and the 2nd one should be reported only once. assert_eq!( - Offences::offence_reports(&KIND, &(session_index, time_slot)), + offence_reports(KIND, time_slot), vec![ OffenceDetails { offender: 5, reporters: vec![] }, OffenceDetails { offender: 4, reporters: vec![] }, From 2803ed33cd9adb52510f701ade61c9b03706d660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 15:32:37 +0200 Subject: [PATCH 164/191] Make it compile, clean up dependencies. --- Cargo.lock | 5 ----- core/consensus/babe/Cargo.toml | 1 - core/consensus/common/primitives/src/lib.rs | 3 +-- core/consensus/slots/Cargo.toml | 4 ++-- core/consensus/slots/src/aux_schema.rs | 7 ++----- core/consensus/slots/src/lib.rs | 1 - core/finality-grandpa/Cargo.toml | 1 - core/finality-grandpa/primitives/Cargo.toml | 3 ++- srml/babe/src/lib.rs | 4 ++-- 9 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b19901335226c..29bd747bb6b24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4465,7 +4465,6 @@ dependencies = [ "sr-primitives 2.0.0", "sr-version 2.0.0", "srml-babe 2.0.0", - "srml-session 2.0.0", "srml-support 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", @@ -4483,7 +4482,6 @@ dependencies = [ "substrate-service 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4571,13 +4569,11 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", - "srml-session 2.0.0", "substrate-application-crypto 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", "substrate-consensus-common-primitives 2.0.0", "substrate-inherents 2.0.0", - "substrate-keystore 2.0.0", "substrate-primitives 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", @@ -4642,7 +4638,6 @@ dependencies = [ "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "srml-finality-tracker 2.0.0", - "srml-session 2.0.0", "substrate-client 2.0.0", "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common 2.0.0", diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index a44f4caeec655..75ab93df053fe 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -20,7 +20,6 @@ inherents = { package = "substrate-inherents", path = "../../inherents" } substrate-telemetry = { path = "../../telemetry" } keystore = { package = "substrate-keystore", path = "../../keystore" } srml-babe = { path = "../../../srml/babe" } -transaction_pool = { package = "substrate-transaction-pool", path = "../../transaction-pool" } client = { package = "substrate-client", path = "../../client" } uncles = { package = "substrate-consensus-uncles", path = "../uncles" } diff --git a/core/consensus/common/primitives/src/lib.rs b/core/consensus/common/primitives/src/lib.rs index f700607eb2c19..001e76840d16f 100644 --- a/core/consensus/common/primitives/src/lib.rs +++ b/core/consensus/common/primitives/src/lib.rs @@ -21,7 +21,6 @@ use codec::{Encode, Decode, Codec}; use client::decl_runtime_apis; use rstd::vec::Vec; -use sr_primitives::traits::Header; /// Represents an Babe equivocation proof. #[cfg_attr(feature = "std", derive(Debug))] @@ -42,4 +41,4 @@ decl_runtime_apis! { /// Returns the set of authorities of the currently active consensus mechanism. fn authorities() -> Vec; } -} \ No newline at end of file +} diff --git a/core/consensus/slots/Cargo.toml b/core/consensus/slots/Cargo.toml index fdb17305072cb..6a98c56c84855 100644 --- a/core/consensus/slots/Cargo.toml +++ b/core/consensus/slots/Cargo.toml @@ -10,11 +10,11 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } client = { package = "substrate-client", path = "../../client" } primitives = { package = "substrate-primitives", path = "../../primitives" } sr-primitives = { path = "../../sr-primitives" } -sr-staking-primitives = { path = "../../sr-staking-primitives", default-features = false } +sr-staking-primitives = { path = "../../sr-staking-primitives" } substrate-telemetry = { path = "../../telemetry" } consensus_common = { package = "substrate-consensus-common", path = "../common" } consensus_common_primitives = { package = "substrate-consensus-common-primitives", path = "../common/primitives" } -app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } +app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto" } inherents = { package = "substrate-inherents", path = "../../inherents" } futures-preview = "0.3.0-alpha.17" futures-timer = "0.2.1" diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index e9903e2693071..1207cd865d69a 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -1,4 +1,4 @@ -/ Copyright 2019 Parity Technologies (UK) Ltd. +// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -16,14 +16,11 @@ //! Schema for slots in the aux-db. -use std::ops::Deref; -use codec::{Encode, Decode, Codec}; +use codec::{Decode, Codec}; use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Header; use app_crypto::RuntimeAppPublic; -use srml_session::historical::Proof; -use sr_staking_primitives::SessionIndex; use consensus_common_primitives::EquivocationProof; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; diff --git a/core/consensus/slots/src/lib.rs b/core/consensus/slots/src/lib.rs index 7a15a01bd1ea9..8fe1356f01ac2 100644 --- a/core/consensus/slots/src/lib.rs +++ b/core/consensus/slots/src/lib.rs @@ -32,7 +32,6 @@ pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND}; use codec::{Decode, Encode}; use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain}; -use consensus_common_primitives::EquivocationProof; use futures::{prelude::*, future::{self, Either}}; use futures_timer::Delay; use inherents::{InherentData, InherentDataProviders}; diff --git a/core/finality-grandpa/Cargo.toml b/core/finality-grandpa/Cargo.toml index 98ceb34ad5cf3..b8de175c6e605 100644 --- a/core/finality-grandpa/Cargo.toml +++ b/core/finality-grandpa/Cargo.toml @@ -25,7 +25,6 @@ inherents = { package = "substrate-inherents", path = "../../core/inherents" } network = { package = "substrate-network", path = "../network" } service = { package = "substrate-service", path = "../service", optional = true } srml-finality-tracker = { path = "../../srml/finality-tracker" } -srml-session = { path = "../../srml/session" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" } grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } diff --git a/core/finality-grandpa/primitives/Cargo.toml b/core/finality-grandpa/primitives/Cargo.toml index 4207668632932..63a8c0280d747 100644 --- a/core/finality-grandpa/primitives/Cargo.toml +++ b/core/finality-grandpa/primitives/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } client = { package = "substrate-client", path = "../../client", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"], default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } serde = { version = "1.0", optional = true, features = ["derive"] } sr-primitives = { path = "../../sr-primitives", default-features = false } @@ -20,6 +20,7 @@ std = [ "app-crypto/std", "client/std", "codec/std", + "grandpa/std", "rstd/std", "serde", "sr-primitives/std", diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 3390143caa555..80585e2973bf3 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -35,7 +35,7 @@ use sr_primitives::{ transaction_validity::{TransactionValidity, ValidTransaction}, }; use sr_primitives::traits::{ - IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Convert, Header, ValidateUnsigned, + IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Header, ValidateUnsigned, }; use sr_staking_primitives::{ SessionIndex, @@ -205,7 +205,7 @@ decl_storage! { storage: &mut (sr_primitives::StorageOverlay, sr_primitives::ChildrenStorageOverlay), config: &GenesisConfig | { - runtime_io::with_storage( + sr_io::with_storage( storage, || Module::::initialize_authorities(&config.authorities), ); From 7781bc991c20607fc62d6f1642f3dde4a9733c8c Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 16 Aug 2019 15:51:20 +0200 Subject: [PATCH 165/191] Address issues. --- srml/babe/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 2 +- srml/im-online/src/lib.rs | 4 ++-- srml/offences/src/lib.rs | 23 +++++++++++------------ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index e6147d92e18fe..8802d7e05b4be 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -289,7 +289,7 @@ impl Offence for BabeEquivocation self.validator_set_count } - fn time_slot(&self) -> u64 { + fn time_slot(&self) -> Self::TimeSlot { self.slot } diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index c66feb67f4dcf..d64939ae0a766 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -446,7 +446,7 @@ impl Offence for GrandpaEquivocat self.validator_set_count } - fn time_slot(&self) -> GrandpaTimeSlot { + fn time_slot(&self) -> Self::TimeSlot { self.time_slot } diff --git a/srml/im-online/src/lib.rs b/srml/im-online/src/lib.rs index bb6d0e4f1ea65..628531c9f318f 100644 --- a/srml/im-online/src/lib.rs +++ b/srml/im-online/src/lib.rs @@ -538,8 +538,8 @@ impl Offence for UnresponsivenessOffence { self.validator_set_count } - fn time_slot(&self) -> SessionIndex { - self.session_index as SessionIndex + fn time_slot(&self) -> Self::TimeSlot { + self.session_index } fn slash_fraction(offenders: u32, validator_set_count: u32) -> Perbill { diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 6c12aabf1b4e3..15bdc7d62454f 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -99,13 +99,10 @@ where let time_slot = offence.time_slot(); let validator_set_count = offence.validator_set_count(); - let mut cache = ReportIndexCache::load(&time_slot); - // Go through all offenders in the report and record unique reports. - let new_offenders = - Self::collect_unique_reports::(reporters, &time_slot, offenders, &mut cache); + let cache = Self::collect_unique_reports::(reporters, &time_slot, offenders); - if new_offenders.is_empty() { + if cache.new_offenders.is_empty() { // The report contained only duplicates, so there is no need to slash again. return; } @@ -123,7 +120,7 @@ where .collect::>(); let offenders_count = concurrent_offenders.len() as u32; - let previous_offenders_count = offenders_count - new_offenders.len() as u32; + let previous_offenders_count = offenders_count - cache.new_offenders.len() as u32; // The amount new offenders are slashed let new_fraction = O::slash_fraction(offenders_count, validator_set_count); @@ -153,7 +150,7 @@ where // calculate how much to slash let slash_perbill = concurrent_offenders .iter() - .map(|details| if previous_offenders_count > 0 && new_offenders.contains(&details.offender) { + .map(|details| if previous_offenders_count > 0 && cache.new_offenders.contains(&details.offender) { new_fraction.clone() } else { old_fraction.clone() @@ -187,15 +184,14 @@ impl Module { reporters: Vec, time_slot: &O::TimeSlot, offenders: Vec, - index_cache: &mut ReportIndexCache, - ) -> BTreeSet { - let mut new_offenders = BTreeSet::new(); + ) -> ReportIndexCache { + let mut index_cache = ReportIndexCache::load(time_slot); for offender in offenders { let report_id = Self::report_id::(time_slot, &offender); if !>::exists(&report_id) { - new_offenders.insert(offender.clone()); + index_cache.new_offenders.insert(offender.clone()); >::insert( &report_id, OffenceDetails { @@ -208,7 +204,7 @@ impl Module { } } - new_offenders + index_cache } } @@ -217,10 +213,12 @@ impl Module { /// /// It is expected that access to the indexes will be only performed through this struct while it /// exists. +#[must_use = "The changes are not saved without called `save`"] struct ReportIndexCache> { opaque_time_slot: OpaqueTimeSlot, concurrent_reports: Vec>, same_kind_reports: Vec<(O::TimeSlot, ReportIdOf)>, + new_offenders: BTreeSet, } impl> ReportIndexCache { @@ -239,6 +237,7 @@ impl> ReportIndexCache { opaque_time_slot, concurrent_reports, same_kind_reports, + new_offenders: BTreeSet::new(), } } From dbd49d79dc11a9ee0816ded2d7f0bae975879eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 15:58:26 +0200 Subject: [PATCH 166/191] More compilation fixes. --- core/consensus/babe/primitives/src/lib.rs | 73 +---------------- core/consensus/babe/src/lib.rs | 8 +- core/consensus/slots/src/aux_schema.rs | 97 ++++++++++++----------- core/finality-grandpa/src/environment.rs | 2 +- core/finality-grandpa/src/lib.rs | 32 ++++---- core/sr-primitives/src/traits.rs | 12 +-- core/transaction-pool/graph/src/pool.rs | 8 +- node/runtime/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 5 +- 9 files changed, 83 insertions(+), 156 deletions(-) diff --git a/core/consensus/babe/primitives/src/lib.rs b/core/consensus/babe/primitives/src/lib.rs index 5c352fcfaae95..c48501673744e 100644 --- a/core/consensus/babe/primitives/src/lib.rs +++ b/core/consensus/babe/primitives/src/lib.rs @@ -23,9 +23,8 @@ mod digest; use codec::{Encode, Decode}; use rstd::vec::Vec; -use sr_primitives::{ConsensusEngineId, traits::Header}; +use sr_primitives::ConsensusEngineId; use substrate_client::decl_runtime_apis; -use sr_staking_primitives::SessionIndex; pub use consensus_common_primitives::EquivocationProof; #[cfg(feature = "std")] @@ -143,76 +142,6 @@ impl slots::SlotData for BabeConfiguration { const SLOT_KEY: &'static [u8] = b"babe_bootstrap_data"; } - -// impl AuthorshipEquivocationProof for BabeEquivocationProof -// where -// H: Header, -// { -// type Header = H; -// type Identity = AuthorityId; -// type Signature = AuthoritySignature; - -// /// Create a new Babe equivocation proof. -// fn new( -// identity: Self::Identity, -// slot: u64, -// first_header: H, -// second_header: H, -// first_signature: Self::Signature, -// second_signature: Self::Signature, -// ) -> Self { -// BabeEquivocationProof { -// reporter: None, -// identity, -// slot, -// session_index: None, -// first_header, -// second_header, -// first_signature, -// second_signature, -// } -// } - -// /// Get the reporter of the equivocation. -// fn reporter(&self) -> Option<&Self::Identity> { -// self.reporter.as_ref() -// } - -// /// Get the slot where the equivocation happened. -// fn slot(&self) -> u64 { -// self.slot -// } - -// /// Get the session index where the equivocation happened. -// fn session_index(&self) -> Option<&SessionIndex> { -// self.session_index.as_ref() -// } - -// /// Get the identity of the suspect of equivocating. -// fn identity(&self) -> &Self::Identity { -// &self.identity -// } - -// /// Get the first header involved in the equivocation. -// fn first_header(&self) -> &H { -// &self.first_header -// } - -// /// Get the second header involved in the equivocation. -// fn second_header(&self) -> &H { -// &self.second_header -// } - -// fn first_signature(&self) -> &Self::Signature { -// &self.first_signature -// } - -// fn second_signature(&self) -> &Self::Signature { -// &self.second_signature -// } -// } - - decl_runtime_apis! { /// API necessary for block authorship with BABE. pub trait BabeApi { diff --git a/core/consensus/babe/src/lib.rs b/core/consensus/babe/src/lib.rs index 9afc5d5059799..875319af8604a 100644 --- a/core/consensus/babe/src/lib.rs +++ b/core/consensus/babe/src/lib.rs @@ -31,7 +31,7 @@ use consensus_common::well_known_cache_keys::Id as CacheKeyId; use sr_primitives::{generic::{BlockId, OpaqueDigestItemId}, Justification}; use sr_primitives::traits::{ Block as BlockT, Header, DigestItemFor, NumberFor, ProvideRuntimeApi, - SimpleBitOps, Zero, SubmitExtrinsic + Zero, SubmitExtrinsic }; use keystore::KeyStorePtr; use codec::{Decode, Encode}; @@ -393,7 +393,7 @@ fn check_header( DigestItemFor: CompatibleDigestItem, C: ProvideRuntimeApi + HeaderBackend, C::Api: BabeApi, - T: SubmitExtrinsic> + Send + Sync + 'static, + T: SubmitExtrinsic, { trace!(target: "babe", "Checking header"); let seal = match header.digest_mut().pop() { @@ -570,7 +570,7 @@ fn median_algorithm( impl Verifier for BabeVerifier where C: ProvideRuntimeApi + HeaderBackend + Send + Sync + AuxStore + ProvideCache, C::Api: BlockBuilderApi + BabeApi, - T: SubmitExtrinsic> + Send + Sync + 'static, + T: SubmitExtrinsic + 'static, { fn verify( &mut self, @@ -1159,7 +1159,7 @@ pub fn import_queue, I, RA, PRA, T>( RA: Send + Sync + 'static, PRA: ProvideRuntimeApi + HeaderBackend + ProvideCache + Send + Sync + AuxStore + 'static, PRA::Api: BlockBuilderApi + BabeApi, - T: SubmitExtrinsic> + Send + Sync + 'static, + T: SubmitExtrinsic + 'static, { register_babe_inherent_data_provider(&inherent_data_providers, config.get())?; initialize_authorities_cache(&*api)?; diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 1207cd865d69a..43a8526560fd5 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -16,7 +16,7 @@ //! Schema for slots in the aux-db. -use codec::{Decode, Codec}; +use codec::{Encode, Decode, Codec}; use client::backend::AuxStore; use client::error::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Header; @@ -64,74 +64,75 @@ pub fn check_equivocation( ::Signature: Clone + Codec, { // We don't check equivocations for old headers out of our capacity. - // if slot_now - slot > MAX_SLOT_CAPACITY { - // return Ok(None) - // } + if slot_now - slot > MAX_SLOT_CAPACITY { + return Ok(None) + } // Key for this slot. - // let mut current_slot_key = SLOT_HEADER_MAP_KEY.to_vec(); - // slot.using_encoded(|s| current_slot_key.extend(s)); + let mut current_slot_key = SLOT_HEADER_MAP_KEY.to_vec(); + slot.using_encoded(|s| current_slot_key.extend(s)); // Get headers of this slot. - // let mut headers_with_signature = load_decode::<_, Vec<(H, V::Signature, V)>>( - // backend.deref(), - // ¤t_slot_key[..], - // )? - // .unwrap_or_else(Vec::new); + let mut headers_with_signature = load_decode::<_, Vec<(H, V::Signature, V)>>( + &*backend, + ¤t_slot_key[..], + )? + .unwrap_or_else(Vec::new); // Get first slot saved. - // let slot_header_start = SLOT_HEADER_START.to_vec(); - // let first_saved_slot = load_decode::<_, u64>(backend, &slot_header_start[..])? - // .unwrap_or(slot); + let slot_header_start = SLOT_HEADER_START.to_vec(); + let first_saved_slot = load_decode::<_, u64>(backend, &slot_header_start[..])? + .unwrap_or(slot); - // for (prev_header, prev_signature, prev_signer) in headers_with_signature.iter() { + for (prev_header, prev_signature, prev_signer) in headers_with_signature.iter() { // A proof of equivocation consists of two headers: // 1) signed by the same voter, - // if prev_signer == signer { + if prev_signer == signer { // 2) with different hash - // if header.hash() != prev_header.hash() { + if header.hash() != prev_header.hash() { return Ok(Some(EquivocationProof { + // TODO [slashing] this is wrong reporter: signer.clone(), identity: signer.clone(), slot, - first_header: header.clone(), + first_header: prev_header.clone(), second_header: header.clone(), - first_signature: signature.clone(), + first_signature: prev_signature.clone(), second_signature: signature.clone(), })); - // } else { + } else { // We don't need to continue in case of duplicated header, // since it's already saved and a possible equivocation // would have been detected before. - // return Ok(None) - // } - // } - // } - - // let mut keys_to_delete = vec![]; - // let mut new_first_saved_slot = first_saved_slot; - - // if slot_now - first_saved_slot >= PRUNING_BOUND { - // let prefix = SLOT_HEADER_MAP_KEY.to_vec(); - // new_first_saved_slot = slot_now.saturating_sub(MAX_SLOT_CAPACITY); - - // for s in first_saved_slot..new_first_saved_slot { - // let mut p = prefix.clone(); - // s.using_encoded(|s| p.extend(s)); - // keys_to_delete.push(p); - // } - // } - - // headers_with_signature.push((header.clone(), signature.clone(), signer.clone())); - - // backend.insert_aux( - // &[ - // (¤t_slot_key[..], headers_with_signature.encode().as_slice()), - // (&slot_header_start[..], new_first_saved_slot.encode().as_slice()), - // ], - // &keys_to_delete.iter().map(|k| &k[..]).collect::>()[..], - // )?; + return Ok(None) + } + } + } + + let mut keys_to_delete = vec![]; + let mut new_first_saved_slot = first_saved_slot; + + if slot_now - first_saved_slot >= PRUNING_BOUND { + let prefix = SLOT_HEADER_MAP_KEY.to_vec(); + new_first_saved_slot = slot_now.saturating_sub(MAX_SLOT_CAPACITY); + + for s in first_saved_slot..new_first_saved_slot { + let mut p = prefix.clone(); + s.using_encoded(|s| p.extend(s)); + keys_to_delete.push(p); + } + } + + headers_with_signature.push((header.clone(), signature.clone(), signer.clone())); + + backend.insert_aux( + &[ + (¤t_slot_key[..], headers_with_signature.encode().as_slice()), + (&slot_header_start[..], new_first_saved_slot.encode().as_slice()), + ], + &keys_to_delete.iter().map(|k| &k[..]).collect::>()[..], + )?; Ok(None) } diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 859944845f881..4eb9d92cede8b 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -538,7 +538,7 @@ where RA: 'static + Send + Sync, SC: SelectChain + 'static, NumberFor: BlockNumberOps, - T: SubmitExtrinsic>, + T: SubmitExtrinsic, Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, { diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index 069e5de97196e..da56d257e3f3e 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -504,11 +504,10 @@ pub fn run_grandpa_voter, N, RA, SC, X, T>( NumberFor: BlockNumberOps, DigestFor: Encode, X: Future + Clone + Send + 'static, - T: Send + Sync + 'static, Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, - RA: Send + Sync + 'static + ConstructRuntimeApi>, - T: SubmitExtrinsic>, + RA: ConstructRuntimeApi> + Send + Sync + 'static, + T: SubmitExtrinsic + 'static, { let GrandpaParams { config, @@ -565,7 +564,8 @@ pub fn run_grandpa_voter, N, RA, SC, X, T>( network, select_chain, persistent_data, - voter_commands_rx + voter_commands_rx, + transaction_pool, ); let voter_work = voter_work @@ -586,22 +586,23 @@ pub fn run_grandpa_voter, N, RA, SC, X, T>( /// Future that powers the voter. #[must_use] -struct VoterWork, RA, SC> { +struct VoterWork, RA, SC, T> { voter: Box>> + Send>, - env: Arc>, + env: Arc>, voter_commands_rx: mpsc::UnboundedReceiver>>, } -impl VoterWork +impl VoterWork where Block: BlockT, N: Network + Sync, N::In: Send + 'static, NumberFor: BlockNumberOps, - RA: 'static + Send + Sync, - E: CallExecutor + Send + Sync + 'static, + RA: ConstructRuntimeApi> + Send + Sync + 'static, + E: CallExecutor + Clone + Send + Sync + 'static, B: Backend + 'static, SC: SelectChain + 'static, + T: SubmitExtrinsic, { fn new( client: Arc>, @@ -610,6 +611,7 @@ where select_chain: SC, persistent_data: PersistentData, voter_commands_rx: mpsc::UnboundedReceiver>>, + transaction_pool: Arc, ) -> Self { let voters = persistent_data.authority_set.current_authorities(); @@ -747,16 +749,17 @@ where } } -impl Future for VoterWork +impl Future for VoterWork where Block: BlockT, N: Network + Sync, N::In: Send + 'static, NumberFor: BlockNumberOps, - RA: 'static + Send + Sync, - E: CallExecutor + Send + Sync + 'static, + RA: ConstructRuntimeApi> + Send + Sync + 'static, + E: CallExecutor + Clone + Send + Sync + 'static, B: Backend + 'static, SC: SelectChain + 'static, + T: SubmitExtrinsic + 'static, { type Item = (); type Error = Error; @@ -813,11 +816,10 @@ pub fn run_grandpa, N, RA, SC, X, T>( NumberFor: BlockNumberOps, DigestFor: Encode, X: Future + Clone + Send + 'static, - T: Sync + Send + 'static, Client: HeaderBackend + ProvideRuntimeApi, as ProvideRuntimeApi>::Api: GrandpaApi, - RA: Send + Sync + 'static + ConstructRuntimeApi>, - T: SubmitExtrinsic>, + RA: ConstructRuntimeApi> + Send + Sync + 'static, + T: SubmitExtrinsic + 'static, { run_grandpa_voter(grandpa_params) } diff --git a/core/sr-primitives/src/traits.rs b/core/sr-primitives/src/traits.rs index d413680bad198..9cfe720d85776 100644 --- a/core/sr-primitives/src/traits.rs +++ b/core/sr-primitives/src/traits.rs @@ -23,8 +23,8 @@ use runtime_io; #[cfg(feature = "std")] use serde::{Serialize, Deserialize, de::DeserializeOwned}; use primitives::{self, Hasher, Blake2Hasher}; use crate::codec::{Codec, Encode, Decode, HasCompact}; +use crate::generic::{Digest, DigestItem, BlockId}; use crate::transaction_validity::{ValidTransaction, TransactionValidity}; -use crate::generic::{Digest, DigestItem}; use crate::weights::DispatchInfo; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ @@ -1239,19 +1239,15 @@ impl AccountIdConver } /// Something that can submit an extrinsic. -pub trait SubmitExtrinsic { - /// Id of the block where the extrinsic is submitted. - type BlockId; - /// The extrinsic submitted. - type Extrinsic: Codec; +pub trait SubmitExtrinsic: Send + Sync { /// Error type in case of failed submission. type Error: core::fmt::Display; /// Imports one unverified extrinsic to the pool fn submit_extrinsic( &self, - at: &Self::BlockId, - xt: Self::Extrinsic, + at: &BlockId, + xt: TBlock::Extrinsic, ) -> Result<(), Self::Error>; } diff --git a/core/transaction-pool/graph/src/pool.rs b/core/transaction-pool/graph/src/pool.rs index dd5283efc6638..1889c3e151fa5 100644 --- a/core/transaction-pool/graph/src/pool.rs +++ b/core/transaction-pool/graph/src/pool.rs @@ -100,16 +100,14 @@ impl Default for Options { } /// Something that can submit an extrinsic. -impl SubmitExtrinsic for Pool { - type BlockId = BlockId; - type Extrinsic = ExtrinsicFor; +impl SubmitExtrinsic for Pool { type Error = String; /// Imports one unverified extrinsic to the pool fn submit_extrinsic( &self, - at: &Self::BlockId, - xt: Self::Extrinsic, + at: &BlockId, + xt: ExtrinsicFor, ) -> Result<(), Self::Error> { self.submit_one(at, xt) .map_err(|e| format!("{}", e)) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 5d84127127e30..76515f4d77713 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -32,7 +32,7 @@ use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; -use codec::{Encode, Decode}; +use codec::Encode; use babe::{AuthorityId as BabeId}; use babe_primitives::EquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 4dc5cbf45bd3e..c6be90c748a88 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -46,7 +46,7 @@ use runtime_io::blake2_256; use sr_staking_primitives::{SessionIndex, offence::{TimeSlot, Offence, Kind}}; use fg_primitives::{ ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, - localized_payload, app + localized_payload, }; use session::historical::Proof; pub use fg_primitives::{AuthorityId, AuthorityWeight, AuthoritySignature}; @@ -172,7 +172,7 @@ decl_storage! { } } -impl ValidateUnsigned for Module where T: Trait +impl ValidateUnsigned for Module where T: Trait { type Call = Call; @@ -260,6 +260,7 @@ decl_module! { _signature: AuthoritySignature ) { ensure_signed(origin)?; + // TODO [slashing] implement me // let to_punish = ::KeyOwnerSystem::check_proof( // (key_types::SR25519, equivocation.identity.encode()), // proof.clone(), From 967ca96f9258a4a2c38d690e99a3bf4fc932f479 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 16 Aug 2019 16:40:52 +0200 Subject: [PATCH 167/191] Try to refactor collect_offence_reports --- srml/offences/src/lib.rs | 98 ++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 15bdc7d62454f..620374b1ec960 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -88,7 +88,6 @@ decl_module! { fn deposit_event() = default; } } - impl> ReportOffence for Module where @@ -99,28 +98,22 @@ where let time_slot = offence.time_slot(); let validator_set_count = offence.validator_set_count(); - // Go through all offenders in the report and record unique reports. - let cache = Self::collect_unique_reports::(reporters, &time_slot, offenders); - - if cache.new_offenders.is_empty() { + // Go through all offenders in the offence report and find all offenders that was spotted + // in unique reports. + let TriageOutcome { + new_offenders, + concurrent_offenders, + } = match Self::triage_offence_report::(reporters, &time_slot, offenders) { + Some(cache) => cache, // The report contained only duplicates, so there is no need to slash again. - return; - } + None => return, + }; // Deposit the event. Self::deposit_event(Event::Offence(O::ID, time_slot.encode())); - // Load report details for the all reports happened at the same time. - let concurrent_offenders = cache - .concurrent_reports - .iter() - .filter_map(|report_id| { - >::get(report_id) - }) - .collect::>(); - let offenders_count = concurrent_offenders.len() as u32; - let previous_offenders_count = offenders_count - cache.new_offenders.len() as u32; + let previous_offenders_count = offenders_count - new_offenders.len() as u32; // The amount new offenders are slashed let new_fraction = O::slash_fraction(offenders_count, validator_set_count); @@ -141,7 +134,8 @@ where let numerator = new_fraction .into_parts() .saturating_sub(previous_fraction.into_parts()); - let denominator = Perbill::from_parts(Perbill::one().into_parts() - previous_fraction.into_parts()); + let denominator = + Perbill::from_parts(Perbill::one().into_parts() - previous_fraction.into_parts()); Perbill::from_parts(denominator * numerator) } else { new_fraction.clone() @@ -150,19 +144,16 @@ where // calculate how much to slash let slash_perbill = concurrent_offenders .iter() - .map(|details| if previous_offenders_count > 0 && cache.new_offenders.contains(&details.offender) { - new_fraction.clone() - } else { - old_fraction.clone() + .map(|details| { + if previous_offenders_count > 0 && new_offenders.contains(&details.offender) { + new_fraction.clone() + } else { + old_fraction.clone() + } }) .collect::>(); - T::OnOffenceHandler::on_offence( - &concurrent_offenders, - &slash_perbill, - ); - - cache.save() + T::OnOffenceHandler::on_offence(&concurrent_offenders, &slash_perbill); } } @@ -177,21 +168,21 @@ impl Module { (O::ID, time_slot.encode(), offender).using_encoded(T::Hashing::hash) } - /// Goes through all offenders in a report and record each unique offence updating indexes. - /// - /// Returns `true` if there were unique reports. - fn collect_unique_reports>( + /// Triages the offence report and returns the set of offenders that was involved in unique + /// reports along with the list of the concurrent offences. + fn triage_offence_report>( reporters: Vec, time_slot: &O::TimeSlot, offenders: Vec, - ) -> ReportIndexCache { - let mut index_cache = ReportIndexCache::load(time_slot); + ) -> Option> { + let mut cache = ReportIndexCache::::load(time_slot); + let mut new_offenders = BTreeSet::new(); for offender in offenders { let report_id = Self::report_id::(time_slot, &offender); if !>::exists(&report_id) { - index_cache.new_offenders.insert(offender.clone()); + new_offenders.insert(offender.clone()); >::insert( &report_id, OffenceDetails { @@ -200,14 +191,36 @@ impl Module { }, ); - index_cache.insert(time_slot, report_id); + cache.insert(time_slot, report_id); } } - index_cache + if !new_offenders.is_empty() { + // Load report details for the all reports happened at the same time. + let concurrent_offenders = cache.concurrent_reports + .iter() + .filter_map(|report_id| >::get(report_id)) + .collect::>(); + + cache.save(); + + Some(TriageOutcome { + new_offenders, + concurrent_offenders, + }) + } else { + None + } } } +struct TriageOutcome { + /// Offenders that was spotted in the unique reports. + new_offenders: BTreeSet, + /// Other reports for the same report kinds. + concurrent_offenders: Vec>, +} + /// An auxilary struct for dealing with caches of report indexes localized for a specific offence /// kind. /// @@ -218,7 +231,6 @@ struct ReportIndexCache> { opaque_time_slot: OpaqueTimeSlot, concurrent_reports: Vec>, same_kind_reports: Vec<(O::TimeSlot, ReportIdOf)>, - new_offenders: BTreeSet, } impl> ReportIndexCache { @@ -237,15 +249,11 @@ impl> ReportIndexCache { opaque_time_slot, concurrent_reports, same_kind_reports, - new_offenders: BTreeSet::new(), } } /// Insert a new report to the index cache. fn insert(&mut self, time_slot: &O::TimeSlot, report_id: ReportIdOf) { - // Update the list of concurrent reports. - self.concurrent_reports.push(report_id); - // Insert the report id into the list while maintaining the ordering by the time // slot. let idx = match self @@ -255,7 +263,11 @@ impl> ReportIndexCache { Ok(idx) => idx, Err(idx) => idx, }; - self.same_kind_reports.insert(idx, (time_slot.clone(), report_id)); + self.same_kind_reports + .insert(idx, (time_slot.clone(), report_id)); + + // Update the list of concurrent reports. + self.concurrent_reports.push(report_id); } /// Dump the indexes to the storage. From ae41ebcd3867ce01309f2fcf6cb6ed46da4a51f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 16:36:38 +0200 Subject: [PATCH 168/191] Even more compilation fixes. --- core/finality-grandpa/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/finality-grandpa/src/lib.rs b/core/finality-grandpa/src/lib.rs index da56d257e3f3e..a7011a12b1c5b 100644 --- a/core/finality-grandpa/src/lib.rs +++ b/core/finality-grandpa/src/lib.rs @@ -602,7 +602,9 @@ where E: CallExecutor + Clone + Send + Sync + 'static, B: Backend + 'static, SC: SelectChain + 'static, - T: SubmitExtrinsic, + T: SubmitExtrinsic + 'static, + Client: HeaderBackend + ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: GrandpaApi, { fn new( client: Arc>, @@ -760,6 +762,8 @@ where B: Backend + 'static, SC: SelectChain + 'static, T: SubmitExtrinsic + 'static, + Client: HeaderBackend + ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: GrandpaApi, { type Item = (); type Error = Error; From 6bc58a825e6963f48b0577b4af8cd0d0066a6901 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 16 Aug 2019 16:55:43 +0200 Subject: [PATCH 169/191] Other fixes. --- srml/offences/src/lib.rs | 14 +++++++------- srml/offences/src/mock.rs | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 620374b1ec960..5b05856d2eebd 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -175,7 +175,7 @@ impl Module { time_slot: &O::TimeSlot, offenders: Vec, ) -> Option> { - let mut cache = ReportIndexCache::::load(time_slot); + let mut cache = ReportIndexStorage::::load(time_slot); let mut new_offenders = BTreeSet::new(); for offender in offenders { @@ -221,19 +221,19 @@ struct TriageOutcome { concurrent_offenders: Vec>, } -/// An auxilary struct for dealing with caches of report indexes localized for a specific offence -/// kind. +/// An auxilary struct for working with storage of indexes localized for a specific offence +/// kind (specified by the `O` type parameter). /// -/// It is expected that access to the indexes will be only performed through this struct while it -/// exists. +/// This struct is responsible for aggregating storage writes and the underlying storage should not +/// accessed directly meanwhile. #[must_use = "The changes are not saved without called `save`"] -struct ReportIndexCache> { +struct ReportIndexStorage> { opaque_time_slot: OpaqueTimeSlot, concurrent_reports: Vec>, same_kind_reports: Vec<(O::TimeSlot, ReportIdOf)>, } -impl> ReportIndexCache { +impl> ReportIndexStorage { /// Preload indexes from the cache for the specific `time_slot` and the kind of the offence. fn load(time_slot: &O::TimeSlot) -> Self { let opaque_time_slot = time_slot.encode(); diff --git a/srml/offences/src/mock.rs b/srml/offences/src/mock.rs index b518b95d16512..78355f642ef76 100644 --- a/srml/offences/src/mock.rs +++ b/srml/offences/src/mock.rs @@ -117,7 +117,10 @@ pub const KIND: [u8; 16] = *b"test_report_1234"; pub fn offence_reports(kind: Kind, time_slot: u128) -> Vec> { >::get(&kind, &time_slot.encode()) .into_iter() - .map(|report_id| >::get(&report_id).unwrap()) + .map(|report_id| { + >::get(&report_id) + .expect("dangling report id is found in ConcurrentReportsIndex") + }) .collect() } From bbc837b9e14c69c49339ae553b3e99916a14e9ec Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Fri, 16 Aug 2019 16:57:32 +0200 Subject: [PATCH 170/191] More fixes. --- srml/offences/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/srml/offences/src/lib.rs b/srml/offences/src/lib.rs index 5b05856d2eebd..a89efa2f830c4 100644 --- a/srml/offences/src/lib.rs +++ b/srml/offences/src/lib.rs @@ -104,7 +104,7 @@ where new_offenders, concurrent_offenders, } = match Self::triage_offence_report::(reporters, &time_slot, offenders) { - Some(cache) => cache, + Some(triage) => triage, // The report contained only duplicates, so there is no need to slash again. None => return, }; @@ -175,7 +175,7 @@ impl Module { time_slot: &O::TimeSlot, offenders: Vec, ) -> Option> { - let mut cache = ReportIndexStorage::::load(time_slot); + let mut storage = ReportIndexStorage::::load(time_slot); let mut new_offenders = BTreeSet::new(); for offender in offenders { @@ -191,18 +191,18 @@ impl Module { }, ); - cache.insert(time_slot, report_id); + storage.insert(time_slot, report_id); } } if !new_offenders.is_empty() { // Load report details for the all reports happened at the same time. - let concurrent_offenders = cache.concurrent_reports + let concurrent_offenders = storage.concurrent_reports .iter() .filter_map(|report_id| >::get(report_id)) .collect::>(); - cache.save(); + storage.save(); Some(TriageOutcome { new_offenders, @@ -234,7 +234,7 @@ struct ReportIndexStorage> { } impl> ReportIndexStorage { - /// Preload indexes from the cache for the specific `time_slot` and the kind of the offence. + /// Preload indexes from the storage for the specific `time_slot` and the kind of the offence. fn load(time_slot: &O::TimeSlot) -> Self { let opaque_time_slot = time_slot.encode(); @@ -252,19 +252,19 @@ impl> ReportIndexStorage { } } - /// Insert a new report to the index cache. + /// Insert a new report to the index. fn insert(&mut self, time_slot: &O::TimeSlot, report_id: ReportIdOf) { // Insert the report id into the list while maintaining the ordering by the time // slot. - let idx = match self + let pos = match self .same_kind_reports .binary_search_by_key(&time_slot, |&(ref when, _)| when) { - Ok(idx) => idx, - Err(idx) => idx, + Ok(pos) => pos, + Err(pos) => pos, }; self.same_kind_reports - .insert(idx, (time_slot.clone(), report_id)); + .insert(pos, (time_slot.clone(), report_id)); // Update the list of concurrent reports. self.concurrent_reports.push(report_id); From 2a7601ec7709ba741baee0c545c30fe880fc0cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 18:12:24 +0200 Subject: [PATCH 171/191] Clean up --- core/consensus/aura/src/lib.rs | 35 +++++++++++---------- core/finality-grandpa/primitives/src/lib.rs | 3 +- core/finality-grandpa/src/environment.rs | 6 ++-- core/test-runtime/src/lib.rs | 30 +++++++----------- node/cli/Cargo.toml | 1 - node/runtime/Cargo.toml | 3 +- 6 files changed, 37 insertions(+), 41 deletions(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 7f4cc4c5f5742..013430452dadd 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -377,21 +377,22 @@ fn check_header( let pre_hash = header.hash(); if P::verify(&sig, pre_hash.as_ref(), expected_author) { - // if let Some(equivocation_proof) = check_equivocation( - // client, - // slot_now, - // slot_num, - // &header, - // sig, - // expected_author, - // ).map_err(|e| e.to_string())? { - // info!( - // "Slot author is equivocating at slot {} with headers {:?} and {:?}", - // slot_num, - // equivocation_proof.fst_header().hash(), - // equivocation_proof.snd_header().hash(), - // ); - // } + if let Some(equivocation_proof) = check_equivocation( + client, + slot_now, + slot_num, + &header, + sig, + expected_author, + ).map_err(|e| e.to_string())? { + // TODO [slashing] report misbehaviour in future. + info!( + "Slot author is equivocating at slot {} with headers {:?} and {:?}", + slot_num, + equivocation_proof.first_header.hash(), + equivocation_proof.second_header.hash(), + ); + } Ok(CheckedHeader::Checked(header, (slot_num, seal))) } else { @@ -657,8 +658,8 @@ pub fn import_queue( let verifier = AuraVerifier { client: client.clone(), inherent_data_providers, - transaction_pool, phantom: PhantomData, + transaction_pool, }; Ok(BasicQueue::new( verifier, @@ -756,8 +757,8 @@ mod tests { AuraVerifier { client, inherent_data_providers, - transaction_pool: Default::default(), phantom: Default::default(), + transaction_pool: Default::default(), } }, PeersClient::Light(_) => unreachable!("No (yet) tests for light client + Aura"), diff --git a/core/finality-grandpa/primitives/src/lib.rs b/core/finality-grandpa/primitives/src/lib.rs index d7f19f8e540c1..03db8390a2d15 100644 --- a/core/finality-grandpa/primitives/src/lib.rs +++ b/core/finality-grandpa/primitives/src/lib.rs @@ -58,6 +58,7 @@ pub fn localized_payload(round: u64, set_id: u64, message: &E) -> Vec (message, round, set_id).encode() } +// TODO [slashing] consider removing and use generic `EquivocationProof`. #[cfg_attr(feature = "std", derive(Debug))] #[derive(Clone, PartialEq, Eq, Encode, Decode)] pub struct GrandpaEquivocation { @@ -72,7 +73,7 @@ pub struct GrandpaEquivocation { /// The identity of the equivocator. pub identity: AuthorityId, /// The first vote in the equivocation. - pub first: (Message, AuthoritySignature), + pub first: (Message, AuthoritySignature), /// The second vote in the equivocation. pub second: (Message, AuthoritySignature), } diff --git a/core/finality-grandpa/src/environment.rs b/core/finality-grandpa/src/environment.rs index 4eb9d92cede8b..dfaae25131255 100644 --- a/core/finality-grandpa/src/environment.rs +++ b/core/finality-grandpa/src/environment.rs @@ -856,7 +856,8 @@ where let grandpa_equivocation = GrandpaEquivocationFrom:: { reporter, round_number: equivocation.round_number, - session_index: SessionIndex::default(), // TODO: add session index. + // TODO [slashing] get proper session index. + session_index: SessionIndex::default(), identity: equivocation.identity, first: (first_vote, first_signature), second: (second_vote, second_signature), @@ -901,7 +902,8 @@ where let grandpa_equivocation = GrandpaEquivocationFrom:: { reporter, round_number: equivocation.round_number, - session_index: SessionIndex::default(), // TODO: add session index. + // TODO [slashing] get proper session index. + session_index: SessionIndex::default(), identity: equivocation.identity, first: (first_vote, first_signature), second: (second_vote, second_signature), diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index f5cf772f7226a..5b6e870e70fe6 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -387,12 +387,10 @@ parameter_types! { pub const ExpectedBlockTime: u64 = 10_000; } -// impl srml_babe::Trait for Runtime { -// type EpochDuration = EpochDuration; -// type ExpectedBlockTime = ExpectedBlockTime; -// } - - +impl srml_babe::Trait for Runtime { + type EpochDuration = EpochDuration; + type ExpectedBlockTime = ExpectedBlockTime; +} /// Adds one to the given input and returns the final result. #[inline(never)] @@ -614,13 +612,10 @@ cfg_if! { let authorities: Vec<_> = authorities.into_iter().map(|x|(x, 1)).collect(); babe_primitives::Epoch { - // start_slot: >::epoch_start_slot(), - start_slot: 0, + start_slot: >::epoch_start_slot(), authorities, - // randomness: >::randomness(), - randomness: [0; 32], - // epoch_index: >::epoch_index(), - epoch_index: 0, + randomness: >::randomness(), + epoch_index: >::epoch_index(), duration: EpochDuration::get(), secondary_slots: >::secondary_slots().0, } @@ -633,7 +628,7 @@ cfg_if! { AuthoritySignature >, ) -> Option> { - Some(vec![]) + None } } @@ -842,13 +837,10 @@ cfg_if! { let authorities: Vec<_> = authorities.into_iter().map(|x|(x, 1)).collect(); babe_primitives::Epoch { - // start_slot: >::epoch_start_slot(), - start_slot: 0, + start_slot: >::epoch_start_slot(), authorities, - // randomness: >::randomness(), - randomness: [0; 32], - // epoch_index: >::epoch_index(), - epoch_index: 0, + randomness: >::randomness(), + epoch_index: >::epoch_index(), duration: EpochDuration::get(), secondary_slots: >::secondary_slots().0, } diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index 3b770b40867b2..c266427439d78 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -43,7 +43,6 @@ system = { package = "srml-system", path = "../../srml/system" } balances = { package = "srml-balances", path = "../../srml/balances" } support = { package = "srml-support", path = "../../srml/support", default-features = false } im_online = { package = "srml-im-online", path = "../../srml/im-online", default-features = false } -keystore = { package = "substrate-keystore", path = "../../core/keystore", default-features = false } [dev-dependencies] keystore = { package = "substrate-keystore", path = "../../core/keystore" } diff --git a/node/runtime/Cargo.toml b/node/runtime/Cargo.toml index cd58b21ca8a9b..c198329323a95 100644 --- a/node/runtime/Cargo.toml +++ b/node/runtime/Cargo.toml @@ -45,7 +45,7 @@ serde = { version = "1.0", optional = true } substrate-keyring = { path = "../../core/keyring", optional = true } substrate-session = { path = "../../core/session", default-features = false } app-crypto = { package = "substrate-application-crypto", path = "../../core/application-crypto", default-features = false } -runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = ["wasm-nice-panic-message" ] } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.2", path = "../../core/utils/wasm-builder-runner" } @@ -79,6 +79,7 @@ std = [ "primitives/std", "rstd/std", "rustc-hex", + "runtime_io/std", "safe-mix/std", "serde", "session/std", From 3112203a6722f30bd33c768d867fdacdf0e16b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 19:44:55 +0200 Subject: [PATCH 172/191] Untangle babe and historical sessions. --- node/runtime/src/lib.rs | 2 ++ srml/babe/Cargo.toml | 2 +- srml/babe/src/lib.rs | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index d1ba323361366..7cbcce5814b9d 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -144,6 +144,8 @@ parameter_types! { impl babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; + type IdentificationTuple = historical::IdentificationTuple; + type Proof = historical::Proof; type KeyOwnerSystem = Historical; type ReportEquivocation = Offences; } diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index f616db6f537c3..02a491e2846f2 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -13,7 +13,7 @@ hex-literal = "0.2" inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } serde = { version = "1.0.93", optional = true } -session = { package = "srml-session", path = "../session", default-features = false, features = ["historical"] } +session = { package = "srml-session", path = "../session", default-features = false } sr-io = { path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } sr-primitives = { path = "../../core/sr-primitives", default-features = false } sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 9e8671214dd1e..34dae1bef1716 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -27,7 +27,7 @@ pub use timestamp; use rstd::{result, prelude::*}; use sr_io::blake2_256; use srml_support::{ - decl_storage, decl_module, StorageValue, StorageMap, + decl_storage, decl_module, StorageValue, StorageMap, Parameter, traits::{FindAuthor, Get, KeyOwnerProofSystem}, }; use timestamp::{OnTimestampSet}; @@ -49,7 +49,6 @@ use codec::{Encode, Decode}; use inherents::{RuntimeString, InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; -use session::historical::{Proof, IdentificationTuple}; use system::{ensure_signed, ensure_root}; use babe_primitives::{ BABE_ENGINE_ID, ConsensusLog, BabeAuthorityWeight, Epoch, RawBabePreDigest, @@ -130,19 +129,21 @@ impl ProvideInherentData for InherentDataProvider { } } -pub trait Trait: timestamp::Trait + session::historical::Trait { +pub trait Trait: timestamp::Trait { type EpochDuration: Get; type ExpectedBlockTime: Get; + type IdentificationTuple: Parameter; + type Proof: Parameter; type KeyOwnerSystem: KeyOwnerProofSystem< (KeyTypeId, Vec), - Proof=Proof, - IdentificationTuple=IdentificationTuple + Proof=Self::Proof, + IdentificationTuple=Self::IdentificationTuple, >; type ReportEquivocation: ReportOffence< Self::AccountId, - IdentificationTuple, - BabeEquivocationOffence>, + Self::IdentificationTuple, + BabeEquivocationOffence, >; } @@ -248,7 +249,7 @@ impl ValidateUnsigned for Module where T: Trait fn equivocation_is_valid( equivocation: &EquivocationProof, - proof: &Proof, + proof: &T::Proof, signature: &AuthoritySignature, ) -> bool { let signed = (equivocation, proof); @@ -323,7 +324,7 @@ decl_module! { fn report_equivocation( origin, equivocation: EquivocationProof, - proof: Proof, + proof: T::Proof, _signature: AuthoritySignature ) { // TODO [slashing] I thought we are porducing an UnsignedTransaction? From 94ae5f6dfc7d46bb6e1ad0cd5f23621673a92291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 19:55:14 +0200 Subject: [PATCH 173/191] Fix test-runtime. --- core/test-runtime/src/lib.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index 5b6e870e70fe6..2a3b6f23fcc65 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -48,7 +48,7 @@ use runtime_version::RuntimeVersion; pub use primitives::{hash::H256, crypto::key_types}; #[cfg(any(feature = "std", test))] use runtime_version::NativeVersion; -use runtime_support::{impl_outer_origin, parameter_types}; +use runtime_support::{impl_outer_origin, parameter_types, traits::KeyOwnerProofSystem}; use inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; @@ -387,9 +387,28 @@ parameter_types! { pub const ExpectedBlockTime: u64 = 10_000; } +pub struct FakeKeyOwnerProofSystem; + +impl KeyOwnerProofSystem for FakeKeyOwnerProofSystem { + type Proof = (); + type IdentificationTuple = (); + + fn prove(_key: Key) -> Option { + None + } + + fn check_proof(_key: Key, _proof: Self::Proof) -> Option { + Some(()) + } +} + impl srml_babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; + type IdentificationTuple = (); + type Proof = (); + type KeyOwnerSystem = FakeKeyOwnerProofSystem; + type ReportEquivocation = (); } /// Adds one to the given input and returns the final result. @@ -622,7 +641,7 @@ cfg_if! { } fn construct_equivocation_transaction( - equivocation: babe_primitives::EquivocationProof< + _equivocation: babe_primitives::EquivocationProof< ::Header, AuthorityId, AuthoritySignature From 40eb793dc20d157d0935d85c11f97fba69bf90c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 22:09:53 +0200 Subject: [PATCH 174/191] Move aura to app-crypto bounds. --- core/consensus/aura/src/lib.rs | 46 ++++++++++++++++------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/core/consensus/aura/src/lib.rs b/core/consensus/aura/src/lib.rs index 013430452dadd..d2538096cc5cd 100644 --- a/core/consensus/aura/src/lib.rs +++ b/core/consensus/aura/src/lib.rs @@ -28,8 +28,9 @@ //! //! NOTE: Aura itself is designed to be generic over the crypto used. #![forbid(missing_docs, unsafe_code)] -use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fmt::Debug, pin::Pin}; +use std::{sync::Arc, time::Duration, thread, marker::PhantomData, pin::Pin}; +use app_crypto::{AppPair, RuntimeAppPublic}; use codec::{Encode, Decode, Codec}; use consensus_common::{self, BlockImport, Environment, Proposer, ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError, @@ -44,9 +45,9 @@ use client::{ }; use sr_primitives::{generic::{BlockId, OpaqueDigestItemId}, Justification}; -use sr_primitives::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member}; - +use sr_primitives::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero}; use primitives::crypto::Pair; + use inherents::{InherentDataProviders, InherentData}; use futures::prelude::*; @@ -96,7 +97,7 @@ impl SlotDuration { } /// Get slot author for given block along with authorities. -fn slot_author(slot_num: u64, authorities: &[AuthorityId

]) -> Option<&AuthorityId

> { +fn slot_author(slot_num: u64, authorities: &[AuthorityId

]) -> Option<&AuthorityId

> { if authorities.is_empty() { return None } let idx = slot_num % (authorities.len() as u64); @@ -147,9 +148,8 @@ pub fn start_aura( E: Environment + Send + Sync + 'static, E::Proposer: Proposer, >::Create: Unpin + Send, - P: Pair + Send + Sync, - P::Public: Hash + Member + Encode + Decode, - P::Signature: Hash + Member + Encode + Decode, + P: AppPair, +

::Signature: Codec, H: Header, I: BlockImport + Send + Sync + 'static, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, @@ -197,9 +197,8 @@ impl slots::SimpleSlotWorker for AuraWorker>::Create: Unpin + Send, H: Header, I: BlockImport + Send + Sync + 'static, - P: Pair + Send + Sync, - P::Public: Member + Encode + Decode + Hash, - P::Signature: Member + Encode + Decode + Hash + Debug, + P: AppPair, +

::Signature: Codec, SO: SyncOracle + Send + Clone, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, { @@ -295,9 +294,8 @@ impl SlotWorker for AuraWorker>::Create: Unpin + Send + 'static, H: Header, I: BlockImport + Send + Sync + 'static, - P: Pair + Send + Sync, - P::Public: Member + Encode + Decode + Hash, - P::Signature: Member + Encode + Decode + Hash + Debug, + P: AppPair, +

::Signature: Codec, SO: SyncOracle + Send + Sync + Clone, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, { @@ -317,10 +315,8 @@ macro_rules! aura_err { }; } -fn find_pre_digest(header: &B::Header) -> Result +fn find_pre_digest(header: &B::Header) -> Result where DigestItemFor: CompatibleDigestItem

, - P::Signature: Decode, - P::Public: Encode + Decode + PartialEq + Clone, { let mut pre_digest: Option = None; for log in header.digest().logs() { @@ -338,7 +334,7 @@ fn find_pre_digest(header: &B::Header) -> Result( +fn check_header( client: &C, slot_now: u64, mut header: B::Header, @@ -347,9 +343,9 @@ fn check_header( _transaction_pool: Option<&T>, ) -> Result)>, String> where DigestItemFor: CompatibleDigestItem

, - P::Signature: Decode, C: client::backend::AuxStore, - P::Public: Encode + Decode + PartialEq + Clone, + AuthorityId

: RuntimeAppPublic::Signature>, +

::Signature: Codec + Clone, T: Send + Sync + 'static, { let seal = match header.digest_mut().pop() { @@ -466,9 +462,9 @@ impl Verifier for AuraVerifier where C: ProvideRuntimeApi + Send + Sync + client::backend::AuxStore + ProvideCache + BlockOf, C::Api: BlockBuilderApi + AuraApi>, DigestItemFor: CompatibleDigestItem

, - P: Pair + Send + Sync + 'static, - P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static, - P::Signature: Encode + Decode, + P: AppPair, + AuthorityId

: RuntimeAppPublic::Signature>, +

::Signature: Codec + Clone, T: Send + Sync + 'static, { fn verify( @@ -647,9 +643,9 @@ pub fn import_queue( C: 'static + ProvideRuntimeApi + BlockOf + ProvideCache + Send + Sync + AuxStore, C::Api: BlockBuilderApi + AuraApi>, DigestItemFor: CompatibleDigestItem

, - P: Pair + Send + Sync + 'static, - P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode, - P::Signature: Encode + Decode, + P: AppPair, + AuthorityId

: RuntimeAppPublic::Signature>, +

::Signature: Codec + Clone, T: Send + Sync + 'static, { register_aura_inherent_data_provider(&inherent_data_providers, slot_duration.get())?; From c2b83df33c96bdf7cfde3959ecd7769c677b34bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 22:26:57 +0200 Subject: [PATCH 175/191] Fix more tests. --- core/consensus/babe/src/tests.rs | 8 +++----- core/consensus/slots/src/aux_schema.rs | 4 ++-- core/finality-grandpa/src/tests.rs | 8 +++----- srml/grandpa/src/mock.rs | 3 +-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/core/consensus/babe/src/tests.rs b/core/consensus/babe/src/tests.rs index 7f52db5267939..b05ed079d9cc8 100644 --- a/core/consensus/babe/src/tests.rs +++ b/core/consensus/babe/src/tests.rs @@ -89,15 +89,13 @@ type TestExtrinsic = ::Extrinsic; struct TransactionPool; -impl SubmitExtrinsic for TransactionPool { - type BlockId = BlockId; - type Extrinsic = TestExtrinsic; +impl SubmitExtrinsic for TransactionPool { type Error = String; fn submit_extrinsic( &self, - at: &Self::BlockId, - xt: Self::Extrinsic, + at: &BlockId, + xt: TestExtrinsic, ) -> Result<(), Self::Error> { Ok(()) } diff --git a/core/consensus/slots/src/aux_schema.rs b/core/consensus/slots/src/aux_schema.rs index 43a8526560fd5..66fb4fa4063e2 100644 --- a/core/consensus/slots/src/aux_schema.rs +++ b/core/consensus/slots/src/aux_schema.rs @@ -140,11 +140,11 @@ pub fn check_equivocation( #[cfg(test)] mod test { use super::*; - use primitives::{sr25519, Pair}; + use primitives::{Pair}; use primitives::hash::H256; use sr_primitives::testing::{Header as HeaderTest, Digest as DigestTest}; use test_client::{ - runtime::app_crypto::ed25519::{AppPair, AppPublic, AppSignature }, + runtime::app_crypto::ed25519::{AppPair, AppSignature }, }; use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation}; diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 892bda210e1d3..fa42dd4cb70c4 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -366,15 +366,13 @@ fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir struct TransactionPool; -impl SubmitExtrinsic for TransactionPool { - type BlockId = BlockId; - type Extrinsic = (); +impl SubmitExtrinsic for TransactionPool { type Error = String; fn submit_extrinsic( &self, - at: &Self::BlockId, - xt: Self::Extrinsic, + at: &BlockId, + xt: Block::Extrinsic, ) -> std::result::Result<(), Self::Error> { Ok(()) } diff --git a/srml/grandpa/src/mock.rs b/srml/grandpa/src/mock.rs index 880678a6dc7ad..156d00a6bff52 100644 --- a/srml/grandpa/src/mock.rs +++ b/srml/grandpa/src/mock.rs @@ -20,12 +20,11 @@ use sr_primitives::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; use runtime_io; -use srml_support::{impl_outer_origin, impl_outer_dispatch, impl_outer_event, parameter_types}; +use srml_support::{impl_outer_origin, impl_outer_event, parameter_types}; use primitives::{H256, Blake2Hasher}; use codec::{Encode, Decode}; use crate::{AuthorityId, GenesisConfig, Trait, Module, ConsensusLog}; use substrate_finality_grandpa_primitives::GRANDPA_ENGINE_ID; -use test_runtime::Extrinsic; impl_outer_origin!{ pub enum Origin for Test {} From 98265a583bc5527a7a504af463e3a468332b0291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 23:06:06 +0200 Subject: [PATCH 176/191] Fix finality-grandpa tests. --- core/finality-grandpa/src/tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index fa42dd4cb70c4..54d6721d652ab 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -372,7 +372,7 @@ impl SubmitExtrinsic for TransactionPool { fn submit_extrinsic( &self, at: &BlockId, - xt: Block::Extrinsic, + xt: ::Extrinsic, ) -> std::result::Result<(), Self::Error> { Ok(()) } @@ -1148,7 +1148,7 @@ fn voter_persists_its_votes() { net: Arc>, client: PeersClient, keystore: KeyStorePtr, - transaction_pool: Arc::new(TransactionPool), + transaction_pool: Arc, } impl Future for ResettableVoter { @@ -1511,7 +1511,7 @@ fn voter_catches_up_to_latest_round_when_behind() { inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, - transaction_pool: Arc::new(TransactionPool), + transaction_pool: Arc::new(TransactionPool::default()), }; Box::new(run_grandpa_voter(grandpa_params).expect("all in order with client and network")) From e7be080c41ad0ee90681ea0a206af5b3d12792ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 23:23:44 +0200 Subject: [PATCH 177/191] Impl grandpa for test-runtime. --- Cargo.lock | 1 + core/consensus/babe/src/tests.rs | 6 +-- core/finality-grandpa/src/tests.rs | 5 ++- core/test-runtime/Cargo.toml | 2 + core/test-runtime/src/lib.rs | 65 +++++++++++++++++++++++++++++- srml/grandpa/Cargo.toml | 4 +- 6 files changed, 75 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2061ee002da3d..aa33208f5183b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5058,6 +5058,7 @@ dependencies = [ "sr-version 2.0.0", "srml-babe 2.0.0", "srml-executive 2.0.0", + "srml-grandpa 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", "srml-timestamp 2.0.0", diff --git a/core/consensus/babe/src/tests.rs b/core/consensus/babe/src/tests.rs index b05ed079d9cc8..af1b45beabd32 100644 --- a/core/consensus/babe/src/tests.rs +++ b/core/consensus/babe/src/tests.rs @@ -94,8 +94,8 @@ impl SubmitExtrinsic for TransactionPool { fn submit_extrinsic( &self, - at: &BlockId, - xt: TestExtrinsic, + _at: &BlockId, + _xt: TestExtrinsic, ) -> Result<(), Self::Error> { Ok(()) } @@ -108,7 +108,7 @@ pub struct TestVerifier { TestBlock, test_client::runtime::RuntimeApi, PeersFullClient, - (), + TransactionPool, >, mutator: Mutator, } diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 54d6721d652ab..bf9524548820c 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -1175,13 +1175,13 @@ fn voter_persists_its_votes() { justification_period: 32, keystore: Some(self.keystore.clone()), name: Some(format!("peer#{}", 0)), - transaction_pool: self.transaction_pool.clone(), }, link, network: self.net.lock().peers[0].network_service().clone(), inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, + transaction_pool: self.transaction_pool.clone(), }; let voter = run_grandpa_voter(grandpa_params) @@ -1213,6 +1213,7 @@ fn voter_persists_its_votes() { net: net.clone(), client: client.clone(), keystore, + transaction_pool: Arc::new(TransactionPool), }); } @@ -1511,7 +1512,7 @@ fn voter_catches_up_to_latest_round_when_behind() { inherent_data_providers: InherentDataProviders::new(), on_exit: Exit, telemetry_on_connect: None, - transaction_pool: Arc::new(TransactionPool::default()), + transaction_pool: Arc::new(TransactionPool), }; Box::new(run_grandpa_voter(grandpa_params).expect("all in order with client and network")) diff --git a/core/test-runtime/Cargo.toml b/core/test-runtime/Cargo.toml index 13186056ce2dc..bb1847a5b567d 100644 --- a/core/test-runtime/Cargo.toml +++ b/core/test-runtime/Cargo.toml @@ -16,6 +16,7 @@ app-crypto = { package = "substrate-application-crypto", path = "../application- inherents = { package = "substrate-inherents", path = "../inherents", default-features = false } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../consensus/aura/primitives", default-features = false } babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../consensus/babe/primitives", default-features = false } +grandpa = { package = "srml-grandpa", path = "../../srml/grandpa", default-features = false } rstd = { package = "sr-std", path = "../sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../sr-io", default-features = false } sr-primitives = { path = "../sr-primitives", default-features = false } @@ -60,6 +61,7 @@ std = [ "runtime_version/std", "aura-primitives/std", "babe-primitives/std", + "grandpa/std", "primitives/std", "substrate-trie/std", "trie-db/std", diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index 2a3b6f23fcc65..2e9402a6aa131 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -41,7 +41,7 @@ use sr_primitives::{ transaction_validity::{TransactionValidity, ValidTransaction}, traits::{ BlindCheckable, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, - GetNodeBlockType, GetRuntimeBlockType, Verify, IdentityLookup, + GetNodeBlockType, GetRuntimeBlockType, Verify, IdentityLookup, DigestFor, NumberFor, }, }; use runtime_version::RuntimeVersion; @@ -51,6 +51,8 @@ use runtime_version::NativeVersion; use runtime_support::{impl_outer_origin, parameter_types, traits::KeyOwnerProofSystem}; use inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; +use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; +use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; // Ensure Babe and Aura use the same crypto to simplify things a bit. pub use babe_primitives::{AuthorityId, AuthoritySignature}; @@ -349,6 +351,12 @@ impl From for Event { } } +impl From for Event { + fn from(_evt: grandpa::Event) -> Self { + unimplemented!("Not required in tests!") + } +} + parameter_types! { pub const BlockHashCount: BlockNumber = 250; pub const MinimumPeriod: u64 = 5; @@ -411,6 +419,12 @@ impl srml_babe::Trait for Runtime { type ReportEquivocation = (); } +impl grandpa::Trait for Runtime { + type Event = Event; +} + +pub type Grandpa = grandpa::Module; + /// Adds one to the given input and returns the final result. #[inline(never)] fn benchmark_add_one(i: u64) -> u64 { @@ -651,6 +665,30 @@ cfg_if! { } } + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_pending_change(digest: &DigestFor) + -> Option>> + { + Grandpa::pending_change(digest) + } + + fn grandpa_forced_change(digest: &DigestFor) + -> Option<(NumberFor, ScheduledChange>)> + { + Grandpa::forced_change(digest) + } + + fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { + Grandpa::grandpa_authorities() + } + + fn construct_equivocation_transaction( + _equivocation: GrandpaEquivocationFrom + ) -> Option> { + unimplemented!() + } + } + impl offchain_primitives::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); @@ -876,6 +914,31 @@ cfg_if! { } } + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_pending_change(digest: &DigestFor) + -> Option>> + { + Grandpa::pending_change(digest) + } + + fn grandpa_forced_change(digest: &DigestFor) + -> Option<(NumberFor, ScheduledChange>)> + { + Grandpa::forced_change(digest) + } + + fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { + Grandpa::grandpa_authorities() + } + + fn construct_equivocation_transaction( + _equivocation: GrandpaEquivocationFrom + ) -> Option> { + unimplemented!() + } + } + + impl offchain_primitives::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); diff --git a/srml/grandpa/Cargo.toml b/srml/grandpa/Cargo.toml index 37a36ce79fc79..21f89aa97c4a1 100644 --- a/srml/grandpa/Cargo.toml +++ b/srml/grandpa/Cargo.toml @@ -10,9 +10,9 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = finality-tracker = { package = "srml-finality-tracker", path = "../finality-tracker", default-features = false } primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } -runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } +runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false, features = ["wasm-nice-panic-message"] } serde = { version = "1.0", optional = true, features = ["derive"] } -session = { package = "srml-session", path = "../session", default-features = false } +session = { package = "srml-session", path = "../session", features = ["historical"], default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false } srml-support = { path = "../support", default-features = false } From 0ff99e74cf5435e25db2fe759134baa750afd8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 16 Aug 2019 23:35:00 +0200 Subject: [PATCH 178/191] Fix warnings. --- core/finality-grandpa/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index bf9524548820c..2a13d9c2f3fa9 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -371,8 +371,8 @@ impl SubmitExtrinsic for TransactionPool { fn submit_extrinsic( &self, - at: &BlockId, - xt: ::Extrinsic, + _at: &BlockId, + _xt: ::Extrinsic, ) -> std::result::Result<(), Self::Error> { Ok(()) } From 8d345e4a159874a0ad14281c0e39bf2c90bbd87e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 00:17:02 +0200 Subject: [PATCH 179/191] Fix should return runtime version test. --- core/rpc/src/state/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 6b4ddc9b920bc..680dfff412f90 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -260,7 +260,7 @@ fn should_return_runtime_version() { \"specVersion\":1,\"implVersion\":1,\"apis\":[[\"0xdf6acb689907609b\",2],\ [\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",1],[\"0x40fe3ad401f8959a\",3],\ [\"0xc6e9a76309f39b09\",1],[\"0xdd718d5cc53262d4\",1],[\"0xcbca25e39f142387\",1],\ - [\"0xf78b278be53f454c\",1],[\"0xab3c0572291feb8b\",1]]}"; + [\"0xed99c5acb25eedf5\",2],[\"0xf78b278be53f454c\",1],[\"0xab3c0572291feb8b\",1]]}"; assert_eq!( serde_json::to_string(&api.runtime_version(None.into()).unwrap()).unwrap(), From 799496de3a4f440cca21f3bf35b540c72a8505f7 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 00:17:25 +0200 Subject: [PATCH 180/191] Fix line width --- node/runtime/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 7cbcce5814b9d..e4dcb218eba26 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -614,7 +614,11 @@ impl_runtime_apis! { } fn construct_equivocation_transaction( - equivocation: EquivocationProof<::Header, babe_primitives::AuthorityId, babe_primitives::AuthoritySignature>, + equivocation: EquivocationProof< + ::Header, + babe_primitives::AuthorityId, + babe_primitives::AuthoritySignature + >, ) -> Option> { let proof = Historical::prove((key_types::BABE, equivocation.identity.encode()))?; let local_keys = runtime_io::sr25519_public_keys(key_types::GRANDPA); From 4f95ff5bbbb90fed26e0a682ac9e93017b15918a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sat, 17 Aug 2019 00:27:22 +0200 Subject: [PATCH 181/191] Fix tests. --- core/rpc/src/state/tests.rs | 2 +- node/cli/src/chain_spec.rs | 2 +- node/runtime/src/lib.rs | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/rpc/src/state/tests.rs b/core/rpc/src/state/tests.rs index 6b4ddc9b920bc..680dfff412f90 100644 --- a/core/rpc/src/state/tests.rs +++ b/core/rpc/src/state/tests.rs @@ -260,7 +260,7 @@ fn should_return_runtime_version() { \"specVersion\":1,\"implVersion\":1,\"apis\":[[\"0xdf6acb689907609b\",2],\ [\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",1],[\"0x40fe3ad401f8959a\",3],\ [\"0xc6e9a76309f39b09\",1],[\"0xdd718d5cc53262d4\",1],[\"0xcbca25e39f142387\",1],\ - [\"0xf78b278be53f454c\",1],[\"0xab3c0572291feb8b\",1]]}"; + [\"0xed99c5acb25eedf5\",2],[\"0xf78b278be53f454c\",1],[\"0xab3c0572291feb8b\",1]]}"; assert_eq!( serde_json::to_string(&api.runtime_version(None.into()).unwrap()).unwrap(), diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index 6693f8bd3a9d0..fe8df33f79939 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -300,7 +300,7 @@ pub fn testnet_genesis( authorities: vec![], }), im_online: Some(ImOnlineConfig { - keys: initial_authorities.iter().map(|x| x.4.clone()).collect(), + keys: vec![], }), grandpa: Some(GrandpaConfig { authorities: vec![], diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 7cbcce5814b9d..e4dcb218eba26 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -614,7 +614,11 @@ impl_runtime_apis! { } fn construct_equivocation_transaction( - equivocation: EquivocationProof<::Header, babe_primitives::AuthorityId, babe_primitives::AuthoritySignature>, + equivocation: EquivocationProof< + ::Header, + babe_primitives::AuthorityId, + babe_primitives::AuthoritySignature + >, ) -> Option> { let proof = Historical::prove((key_types::BABE, equivocation.identity.encode()))?; let local_keys = runtime_io::sr25519_public_keys(key_types::GRANDPA); From 68468e4a874bffc350fe14de6c56aaaf41a5eeec Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 00:47:22 +0200 Subject: [PATCH 182/191] Remove ValidateUnsigned from babe srml. --- node/runtime/src/lib.rs | 2 +- srml/babe/src/lib.rs | 36 +++++++----------------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index e4dcb218eba26..a392d5dac13f0 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -440,7 +440,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Storage, Config, Event}, - Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp), ValidateUnsigned}, + Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, Timestamp: timestamp::{Module, Call, Storage, Inherent}, Authorship: authorship::{Module, Call, Storage, Inherent}, Indices: indices, diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 34dae1bef1716..9ae4c14ca1b97 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -33,10 +33,7 @@ use srml_support::{ use timestamp::{OnTimestampSet}; use sr_primitives::{ generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId, - transaction_validity::{TransactionValidity, ValidTransaction}, - traits::{ - IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Header, ValidateUnsigned, - }, + traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Header}, weights::SimpleDispatchInfo, }; use sr_staking_primitives::{ @@ -224,29 +221,6 @@ decl_storage! { } } -impl ValidateUnsigned for Module where T: Trait -{ - type Call = Call; - - fn validate_unsigned(call: &Self::Call) -> TransactionValidity { - match call { - Call::report_equivocation(equivocation, proof, signature) - if equivocation_is_valid::(equivocation, proof, signature) => { - return TransactionValidity::Valid( - ValidTransaction { - priority: 0, - requires: vec![], - provides: vec![], - longevity: 18446744073709551615, - propagate: true, - } - ) - }, - _ => TransactionValidity::Invalid(0), - } - } -} - fn equivocation_is_valid( equivocation: &EquivocationProof, proof: &T::Proof, @@ -325,10 +299,14 @@ decl_module! { origin, equivocation: EquivocationProof, proof: T::Proof, - _signature: AuthoritySignature + signature: AuthoritySignature ) { - // TODO [slashing] I thought we are porducing an UnsignedTransaction? let who = ensure_signed(origin)?; + + if !equivocation_is_valid::(&equivocation, &proof, &signature) { + return Err("invalid equivocation") + } + let to_punish = ::KeyOwnerSystem::check_proof( (key_types::BABE, equivocation.identity.encode()), proof.clone(), From 6e5068b3285ea90200a4cc2d87e2f7abcf85e0fa Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 00:55:50 +0200 Subject: [PATCH 183/191] Remove ValidateUnsigned from Grandpa srml. --- node/runtime/src/lib.rs | 2 +- srml/grandpa/src/lib.rs | 40 +++++++++------------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index a392d5dac13f0..be5f314e4d85a 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -454,7 +454,7 @@ construct_runtime!( Elections: elections::{Module, Call, Storage, Event, Config}, TechnicalMembership: membership::::{Module, Call, Storage, Event, Config}, FinalityTracker: finality_tracker::{Module, Call, Inherent}, - Grandpa: grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned}, + Grandpa: grandpa::{Module, Call, Storage, Config, Event}, Treasury: treasury::{Module, Call, Storage, Event}, Contracts: contracts, Sudo: sudo, diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 970c20711f71a..f89aff72d3265 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -38,10 +38,7 @@ use srml_support::{ }; use app_crypto::RuntimeAppPublic; use sr_primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, - transaction_validity::{TransactionValidity, ValidTransaction}, - traits::{Zero, ValidateUnsigned}, - Perbill, KeyTypeId, + generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, KeyTypeId, }; use sr_staking_primitives::{ SessionIndex, @@ -176,29 +173,6 @@ decl_storage! { } } -impl ValidateUnsigned for Module where T: Trait -{ - type Call = Call; - - fn validate_unsigned(call: &Self::Call) -> TransactionValidity { - match call { - Call::report_equivocation(equivocation, proof, signature) - if equivocation_is_valid::(equivocation, proof, signature) => { - return TransactionValidity::Valid( - ValidTransaction { - priority: 0, - requires: vec![], - provides: vec![], - longevity: 18446744073709551615, - propagate: true, - } - ) - }, - _ => TransactionValidity::Invalid(0), - } - } -} - fn equivocation_is_valid( equivocation: &GrandpaEquivocation, proof: &Proof, @@ -259,11 +233,15 @@ decl_module! { /// Report some misbehavior. fn report_equivocation( origin, - _equivocation: GrandpaEquivocation, - _proof: Proof, - _signature: AuthoritySignature + equivocation: GrandpaEquivocation, + proof: Proof, + signature: AuthoritySignature ) { - ensure_signed(origin)?; + let _who = ensure_signed(origin)?; + + if !equivocation_is_valid(&equivocation, &proof, &signature) { + return Err("invalid equivocation") + } // TODO [slashing] implement me // let to_punish = ::KeyOwnerSystem::check_proof( // (key_types::SR25519, equivocation.identity.encode()), From ea6b4fa10597c08b1040d8fd7d6d35f57379f6c4 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 01:03:13 +0200 Subject: [PATCH 184/191] Add commented report_equivocation to Grandpa. --- srml/grandpa/src/lib.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index f89aff72d3265..b9ea899bd267e 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -38,7 +38,7 @@ use srml_support::{ }; use app_crypto::RuntimeAppPublic; use sr_primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, KeyTypeId, + generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, key_types, KeyTypeId }; use sr_staking_primitives::{ SessionIndex, @@ -230,7 +230,7 @@ decl_module! { pub struct Module for enum Call where origin: T::Origin { fn deposit_event() = default; - /// Report some misbehavior. + /// Report a Grandpa vote equivocation. fn report_equivocation( origin, equivocation: GrandpaEquivocation, @@ -242,13 +242,19 @@ decl_module! { if !equivocation_is_valid(&equivocation, &proof, &signature) { return Err("invalid equivocation") } - // TODO [slashing] implement me + // let to_punish = ::KeyOwnerSystem::check_proof( - // (key_types::SR25519, equivocation.identity.encode()), + // (key_types::GRANDPA, equivocation.identity.encode()), // proof.clone(), // ); - // if to_punish.is_some() { - // // TODO: Slash. + // if let Some(to_punish) = to_punish { + // let offence = GrandpaEquivocationOffence { + // time_slot: equivocation.slot, + // session_index: SessionIndex::default(), + // validator_set_count: 0, + // offender: to_punish, + // }; + // T::ReportEquivocation::report_offence(vec![who], offence); // } } From 3ed3e26465594b36f09ebd33c813c87175d42bce Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 01:48:27 +0200 Subject: [PATCH 185/191] Make stuff no-std for Extra. --- srml/balances/src/lib.rs | 1 - srml/system/src/lib.rs | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/srml/balances/src/lib.rs b/srml/balances/src/lib.rs index 66d0ee028495f..4b09a873562e9 100644 --- a/srml/balances/src/lib.rs +++ b/srml/balances/src/lib.rs @@ -1168,7 +1168,6 @@ pub struct TakeFees, I: Instance = DefaultInstance>(#[codec(compact) impl, I: Instance> TakeFees { /// utility constructor. Used only in client/factory code. - #[cfg(feature = "std")] pub fn from(fee: T::Balance) -> Self { Self(fee) } diff --git a/srml/system/src/lib.rs b/srml/system/src/lib.rs index 1d17ef2b1c986..009c5be6b61e1 100644 --- a/srml/system/src/lib.rs +++ b/srml/system/src/lib.rs @@ -872,7 +872,6 @@ impl CheckWeight { } /// Utility constructor for tests and client code. - #[cfg(feature = "std")] pub fn new() -> Self { Self(PhantomData) } @@ -927,7 +926,6 @@ impl rstd::fmt::Debug for CheckWeight { #[derive(Encode, Decode, Clone, Eq, PartialEq)] pub struct CheckNonce(#[codec(compact)] T::Index); -#[cfg(feature = "std")] impl CheckNonce { /// utility constructor. Used only in client/factory code. pub fn from(nonce: T::Index) -> Self { @@ -1001,7 +999,6 @@ impl SignedExtension for CheckNonce { #[derive(Encode, Decode, Clone, Eq, PartialEq)] pub struct CheckEra((Era, rstd::marker::PhantomData)); -#[cfg(feature = "std")] impl CheckEra { /// utility constructor. Used only in client/factory code. pub fn from(era: Era) -> Self { @@ -1041,10 +1038,9 @@ impl rstd::fmt::Debug for CheckGenesis { } } -#[cfg(feature = "std")] impl CheckGenesis { pub fn new() -> Self { - Self(std::marker::PhantomData) + Self(core::marker::PhantomData) } } From cf17c79f276d3099fc16317c0d4031d66c9d3b9b Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 01:49:06 +0200 Subject: [PATCH 186/191] Add implementation for signed tx to Babe node. --- node/runtime/src/lib.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index be5f314e4d85a..ec017be572cf9 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -43,6 +43,7 @@ use client::{ use sr_primitives::{ApplyResult, impl_opaque_keys, generic, create_runtime_str, key_types}; use sr_primitives::transaction_validity::TransactionValidity; use sr_primitives::weights::Weight; +use sr_primitives::generic::Era; use sr_primitives::traits::{ BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup, }; @@ -625,19 +626,31 @@ impl_runtime_apis! { if local_keys.len() > 0 { let reporter = &local_keys[0]; - let to_sign = (equivocation.clone(), proof.clone()); - let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { + let call = BabeCall::report_equivocation(equivocation, proof); + let function = Call::Babe(call); + + // TODO: fix these parameters. + let check_genesis = system::CheckGenesis::new(); + let check_era = system::CheckEra::from(Era::Immortal); + let check_nonce = system::CheckNonce::from(0); + let check_weight = system::CheckWeight::new(); + let take_fees = balances::TakeFees::from(0); + let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees); + + let genesis_hash = System::block_hash(0); + let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash); + + let maybe_signature = raw_payload.using_encoded(|payload| if payload.len() > 256 { runtime_io::sr25519_sign(key_types::BABE, reporter, &runtime_io::blake2_256(payload)) } else { runtime_io::sr25519_sign(key_types::BABE, reporter, &payload) }); if let Some(signature) = maybe_signature { - let call = BabeCall::report_equivocation(equivocation, proof, signature.into()); - let babe_call = Call::Babe(call); - let ex = UncheckedExtrinsic::new_unsigned(babe_call); - return Some(ex.encode()) + let signed = indices::address::Address::from(reporter.clone()); + let extrinsic = UncheckedExtrinsic::new_signed(raw_payload.0, signed, signature.into(), extra); + return Some(extrinsic.encode()) } } From fb3002e8ad365b065d1eea98d9a7a4f65c433eaf Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 01:49:48 +0200 Subject: [PATCH 187/191] Remove signature from validate equivocation in Babe srml. --- srml/babe/src/lib.rs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 9ae4c14ca1b97..993c80a7c8851 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -25,7 +25,6 @@ pub use timestamp; use rstd::{result, prelude::*}; -use sr_io::blake2_256; use srml_support::{ decl_storage, decl_module, StorageValue, StorageMap, Parameter, traits::{FindAuthor, Get, KeyOwnerProofSystem}, @@ -223,22 +222,7 @@ decl_storage! { fn equivocation_is_valid( equivocation: &EquivocationProof, - proof: &T::Proof, - signature: &AuthoritySignature, ) -> bool { - let signed = (equivocation, proof); - let reporter = &equivocation.reporter; - - let signature_valid = signed.using_encoded(|signed| if signed.len() > 256 { - reporter.verify(&blake2_256(signed), &signature) - } else { - reporter.verify(&signed, &signature) - }); - - if !signature_valid { - return false - } - let first_header = &equivocation.first_header; let second_header = &equivocation.second_header; @@ -294,16 +278,15 @@ decl_module! { Initialized::kill(); } - /// Report equivocation. + /// Report a Babe equivocation. fn report_equivocation( origin, equivocation: EquivocationProof, - proof: T::Proof, - signature: AuthoritySignature + proof: T::Proof ) { let who = ensure_signed(origin)?; - if !equivocation_is_valid::(&equivocation, &proof, &signature) { + if !equivocation_is_valid::(&equivocation) { return Err("invalid equivocation") } From 2ded0a7aee97d6100615af836e612ed6e2015d17 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 02:16:51 +0200 Subject: [PATCH 188/191] Implemente signed tx for Grandpa node. --- node/runtime/src/lib.rs | 32 ++++++++++++++++++++++---------- srml/grandpa/src/lib.rs | 21 ++------------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index ec017be572cf9..209655bb90ae3 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -565,23 +565,35 @@ impl_runtime_apis! { equivocation: GrandpaEquivocationFrom ) -> Option> { let proof = Historical::prove((key_types::GRANDPA, equivocation.identity.encode()))?; - let local_keys = runtime_io::ed25519_public_keys(key_types::GRANDPA); + let local_keys = runtime_io::sr25519_public_keys(key_types::GRANDPA); if local_keys.len() > 0 { let reporter = &local_keys[0]; - let to_sign = (equivocation.clone(), proof.clone()); - let maybe_signature = to_sign.using_encoded(|payload| if payload.len() > 256 { - runtime_io::ed25519_sign(key_types::GRANDPA, reporter, &runtime_io::blake2_256(payload)) + let call = GrandpaCall::report_equivocation(equivocation, proof); + let function = Call::Grandpa(call); + + // TODO: fix these parameters. + let check_genesis = system::CheckGenesis::new(); + let check_era = system::CheckEra::from(Era::Immortal); + let check_nonce = system::CheckNonce::from(0); + let check_weight = system::CheckWeight::new(); + let take_fees = balances::TakeFees::from(0); + let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees); + + let genesis_hash = System::block_hash(0); + let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash); + + let maybe_signature = raw_payload.using_encoded(|payload| if payload.len() > 256 { + runtime_io::sr25519_sign(key_types::GRANDPA, reporter, &runtime_io::blake2_256(payload)) } else { - runtime_io::ed25519_sign(key_types::GRANDPA, reporter, &payload) + runtime_io::sr25519_sign(key_types::GRANDPA, reporter, &payload) }); if let Some(signature) = maybe_signature { - let call = GrandpaCall::report_equivocation(equivocation, proof, signature.into()); - let grandpa_call = Call::Grandpa(call); - let ex = UncheckedExtrinsic::new_unsigned(grandpa_call); - return Some(ex.encode()) + let signed = indices::address::Address::from(reporter.clone()); + let extrinsic = UncheckedExtrinsic::new_signed(raw_payload.0, signed, signature.into(), extra); + return Some(extrinsic.encode()) } } @@ -622,7 +634,7 @@ impl_runtime_apis! { >, ) -> Option> { let proof = Historical::prove((key_types::BABE, equivocation.identity.encode()))?; - let local_keys = runtime_io::sr25519_public_keys(key_types::GRANDPA); + let local_keys = runtime_io::sr25519_public_keys(key_types::BABE); if local_keys.len() > 0 { let reporter = &local_keys[0]; diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index b9ea899bd267e..9b2e2c251f4e1 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -44,7 +44,6 @@ use sr_staking_primitives::{ SessionIndex, offence::{Offence, Kind}, }; -use runtime_io::blake2_256; use fg_primitives::{ ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, localized_payload, @@ -175,22 +174,7 @@ decl_storage! { fn equivocation_is_valid( equivocation: &GrandpaEquivocation, - proof: &Proof, - signature: &AuthoritySignature ) -> bool { - let signed = (equivocation, proof); - let reporter = &equivocation.reporter; - - let signature_valid = signed.using_encoded(|signed| if signed.len() > 256 { - reporter.verify(&blake2_256(signed), &signature) - } else { - reporter.verify(&signed, &signature) - }); - - if !signature_valid { - return false - } - let first_vote = &equivocation.first.0; let first_signature = &equivocation.first.1; @@ -234,12 +218,11 @@ decl_module! { fn report_equivocation( origin, equivocation: GrandpaEquivocation, - proof: Proof, - signature: AuthoritySignature + _proof: Proof ) { let _who = ensure_signed(origin)?; - if !equivocation_is_valid(&equivocation, &proof, &signature) { + if !equivocation_is_valid(&equivocation) { return Err("invalid equivocation") } From 85309345ac9313b91bf03abba525d94039910278 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 10:35:12 +0200 Subject: [PATCH 189/191] Move implementations of construct_equivocation to srmls. --- Cargo.lock | 4 +++ node/runtime/src/lib.rs | 80 ++++------------------------------------- srml/babe/Cargo.toml | 5 ++- srml/babe/src/lib.rs | 53 +++++++++++++++++++++++++-- srml/grandpa/Cargo.toml | 4 +++ srml/grandpa/src/lib.rs | 67 ++++++++++++++++++++++++++++++---- 6 files changed, 128 insertions(+), 85 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa33208f5183b..a6c48c22b50eb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3743,6 +3743,8 @@ dependencies = [ "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", + "srml-balances 2.0.0", + "srml-indices 2.0.0", "srml-session 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", @@ -3914,7 +3916,9 @@ dependencies = [ "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", "sr-std 2.0.0", + "srml-balances 2.0.0", "srml-finality-tracker 2.0.0", + "srml-indices 2.0.0", "srml-session 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 209655bb90ae3..d679180122c8b 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -23,16 +23,13 @@ use rstd::prelude::*; use support::{ construct_runtime, parameter_types, - traits::{ - SplitTwoWays, Currency, KeyOwnerProofSystem - } + traits::{SplitTwoWays, Currency} }; use primitives::u32_trait::{_1, _2, _3, _4}; use node_primitives::{ AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature, }; -use codec::Encode; use babe::{AuthorityId as BabeId}; use babe_primitives::EquivocationProof; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; @@ -43,7 +40,6 @@ use client::{ use sr_primitives::{ApplyResult, impl_opaque_keys, generic, create_runtime_str, key_types}; use sr_primitives::transaction_validity::TransactionValidity; use sr_primitives::weights::Weight; -use sr_primitives::generic::Era; use sr_primitives::traits::{ BlakeTwo256, Block as BlockT, DigestFor, NumberFor, StaticLookup, }; @@ -420,7 +416,9 @@ impl offences::Trait for Runtime { impl grandpa::Trait for Runtime { type Event = Event; - // type KeyOwnerSystem = Historical; + type IdentificationTuple = historical::IdentificationTuple; + type Proof = historical::Proof; + type KeyOwnerSystem = Historical; } parameter_types! { @@ -564,40 +562,7 @@ impl_runtime_apis! { fn construct_equivocation_transaction( equivocation: GrandpaEquivocationFrom ) -> Option> { - let proof = Historical::prove((key_types::GRANDPA, equivocation.identity.encode()))?; - let local_keys = runtime_io::sr25519_public_keys(key_types::GRANDPA); - - if local_keys.len() > 0 { - let reporter = &local_keys[0]; - - let call = GrandpaCall::report_equivocation(equivocation, proof); - let function = Call::Grandpa(call); - - // TODO: fix these parameters. - let check_genesis = system::CheckGenesis::new(); - let check_era = system::CheckEra::from(Era::Immortal); - let check_nonce = system::CheckNonce::from(0); - let check_weight = system::CheckWeight::new(); - let take_fees = balances::TakeFees::from(0); - let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees); - - let genesis_hash = System::block_hash(0); - let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash); - - let maybe_signature = raw_payload.using_encoded(|payload| if payload.len() > 256 { - runtime_io::sr25519_sign(key_types::GRANDPA, reporter, &runtime_io::blake2_256(payload)) - } else { - runtime_io::sr25519_sign(key_types::GRANDPA, reporter, &payload) - }); - - if let Some(signature) = maybe_signature { - let signed = indices::address::Address::from(reporter.clone()); - let extrinsic = UncheckedExtrinsic::new_signed(raw_payload.0, signed, signature.into(), extra); - return Some(extrinsic.encode()) - } - } - - None + Grandpa::construct_equivocation_transaction(equivocation) } } @@ -633,40 +598,7 @@ impl_runtime_apis! { babe_primitives::AuthoritySignature >, ) -> Option> { - let proof = Historical::prove((key_types::BABE, equivocation.identity.encode()))?; - let local_keys = runtime_io::sr25519_public_keys(key_types::BABE); - - if local_keys.len() > 0 { - let reporter = &local_keys[0]; - - let call = BabeCall::report_equivocation(equivocation, proof); - let function = Call::Babe(call); - - // TODO: fix these parameters. - let check_genesis = system::CheckGenesis::new(); - let check_era = system::CheckEra::from(Era::Immortal); - let check_nonce = system::CheckNonce::from(0); - let check_weight = system::CheckWeight::new(); - let take_fees = balances::TakeFees::from(0); - let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees); - - let genesis_hash = System::block_hash(0); - let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash); - - let maybe_signature = raw_payload.using_encoded(|payload| if payload.len() > 256 { - runtime_io::sr25519_sign(key_types::BABE, reporter, &runtime_io::blake2_256(payload)) - } else { - runtime_io::sr25519_sign(key_types::BABE, reporter, &payload) - }); - - if let Some(signature) = maybe_signature { - let signed = indices::address::Address::from(reporter.clone()); - let extrinsic = UncheckedExtrinsic::new_signed(raw_payload.0, signed, signature.into(), extra); - return Some(extrinsic.encode()) - } - } - - None + Babe::construct_equivocation_transaction(equivocation) } } diff --git a/srml/babe/Cargo.toml b/srml/babe/Cargo.toml index 02a491e2846f2..d2fe21fc585c2 100644 --- a/srml/babe/Cargo.toml +++ b/srml/babe/Cargo.toml @@ -9,17 +9,19 @@ app-crypto = { package = "substrate-application-crypto", path = "../../core/appl babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../core/consensus/babe/primitives", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } consensus-common-primitives = { package = "substrate-consensus-common-primitives", path = "../../core/consensus/common/primitives", default-features = false } -hex-literal = "0.2" inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } serde = { version = "1.0.93", optional = true } session = { package = "srml-session", path = "../session", default-features = false } +balances = { package = "srml-balances", path = "../balances", default-features = false } +indices = { package = "srml-indices", path = "../indices", default-features = false } sr-io = { path = "../../core/sr-io", default-features = false, features = [ "wasm-nice-panic-message" ] } sr-primitives = { path = "../../core/sr-primitives", default-features = false } sr-staking-primitives = { path = "../../core/sr-staking-primitives", 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 } +hex-literal = "0.2" [dev-dependencies] lazy_static = "1.3.0" @@ -35,6 +37,7 @@ std = [ "rstd/std", "serde", "session/std", + "balances/std", "sr-io/std", "sr-primitives/std", "sr-staking-primitives/std", diff --git a/srml/babe/src/lib.rs b/srml/babe/src/lib.rs index 993c80a7c8851..218d1684037df 100644 --- a/srml/babe/src/lib.rs +++ b/srml/babe/src/lib.rs @@ -31,8 +31,8 @@ use srml_support::{ }; use timestamp::{OnTimestampSet}; use sr_primitives::{ - generic::DigestItem, ConsensusEngineId, Perbill, key_types, KeyTypeId, - traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Header}, + generic::{DigestItem, Era, UncheckedExtrinsic}, ConsensusEngineId, Perbill, key_types, KeyTypeId, + traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon, Header, Zero}, weights::SimpleDispatchInfo, }; use sr_staking_primitives::{ @@ -125,7 +125,7 @@ impl ProvideInherentData for InherentDataProvider { } } -pub trait Trait: timestamp::Trait { +pub trait Trait: timestamp::Trait + balances::Trait + indices::Trait + Send + Sync { type EpochDuration: Get; type ExpectedBlockTime: Get; type IdentificationTuple: Parameter; @@ -424,6 +424,53 @@ impl Module { ::MinimumPeriod::get().saturating_mul(2.into()) } + pub fn construct_equivocation_transaction( + equivocation: EquivocationProof + ) -> Option> { + let proof = T::KeyOwnerSystem::prove(( + key_types::BABE, + equivocation.identity.encode(), + ))?; + + let local_keys = app::Public::all(); + + if local_keys.len() > 0 { + let reporter = &local_keys[0]; + let function = Call::report_equivocation::(equivocation, proof); + + // TODO: fix these parameters. + let check_genesis = system::CheckGenesis::::new(); + let check_era = system::CheckEra::::from(Era::Immortal); + let check_nonce = system::CheckNonce::::from(Default::default()); + let check_weight = system::CheckWeight::::new(); + let take_fees = balances::TakeFees::::from(Default::default()); + let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees); + + let genesis_hash = >::block_hash(T::BlockNumber::zero()); + let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash); + + let maybe_signature: Option = raw_payload.using_encoded(|payload| if payload.len() > 256 { + reporter.sign(&sr_io::blake2_256(payload)) + } else { + reporter.sign(&payload) + }); + + if let Some(signature) = maybe_signature { + let signed = indices::address::Address::::Id(reporter.clone()); + let extrinsic = UncheckedExtrinsic::new_signed( + raw_payload.0, + signed, + signature, + extra, + ).encode(); + + return Some(extrinsic.encode()) + } + } + + None + } + fn deposit_consensus(new: U) { let log: DigestItem = DigestItem::Consensus(BABE_ENGINE_ID, new.encode()); >::deposit_log(log.into()) diff --git a/srml/grandpa/Cargo.toml b/srml/grandpa/Cargo.toml index 21f89aa97c4a1..01ba3003877e6 100644 --- a/srml/grandpa/Cargo.toml +++ b/srml/grandpa/Cargo.toml @@ -18,6 +18,8 @@ sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-fea srml-support = { path = "../support", default-features = false } substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } +balances = { package = "srml-balances", path = "../balances", default-features = false } +indices = { package = "srml-indices", path = "../indices", default-features = false } [dev-dependencies] runtime_io = { package = "sr-io", path = "../../core/sr-io" } @@ -39,4 +41,6 @@ std = [ "srml-support/std", "substrate-finality-grandpa-primitives/std", "system/std", + "balances/std", + "indices/std", ] diff --git a/srml/grandpa/src/lib.rs b/srml/grandpa/src/lib.rs index 9b2e2c251f4e1..a395de869d1d8 100644 --- a/srml/grandpa/src/lib.rs +++ b/srml/grandpa/src/lib.rs @@ -34,11 +34,12 @@ use rstd::prelude::*; use codec::{self as codec, Encode, Decode, Error, Codec}; use srml_support::{ decl_event, decl_storage, decl_module, dispatch::Result, storage::StorageValue, - traits::KeyOwnerProofSystem + traits::KeyOwnerProofSystem, Parameter }; use app_crypto::RuntimeAppPublic; use sr_primitives::{ - generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, key_types, KeyTypeId + generic::{DigestItem, OpaqueDigestItemId, Era, UncheckedExtrinsic}, + traits::Zero, Perbill, key_types, KeyTypeId }; use sr_staking_primitives::{ SessionIndex, @@ -48,17 +49,22 @@ use fg_primitives::{ ScheduledChange, ConsensusLog, GRANDPA_ENGINE_ID, GrandpaEquivocation, localized_payload, }; -use session::historical::Proof; -pub use fg_primitives::{AuthorityId, AuthorityWeight, AuthoritySignature}; +pub use fg_primitives::{AuthorityId, AuthorityWeight, AuthoritySignature, app}; use system::{ensure_signed, DigestOf}; mod mock; mod tests; -pub trait Trait: system::Trait { +pub trait Trait: system::Trait + balances::Trait + indices::Trait + Send + Sync { /// The event type of this module. type Event: From + Into<::Event>; - // type KeyOwnerSystem: KeyOwnerProofSystem<(KeyTypeId, Vec), Proof=Proof>; + type IdentificationTuple: Parameter; + type Proof: Parameter; + type KeyOwnerSystem: KeyOwnerProofSystem< + (KeyTypeId, Vec), + Proof=Self::Proof, + IdentificationTuple=Self::IdentificationTuple, + >; } /// A stored pending change, old format. @@ -218,7 +224,7 @@ decl_module! { fn report_equivocation( origin, equivocation: GrandpaEquivocation, - _proof: Proof + _proof: T::Proof ) { let _who = ensure_signed(origin)?; @@ -387,6 +393,53 @@ impl Module { } } + pub fn construct_equivocation_transaction( + equivocation: GrandpaEquivocation + ) -> Option> { + let proof = T::KeyOwnerSystem::prove(( + key_types::GRANDPA, + equivocation.identity.encode(), + ))?; + + let local_keys = app::Public::all(); + + if local_keys.len() > 0 { + let reporter = &local_keys[0]; + let function = Call::report_equivocation::(equivocation, proof); + + // TODO: fix these parameters. + let check_genesis = system::CheckGenesis::::new(); + let check_era = system::CheckEra::::from(Era::Immortal); + let check_nonce = system::CheckNonce::::from(Default::default()); + let check_weight = system::CheckWeight::::new(); + let take_fees = balances::TakeFees::::from(Default::default()); + let extra = (check_genesis, check_era, check_nonce, check_weight, take_fees); + + let genesis_hash = >::block_hash(T::BlockNumber::zero()); + let raw_payload = (function, extra.clone(), genesis_hash, genesis_hash); + + let maybe_signature: Option = raw_payload.using_encoded(|payload| if payload.len() > 256 { + reporter.sign(&runtime_io::blake2_256(payload)) + } else { + reporter.sign(&payload) + }); + + if let Some(signature) = maybe_signature { + let signed = indices::address::Address::::Id(reporter.clone()); + let extrinsic = UncheckedExtrinsic::new_signed( + raw_payload.0, + signed, + signature, + extra, + ).encode(); + + return Some(extrinsic.encode()) + } + } + + None + } + /// Deposit one of this module's logs. fn deposit_log(log: ConsensusLog) { let log: DigestItem = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); From 4dde8a281c9dc86024d73fb86a0d15a2e4d46d07 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 17 Aug 2019 11:33:56 +0200 Subject: [PATCH 190/191] Make tests compile. --- Cargo.lock | 2 + core/finality-grandpa/src/tests.rs | 2 +- core/test-runtime/Cargo.toml | 2 + core/test-runtime/src/lib.rs | 60 ++++++++++++++++++++++ srml/grandpa/src/mock.rs | 82 +++++++++++++++++++++++++++++- 5 files changed, 145 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6c48c22b50eb..8b2068e0369e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5061,8 +5061,10 @@ dependencies = [ "sr-std 2.0.0", "sr-version 2.0.0", "srml-babe 2.0.0", + "srml-balances 2.0.0", "srml-executive 2.0.0", "srml-grandpa 2.0.0", + "srml-indices 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", "srml-timestamp 2.0.0", diff --git a/core/finality-grandpa/src/tests.rs b/core/finality-grandpa/src/tests.rs index 2a13d9c2f3fa9..c7cee5cefb529 100644 --- a/core/finality-grandpa/src/tests.rs +++ b/core/finality-grandpa/src/tests.rs @@ -313,7 +313,7 @@ impl GrandpaApi for RuntimeApi { fn GrandpaApi_construct_equivocation_transaction_runtime_api_impl( &self, - at: &BlockId, + _at: &BlockId, _: ExecutionContext, _: Option<(GrandpaEquivocationFrom)>, _: Vec, diff --git a/core/test-runtime/Cargo.toml b/core/test-runtime/Cargo.toml index bb1847a5b567d..8f8831357d8b3 100644 --- a/core/test-runtime/Cargo.toml +++ b/core/test-runtime/Cargo.toml @@ -17,6 +17,8 @@ inherents = { package = "substrate-inherents", path = "../inherents", default-fe aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../consensus/aura/primitives", default-features = false } babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../consensus/babe/primitives", default-features = false } grandpa = { package = "srml-grandpa", path = "../../srml/grandpa", default-features = false } +indices = { package = "srml-indices", path = "../../srml/indices", default-features = false } +balances = { package = "srml-balances", path = "../../srml/balances", default-features = false } rstd = { package = "sr-std", path = "../sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../sr-io", default-features = false } sr-primitives = { path = "../sr-primitives", default-features = false } diff --git a/core/test-runtime/src/lib.rs b/core/test-runtime/src/lib.rs index 2e9402a6aa131..49df59b735c8a 100644 --- a/core/test-runtime/src/lib.rs +++ b/core/test-runtime/src/lib.rs @@ -53,6 +53,9 @@ use inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; +use indices::ResolveHint; +use srml_system::IsDeadAccount; +use runtime_support::traits::Get; // Ensure Babe and Aura use the same crypto to simplify things a bit. pub use babe_primitives::{AuthorityId, AuthoritySignature}; @@ -357,6 +360,12 @@ impl From for Event { } } +impl From<()> for Event { + fn from(_evt: ()) -> Self { + unimplemented!("Not required in tests!") + } +} + parameter_types! { pub const BlockHashCount: BlockNumber = 250; pub const MinimumPeriod: u64 = 5; @@ -421,6 +430,57 @@ impl srml_babe::Trait for Runtime { impl grandpa::Trait for Runtime { type Event = Event; + type IdentificationTuple = (); + type Proof = (); + type KeyOwnerSystem = FakeKeyOwnerProofSystem; +} + +pub struct TestIsDeadAccount {} +impl IsDeadAccount for TestIsDeadAccount { + fn is_dead_account(_who: &u64) -> bool { + false + } +} + +pub struct TestResolveHint; +impl ResolveHint for TestResolveHint { + fn resolve_hint(who: &u64) -> Option { + if *who < 256 { + None + } else { + Some(*who - 256) + } + } +} + +impl indices::Trait for Runtime { + type AccountIndex = u64; + type IsDeadAccount = TestIsDeadAccount; + type ResolveHint = TestResolveHint; + type Event = (); +} + +pub struct Getter; +impl Get for Getter { + fn get() -> u64 { + 0 + } +} + +impl balances::Trait for Runtime { + type Balance = u64; + type OnFreeBalanceZero = (); + type OnNewAccount = (); + type Event = (); + type TransactionPayment = (); + type DustRemoval = (); + type TransferPayment = (); + type ExistentialDeposit = Getter; + type TransferFee = Getter; + type CreationFee = Getter; + type TransactionBaseFee = Getter; + type TransactionByteFee = Getter; + type WeightToFee = (); } pub type Grandpa = grandpa::Module; diff --git a/srml/grandpa/src/mock.rs b/srml/grandpa/src/mock.rs index 156d00a6bff52..6ad965545958c 100644 --- a/srml/grandpa/src/mock.rs +++ b/srml/grandpa/src/mock.rs @@ -20,11 +20,16 @@ use sr_primitives::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; use runtime_io; -use srml_support::{impl_outer_origin, impl_outer_event, parameter_types}; +use srml_support::{ + impl_outer_origin, impl_outer_event, parameter_types, + traits::{Get, KeyOwnerProofSystem} +}; use primitives::{H256, Blake2Hasher}; use codec::{Encode, Decode}; use crate::{AuthorityId, GenesisConfig, Trait, Module, ConsensusLog}; use substrate_finality_grandpa_primitives::GRANDPA_ENGINE_ID; +use indices::ResolveHint; +use system::IsDeadAccount; impl_outer_origin!{ pub enum Origin for Test {} @@ -34,13 +39,31 @@ pub fn grandpa_log(log: ConsensusLog) -> DigestItem { DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()) } +pub struct FakeKeyOwnerProofSystem; + +impl KeyOwnerProofSystem for FakeKeyOwnerProofSystem { + type Proof = (); + type IdentificationTuple = (); + + fn prove(_key: Key) -> Option { + None + } + + fn check_proof(_key: Key, _proof: Self::Proof) -> Option { + Some(()) + } +} + // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, PartialEq, Eq, Debug, Decode, Encode)] pub struct Test; impl Trait for Test { type Event = TestEvent; - // type KeyOwnerSystem = (); + type IdentificationTuple = (); + type Proof = (); + type KeyOwnerSystem = FakeKeyOwnerProofSystem; } + parameter_types! { pub const BlockHashCount: u64 = 250; pub const MaximumBlockWeight: u32 = 1024; @@ -65,6 +88,61 @@ impl system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; } +pub struct TestIsDeadAccount {} +impl IsDeadAccount for TestIsDeadAccount { + fn is_dead_account(_who: &u64) -> bool { + false + } +} + +pub struct TestResolveHint; +impl ResolveHint for TestResolveHint { + fn resolve_hint(who: &u64) -> Option { + if *who < 256 { + None + } else { + Some(*who - 256) + } + } +} + +impl indices::Trait for Test { + type AccountIndex = u64; + type IsDeadAccount = TestIsDeadAccount; + type ResolveHint = TestResolveHint; + type Event = (); +} + +pub struct Getter; +impl Get for Getter { + fn get() -> u64 { + 0 + } +} + +impl balances::Trait for Test { + type Balance = u64; + type OnFreeBalanceZero = (); + type OnNewAccount = (); + type Event = (); + type TransactionPayment = (); + type DustRemoval = (); + type TransferPayment = (); + type ExistentialDeposit = Getter; + type TransferFee = Getter; + type CreationFee = Getter; + type TransactionBaseFee = Getter; + type TransactionByteFee = Getter; + type WeightToFee = (); +} + +impl From<()> for TestEvent { + fn from(_evt: ()) -> Self { + unimplemented!("Not required in tests!") + } +} + + mod grandpa { pub use crate::Event; } From 934876995e5a71c1c3c8a77e5fc6c90f13fc2396 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 20 Aug 2019 21:17:24 +0200 Subject: [PATCH 191/191] Fix node-template --- node-template/runtime/src/lib.rs | 45 +++++++++++++++++++++++++++++--- node-template/src/service.rs | 1 + 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/node-template/runtime/src/lib.rs b/node-template/runtime/src/lib.rs index 9f520971ad921..c28734d6ff2c5 100644 --- a/node-template/runtime/src/lib.rs +++ b/node-template/runtime/src/lib.rs @@ -16,9 +16,10 @@ use sr_primitives::{ }; use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Verify, ConvertInto}; use sr_primitives::weights::Weight; -use babe::{AuthorityId as BabeId}; +use babe::{AuthorityId as BabeId, AuthoritySignature}; +use consensus_primitives::EquivocationProof; use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; -use grandpa::fg_primitives::{self, ScheduledChange}; +use grandpa::fg_primitives::{self, ScheduledChange, GrandpaEquivocationFrom}; use client::{ block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api}, runtime_api as client_api, impl_runtime_apis @@ -33,7 +34,7 @@ pub use sr_primitives::BuildStorage; pub use timestamp::Call as TimestampCall; pub use balances::Call as BalancesCall; pub use sr_primitives::{Permill, Perbill}; -pub use support::{StorageValue, construct_runtime, parameter_types}; +pub use support::{StorageValue, construct_runtime, parameter_types, traits::KeyOwnerProofSystem}; /// An index to a block. pub type BlockNumber = u32; @@ -186,13 +187,35 @@ parameter_types! { pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; } +pub struct FakeKeyOwnerProofSystem; + +impl KeyOwnerProofSystem for FakeKeyOwnerProofSystem { + type Proof = (); + type IdentificationTuple = (); + + fn prove(_key: Key) -> Option { + None + } + + fn check_proof(_key: Key, _proof: Self::Proof) -> Option { + Some(()) + } +} + impl babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; + type IdentificationTuple = (); + type Proof = (); + type KeyOwnerSystem = FakeKeyOwnerProofSystem; + type ReportEquivocation = (); } impl grandpa::Trait for Runtime { type Event = Event; + type IdentificationTuple = (); + type Proof = (); + type KeyOwnerSystem = FakeKeyOwnerProofSystem; } impl indices::Trait for Runtime { @@ -372,6 +395,12 @@ impl_runtime_apis! { fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> { Grandpa::grandpa_authorities() } + + fn construct_equivocation_transaction( + _equivocation: GrandpaEquivocationFrom + ) -> Option> { + unimplemented!() + } } impl babe_primitives::BabeApi for Runtime { @@ -398,6 +427,16 @@ impl_runtime_apis! { secondary_slots: Babe::secondary_slots().0, } } + + fn construct_equivocation_transaction( + _equivocation: babe_primitives::EquivocationProof< + ::Header, + BabeId, + AuthoritySignature + >, + ) -> Option> { + None + } } impl consensus_primitives::ConsensusApi for Runtime { diff --git a/node-template/src/service.rs b/node-template/src/service.rs index b4a1a96413cfa..a623e08f74360 100644 --- a/node-template/src/service.rs +++ b/node-template/src/service.rs @@ -178,6 +178,7 @@ construct_service_factory! { service.config().custom.inherent_data_providers.clone(), on_exit: service.on_exit(), telemetry_on_connect: Some(telemetry_on_connect), + transaction_pool: service.transaction_pool(), }; // the GRANDPA voter task is considered infallible, i.e.