From d6a2eb2e3ca83a6fe4f68997a3356746b81aaea9 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 6 May 2022 13:56:00 +0200 Subject: [PATCH 01/75] disputes: runtime part of slashing --- runtime/kusama/src/lib.rs | 18 +- runtime/parachains/src/disputes.rs | 80 ++- runtime/parachains/src/disputes/slashing.rs | 550 ++++++++++++++++++++ runtime/parachains/src/disputes/tests.rs | 17 - runtime/parachains/src/initializer.rs | 6 +- runtime/parachains/src/mock.rs | 30 +- runtime/polkadot/src/lib.rs | 18 +- runtime/rococo/src/lib.rs | 18 +- runtime/test-runtime/src/lib.rs | 18 +- runtime/westend/src/lib.rs | 23 +- 10 files changed, 706 insertions(+), 72 deletions(-) create mode 100644 runtime/parachains/src/disputes/slashing.rs diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 9059cd90a871..bfb24f72bf2a 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -37,8 +37,9 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*}; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, @@ -1314,11 +1315,22 @@ impl parachains_initializer::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type RewardValidators = (); type PunishValidators = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleSlashingReportsForOldSessions = (); // TODO + type WeightInfo = parachains_slashing::TestWeightInfo; // TODO +} + parameter_types! { pub const ParaDeposit: Balance = 40 * UNITS; } diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 65ff35111f7c..cc7d2b940be9 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -39,6 +39,8 @@ use sp_std::{cmp::Ordering, prelude::*}; #[allow(unused_imports)] pub(crate) use self::tests::run_to_block; +pub mod slashing; + #[cfg(test)] mod tests; @@ -59,49 +61,60 @@ pub enum DisputeResult { Invalid, } -/// Reward hooks for disputes. -pub trait RewardValidators { - // Give each validator a reward, likely small, for participating in the dispute. - fn reward_dispute_statement( - session: SessionIndex, - validators: impl IntoIterator, - ); -} - -impl RewardValidators for () { - fn reward_dispute_statement(_: SessionIndex, _: impl IntoIterator) {} -} - /// Punishment hooks for disputes. pub trait PunishValidators { /// Punish a series of validators who were for an invalid parablock. This is expected to be a major /// punishment. + /// + /// `validator_set_count` is the size of the validator set in that session. fn punish_for_invalid( session: SessionIndex, + candidate_hash: CandidateHash, validators: impl IntoIterator, ); /// Punish a series of validators who were against a valid parablock. This is expected to be a minor /// punishment. + /// + /// `validator_set_count` is the size of the validator set in that session. fn punish_against_valid( session: SessionIndex, + candidate_hash: CandidateHash, validators: impl IntoIterator, ); /// Punish a series of validators who were part of a dispute which never concluded. This is expected /// to be a minor punishment. + /// + /// `validator_set_count` is the size of the validator set in that session. fn punish_inconclusive( session: SessionIndex, + candidate_hash: CandidateHash, validators: impl IntoIterator, ); } impl PunishValidators for () { - fn punish_for_invalid(_: SessionIndex, _: impl IntoIterator) {} + fn punish_for_invalid( + _: SessionIndex, + _: CandidateHash, + _: impl IntoIterator, + ) { + } - fn punish_against_valid(_: SessionIndex, _: impl IntoIterator) {} + fn punish_against_valid( + _: SessionIndex, + _: CandidateHash, + _: impl IntoIterator, + ) { + } - fn punish_inconclusive(_: SessionIndex, _: impl IntoIterator) {} + fn punish_inconclusive( + _: SessionIndex, + _: CandidateHash, + _: impl IntoIterator, + ) { + } } /// Binary discriminator to determine if the expensive signature @@ -411,7 +424,18 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + configuration::Config + session_info::Config { type Event: From> + IsType<::Event>; - type RewardValidators: RewardValidators; + + /// A type that gives us the ability to submit dispute offence reports. + // type ReportDisputeOffences: ReportOffence< + // Self::AccountId, + // IdentificationTuple, + // slashing::ForInvalidOffence>, + // > + ReportOffence< + // Self::AccountId, + // IdentificationTuple, + // slashing::AgainstValidOffence>, + // >; + type PunishValidators: PunishValidators; /// Weight information for extrinsics in this pallet. @@ -570,6 +594,7 @@ struct ImportSummary { /// Validators to slash for being (wrongly) on the FOR side. slash_for: Vec, // New participants in the dispute. + #[allow(unused)] // FIXME new_participants: bitvec::vec::BitVec, // Difference in state flags from previous. new_flags: DisputeStateFlags, @@ -837,6 +862,7 @@ impl Pallet { // others in a timely manner. T::PunishValidators::punish_inconclusive( session_index, + candidate_hash, participating.iter_ones().map(|i| ValidatorIndex(i as _)), ); }); @@ -1187,7 +1213,9 @@ impl Pallet { Error::::SingleSidedDispute, ); - let DisputeStatementSet { session, candidate_hash, .. } = set.clone(); + let DisputeStatementSet { ref session, ref candidate_hash, .. } = set; + let session = *session; + let candidate_hash = *candidate_hash; // we can omit spam slot checks, `fn filter_disputes_data` is // always called before calling this `fn`. @@ -1219,18 +1247,22 @@ impl Pallet { } // Reward statements. - T::RewardValidators::reward_dispute_statement( - session, - summary.new_participants.iter_ones().map(|i| ValidatorIndex(i as _)), - ); + // T::RewardValidators::reward_dispute_statement( + // session, + // summary.new_participants.iter_ones().map(|i| ValidatorIndex(i as _)), + // ); // Slash participants on a losing side. { // a valid candidate, according to 2/3. Punish those on the 'against' side. - T::PunishValidators::punish_against_valid(session, summary.slash_against); + T::PunishValidators::punish_against_valid( + session, + candidate_hash, + summary.slash_against, + ); // an invalid candidate, according to 2/3. Punish those on the 'for' side. - T::PunishValidators::punish_for_invalid(session, summary.slash_for); + T::PunishValidators::punish_for_invalid(session, candidate_hash, summary.slash_for); } >::insert(&session, &candidate_hash, &summary.state); diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs new file mode 100644 index 000000000000..7bdbe466e45d --- /dev/null +++ b/runtime/parachains/src/disputes/slashing.rs @@ -0,0 +1,550 @@ +// Copyright 2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +//! Dispute slashing types for the substrate offences pallet. + +// use pallet_session::KeyOwner; +// use super::{Config, IdentificationTuple, IdentifyValidatorsInSession}; +use crate::{initializer::SessionChangeNotification, session_info::IdentificationTuple}; +use frame_support::{ + traits::{Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, + weights::{Pays, Weight}, +}; +use parity_scale_codec::{Decode, Encode}; +use primitives::v2::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; +use scale_info::TypeInfo; +use sp_runtime::{traits::Convert, DispatchResult, KeyTypeId, Perbill, RuntimeDebug}; +use sp_session::{GetSessionNumber, GetValidatorCount}; +use sp_staking::offence::{DisableStrategy, Kind, Offence, OffenceError, ReportOffence}; +use sp_std::{collections::btree_set::BTreeSet, prelude::*}; + +// TODO: docs +// timeslots should uniquely identify offences +// and are used for deduplication +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] +pub struct DisputesTimeSlot { + // TODO: `TimeSlot` docs says it should fit into `u128` + // any proofs? + + // ordering is important for timeslots + // why? + session_index: SessionIndex, + candidate_hash: CandidateHash, +} + +impl DisputesTimeSlot { + pub fn new(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self { + Self { session_index, candidate_hash } + } +} + +// TODO design: one offence type vs multiple + +/// An offence that is filed when a series of validators lost a dispute +/// about an invalid candidate. +#[derive(RuntimeDebug, TypeInfo)] +#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] +pub struct ForInvalidOffence { + /// The size of the validator set in that session. + /// Note: this included not only parachain validators. + pub validator_set_count: u32, + /// Should be unique per dispute. + pub time_slot: DisputesTimeSlot, + /// Staking information about the validators that lost the dispute + /// needed for slashing. + pub offenders: Vec, +} + +impl Offence for ForInvalidOffence +where + Offender: Clone, +{ + const ID: Kind = *b"disputes:invalid"; + + type TimeSlot = DisputesTimeSlot; + + fn offenders(&self) -> Vec { + self.offenders.clone() + } + + fn session_index(&self) -> SessionIndex { + self.time_slot.session_index + } + + fn validator_set_count(&self) -> u32 { + self.validator_set_count + } + + fn time_slot(&self) -> Self::TimeSlot { + self.time_slot.clone() + } + + fn disable_strategy(&self) -> DisableStrategy { + // The default is `DisableStrategy::DisableWhenSlashed` + // which is true for this offence type, but we're being explicit + DisableStrategy::Always + } + + fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + Perbill::from_percent(100) // ggez + } +} + +// TODO: this can include a multiplier to make slashing worse +// and enable disabling +/// An offence that is filed when a series of validators lost a dispute +/// about an valid candidate. +#[derive(RuntimeDebug, TypeInfo)] +#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] +pub struct AgainstValidOffence { + /// The size of the validator set in that session. + /// Note: this included not only parachain validators. + pub validator_set_count: u32, + /// Should be unique per dispute. + pub time_slot: DisputesTimeSlot, + /// Staking information about the validators that lost the dispute + /// needed for slashing. + pub offenders: Vec, +} + +impl Offence for AgainstValidOffence +where + Offender: Clone, +{ + const ID: Kind = *b"disputes:valid::"; + + type TimeSlot = DisputesTimeSlot; + + fn offenders(&self) -> Vec { + self.offenders.clone() + } + + fn session_index(&self) -> SessionIndex { + self.time_slot.session_index + } + + fn validator_set_count(&self) -> u32 { + self.validator_set_count + } + + fn time_slot(&self) -> Self::TimeSlot { + self.time_slot.clone() + } + + fn disable_strategy(&self) -> DisableStrategy { + DisableStrategy::Never + } + + fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + Perbill::from_percent(1) // TODO + } +} + +/// This type implements `PunishValidators`. +pub struct SlashValidatorsForDisputes { + _phantom: sp_std::marker::PhantomData<(C, R)>, +} + +impl Default for SlashValidatorsForDisputes { + fn default() -> Self { + Self { _phantom: Default::default() } + } +} + +impl SlashValidatorsForDisputes +where + T: Config + crate::session_info::Config, + R: ReportOffence< + T::AccountId, + IdentificationTuple, + ForInvalidOffence>, + > + ReportOffence< + T::AccountId, + IdentificationTuple, + AgainstValidOffence>, + >, +{ + /// If in the current session, returns the identified validators + /// along with the validator set count for that session. `None` otherwise. + fn maybe_identify_validators( + session_index: SessionIndex, + validators: impl IntoIterator, + ) -> Option<(Vec>, u32)> { + // We use `ValidatorSet::session_index` and not `shared::Pallet::session_index()` + // because at the first block of a new era, the `IdentificationOf` of a validator + // in the previous session might be missing, while `shared` pallet would return + // the same session index as being updated at the end of the block. + let current_session = T::ValidatorSet::session_index(); + if session_index == current_session { + if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) + { + let validator_set_count = account_ids.len() as u32; + let fully_identified = validators + .into_iter() + .flat_map(|i| account_ids.get(i.0 as usize).cloned()) + .filter_map(|id| { + >::IdentificationOf::convert( + id.clone() + ).map(|full_id| (id, full_id)) + }) + .collect::>>(); + return Some((fully_identified, validator_set_count)) + } + } + None + } +} + +impl super::PunishValidators for SlashValidatorsForDisputes +where + T: Config + crate::session_info::Config, + R: ReportOffence< + T::AccountId, + IdentificationTuple, + ForInvalidOffence>, + > + ReportOffence< + T::AccountId, + IdentificationTuple, + AgainstValidOffence>, + >, +{ + fn punish_for_invalid( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validators: impl IntoIterator, + ) { + // TODO: set reporters to the winning side of the dispute + + let validators: BTreeSet = validators.into_iter().collect(); + let maybe = Self::maybe_identify_validators(session_index, validators.iter().cloned()); + if let Some((offenders, validator_set_count)) = maybe { + let reporters = vec![]; + let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); + let offence = ForInvalidOffence { validator_set_count, time_slot, offenders }; + // TODO: log error? + let _ = R::report_offence(reporters, offence); + return + } + >::insert(session_index, candidate_hash, validators); + } + + fn punish_against_valid( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validators: impl IntoIterator, + ) { + // TODO: set reporters to the winning side of the dispute + + let validators: BTreeSet = validators.into_iter().collect(); + let maybe = Self::maybe_identify_validators(session_index, validators.iter().cloned()); + if let Some((offenders, validator_set_count)) = maybe { + let reporters = vec![]; + let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); + let offence = AgainstValidOffence { validator_set_count, time_slot, offenders }; + // TODO: log error? + let _ = R::report_offence(reporters, offence); + return + } + + >::insert(session_index, candidate_hash, validators); + } + + fn punish_inconclusive( + _session_index: SessionIndex, + _candidate_hash: CandidateHash, + _validators: impl IntoIterator, + ) { + // TODO + } +} + +#[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] +pub enum SlashingOffenceKind { + #[codec(index = 0)] + ForInvalid, + #[codec(index = 1)] + AgainstValid, +} + +pub trait SlashingOffence: Offence { + /// Create a new dispute offence using the given details. + fn new( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validator_set_count: u32, + offender: KeyOwnerIdentification, + ) -> Self; + + /// Create a new dispute offence time slot. + fn new_time_slot(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self::TimeSlot; +} + +impl SlashingOffence + for ForInvalidOffence +where + KeyOwnerIdentification: Clone, +{ + fn new( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validator_set_count: u32, + offender: KeyOwnerIdentification, + ) -> Self { + let time_slot = Self::new_time_slot(session_index, candidate_hash); + Self { time_slot, validator_set_count, offenders: vec![offender] } + } + + fn new_time_slot(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self::TimeSlot { + DisputesTimeSlot { session_index, candidate_hash } + } +} + +impl SlashingOffence + for AgainstValidOffence +where + KeyOwnerIdentification: Clone, +{ + fn new( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validator_set_count: u32, + offender: KeyOwnerIdentification, + ) -> Self { + let time_slot = Self::new_time_slot(session_index, candidate_hash); + Self { time_slot, validator_set_count, offenders: vec![offender] } + } + + fn new_time_slot(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self::TimeSlot { + DisputesTimeSlot { session_index, candidate_hash } + } +} + +pub trait HandleSlashingReportsForOldSessions { + /// The offence type used for reporting offences on valid reports for disputes + /// lost about a valid candidate. + type OffenceForInvalid: SlashingOffence; + + /// The offence type used for reporting offences on valid reports for disputes + /// lost about an invalid candidate. + type OffenceAgainstValid: SlashingOffence; + + /// The longevity, in blocks, that the offence report is valid for. When using the staking + /// pallet this should be equal to the bonding duration (in blocks, not eras). + type ReportLongevity: Get; + + /// Report a for valid offence. + /// TODO: do we want to pass reporters or derive from the dispute? + fn report_for_invalid_offence(offence: Self::OffenceForInvalid) -> Result<(), OffenceError>; + + /// Report an against invalid offence. + fn report_against_valid_offence(offence: Self::OffenceAgainstValid) + -> Result<(), OffenceError>; + + /// Returns true if the offender at the given time slot has already been reported. + fn is_known_for_invalid_offence( + offenders: &T::KeyOwnerIdentification, + time_slot: &>::TimeSlot, + ) -> bool; + + /// Returns true if the offender at the given time slot has already been reported. + fn is_known_against_valid_offence( + offenders: &T::KeyOwnerIdentification, + time_slot: &>::TimeSlot, + ) -> bool; + + /// Create and dispatch a slashing report extrinsic. + fn submit_unsigned_slashing_report( + session_index: SessionIndex, + candidate_hash: CandidateHash, + kind: SlashingOffenceKind, + key_owner_proof: T::KeyOwnerProof, + ) -> DispatchResult; +} + +impl HandleSlashingReportsForOldSessions for () { + type OffenceForInvalid = ForInvalidOffence; + type OffenceAgainstValid = AgainstValidOffence; + type ReportLongevity = (); + + fn report_for_invalid_offence(_offence: Self::OffenceForInvalid) -> Result<(), OffenceError> { + Ok(()) + } + + fn report_against_valid_offence( + _offence: Self::OffenceAgainstValid, + ) -> Result<(), OffenceError> { + Ok(()) + } + + fn is_known_for_invalid_offence( + _offenders: &T::KeyOwnerIdentification, + _time_slot: &>::TimeSlot, + ) -> bool { + true + } + + fn is_known_against_valid_offence( + _offenders: &T::KeyOwnerIdentification, + _time_slot: &>::TimeSlot, + ) -> bool { + true + } + + fn submit_unsigned_slashing_report( + _session_index: SessionIndex, + _candidate_hash: CandidateHash, + _kind: SlashingOffenceKind, + _key_owner_proof: T::KeyOwnerProof, + ) -> DispatchResult { + Ok(()) + } +} + +pub trait WeightInfo { + fn report_dispute_lost(validator_count: u32) -> Weight; +} + +pub struct TestWeightInfo; +impl WeightInfo for TestWeightInfo { + fn report_dispute_lost(_validator_count: u32) -> Weight { + 0 + } +} + +pub use pallet::*; +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_system::pallet_prelude::*; + + #[pallet::config] + pub trait Config: frame_system::Config + crate::disputes::Config { + // type Event: From> + IsType<::Event>; + + /// The proof of key ownership, used for validating slashing reports. + /// The proof must include the session index and validator count of the + /// session at which the equivocation occurred. + type KeyOwnerProof: Parameter + GetSessionNumber + GetValidatorCount; + + /// The identification of a key owner, used when reporting slashes. + type KeyOwnerIdentification: Parameter; + + /// A system for proving ownership of keys, i.e. that a given key was part + /// of a validator set, needed for validating slashing reports. + type KeyOwnerProofSystem: KeyOwnerProofSystem< + (KeyTypeId, ValidatorId), + Proof = Self::KeyOwnerProof, + IdentificationTuple = Self::KeyOwnerIdentification, + >; + + /// The slashing report handling subsystem, defines methods to report an + /// offence (after the slashing report has been validated) and for submitting a + /// transaction to report a slash (from an offchain context). + /// NOTE: when enabling slashing report handling (i.e. this type isn't set to + /// `()`) you must use this pallet's `ValidateUnsigned` in the runtime + /// definition. + type HandleSlashingReportsForOldSessions: HandleSlashingReportsForOldSessions; + + /// Weight information for extrinsics in this pallet. + type WeightInfo: WeightInfo; + } + + #[pallet::pallet] + #[pallet::without_storage_info] + pub struct Pallet(_); + + /// Pending "for invalid" dispute slashes for the last several sessions. + #[pallet::storage] + pub(super) type PendingSlashesForInvalid = StorageDoubleMap< + _, + Twox64Concat, + SessionIndex, + Blake2_128Concat, + CandidateHash, + BTreeSet, // TODO: also store winners + >; + + /// Pending "against valid" dispute slashes for the last several sessions. + #[pallet::storage] + pub(super) type PendingSlashesAgainstValid = StorageDoubleMap< + _, + Twox64Concat, + SessionIndex, + Blake2_128Concat, + CandidateHash, + BTreeSet, // TODO separate backing from approval and dispute votes? + >; + + #[pallet::error] + pub enum Error { + /// A key ownership proof provided as part of an slashing report is invalid. + InvalidKeyOwnershipProof, + /// The session index provided as part of an slashing report is invalid. + InvalidSessionIndex, + /// The candidate hash provided as part of an slashing report is invalid. + InvalidCandidateHash, + /// A given slashing report is valid but already previously reported. + DuplicateSlashingReport, + } + + #[pallet::call] + impl Pallet { + #[pallet::weight(::WeightInfo::report_dispute_lost( + _key_owner_proof.validator_count() + ))] + pub fn report_dispute_lost_unsigned( + origin: OriginFor, + _session_index: SessionIndex, + _candidate_hash: CandidateHash, + _kind: SlashingOffenceKind, + _key_owner_proof: T::KeyOwnerProof, + ) -> DispatchResultWithPostInfo { + ensure_none(origin)?; + // TODO: impl + Ok(Pays::No.into()) + } + } +} + +impl Pallet { + /// Called by the initializer to initialize the disputes slashing module. + pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { + 0 + } + + /// Called by the initializer to finalize the disputes slashing pallet. + pub(crate) fn initializer_finalize() {} + + /// Called by the initializer to note a new session in the disputes slashing pallet. + pub(crate) fn initializer_on_new_session( + notification: &SessionChangeNotification, + ) { + let config = >::config(); + if notification.session_index <= config.dispute_period + 1 { + return + } + + // TODO: we could keep em longer than dispute_period? + let pruning_target = notification.session_index - config.dispute_period - 1; + let to_prune = pruning_target..=pruning_target; + + for old_session in to_prune { + >::remove_prefix(old_session, None); + >::remove_prefix(old_session, None); + } + } +} diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 2897ced22ed0..e96d7ab1f0c2 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -21,7 +21,6 @@ use crate::{ mock::{ new_test_ext, AccountId, AllPalletsWithSystem, Initializer, MockGenesisConfig, System, Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, - REWARD_VALIDATORS, }, }; use assert_matches::assert_matches; @@ -1271,22 +1270,6 @@ fn test_provide_multi_dispute_success_and_other() { Pallet::::note_included(4, candidate_hash.clone(), 4); assert_eq!(SpamSlots::::get(4), Some(vec![0, 0, 0, 0, 0, 0, 0])); - // Ensure the `reward_validator` function was correctly called - assert_eq!( - REWARD_VALIDATORS.with(|r| r.borrow().clone()), - vec![ - (3, vec![ValidatorIndex(0), ValidatorIndex(2)]), - (4, vec![ValidatorIndex(2), ValidatorIndex(3)]), - (3, vec![ValidatorIndex(3)]), - (3, vec![ValidatorIndex(5)]), - (5, vec![ValidatorIndex(2), ValidatorIndex(5)]), - (3, vec![ValidatorIndex(6)]), - (5, vec![ValidatorIndex(6)]), - (5, vec![ValidatorIndex(0), ValidatorIndex(1), ValidatorIndex(4)]), - (3, vec![ValidatorIndex(1), ValidatorIndex(4)]), - ], - ); - // Ensure punishment against is called assert_eq!( PUNISH_VALIDATORS_AGAINST.with(|r| r.borrow().clone()), diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 027dd677bbba..4137d720732a 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -21,7 +21,7 @@ use crate::{ configuration::{self, HostConfiguration}, - disputes::DisputesHandler, + disputes::{self, DisputesHandler}, dmp, hrmp, inclusion, paras, scheduler, session_info, shared, ump, }; use frame_support::{ @@ -109,6 +109,7 @@ pub mod pallet { + scheduler::Config + inclusion::Config + session_info::Config + + disputes::slashing::Config + dmp::Config + ump::Config + hrmp::Config @@ -163,6 +164,7 @@ pub mod pallet { inclusion::Pallet::::initializer_initialize(now) + session_info::Pallet::::initializer_initialize(now) + T::DisputesHandler::initializer_initialize(now) + + disputes::slashing::Pallet::::initializer_initialize(now) + dmp::Pallet::::initializer_initialize(now) + ump::Pallet::::initializer_initialize(now) + hrmp::Pallet::::initializer_initialize(now); @@ -177,6 +179,7 @@ pub mod pallet { hrmp::Pallet::::initializer_finalize(); ump::Pallet::::initializer_finalize(); dmp::Pallet::::initializer_finalize(); + disputes::slashing::Pallet::::initializer_finalize(); T::DisputesHandler::initializer_finalize(); session_info::Pallet::::initializer_finalize(); inclusion::Pallet::::initializer_finalize(); @@ -260,6 +263,7 @@ impl Pallet { inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Pallet::::initializer_on_new_session(¬ification); T::DisputesHandler::initializer_on_new_session(¬ification); + disputes::slashing::Pallet::::initializer_on_new_session(¬ification); dmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); ump::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); hrmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 064b9918ff5f..08953eee5e66 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -31,8 +31,8 @@ use frame_support::{ use frame_support_test::TestRandomness; use parity_scale_codec::Decode; use primitives::v2::{ - AuthorityDiscoveryId, Balance, BlockNumber, Header, Moment, SessionIndex, UpwardMessage, - ValidatorIndex, + AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Header, Moment, SessionIndex, + UpwardMessage, ValidatorId, ValidatorIndex, }; use sp_core::H256; use sp_io::TestExternalities; @@ -242,30 +242,32 @@ impl crate::hrmp::Config for Test { impl crate::disputes::Config for Test { type Event = Event; - type RewardValidators = Self; type PunishValidators = Self; type WeightInfo = crate::disputes::TestWeightInfo; } +impl crate::disputes::slashing::Config for Test { + type KeyOwnerProofSystem = (); + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleSlashingReportsForOldSessions = (); + type WeightInfo = crate::disputes::slashing::TestWeightInfo; +} + thread_local! { - pub static REWARD_VALIDATORS: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_FOR: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_AGAINST: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_INCONCLUSIVE: RefCell)>> = RefCell::new(Vec::new()); } -impl crate::disputes::RewardValidators for Test { - fn reward_dispute_statement( - session: SessionIndex, - validators: impl IntoIterator, - ) { - REWARD_VALIDATORS.with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) - } -} - impl crate::disputes::PunishValidators for Test { fn punish_for_invalid( session: SessionIndex, + _: CandidateHash, validators: impl IntoIterator, ) { PUNISH_VALIDATORS_FOR @@ -274,6 +276,7 @@ impl crate::disputes::PunishValidators for Test { fn punish_against_valid( session: SessionIndex, + _: CandidateHash, validators: impl IntoIterator, ) { PUNISH_VALIDATORS_AGAINST @@ -282,6 +285,7 @@ impl crate::disputes::PunishValidators for Test { fn punish_inconclusive( session: SessionIndex, + _: CandidateHash, validators: impl IntoIterator, ) { PUNISH_VALIDATORS_INCONCLUSIVE diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 17296d36fa92..4d5a688b812f 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -28,8 +28,9 @@ use runtime_common::{ use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, @@ -1297,11 +1298,22 @@ impl parachains_initializer::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type RewardValidators = (); type PunishValidators = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleSlashingReportsForOldSessions = (); // TODO + type WeightInfo = parachains_slashing::TestWeightInfo; // TODO +} + parameter_types! { // Mostly arbitrary deposit price, but should provide an adequate incentive not to spam reserve // `ParaId`s. diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index e79c32d1d40b..8ba8b72a0050 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -68,8 +68,9 @@ use sp_version::RuntimeVersion; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; @@ -371,11 +372,22 @@ impl pallet_session::historical::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type RewardValidators = (); type PunishValidators = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleSlashingReportsForOldSessions = (); // TODO + type WeightInfo = parachains_slashing::TestWeightInfo; // TODO +} + parameter_types! { pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 783c1801a8e9..7b6627cc5b7f 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -26,8 +26,9 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use polkadot_runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, runtime_api_impl::v2 as runtime_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, @@ -484,11 +485,22 @@ impl parachains_inclusion::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type RewardValidators = (); type PunishValidators = (); type WeightInfo = parachains_disputes::TestWeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = (); + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleSlashingReportsForOldSessions = (); // TODO + type WeightInfo = parachains_slashing::TestWeightInfo; +} + impl parachains_paras_inherent::Config for Runtime { type WeightInfo = parachains_paras_inherent::TestWeightInfo; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index dcbee5ef7040..6852db07cf23 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -48,12 +48,14 @@ use runtime_common::{ BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate, }; use runtime_parachains::{ - configuration as parachains_configuration, disputes as parachains_disputes, + configuration as parachains_configuration, + disputes::{self as parachains_disputes, slashing as parachains_slashing}, dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, - runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, - session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, + runtime_api_impl::v2 as parachains_runtime_api_impl, + scheduler as parachains_scheduler, session_info as parachains_session_info, + shared as parachains_shared, ump as parachains_ump, }; use scale_info::TypeInfo; use sp_core::{OpaqueMetadata, RuntimeDebug}; @@ -939,11 +941,22 @@ impl assigned_slots::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type RewardValidators = (); - type PunishValidators = (); + type PunishValidators = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleSlashingReportsForOldSessions = (); // TODO + type WeightInfo = parachains_slashing::TestWeightInfo; // TODO +} + parameter_types! { pub const ParaDeposit: Balance = 2000 * CENTS; pub const DataDepositPerByte: Balance = deposit(0, 1); From fd2194a247d8e8bd282cf1e7715851ca2b747155 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 9 May 2022 12:59:01 +0200 Subject: [PATCH 02/75] disputes: reward winners --- runtime/parachains/src/disputes.rs | 24 ++++--- runtime/parachains/src/disputes/slashing.rs | 72 +++++++++++++-------- runtime/parachains/src/mock.rs | 10 +-- 3 files changed, 65 insertions(+), 41 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index cc7d2b940be9..0b76c7ab1b73 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -65,32 +65,28 @@ pub enum DisputeResult { pub trait PunishValidators { /// Punish a series of validators who were for an invalid parablock. This is expected to be a major /// punishment. - /// - /// `validator_set_count` is the size of the validator set in that session. fn punish_for_invalid( session: SessionIndex, candidate_hash: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, + winners: impl IntoIterator, ); /// Punish a series of validators who were against a valid parablock. This is expected to be a minor /// punishment. - /// - /// `validator_set_count` is the size of the validator set in that session. fn punish_against_valid( session: SessionIndex, candidate_hash: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, + winners: impl IntoIterator, ); /// Punish a series of validators who were part of a dispute which never concluded. This is expected /// to be a minor punishment. - /// - /// `validator_set_count` is the size of the validator set in that session. fn punish_inconclusive( session: SessionIndex, candidate_hash: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, ); } @@ -99,6 +95,7 @@ impl PunishValidators for () { _: SessionIndex, _: CandidateHash, _: impl IntoIterator, + _: impl IntoIterator, ) { } @@ -106,6 +103,7 @@ impl PunishValidators for () { _: SessionIndex, _: CandidateHash, _: impl IntoIterator, + _: impl IntoIterator, ) { } @@ -1259,10 +1257,16 @@ impl Pallet { session, candidate_hash, summary.slash_against, + summary.state.validators_for.iter_ones().map(|i| ValidatorIndex(i as _)), ); // an invalid candidate, according to 2/3. Punish those on the 'for' side. - T::PunishValidators::punish_for_invalid(session, candidate_hash, summary.slash_for); + T::PunishValidators::punish_for_invalid( + session, + candidate_hash, + summary.slash_for, + summary.state.validators_against.iter_ones().map(|i| ValidatorIndex(i as _)), + ); } >::insert(&session, &candidate_hash, &summary.state); diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 7bdbe466e45d..4f366138537e 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -18,7 +18,7 @@ // use pallet_session::KeyOwner; // use super::{Config, IdentificationTuple, IdentifyValidatorsInSession}; -use crate::{initializer::SessionChangeNotification, session_info::IdentificationTuple}; +use crate::{initializer::SessionChangeNotification, session_info::{AccountId, IdentificationTuple}}; use frame_support::{ traits::{Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, weights::{Pays, Weight}, @@ -168,11 +168,11 @@ impl SlashValidatorsForDisputes where T: Config + crate::session_info::Config, R: ReportOffence< - T::AccountId, + AccountId, IdentificationTuple, ForInvalidOffence>, > + ReportOffence< - T::AccountId, + AccountId, IdentificationTuple, AgainstValidOffence>, >, @@ -182,15 +182,14 @@ where fn maybe_identify_validators( session_index: SessionIndex, validators: impl IntoIterator, - ) -> Option<(Vec>, u32)> { + ) -> Option<(Vec>, Vec>, u32)> { // We use `ValidatorSet::session_index` and not `shared::Pallet::session_index()` // because at the first block of a new era, the `IdentificationOf` of a validator // in the previous session might be missing, while `shared` pallet would return // the same session index as being updated at the end of the block. let current_session = T::ValidatorSet::session_index(); if session_index == current_session { - if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) - { + if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index){ let validator_set_count = account_ids.len() as u32; let fully_identified = validators .into_iter() @@ -201,7 +200,7 @@ where ).map(|full_id| (id, full_id)) }) .collect::>>(); - return Some((fully_identified, validator_set_count)) + return Some((fully_identified, account_ids, validator_set_count)) } } None @@ -212,11 +211,11 @@ impl super::PunishValidators for SlashValidatorsForDisputes where T: Config + crate::session_info::Config, R: ReportOffence< - T::AccountId, + AccountId, IdentificationTuple, ForInvalidOffence>, > + ReportOffence< - T::AccountId, + AccountId, IdentificationTuple, AgainstValidOffence>, >, @@ -224,34 +223,41 @@ where fn punish_for_invalid( session_index: SessionIndex, candidate_hash: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, + winners: impl IntoIterator, ) { - // TODO: set reporters to the winning side of the dispute - - let validators: BTreeSet = validators.into_iter().collect(); - let maybe = Self::maybe_identify_validators(session_index, validators.iter().cloned()); - if let Some((offenders, validator_set_count)) = maybe { - let reporters = vec![]; + let losers: BTreeSet = losers.into_iter().collect(); + let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); + if let Some((offenders, account_ids, validator_set_count)) = maybe { + let reporters = winners.into_iter() + .filter_map(|i| account_ids.get(i.0 as usize).cloned()) + .collect(); let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = ForInvalidOffence { validator_set_count, time_slot, offenders }; // TODO: log error? let _ = R::report_offence(reporters, offence); return } - >::insert(session_index, candidate_hash, validators); + let winners: BTreeSet = winners.into_iter().collect(); + let results = DisputeResults { + winners, + losers, + }; + >::insert(session_index, candidate_hash, results); } fn punish_against_valid( session_index: SessionIndex, candidate_hash: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, + winners: impl IntoIterator, ) { - // TODO: set reporters to the winning side of the dispute - - let validators: BTreeSet = validators.into_iter().collect(); - let maybe = Self::maybe_identify_validators(session_index, validators.iter().cloned()); - if let Some((offenders, validator_set_count)) = maybe { - let reporters = vec![]; + let losers: BTreeSet = losers.into_iter().collect(); + let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); + if let Some((offenders, account_ids, validator_set_count)) = maybe { + let reporters = winners.into_iter() + .filter_map(|i| account_ids.get(i.0 as usize).cloned()) + .collect(); let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = AgainstValidOffence { validator_set_count, time_slot, offenders }; // TODO: log error? @@ -259,7 +265,12 @@ where return } - >::insert(session_index, candidate_hash, validators); + let winners: BTreeSet = winners.into_iter().collect(); + let results = DisputeResults { + winners, + losers, + }; + >::insert(session_index, candidate_hash, results); } fn punish_inconclusive( @@ -279,6 +290,13 @@ pub enum SlashingOffenceKind { AgainstValid, } +// TODO: docs +#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct DisputeResults { + pub winners: BTreeSet, + pub losers: BTreeSet, +} + pub trait SlashingOffence: Offence { /// Create a new dispute offence using the given details. fn new( @@ -475,7 +493,7 @@ pub mod pallet { SessionIndex, Blake2_128Concat, CandidateHash, - BTreeSet, // TODO: also store winners + DisputeResults, >; /// Pending "against valid" dispute slashes for the last several sessions. @@ -486,7 +504,7 @@ pub mod pallet { SessionIndex, Blake2_128Concat, CandidateHash, - BTreeSet, // TODO separate backing from approval and dispute votes? + DisputeResults, >; #[pallet::error] diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 08953eee5e66..cefba2388991 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -268,19 +268,21 @@ impl crate::disputes::PunishValidators for Test { fn punish_for_invalid( session: SessionIndex, _: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, + _winners: impl IntoIterator, ) { PUNISH_VALIDATORS_FOR - .with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) + .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } fn punish_against_valid( session: SessionIndex, _: CandidateHash, - validators: impl IntoIterator, + losers: impl IntoIterator, + _winners: impl IntoIterator, ) { PUNISH_VALIDATORS_AGAINST - .with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) + .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } fn punish_inconclusive( From 9f8daefeec93aa26b6e567b91b24390f7ca65fb7 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 11 May 2022 14:50:44 +0200 Subject: [PATCH 03/75] disputes/slashing: validate_unsigned impl --- runtime/parachains/src/disputes/slashing.rs | 146 ++++++++++++++++++-- 1 file changed, 131 insertions(+), 15 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 4f366138537e..0c45e589ae16 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -26,21 +26,27 @@ use frame_support::{ use parity_scale_codec::{Decode, Encode}; use primitives::v2::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; use scale_info::TypeInfo; -use sp_runtime::{traits::Convert, DispatchResult, KeyTypeId, Perbill, RuntimeDebug}; +use sp_runtime::{ + traits::Convert, DispatchResult, KeyTypeId, Perbill, RuntimeDebug, + transaction_validity::{ + InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, + TransactionValidityError, ValidTransaction, + }, +}; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::offence::{DisableStrategy, Kind, Offence, OffenceError, ReportOffence}; use sp_std::{collections::btree_set::BTreeSet, prelude::*}; -// TODO: docs -// timeslots should uniquely identify offences -// and are used for deduplication +const LOG_TARGET: &str = "runtime::slashing"; + +/// Timeslots should uniquely identify offences +/// and are used for the offence deduplication. #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] pub struct DisputesTimeSlot { // TODO: `TimeSlot` docs says it should fit into `u128` // any proofs? - // ordering is important for timeslots - // why? + // The order of these matters for `derive(Ord)`. session_index: SessionIndex, candidate_hash: CandidateHash, } @@ -51,15 +57,13 @@ impl DisputesTimeSlot { } } -// TODO design: one offence type vs multiple - /// An offence that is filed when a series of validators lost a dispute /// about an invalid candidate. #[derive(RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] pub struct ForInvalidOffence { /// The size of the validator set in that session. - /// Note: this included not only parachain validators. + /// Note: this includes not only parachain validators. pub validator_set_count: u32, /// Should be unique per dispute. pub time_slot: DisputesTimeSlot, @@ -111,7 +115,7 @@ where #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] pub struct AgainstValidOffence { /// The size of the validator set in that session. - /// Note: this included not only parachain validators. + /// Note: this includes not only parachain validators. pub validator_set_count: u32, /// Should be unique per dispute. pub time_slot: DisputesTimeSlot, @@ -290,6 +294,21 @@ pub enum SlashingOffenceKind { AgainstValid, } +/// We store most of the information about a lost dispute on chain. +/// This is a minimum required to identify and verify it. +#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct DisputeProof { + /// Time slot when the dispute occured. + pub time_slot: DisputesTimeSlot, + /// The dispute outcome. + pub kind: SlashingOffenceKind, + // TODO: ValidatorIndex as well? + /// The index of the validator who lost a dispute. + // pub validator_index: ValidatorIndex, + /// The parachain session key of the offender. + pub validator_id: ValidatorId, +} + // TODO: docs #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct DisputeResults { @@ -364,7 +383,6 @@ pub trait HandleSlashingReportsForOldSessions { type ReportLongevity: Get; /// Report a for valid offence. - /// TODO: do we want to pass reporters or derive from the dispute? fn report_for_invalid_offence(offence: Self::OffenceForInvalid) -> Result<(), OffenceError>; /// Report an against invalid offence. @@ -526,9 +544,7 @@ pub mod pallet { ))] pub fn report_dispute_lost_unsigned( origin: OriginFor, - _session_index: SessionIndex, - _candidate_hash: CandidateHash, - _kind: SlashingOffenceKind, + _dispute_proof: DisputeProof, _key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -556,7 +572,6 @@ impl Pallet { return } - // TODO: we could keep em longer than dispute_period? let pruning_target = notification.session_index - config.dispute_period - 1; let to_prune = pruning_target..=pruning_target; @@ -566,3 +581,104 @@ impl Pallet { } } } + +/// Methods for the `ValidateUnsigned` implementation: +/// It restricts calls to `report_dispute_lost_unsigned` to local calls (i.e. extrinsics generated +/// on this node) or that already in a block. This guarantees that only block authors can include +/// unsigned slashing reports. +impl Pallet { + pub fn validate_unsigned(source: TransactionSource, call: &Call) -> TransactionValidity { + if let Call::report_dispute_lost_unsigned { dispute_proof, key_owner_proof } = call { + // discard slashing report not coming from the local node + match source { + TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ }, + _ => { + log::warn!( + target: LOG_TARGET, + "rejecting unsigned transaction because it is not local/in-block." + ); + + return InvalidTransaction::Call.into() + }, + } + + // check report staleness + is_known_offence::(dispute_proof, key_owner_proof)?; + + let longevity = + >::ReportLongevity::get(); + + let tag_prefix = match dispute_proof.kind { + SlashingOffenceKind::ForInvalid => "DisputeForInvalid", + SlashingOffenceKind::AgainstValid => "DisputeAgainstValid", + }; + + ValidTransaction::with_tag_prefix(tag_prefix) + // We assign the maximum priority for any report. + .priority(TransactionPriority::max_value()) + // Only one report for the same offender at the same slot. + .and_provides(( + dispute_proof.time_slot.clone(), + dispute_proof.validator_id.clone(), + )) + .longevity(longevity) + // We don't propagate this. This can never be included on a remote node. + .propagate(false) + .build() + } else { + InvalidTransaction::Call.into() + } + } + + pub fn pre_dispatch(call: &Call) -> Result<(), TransactionValidityError> { + if let Call::report_dispute_lost_unsigned { dispute_proof, key_owner_proof } = call { + is_known_offence::(dispute_proof, key_owner_proof) + } else { + Err(InvalidTransaction::Call.into()) + } + } +} + +fn is_known_offence( + dispute_proof: &DisputeProof, + key_owner_proof: &T::KeyOwnerProof, +) -> Result<(), TransactionValidityError> { + // check the membership proof to extract the offender's id + let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + + let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) + .ok_or(InvalidTransaction::BadProof)?; + + // check if the offence has already been reported, + // and if so then we can discard the report. + let is_known_offence = match dispute_proof.kind { + SlashingOffenceKind::ForInvalid => { + let time_slot = >::OffenceForInvalid::new_time_slot( + dispute_proof.time_slot.session_index, + dispute_proof.time_slot.candidate_hash, + ); + + T::HandleSlashingReportsForOldSessions::is_known_for_invalid_offence( + &offender, + &time_slot, + ) + }, + SlashingOffenceKind::AgainstValid => { + let time_slot = >::OffenceAgainstValid::new_time_slot( + dispute_proof.time_slot.session_index, + dispute_proof.time_slot.candidate_hash, + ); + + T::HandleSlashingReportsForOldSessions::is_known_against_valid_offence( + &offender, + &time_slot, + ) + }, + }; + + if is_known_offence { + Err(InvalidTransaction::Stale.into()) + } else { + Ok(()) + } +} From ee46d14949eef279f4db17aaa7fdb126852aac2b Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 11 May 2022 16:44:30 +0200 Subject: [PATCH 04/75] fmt --- runtime/parachains/src/disputes/slashing.rs | 64 +++++++++++---------- runtime/parachains/src/mock.rs | 3 +- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 0c45e589ae16..15a93855dedc 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -18,7 +18,10 @@ // use pallet_session::KeyOwner; // use super::{Config, IdentificationTuple, IdentifyValidatorsInSession}; -use crate::{initializer::SessionChangeNotification, session_info::{AccountId, IdentificationTuple}}; +use crate::{ + initializer::SessionChangeNotification, + session_info::{AccountId, IdentificationTuple}, +}; use frame_support::{ traits::{Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, weights::{Pays, Weight}, @@ -27,11 +30,12 @@ use parity_scale_codec::{Decode, Encode}; use primitives::v2::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; use scale_info::TypeInfo; use sp_runtime::{ - traits::Convert, DispatchResult, KeyTypeId, Perbill, RuntimeDebug, + traits::Convert, transaction_validity::{ InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, ValidTransaction, }, + DispatchResult, KeyTypeId, Perbill, RuntimeDebug, }; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::offence::{DisableStrategy, Kind, Offence, OffenceError, ReportOffence}; @@ -193,7 +197,8 @@ where // the same session index as being updated at the end of the block. let current_session = T::ValidatorSet::session_index(); if session_index == current_session { - if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index){ + if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) + { let validator_set_count = account_ids.len() as u32; let fully_identified = validators .into_iter() @@ -233,7 +238,8 @@ where let losers: BTreeSet = losers.into_iter().collect(); let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); if let Some((offenders, account_ids, validator_set_count)) = maybe { - let reporters = winners.into_iter() + let reporters = winners + .into_iter() .filter_map(|i| account_ids.get(i.0 as usize).cloned()) .collect(); let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); @@ -243,10 +249,7 @@ where return } let winners: BTreeSet = winners.into_iter().collect(); - let results = DisputeResults { - winners, - losers, - }; + let results = DisputeResults { winners, losers }; >::insert(session_index, candidate_hash, results); } @@ -259,7 +262,8 @@ where let losers: BTreeSet = losers.into_iter().collect(); let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); if let Some((offenders, account_ids, validator_set_count)) = maybe { - let reporters = winners.into_iter() + let reporters = winners + .into_iter() .filter_map(|i| account_ids.get(i.0 as usize).cloned()) .collect(); let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); @@ -270,10 +274,7 @@ where } let winners: BTreeSet = winners.into_iter().collect(); - let results = DisputeResults { - winners, - losers, - }; + let results = DisputeResults { winners, losers }; >::insert(session_index, candidate_hash, results); } @@ -606,7 +607,9 @@ impl Pallet { is_known_offence::(dispute_proof, key_owner_proof)?; let longevity = - >::ReportLongevity::get(); + >::ReportLongevity::get(); let tag_prefix = match dispute_proof.kind { SlashingOffenceKind::ForInvalid => "DisputeForInvalid", @@ -617,10 +620,7 @@ impl Pallet { // We assign the maximum priority for any report. .priority(TransactionPriority::max_value()) // Only one report for the same offender at the same slot. - .and_provides(( - dispute_proof.time_slot.clone(), - dispute_proof.validator_id.clone(), - )) + .and_provides((dispute_proof.time_slot.clone(), dispute_proof.validator_id.clone())) .longevity(longevity) // We don't propagate this. This can never be included on a remote node. .propagate(false) @@ -653,25 +653,29 @@ fn is_known_offence( // and if so then we can discard the report. let is_known_offence = match dispute_proof.kind { SlashingOffenceKind::ForInvalid => { - let time_slot = >::OffenceForInvalid::new_time_slot( - dispute_proof.time_slot.session_index, - dispute_proof.time_slot.candidate_hash, - ); + let time_slot = + >::OffenceForInvalid::new_time_slot( + dispute_proof.time_slot.session_index, + dispute_proof.time_slot.candidate_hash, + ); T::HandleSlashingReportsForOldSessions::is_known_for_invalid_offence( - &offender, - &time_slot, + &offender, &time_slot, ) }, SlashingOffenceKind::AgainstValid => { - let time_slot = >::OffenceAgainstValid::new_time_slot( - dispute_proof.time_slot.session_index, - dispute_proof.time_slot.candidate_hash, - ); + let time_slot = + >::OffenceAgainstValid::new_time_slot( + dispute_proof.time_slot.session_index, + dispute_proof.time_slot.candidate_hash, + ); T::HandleSlashingReportsForOldSessions::is_known_against_valid_offence( - &offender, - &time_slot, + &offender, &time_slot, ) }, }; diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index cefba2388991..bbddad1a075d 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -271,8 +271,7 @@ impl crate::disputes::PunishValidators for Test { losers: impl IntoIterator, _winners: impl IntoIterator, ) { - PUNISH_VALIDATORS_FOR - .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) + PUNISH_VALIDATORS_FOR.with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } fn punish_against_valid( From 7b158f60f79662bcdf033330def8910ea1d5933d Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 11 May 2022 20:35:07 +0200 Subject: [PATCH 05/75] disputes/slashing: report_dispute_lost_unsigned --- runtime/kusama/src/lib.rs | 2 +- runtime/parachains/src/disputes/slashing.rs | 154 ++++++++++++++------ runtime/parachains/src/mock.rs | 2 +- runtime/polkadot/src/lib.rs | 2 +- runtime/rococo/src/lib.rs | 2 +- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 2 +- 7 files changed, 119 insertions(+), 47 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index bfb24f72bf2a..322da47b8d97 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1327,7 +1327,7 @@ impl parachains_slashing::Config for Runtime { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleSlashingReportsForOldSessions = (); // TODO + type HandleReports = (); // TODO type WeightInfo = parachains_slashing::TestWeightInfo; // TODO } diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 15a93855dedc..ec1ca83179e0 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -107,7 +107,7 @@ where } fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { - Perbill::from_percent(100) // ggez + Perbill::from_percent(100) // TODO } } @@ -249,7 +249,7 @@ where return } let winners: BTreeSet = winners.into_iter().collect(); - let results = DisputeResults { winners, losers }; + let results = PendingIndices { winners, losers }; >::insert(session_index, candidate_hash, results); } @@ -274,7 +274,7 @@ where } let winners: BTreeSet = winners.into_iter().collect(); - let results = DisputeResults { winners, losers }; + let results = PendingIndices { winners, losers }; >::insert(session_index, candidate_hash, results); } @@ -296,25 +296,25 @@ pub enum SlashingOffenceKind { } /// We store most of the information about a lost dispute on chain. -/// This is a minimum required to identify and verify it. +/// This struct is required to identify and verify it. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct DisputeProof { /// Time slot when the dispute occured. pub time_slot: DisputesTimeSlot, /// The dispute outcome. pub kind: SlashingOffenceKind, - // TODO: ValidatorIndex as well? /// The index of the validator who lost a dispute. - // pub validator_index: ValidatorIndex, - /// The parachain session key of the offender. + pub validator_index: ValidatorIndex, + /// The parachain session key of the validator. pub validator_id: ValidatorId, } // TODO: docs #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] -pub struct DisputeResults { - pub winners: BTreeSet, +pub struct PendingIndices { pub losers: BTreeSet, + // TODO: put winners somewhere else + pub winners: BTreeSet, } pub trait SlashingOffence: Offence { @@ -370,7 +370,7 @@ where } } -pub trait HandleSlashingReportsForOldSessions { +pub trait HandleReports { /// The offence type used for reporting offences on valid reports for disputes /// lost about a valid candidate. type OffenceForInvalid: SlashingOffence; @@ -384,9 +384,11 @@ pub trait HandleSlashingReportsForOldSessions { type ReportLongevity: Get; /// Report a for valid offence. + // TODO: pass reporters fn report_for_invalid_offence(offence: Self::OffenceForInvalid) -> Result<(), OffenceError>; /// Report an against invalid offence. + // TODO: pass reporters fn report_against_valid_offence(offence: Self::OffenceAgainstValid) -> Result<(), OffenceError>; @@ -411,7 +413,7 @@ pub trait HandleSlashingReportsForOldSessions { ) -> DispatchResult; } -impl HandleSlashingReportsForOldSessions for () { +impl HandleReports for () { type OffenceForInvalid = ForInvalidOffence; type OffenceAgainstValid = AgainstValidOffence; type ReportLongevity = (); @@ -494,7 +496,7 @@ pub mod pallet { /// NOTE: when enabling slashing report handling (i.e. this type isn't set to /// `()`) you must use this pallet's `ValidateUnsigned` in the runtime /// definition. - type HandleSlashingReportsForOldSessions: HandleSlashingReportsForOldSessions; + type HandleReports: HandleReports; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -512,7 +514,7 @@ pub mod pallet { SessionIndex, Blake2_128Concat, CandidateHash, - DisputeResults, + PendingIndices, >; /// Pending "against valid" dispute slashes for the last several sessions. @@ -523,33 +525,114 @@ pub mod pallet { SessionIndex, Blake2_128Concat, CandidateHash, - DisputeResults, + PendingIndices, >; #[pallet::error] pub enum Error { - /// A key ownership proof provided as part of an slashing report is invalid. + /// The key ownership proof is invalid. InvalidKeyOwnershipProof, - /// The session index provided as part of an slashing report is invalid. + /// The session index is too old or invalid. InvalidSessionIndex, - /// The candidate hash provided as part of an slashing report is invalid. + /// The candidate hash is invalid. InvalidCandidateHash, - /// A given slashing report is valid but already previously reported. + /// There is no pending slash for the given validator index and time slot. + InvalidValidatorIndex, + /// The validator index does not match the validator id. + ValidatorIndexIdMismatch, + /// The given slashing report is valid but already previously reported. DuplicateSlashingReport, } #[pallet::call] impl Pallet { #[pallet::weight(::WeightInfo::report_dispute_lost( - _key_owner_proof.validator_count() + key_owner_proof.validator_count() ))] pub fn report_dispute_lost_unsigned( origin: OriginFor, - _dispute_proof: DisputeProof, - _key_owner_proof: T::KeyOwnerProof, + dispute_proof: DisputeProof, + key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; - // TODO: impl + + // check the membership proof to extract the offender's id + let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); + let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) + .ok_or(Error::::InvalidKeyOwnershipProof)?; + + // check that `validator_index` matches `validator_id` + let session_index = dispute_proof.time_slot.session_index; + let validator_set_count = + if let Some(info) = crate::session_info::Pallet::::session_info(session_index) { + let i = dispute_proof.validator_index.0 as usize; + ensure!( + info.validators.get(i) == Some(&dispute_proof.validator_id), + Error::::ValidatorIndexIdMismatch + ); + // number of all validators (not only parachain) in the session + info.discovery_keys.len() as u32 + } else { + return Err(Error::::InvalidSessionIndex.into()) + }; + + // check that there is a pending slash for the given + // validator index and candidate hash + let candidate_hash = dispute_proof.time_slot.candidate_hash; + let try_remove = |v: &mut Option| -> Result<(), DispatchError> { + let mut indices = v.take().ok_or(Error::::InvalidCandidateHash)?; + + ensure!( + indices.losers.remove(&dispute_proof.validator_index), + Error::::InvalidValidatorIndex, + ); + + if !indices.losers.is_empty() { + *v = Some(indices); + } + + Ok(()) + }; + match dispute_proof.kind { + SlashingOffenceKind::ForInvalid => { + >::try_mutate_exists( + &session_index, + &candidate_hash, + try_remove, + )?; + + let offence = >::OffenceForInvalid::new( + session_index, + candidate_hash, + validator_set_count, + offender, + ); + // We can't really submit a duplicate report + // unless there's a bug. + >::report_for_invalid_offence(offence) + .map_err(|_| Error::::DuplicateSlashingReport)?; + }, + SlashingOffenceKind::AgainstValid => { + >::try_mutate_exists( + &session_index, + &candidate_hash, + try_remove, + )?; + + // submit an offence report + let offence = >::OffenceAgainstValid::new( + session_index, + candidate_hash, + validator_set_count, + offender, + ); + // We can't really submit a duplicate report + // unless there's a bug. + >::report_against_valid_offence(offence) + .map_err(|_| Error::::DuplicateSlashingReport)?; + }, + } + Ok(Pays::No.into()) } } @@ -573,13 +656,9 @@ impl Pallet { return } - let pruning_target = notification.session_index - config.dispute_period - 1; - let to_prune = pruning_target..=pruning_target; - - for old_session in to_prune { - >::remove_prefix(old_session, None); - >::remove_prefix(old_session, None); - } + let old_session = notification.session_index - config.dispute_period - 1; + >::remove_prefix(old_session, None); + >::remove_prefix(old_session, None); } } @@ -606,10 +685,7 @@ impl Pallet { // check report staleness is_known_offence::(dispute_proof, key_owner_proof)?; - let longevity = - >::ReportLongevity::get(); + let longevity = >::ReportLongevity::get(); let tag_prefix = match dispute_proof.kind { SlashingOffenceKind::ForInvalid => "DisputeForInvalid", @@ -654,27 +730,23 @@ fn is_known_offence( let is_known_offence = match dispute_proof.kind { SlashingOffenceKind::ForInvalid => { let time_slot = - >::OffenceForInvalid::new_time_slot( + >::OffenceForInvalid::new_time_slot( dispute_proof.time_slot.session_index, dispute_proof.time_slot.candidate_hash, ); - T::HandleSlashingReportsForOldSessions::is_known_for_invalid_offence( + >::is_known_for_invalid_offence( &offender, &time_slot, ) }, SlashingOffenceKind::AgainstValid => { let time_slot = - >::OffenceAgainstValid::new_time_slot( + >::OffenceAgainstValid::new_time_slot( dispute_proof.time_slot.session_index, dispute_proof.time_slot.candidate_hash, ); - T::HandleSlashingReportsForOldSessions::is_known_against_valid_offence( + >::is_known_against_valid_offence( &offender, &time_slot, ) }, diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index bbddad1a075d..f0f6afef30c0 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -254,7 +254,7 @@ impl crate::disputes::slashing::Config for Test { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleSlashingReportsForOldSessions = (); + type HandleReports = (); type WeightInfo = crate::disputes::slashing::TestWeightInfo; } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 4d5a688b812f..83f81d3a0c38 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1310,7 +1310,7 @@ impl parachains_slashing::Config for Runtime { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleSlashingReportsForOldSessions = (); // TODO + type HandleReports = (); // TODO type WeightInfo = parachains_slashing::TestWeightInfo; // TODO } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 8ba8b72a0050..907e95c4625a 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -384,7 +384,7 @@ impl parachains_slashing::Config for Runtime { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleSlashingReportsForOldSessions = (); // TODO + type HandleReports = (); // TODO type WeightInfo = parachains_slashing::TestWeightInfo; // TODO } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 7b6627cc5b7f..0210c766a1ff 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -497,7 +497,7 @@ impl parachains_slashing::Config for Runtime { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleSlashingReportsForOldSessions = (); // TODO + type HandleReports = (); // TODO type WeightInfo = parachains_slashing::TestWeightInfo; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 6852db07cf23..13bbe2bb863c 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -953,7 +953,7 @@ impl parachains_slashing::Config for Runtime { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleSlashingReportsForOldSessions = (); // TODO + type HandleReports = (); // TODO type WeightInfo = parachains_slashing::TestWeightInfo; // TODO } From 60a82a4d8f60fcb4484b791463d425c185f181a2 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 13 May 2022 17:24:33 +0200 Subject: [PATCH 06/75] disputes/slashing: separate winners from losers and report winners --- runtime/parachains/src/disputes/slashing.rs | 135 ++++++++++++++------ 1 file changed, 98 insertions(+), 37 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index ec1ca83179e0..feb54220971d 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -235,7 +235,7 @@ where losers: impl IntoIterator, winners: impl IntoIterator, ) { - let losers: BTreeSet = losers.into_iter().collect(); + let losers: Losers = losers.into_iter().collect(); let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); if let Some((offenders, account_ids, validator_set_count)) = maybe { let reporters = winners @@ -248,9 +248,17 @@ where let _ = R::report_offence(reporters, offence); return } - let winners: BTreeSet = winners.into_iter().collect(); - let results = PendingIndices { winners, losers }; - >::insert(session_index, candidate_hash, results); + let winners: Winners = if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) { + winners + .into_iter() + .filter_map(|i| account_ids.get(i.0 as usize).cloned()) + .collect() + } else { + // Shouldn't really happen + Default::default() + }; + >::insert(session_index, candidate_hash, losers); + >::insert(session_index, candidate_hash, winners); } fn punish_against_valid( @@ -259,7 +267,7 @@ where losers: impl IntoIterator, winners: impl IntoIterator, ) { - let losers: BTreeSet = losers.into_iter().collect(); + let losers: Losers = losers.into_iter().collect(); let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); if let Some((offenders, account_ids, validator_set_count)) = maybe { let reporters = winners @@ -273,9 +281,17 @@ where return } - let winners: BTreeSet = winners.into_iter().collect(); - let results = PendingIndices { winners, losers }; - >::insert(session_index, candidate_hash, results); + let winners: Winners = if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) { + winners + .into_iter() + .filter_map(|i| account_ids.get(i.0 as usize).cloned()) + .collect() + } else { + // Shouldn't really happen + Default::default() + }; + >::insert(session_index, candidate_hash, losers); + >::insert(session_index, candidate_hash, winners); } fn punish_inconclusive( @@ -310,12 +326,8 @@ pub struct DisputeProof { } // TODO: docs -#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] -pub struct PendingIndices { - pub losers: BTreeSet, - // TODO: put winners somewhere else - pub winners: BTreeSet, -} +pub type Losers = BTreeSet; +pub type Winners = Vec>; pub trait SlashingOffence: Offence { /// Create a new dispute offence using the given details. @@ -370,6 +382,7 @@ where } } +// TODO: does it need to be that generic? pub trait HandleReports { /// The offence type used for reporting offences on valid reports for disputes /// lost about a valid candidate. @@ -384,13 +397,17 @@ pub trait HandleReports { type ReportLongevity: Get; /// Report a for valid offence. - // TODO: pass reporters - fn report_for_invalid_offence(offence: Self::OffenceForInvalid) -> Result<(), OffenceError>; + // TODO: generic over reporter type? + fn report_for_invalid_offence( + reporters: Vec>, + offence: Self::OffenceForInvalid, + ) -> Result<(), OffenceError>; /// Report an against invalid offence. - // TODO: pass reporters - fn report_against_valid_offence(offence: Self::OffenceAgainstValid) - -> Result<(), OffenceError>; + fn report_against_valid_offence( + reporters: Vec>, + offence: Self::OffenceAgainstValid, + ) -> Result<(), OffenceError>; /// Returns true if the offender at the given time slot has already been reported. fn is_known_for_invalid_offence( @@ -405,6 +422,7 @@ pub trait HandleReports { ) -> bool; /// Create and dispatch a slashing report extrinsic. + /// This should be called offchain. fn submit_unsigned_slashing_report( session_index: SessionIndex, candidate_hash: CandidateHash, @@ -418,11 +436,15 @@ impl HandleReports for () { type OffenceAgainstValid = AgainstValidOffence; type ReportLongevity = (); - fn report_for_invalid_offence(_offence: Self::OffenceForInvalid) -> Result<(), OffenceError> { + fn report_for_invalid_offence( + _reporters: Vec>, + _offence: Self::OffenceForInvalid, + ) -> Result<(), OffenceError> { Ok(()) } fn report_against_valid_offence( + _reporters: Vec>, _offence: Self::OffenceAgainstValid, ) -> Result<(), OffenceError> { Ok(()) @@ -506,26 +528,48 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(_); - /// Pending "for invalid" dispute slashes for the last several sessions. + /// Indices of the validators pending "for invalid" dispute slashes. #[pallet::storage] - pub(super) type PendingSlashesForInvalid = StorageDoubleMap< + pub(super) type PendingForInvalidLosers = StorageDoubleMap< _, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, - PendingIndices, + Losers, >; - /// Pending "against valid" dispute slashes for the last several sessions. + /// Indices of the validators who won in "for invalid" disputes. #[pallet::storage] - pub(super) type PendingSlashesAgainstValid = StorageDoubleMap< + pub(super) type ForInvalidWinners = StorageDoubleMap< _, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, - PendingIndices, + Winners, + >; + + /// Indices of the validators pending "against valid" dispute slashes. + #[pallet::storage] + pub(super) type PendingAgainstValidLosers = StorageDoubleMap< + _, + Twox64Concat, + SessionIndex, + Blake2_128Concat, + CandidateHash, + Losers, + >; + + /// Indices of the validators who won in "against valid" disputes. + #[pallet::storage] + pub(super) type AgainstValidWinners = StorageDoubleMap< + _, + Twox64Concat, + SessionIndex, + Blake2_128Concat, + CandidateHash, + Winners, >; #[pallet::error] @@ -579,15 +623,15 @@ pub mod pallet { // check that there is a pending slash for the given // validator index and candidate hash let candidate_hash = dispute_proof.time_slot.candidate_hash; - let try_remove = |v: &mut Option| -> Result<(), DispatchError> { + let try_remove = |v: &mut Option| -> Result<(), DispatchError> { let mut indices = v.take().ok_or(Error::::InvalidCandidateHash)?; ensure!( - indices.losers.remove(&dispute_proof.validator_index), + indices.remove(&dispute_proof.validator_index), Error::::InvalidValidatorIndex, ); - if !indices.losers.is_empty() { + if !indices.is_empty() { *v = Some(indices); } @@ -595,30 +639,43 @@ pub mod pallet { }; match dispute_proof.kind { SlashingOffenceKind::ForInvalid => { - >::try_mutate_exists( + >::try_mutate_exists( &session_index, &candidate_hash, try_remove, )?; + let winners = >::get( + &session_index, + &candidate_hash, + ).unwrap_or_default(); + let offence = >::OffenceForInvalid::new( session_index, candidate_hash, validator_set_count, offender, ); + // We can't really submit a duplicate report // unless there's a bug. - >::report_for_invalid_offence(offence) - .map_err(|_| Error::::DuplicateSlashingReport)?; + >::report_for_invalid_offence( + winners, + offence, + ).map_err(|_| Error::::DuplicateSlashingReport)?; }, SlashingOffenceKind::AgainstValid => { - >::try_mutate_exists( + >::try_mutate_exists( &session_index, &candidate_hash, try_remove, )?; + let winners = >::get( + &session_index, + &candidate_hash, + ).unwrap_or_default(); + // submit an offence report let offence = >::OffenceAgainstValid::new( session_index, @@ -628,8 +685,10 @@ pub mod pallet { ); // We can't really submit a duplicate report // unless there's a bug. - >::report_against_valid_offence(offence) - .map_err(|_| Error::::DuplicateSlashingReport)?; + >::report_against_valid_offence( + winners, + offence, + ).map_err(|_| Error::::DuplicateSlashingReport)?; }, } @@ -657,8 +716,10 @@ impl Pallet { } let old_session = notification.session_index - config.dispute_period - 1; - >::remove_prefix(old_session, None); - >::remove_prefix(old_session, None); + >::remove_prefix(old_session, None); + >::remove_prefix(old_session, None); + >::remove_prefix(old_session, None); + >::remove_prefix(old_session, None); } } From b303ee481f89c1207084da896779e4b571c9c97c Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 13 May 2022 17:48:44 +0200 Subject: [PATCH 07/75] disputes/slashing: refactoring --- runtime/parachains/src/disputes/slashing.rs | 139 +++++++++----------- 1 file changed, 62 insertions(+), 77 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index feb54220971d..a103f5a7b74b 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -189,28 +189,26 @@ where /// along with the validator set count for that session. `None` otherwise. fn maybe_identify_validators( session_index: SessionIndex, + account_ids: &[AccountId], validators: impl IntoIterator, - ) -> Option<(Vec>, Vec>, u32)> { + ) -> Option<(Vec>, u32)> { // We use `ValidatorSet::session_index` and not `shared::Pallet::session_index()` // because at the first block of a new era, the `IdentificationOf` of a validator // in the previous session might be missing, while `shared` pallet would return // the same session index as being updated at the end of the block. let current_session = T::ValidatorSet::session_index(); if session_index == current_session { - if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) - { - let validator_set_count = account_ids.len() as u32; - let fully_identified = validators - .into_iter() - .flat_map(|i| account_ids.get(i.0 as usize).cloned()) - .filter_map(|id| { - >::IdentificationOf::convert( - id.clone() - ).map(|full_id| (id, full_id)) - }) - .collect::>>(); - return Some((fully_identified, account_ids, validator_set_count)) - } + let validator_set_count = account_ids.len() as u32; + let fully_identified = validators + .into_iter() + .flat_map(|i| account_ids.get(i.0 as usize).cloned()) + .filter_map(|id| { + >::IdentificationOf::convert( + id.clone() + ).map(|full_id| (id, full_id)) + }) + .collect::>>(); + return Some((fully_identified, validator_set_count)) } None } @@ -236,27 +234,28 @@ where winners: impl IntoIterator, ) { let losers: Losers = losers.into_iter().collect(); - let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); - if let Some((offenders, account_ids, validator_set_count)) = maybe { - let reporters = winners - .into_iter() - .filter_map(|i| account_ids.get(i.0 as usize).cloned()) - .collect(); + let account_keys = crate::session_info::Pallet::::account_keys(session_index); + let account_ids = match account_keys { + Some(account_keys) => account_keys, + None => { + // TODO: warn + return + }, + }; + let winners: Winners = winners + .into_iter() + .filter_map(|i| account_ids.get(i.0 as usize).cloned()) + .collect(); + let maybe = + Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); + if let Some((offenders, validator_set_count)) = maybe { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = ForInvalidOffence { validator_set_count, time_slot, offenders }; // TODO: log error? - let _ = R::report_offence(reporters, offence); + let _ = R::report_offence(winners, offence); return } - let winners: Winners = if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) { - winners - .into_iter() - .filter_map(|i| account_ids.get(i.0 as usize).cloned()) - .collect() - } else { - // Shouldn't really happen - Default::default() - }; + >::insert(session_index, candidate_hash, losers); >::insert(session_index, candidate_hash, winners); } @@ -268,28 +267,28 @@ where winners: impl IntoIterator, ) { let losers: Losers = losers.into_iter().collect(); - let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); - if let Some((offenders, account_ids, validator_set_count)) = maybe { - let reporters = winners - .into_iter() - .filter_map(|i| account_ids.get(i.0 as usize).cloned()) - .collect(); + let account_keys = crate::session_info::Pallet::::account_keys(session_index); + let account_ids = match account_keys { + Some(account_keys) => account_keys, + None => { + // TODO: warn + return + }, + }; + let winners: Winners = winners + .into_iter() + .filter_map(|i| account_ids.get(i.0 as usize).cloned()) + .collect(); + let maybe = + Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); + if let Some((offenders, validator_set_count)) = maybe { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = AgainstValidOffence { validator_set_count, time_slot, offenders }; // TODO: log error? - let _ = R::report_offence(reporters, offence); + let _ = R::report_offence(winners, offence); return } - let winners: Winners = if let Some(account_ids) = crate::session_info::Pallet::::account_keys(session_index) { - winners - .into_iter() - .filter_map(|i| account_ids.get(i.0 as usize).cloned()) - .collect() - } else { - // Shouldn't really happen - Default::default() - }; >::insert(session_index, candidate_hash, losers); >::insert(session_index, candidate_hash, winners); } @@ -530,14 +529,8 @@ pub mod pallet { /// Indices of the validators pending "for invalid" dispute slashes. #[pallet::storage] - pub(super) type PendingForInvalidLosers = StorageDoubleMap< - _, - Twox64Concat, - SessionIndex, - Blake2_128Concat, - CandidateHash, - Losers, - >; + pub(super) type PendingForInvalidLosers = + StorageDoubleMap<_, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, Losers>; /// Indices of the validators who won in "for invalid" disputes. #[pallet::storage] @@ -552,14 +545,8 @@ pub mod pallet { /// Indices of the validators pending "against valid" dispute slashes. #[pallet::storage] - pub(super) type PendingAgainstValidLosers = StorageDoubleMap< - _, - Twox64Concat, - SessionIndex, - Blake2_128Concat, - CandidateHash, - Losers, - >; + pub(super) type PendingAgainstValidLosers = + StorageDoubleMap<_, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, Losers>; /// Indices of the validators who won in "against valid" disputes. #[pallet::storage] @@ -645,10 +632,8 @@ pub mod pallet { try_remove, )?; - let winners = >::get( - &session_index, - &candidate_hash, - ).unwrap_or_default(); + let winners = >::get(&session_index, &candidate_hash) + .unwrap_or_default(); let offence = >::OffenceForInvalid::new( session_index, @@ -660,9 +645,9 @@ pub mod pallet { // We can't really submit a duplicate report // unless there's a bug. >::report_for_invalid_offence( - winners, - offence, - ).map_err(|_| Error::::DuplicateSlashingReport)?; + winners, offence, + ) + .map_err(|_| Error::::DuplicateSlashingReport)?; }, SlashingOffenceKind::AgainstValid => { >::try_mutate_exists( @@ -671,10 +656,8 @@ pub mod pallet { try_remove, )?; - let winners = >::get( - &session_index, - &candidate_hash, - ).unwrap_or_default(); + let winners = >::get(&session_index, &candidate_hash) + .unwrap_or_default(); // submit an offence report let offence = >::OffenceAgainstValid::new( @@ -686,9 +669,9 @@ pub mod pallet { // We can't really submit a duplicate report // unless there's a bug. >::report_against_valid_offence( - winners, - offence, - ).map_err(|_| Error::::DuplicateSlashingReport)?; + winners, offence, + ) + .map_err(|_| Error::::DuplicateSlashingReport)?; }, } @@ -716,6 +699,8 @@ impl Pallet { } let old_session = notification.session_index - config.dispute_period - 1; + + // TODO: warn if there were pending slashes? >::remove_prefix(old_session, None); >::remove_prefix(old_session, None); >::remove_prefix(old_session, None); From 6f1d72412872e2f0c93935b8b081991f85b5e20e Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 16 May 2022 12:23:21 +0200 Subject: [PATCH 08/75] impl HandleReports --- runtime/parachains/src/disputes/slashing.rs | 140 +++++++++++++++++--- 1 file changed, 123 insertions(+), 17 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index a103f5a7b74b..49e764f13ed0 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -16,8 +16,6 @@ //! Dispute slashing types for the substrate offences pallet. -// use pallet_session::KeyOwner; -// use super::{Config, IdentificationTuple, IdentifyValidatorsInSession}; use crate::{ initializer::SessionChangeNotification, session_info::{AccountId, IdentificationTuple}, @@ -217,6 +215,7 @@ where impl super::PunishValidators for SlashValidatorsForDisputes where T: Config + crate::session_info::Config, + // TODO: use HandleReports instead? R: ReportOffence< AccountId, IdentificationTuple, @@ -234,6 +233,10 @@ where winners: impl IntoIterator, ) { let losers: Losers = losers.into_iter().collect(); + if losers.is_empty() { + // Nothing to do + return + } let account_keys = crate::session_info::Pallet::::account_keys(session_index); let account_ids = match account_keys { Some(account_keys) => account_keys, @@ -267,6 +270,10 @@ where winners: impl IntoIterator, ) { let losers: Losers = losers.into_iter().collect(); + if losers.is_empty() { + // Nothing to do + return + } let account_keys = crate::session_info::Pallet::::account_keys(session_index); let account_ids = match account_keys { Some(account_keys) => account_keys, @@ -408,24 +415,22 @@ pub trait HandleReports { offence: Self::OffenceAgainstValid, ) -> Result<(), OffenceError>; - /// Returns true if the offender at the given time slot has already been reported. + /// Returns true if the offenders at the given time slot has already been reported. fn is_known_for_invalid_offence( - offenders: &T::KeyOwnerIdentification, + offenders: &[T::KeyOwnerIdentification], time_slot: &>::TimeSlot, ) -> bool; - /// Returns true if the offender at the given time slot has already been reported. + /// Returns true if the offenders at the given time slot has already been reported. fn is_known_against_valid_offence( - offenders: &T::KeyOwnerIdentification, + offenders: &[T::KeyOwnerIdentification], time_slot: &>::TimeSlot, ) -> bool; /// Create and dispatch a slashing report extrinsic. /// This should be called offchain. fn submit_unsigned_slashing_report( - session_index: SessionIndex, - candidate_hash: CandidateHash, - kind: SlashingOffenceKind, + dispute_proof: DisputeProof, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResult; } @@ -450,23 +455,21 @@ impl HandleReports for () { } fn is_known_for_invalid_offence( - _offenders: &T::KeyOwnerIdentification, + _offenders: &[T::KeyOwnerIdentification], _time_slot: &>::TimeSlot, ) -> bool { true } fn is_known_against_valid_offence( - _offenders: &T::KeyOwnerIdentification, + _offenders: &[T::KeyOwnerIdentification], _time_slot: &>::TimeSlot, ) -> bool { true } fn submit_unsigned_slashing_report( - _session_index: SessionIndex, - _candidate_hash: CandidateHash, - _kind: SlashingOffenceKind, + _dispute_proof: DisputeProof, _key_owner_proof: T::KeyOwnerProof, ) -> DispatchResult { Ok(()) @@ -582,7 +585,8 @@ pub mod pallet { ))] pub fn report_dispute_lost_unsigned( origin: OriginFor, - dispute_proof: DisputeProof, + // box to decrease the size of the call + dispute_proof: Box, key_owner_proof: T::KeyOwnerProof, ) -> DispatchResultWithPostInfo { ensure_none(origin)?; @@ -782,7 +786,7 @@ fn is_known_offence( ); >::is_known_for_invalid_offence( - &offender, &time_slot, + &[offender], &time_slot, ) }, SlashingOffenceKind::AgainstValid => { @@ -793,7 +797,7 @@ fn is_known_offence( ); >::is_known_against_valid_offence( - &offender, &time_slot, + &[offender], &time_slot, ) }, }; @@ -804,3 +808,105 @@ fn is_known_offence( Ok(()) } } + +struct SlashingReportHandler { + _phantom: sp_std::marker::PhantomData<(T, R, L)>, +} + +impl Default for SlashingReportHandler { + fn default() -> Self { + Self { _phantom: Default::default() } + } +} + +impl HandleReports for SlashingReportHandler +where + T: Config + frame_system::offchain::SendTransactionTypes>, + R: ReportOffence< + AccountId, + T::KeyOwnerIdentification, + ForInvalidOffence, + > + ReportOffence< + AccountId, + T::KeyOwnerIdentification, + AgainstValidOffence, + >, + L: Get, +{ + type OffenceForInvalid = ForInvalidOffence; + + type OffenceAgainstValid = AgainstValidOffence; + + type ReportLongevity = L; + + fn report_for_invalid_offence( + reporters: Vec>, + offence: Self::OffenceForInvalid, + ) -> Result<(), OffenceError> { + R::report_offence(reporters, offence) + } + + fn report_against_valid_offence( + reporters: Vec>, + offence: Self::OffenceAgainstValid, + ) -> Result<(), OffenceError> { + R::report_offence(reporters, offence) + } + + fn is_known_for_invalid_offence( + offenders: &[T::KeyOwnerIdentification], + time_slot: &DisputesTimeSlot, + ) -> bool { + , + T::KeyOwnerIdentification, + ForInvalidOffence, + >>::is_known_offence(offenders, time_slot) + } + + fn is_known_against_valid_offence( + offenders: &[T::KeyOwnerIdentification], + time_slot: &DisputesTimeSlot, + ) -> bool { + , + T::KeyOwnerIdentification, + AgainstValidOffence, + >>::is_known_offence(offenders, time_slot) + } + + fn submit_unsigned_slashing_report( + dispute_proof: DisputeProof, + key_owner_proof: ::KeyOwnerProof, + ) -> DispatchResult { + use frame_system::offchain::SubmitTransaction; + + let session_index = dispute_proof.time_slot.session_index; + let validator_index = dispute_proof.validator_index.0; + let kind = dispute_proof.kind; + + let call = Call::report_dispute_lost_unsigned { + dispute_proof: Box::new(dispute_proof), + key_owner_proof, + }; + + match SubmitTransaction::>::submit_unsigned_transaction(call.into()) { + Ok(()) => log::info!( + target: LOG_TARGET, + "Submitted dispute slashing report, session: {}, validator: {}, kind: {:?}", + session_index, + validator_index, + kind, + ), + Err(()) => log::error!( + target: LOG_TARGET, + "Error submitting dispute slashing report, session: {}, validator: {}, kind: {:?}", + session_index, + validator_index, + kind, + ), + } + + Ok(()) + } +} From 4a55be937c54076222b6e0386eaad293650107d3 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 16 May 2022 12:26:33 +0200 Subject: [PATCH 09/75] enable on Wenstend --- runtime/parachains/src/disputes/slashing.rs | 21 +++++++++++++++++---- runtime/westend/src/lib.rs | 7 ++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 49e764f13ed0..f902365ba88c 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -682,6 +682,18 @@ pub mod pallet { Ok(Pays::No.into()) } } + + #[pallet::validate_unsigned] + impl ValidateUnsigned for Pallet { + type Call = Call; + fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity { + Self::validate_unsigned(source, call) + } + + fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> { + Self::pre_dispatch(call) + } + } } impl Pallet { @@ -809,17 +821,18 @@ fn is_known_offence( } } -struct SlashingReportHandler { - _phantom: sp_std::marker::PhantomData<(T, R, L)>, +// TODO: docs +pub struct SlashingReportHandler { + _phantom: sp_std::marker::PhantomData<(I, R, L)>, } -impl Default for SlashingReportHandler { +impl Default for SlashingReportHandler { fn default() -> Self { Self { _phantom: Default::default() } } } -impl HandleReports for SlashingReportHandler +impl HandleReports for SlashingReportHandler where T: Config + frame_system::offchain::SendTransactionTypes>, R: ReportOffence< diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 13bbe2bb863c..c4460fbebb58 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -953,7 +953,11 @@ impl parachains_slashing::Config for Runtime { KeyTypeId, ValidatorId, )>>::IdentificationTuple; - type HandleReports = (); // TODO + type HandleReports = parachains_slashing::SlashingReportHandler< + Self::KeyOwnerIdentification, + Offences, + ReportLongevity, + >; type WeightInfo = parachains_slashing::TestWeightInfo; // TODO } @@ -1139,6 +1143,7 @@ construct_runtime! { Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event, Config} = 51, ParaSessionInfo: parachains_session_info::{Pallet, Storage} = 52, ParasDisputes: parachains_disputes::{Pallet, Call, Storage, Event} = 53, + ParasSlashing: parachains_slashing::{Pallet, Call, Storage, ValidateUnsigned} = 54, // Parachain Onboarding Pallets. Start indices at 60 to leave room. Registrar: paras_registrar::{Pallet, Call, Storage, Event, Config} = 60, From 194154378adcd7697285cff6c1d48c4c5a95cb48 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 16 May 2022 14:36:52 +0200 Subject: [PATCH 10/75] fmt --- runtime/parachains/src/disputes/slashing.rs | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index f902365ba88c..ce03d84ea1a4 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -798,7 +798,8 @@ fn is_known_offence( ); >::is_known_for_invalid_offence( - &[offender], &time_slot, + &[offender], + &time_slot, ) }, SlashingOffenceKind::AgainstValid => { @@ -809,7 +810,8 @@ fn is_known_offence( ); >::is_known_against_valid_offence( - &[offender], &time_slot, + &[offender], + &time_slot, ) }, }; @@ -836,14 +838,14 @@ impl HandleReports for SlashingReportHandler>, R: ReportOffence< - AccountId, - T::KeyOwnerIdentification, - ForInvalidOffence, - > + ReportOffence< - AccountId, - T::KeyOwnerIdentification, - AgainstValidOffence, - >, + AccountId, + T::KeyOwnerIdentification, + ForInvalidOffence, + > + ReportOffence< + AccountId, + T::KeyOwnerIdentification, + AgainstValidOffence, + >, L: Get, { type OffenceForInvalid = ForInvalidOffence; From 04ad120aafc24c30dcdd9532be717af8d141651f Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 16 May 2022 18:23:15 +0200 Subject: [PATCH 11/75] add slashing pallet to the mock and test runtimes --- runtime/parachains/src/mock.rs | 3 ++- runtime/test-runtime/src/lib.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index f0f6afef30c0..aad10d76bb69 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -18,7 +18,7 @@ use crate::{ configuration, disputes, dmp, hrmp, inclusion, initializer, origin, paras, paras_inherent, - scheduler, session_info, shared, + scheduler, session_info, shared, disputes::slashing, ump::{self, MessageId, UmpSink}, ParaId, }; @@ -68,6 +68,7 @@ frame_support::construct_runtime!( SessionInfo: session_info, Disputes: disputes, Babe: pallet_babe, + Slashing: slashing, } ); diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 0210c766a1ff..244660fd9be5 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -714,6 +714,7 @@ construct_runtime! { Dmp: parachains_dmp::{Pallet, Call, Storage}, Xcm: pallet_xcm::{Pallet, Call, Event, Origin}, ParasDisputes: parachains_disputes::{Pallet, Storage, Event}, + ParasSlashing: parachains_slashing::{Pallet, Storage, Call, ValidateUnsigned}, Sudo: pallet_sudo::{Pallet, Call, Storage, Config, Event}, From 37845916b8da96e9a3aae3ecb4acd39335488f3f Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 16 May 2022 18:43:49 +0200 Subject: [PATCH 12/75] fix a bug in report_dispute_lost_unsigned --- runtime/parachains/src/disputes/slashing.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index ce03d84ea1a4..7ae0fe67955b 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -615,15 +615,15 @@ pub mod pallet { // validator index and candidate hash let candidate_hash = dispute_proof.time_slot.candidate_hash; let try_remove = |v: &mut Option| -> Result<(), DispatchError> { - let mut indices = v.take().ok_or(Error::::InvalidCandidateHash)?; + let indices = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; ensure!( indices.remove(&dispute_proof.validator_index), Error::::InvalidValidatorIndex, ); - if !indices.is_empty() { - *v = Some(indices); + if indices.is_empty() { + *v = None; } Ok(()) From f49b55fcc61cb163e8190b0ebc4d0ba87922b1d0 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 16 May 2022 19:12:57 +0200 Subject: [PATCH 13/75] fmt --- runtime/parachains/src/mock.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index aad10d76bb69..80cef42881c1 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -17,8 +17,10 @@ //! Mocks for all the traits. use crate::{ - configuration, disputes, dmp, hrmp, inclusion, initializer, origin, paras, paras_inherent, - scheduler, session_info, shared, disputes::slashing, + configuration, disputes, + disputes::slashing, + dmp, hrmp, inclusion, initializer, origin, paras, paras_inherent, scheduler, session_info, + shared, ump::{self, MessageId, UmpSink}, ParaId, }; From cbcf176a1c39c75df6c11bea3275937d5bd993e2 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 13:24:25 +0200 Subject: [PATCH 14/75] disputes: remove new_participants from summary --- runtime/parachains/src/disputes.rs | 10 ---------- runtime/parachains/src/disputes/tests.rs | 4 ---- 2 files changed, 14 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 0b76c7ab1b73..b74906fe558a 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -591,9 +591,6 @@ struct ImportSummary { slash_against: Vec, /// Validators to slash for being (wrongly) on the FOR side. slash_for: Vec, - // New participants in the dispute. - #[allow(unused)] // FIXME - new_participants: bitvec::vec::BitVec, // Difference in state flags from previous. new_flags: DisputeStateFlags, } @@ -765,7 +762,6 @@ impl DisputeStateImporter { spam_slot_changes, slash_against, slash_for, - new_participants: self.new_participants, new_flags: post_flags - pre_flags, } } @@ -1244,12 +1240,6 @@ impl Pallet { } } - // Reward statements. - // T::RewardValidators::reward_dispute_statement( - // session, - // summary.new_participants.iter_ones().map(|i| ValidatorIndex(i as _)), - // ); - // Slash participants on a losing side. { // a valid candidate, according to 2/3. Punish those on the 'against' side. diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index e96d7ab1f0c2..66ea55957472 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -174,7 +174,6 @@ fn test_import_new_participant_spam_inc() { assert_eq!(summary.spam_slot_changes, vec![(ValidatorIndex(2), SpamSlotChange::Inc)]); assert!(summary.slash_for.is_empty()); assert!(summary.slash_against.is_empty()); - assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0, 0]); } #[test] @@ -207,7 +206,6 @@ fn test_import_prev_participant_spam_dec_confirmed() { ); assert!(summary.slash_for.is_empty()); assert!(summary.slash_against.is_empty()); - assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0, 0]); assert_eq!(summary.new_flags, DisputeStateFlags::CONFIRMED); } @@ -246,7 +244,6 @@ fn test_import_prev_participant_spam_dec_confirmed_slash_for() { ); assert_eq!(summary.slash_for, vec![ValidatorIndex(0), ValidatorIndex(2)]); assert!(summary.slash_against.is_empty()); - assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 1, 1, 1, 1, 0]); assert_eq!( summary.new_flags, DisputeStateFlags::CONFIRMED | DisputeStateFlags::AGAINST_SUPERMAJORITY, @@ -284,7 +281,6 @@ fn test_import_slash_against() { assert!(summary.spam_slot_changes.is_empty()); assert!(summary.slash_for.is_empty()); assert_eq!(summary.slash_against, vec![ValidatorIndex(1), ValidatorIndex(5)]); - assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 0, 1, 1, 1, 1, 1]); assert_eq!(summary.new_flags, DisputeStateFlags::FOR_SUPERMAJORITY); } From 7b82f0d7ddfdea67832d952006334181667fcb0b Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 13:31:12 +0200 Subject: [PATCH 15/75] disputes: remove punish_inconclusive --- runtime/parachains/src/disputes.rs | 36 +-------------------- runtime/parachains/src/disputes/slashing.rs | 8 ----- runtime/parachains/src/disputes/tests.rs | 10 ++---- runtime/parachains/src/mock.rs | 10 ------ 4 files changed, 4 insertions(+), 60 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index b74906fe558a..c3ce065820b5 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -80,14 +80,6 @@ pub trait PunishValidators { losers: impl IntoIterator, winners: impl IntoIterator, ); - - /// Punish a series of validators who were part of a dispute which never concluded. This is expected - /// to be a minor punishment. - fn punish_inconclusive( - session: SessionIndex, - candidate_hash: CandidateHash, - losers: impl IntoIterator, - ); } impl PunishValidators for () { @@ -106,13 +98,6 @@ impl PunishValidators for () { _: impl IntoIterator, ) { } - - fn punish_inconclusive( - _: SessionIndex, - _: CandidateHash, - _: impl IntoIterator, - ) { - } } /// Binary discriminator to determine if the expensive signature @@ -423,17 +408,6 @@ pub mod pallet { pub trait Config: frame_system::Config + configuration::Config + session_info::Config { type Event: From> + IsType<::Event>; - /// A type that gives us the ability to submit dispute offence reports. - // type ReportDisputeOffences: ReportOffence< - // Self::AccountId, - // IdentificationTuple, - // slashing::ForInvalidOffence>, - // > + ReportOffence< - // Self::AccountId, - // IdentificationTuple, - // slashing::AgainstValidOffence>, - // >; - type PunishValidators: PunishValidators; /// Weight information for extrinsics in this pallet. @@ -850,15 +824,7 @@ impl Pallet { // it would be unexpected for any change here to occur when the dispute has not concluded // in time, as a dispute guaranteed to have at least one honest participant should // conclude quickly. - let participating = decrement_spam(spam_slots, &dispute); - - // Slight punishment as these validators have failed to make data available to - // others in a timely manner. - T::PunishValidators::punish_inconclusive( - session_index, - candidate_hash, - participating.iter_ones().map(|i| ValidatorIndex(i as _)), - ); + let _participating = decrement_spam(spam_slots, &dispute); }); weight += T::DbWeight::get().reads_writes(2, 2); diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 7ae0fe67955b..6a1d4b4a664c 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -299,14 +299,6 @@ where >::insert(session_index, candidate_hash, losers); >::insert(session_index, candidate_hash, winners); } - - fn punish_inconclusive( - _session_index: SessionIndex, - _candidate_hash: CandidateHash, - _validators: impl IntoIterator, - ) { - // TODO - } } #[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 66ea55957472..1af9cbe91563 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -20,7 +20,7 @@ use crate::{ disputes::DisputesHandler, mock::{ new_test_ext, AccountId, AllPalletsWithSystem, Initializer, MockGenesisConfig, System, - Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, PUNISH_VALIDATORS_INCONCLUSIVE, + Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, }, }; use assert_matches::assert_matches; @@ -495,9 +495,9 @@ fn dispute_statement_becoming_onesided_due_to_spamslots_is_accepted() { }); } -// Test that punish_inconclusive is correctly called. +// Test that dispute timeout is handled correctly. #[test] -fn test_initializer_initialize() { +fn test_dispute_timeout() { let dispute_conclusion_by_time_out_period = 3; let start = 10; @@ -597,10 +597,6 @@ fn test_initializer_initialize() { // Run to timeout + 1 in order to executive on_finalize(timeout) run_to_block(start + dispute_conclusion_by_time_out_period + 1, |_| None); assert_eq!(SpamSlots::::get(start - 1), Some(vec![0, 0, 0, 0, 0, 0, 0])); - assert_eq!( - PUNISH_VALIDATORS_INCONCLUSIVE.with(|r| r.borrow()[0].clone()), - (9, vec![ValidatorIndex(0), ValidatorIndex(6)]), - ); }); } diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 80cef42881c1..f190a766ba95 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -264,7 +264,6 @@ impl crate::disputes::slashing::Config for Test { thread_local! { pub static PUNISH_VALIDATORS_FOR: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_AGAINST: RefCell)>> = RefCell::new(Vec::new()); - pub static PUNISH_VALIDATORS_INCONCLUSIVE: RefCell)>> = RefCell::new(Vec::new()); } impl crate::disputes::PunishValidators for Test { @@ -286,15 +285,6 @@ impl crate::disputes::PunishValidators for Test { PUNISH_VALIDATORS_AGAINST .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } - - fn punish_inconclusive( - session: SessionIndex, - _: CandidateHash, - validators: impl IntoIterator, - ) { - PUNISH_VALIDATORS_INCONCLUSIVE - .with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) - } } impl crate::scheduler::Config for Test {} From f863bafa7e34bca8f6ac0edbc322492df9f5a514 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 16:26:08 +0200 Subject: [PATCH 16/75] impl SlashingHandler for Pallet for type-safety --- runtime/kusama/src/lib.rs | 2 +- runtime/parachains/src/disputes.rs | 27 ++++++++++++--- runtime/parachains/src/disputes/slashing.rs | 37 +++++++++++---------- runtime/parachains/src/initializer.rs | 10 +++--- runtime/parachains/src/mock.rs | 12 +++++-- runtime/polkadot/src/lib.rs | 2 +- runtime/rococo/src/lib.rs | 2 +- runtime/test-runtime/src/lib.rs | 2 +- runtime/westend/src/lib.rs | 2 +- 9 files changed, 61 insertions(+), 35 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 322da47b8d97..e7dc7872f21b 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1315,7 +1315,7 @@ impl parachains_initializer::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type PunishValidators = (); + type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index c3ce065820b5..5b926ba32cc6 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -62,7 +62,7 @@ pub enum DisputeResult { } /// Punishment hooks for disputes. -pub trait PunishValidators { +pub trait SlashingHandler { /// Punish a series of validators who were for an invalid parablock. This is expected to be a major /// punishment. fn punish_for_invalid( @@ -80,9 +80,18 @@ pub trait PunishValidators { losers: impl IntoIterator, winners: impl IntoIterator, ); + + /// Called by the initializer to initialize the slashing pallet. + fn initializer_initialize(now: BlockNumber) -> Weight; + + /// Called by the initializer to finalize the slashing pallet. + fn initializer_finalize(); + + /// Called by the initializer to note that a new session has started. + fn initializer_on_new_session(notification: &SessionChangeNotification); } -impl PunishValidators for () { +impl SlashingHandler for () { fn punish_for_invalid( _: SessionIndex, _: CandidateHash, @@ -98,6 +107,14 @@ impl PunishValidators for () { _: impl IntoIterator, ) { } + + fn initializer_initialize(_now: BlockNumber) -> Weight { + 0 + } + + fn initializer_finalize() {} + + fn initializer_on_new_session(_notification: &SessionChangeNotification) {} } /// Binary discriminator to determine if the expensive signature @@ -408,7 +425,7 @@ pub mod pallet { pub trait Config: frame_system::Config + configuration::Config + session_info::Config { type Event: From> + IsType<::Event>; - type PunishValidators: PunishValidators; + type SlashingHandler: SlashingHandler; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -1209,7 +1226,7 @@ impl Pallet { // Slash participants on a losing side. { // a valid candidate, according to 2/3. Punish those on the 'against' side. - T::PunishValidators::punish_against_valid( + T::SlashingHandler::punish_against_valid( session, candidate_hash, summary.slash_against, @@ -1217,7 +1234,7 @@ impl Pallet { ); // an invalid candidate, according to 2/3. Punish those on the 'for' side. - T::PunishValidators::punish_for_invalid( + T::SlashingHandler::punish_for_invalid( session, candidate_hash, summary.slash_for, diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 6a1d4b4a664c..4f7152417f04 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -105,7 +105,7 @@ where } fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { - Perbill::from_percent(100) // TODO + Perbill::from_percent(100) } } @@ -155,7 +155,7 @@ where } fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { - Perbill::from_percent(1) // TODO + Perbill::from_percent(1) } } @@ -170,18 +170,9 @@ impl Default for SlashValidatorsForDisputes { } } -impl SlashValidatorsForDisputes +impl SlashValidatorsForDisputes, R> where T: Config + crate::session_info::Config, - R: ReportOffence< - AccountId, - IdentificationTuple, - ForInvalidOffence>, - > + ReportOffence< - AccountId, - IdentificationTuple, - AgainstValidOffence>, - >, { /// If in the current session, returns the identified validators /// along with the validator set count for that session. `None` otherwise. @@ -212,7 +203,7 @@ where } } -impl super::PunishValidators for SlashValidatorsForDisputes +impl super::SlashingHandler for SlashValidatorsForDisputes, R> where T: Config + crate::session_info::Config, // TODO: use HandleReports instead? @@ -299,6 +290,18 @@ where >::insert(session_index, candidate_hash, losers); >::insert(session_index, candidate_hash, winners); } + + fn initializer_initialize(now: T::BlockNumber) -> Weight { + Pallet::::initializer_initialize(now) + } + + fn initializer_finalize() { + Pallet::::initializer_finalize() + } + + fn initializer_on_new_session(notification: &SessionChangeNotification) { + Pallet::::initializer_on_new_session(notification) + } } #[derive(PartialEq, Eq, Clone, Copy, Encode, Decode, RuntimeDebug, TypeInfo)] @@ -690,17 +693,15 @@ pub mod pallet { impl Pallet { /// Called by the initializer to initialize the disputes slashing module. - pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight { + fn initializer_initialize(_now: T::BlockNumber) -> Weight { 0 } /// Called by the initializer to finalize the disputes slashing pallet. - pub(crate) fn initializer_finalize() {} + fn initializer_finalize() {} /// Called by the initializer to note a new session in the disputes slashing pallet. - pub(crate) fn initializer_on_new_session( - notification: &SessionChangeNotification, - ) { + fn initializer_on_new_session(notification: &SessionChangeNotification) { let config = >::config(); if notification.session_index <= config.dispute_period + 1 { return diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 4137d720732a..aa817499e56e 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -21,7 +21,7 @@ use crate::{ configuration::{self, HostConfiguration}, - disputes::{self, DisputesHandler}, + disputes::{self, DisputesHandler as _, SlashingHandler as _}, dmp, hrmp, inclusion, paras, scheduler, session_info, shared, ump, }; use frame_support::{ @@ -109,7 +109,7 @@ pub mod pallet { + scheduler::Config + inclusion::Config + session_info::Config - + disputes::slashing::Config + + disputes::Config + dmp::Config + ump::Config + hrmp::Config @@ -164,7 +164,7 @@ pub mod pallet { inclusion::Pallet::::initializer_initialize(now) + session_info::Pallet::::initializer_initialize(now) + T::DisputesHandler::initializer_initialize(now) + - disputes::slashing::Pallet::::initializer_initialize(now) + + T::SlashingHandler::initializer_initialize(now) + dmp::Pallet::::initializer_initialize(now) + ump::Pallet::::initializer_initialize(now) + hrmp::Pallet::::initializer_initialize(now); @@ -179,7 +179,7 @@ pub mod pallet { hrmp::Pallet::::initializer_finalize(); ump::Pallet::::initializer_finalize(); dmp::Pallet::::initializer_finalize(); - disputes::slashing::Pallet::::initializer_finalize(); + T::SlashingHandler::initializer_finalize(); T::DisputesHandler::initializer_finalize(); session_info::Pallet::::initializer_finalize(); inclusion::Pallet::::initializer_finalize(); @@ -263,7 +263,7 @@ impl Pallet { inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Pallet::::initializer_on_new_session(¬ification); T::DisputesHandler::initializer_on_new_session(¬ification); - disputes::slashing::Pallet::::initializer_on_new_session(¬ification); + T::SlashingHandler::initializer_on_new_session(¬ification); dmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); ump::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); hrmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index f190a766ba95..81830241e672 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -245,7 +245,7 @@ impl crate::hrmp::Config for Test { impl crate::disputes::Config for Test { type Event = Event; - type PunishValidators = Self; + type SlashingHandler = Self; type WeightInfo = crate::disputes::TestWeightInfo; } @@ -266,7 +266,7 @@ thread_local! { pub static PUNISH_VALIDATORS_AGAINST: RefCell)>> = RefCell::new(Vec::new()); } -impl crate::disputes::PunishValidators for Test { +impl crate::disputes::SlashingHandler for Test { fn punish_for_invalid( session: SessionIndex, _: CandidateHash, @@ -285,6 +285,14 @@ impl crate::disputes::PunishValidators for Test { PUNISH_VALIDATORS_AGAINST .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } + + fn initializer_initialize(_now: BlockNumber) -> Weight { + 0 + } + + fn initializer_finalize() {} + + fn initializer_on_new_session(_: &initializer::SessionChangeNotification) {} } impl crate::scheduler::Config for Test {} diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 83f81d3a0c38..46728d744761 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1298,7 +1298,7 @@ impl parachains_initializer::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type PunishValidators = (); + type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 907e95c4625a..31765a445ae1 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -372,7 +372,7 @@ impl pallet_session::historical::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type PunishValidators = (); + type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 244660fd9be5..907ceb017f2a 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -485,7 +485,7 @@ impl parachains_inclusion::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type PunishValidators = (); + type SlashingHandler = (); type WeightInfo = parachains_disputes::TestWeightInfo; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index c4460fbebb58..d510ce673e00 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -941,7 +941,7 @@ impl assigned_slots::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type PunishValidators = parachains_slashing::SlashValidatorsForDisputes; + type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } From b4fa68244c7c701f1f4f9030d8c978f5905011bf Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 17:22:44 +0200 Subject: [PATCH 17/75] do not impl slashing::Config on mainnets yet --- runtime/kusama/src/lib.rs | 14 +------------- runtime/parachains/src/mock.rs | 21 +++------------------ runtime/polkadot/src/lib.rs | 14 +------------- runtime/rococo/src/lib.rs | 14 +------------- runtime/test-runtime/src/lib.rs | 15 +-------------- 5 files changed, 7 insertions(+), 71 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index e7dc7872f21b..d0dd7708b941 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -37,7 +37,7 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*}; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, @@ -1319,18 +1319,6 @@ impl parachains_disputes::Config for Runtime { type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } -impl parachains_slashing::Config for Runtime { - type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleReports = (); // TODO - type WeightInfo = parachains_slashing::TestWeightInfo; // TODO -} - parameter_types! { pub const ParaDeposit: Balance = 40 * UNITS; } diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 81830241e672..32a239f2361c 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -17,10 +17,8 @@ //! Mocks for all the traits. use crate::{ - configuration, disputes, - disputes::slashing, - dmp, hrmp, inclusion, initializer, origin, paras, paras_inherent, scheduler, session_info, - shared, + configuration, disputes, dmp, hrmp, inclusion, initializer, origin, paras, paras_inherent, + scheduler, session_info, shared, ump::{self, MessageId, UmpSink}, ParaId, }; @@ -34,7 +32,7 @@ use frame_support_test::TestRandomness; use parity_scale_codec::Decode; use primitives::v2::{ AuthorityDiscoveryId, Balance, BlockNumber, CandidateHash, Header, Moment, SessionIndex, - UpwardMessage, ValidatorId, ValidatorIndex, + UpwardMessage, ValidatorIndex, }; use sp_core::H256; use sp_io::TestExternalities; @@ -70,7 +68,6 @@ frame_support::construct_runtime!( SessionInfo: session_info, Disputes: disputes, Babe: pallet_babe, - Slashing: slashing, } ); @@ -249,18 +246,6 @@ impl crate::disputes::Config for Test { type WeightInfo = crate::disputes::TestWeightInfo; } -impl crate::disputes::slashing::Config for Test { - type KeyOwnerProofSystem = (); - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleReports = (); - type WeightInfo = crate::disputes::slashing::TestWeightInfo; -} - thread_local! { pub static PUNISH_VALIDATORS_FOR: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_AGAINST: RefCell)>> = RefCell::new(Vec::new()); diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 46728d744761..c96778cc3e88 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -28,7 +28,7 @@ use runtime_common::{ use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, @@ -1302,18 +1302,6 @@ impl parachains_disputes::Config for Runtime { type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } -impl parachains_slashing::Config for Runtime { - type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleReports = (); // TODO - type WeightInfo = parachains_slashing::TestWeightInfo; // TODO -} - parameter_types! { // Mostly arbitrary deposit price, but should provide an adequate incentive not to spam reserve // `ParaId`s. diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 31765a445ae1..7db15baafc35 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -68,7 +68,7 @@ use sp_version::RuntimeVersion; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, @@ -376,18 +376,6 @@ impl parachains_disputes::Config for Runtime { type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } -impl parachains_slashing::Config for Runtime { - type KeyOwnerProofSystem = Historical; - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleReports = (); // TODO - type WeightInfo = parachains_slashing::TestWeightInfo; // TODO -} - parameter_types! { pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 907ceb017f2a..bcbb4447d15a 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -26,7 +26,7 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use polkadot_runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, runtime_api_impl::v2 as runtime_impl, @@ -489,18 +489,6 @@ impl parachains_disputes::Config for Runtime { type WeightInfo = parachains_disputes::TestWeightInfo; } -impl parachains_slashing::Config for Runtime { - type KeyOwnerProofSystem = (); - type KeyOwnerProof = - >::Proof; - type KeyOwnerIdentification = >::IdentificationTuple; - type HandleReports = (); // TODO - type WeightInfo = parachains_slashing::TestWeightInfo; -} - impl parachains_paras_inherent::Config for Runtime { type WeightInfo = parachains_paras_inherent::TestWeightInfo; } @@ -714,7 +702,6 @@ construct_runtime! { Dmp: parachains_dmp::{Pallet, Call, Storage}, Xcm: pallet_xcm::{Pallet, Call, Event, Origin}, ParasDisputes: parachains_disputes::{Pallet, Storage, Event}, - ParasSlashing: parachains_slashing::{Pallet, Storage, Call, ValidateUnsigned}, Sudo: pallet_sudo::{Pallet, Call, Storage, Config, Event}, From 273990006b2051591ba193f7e1d7393fbfaaaff6 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 17:28:39 +0200 Subject: [PATCH 18/75] teach spellcheck deduplication --- runtime/kusama/src/lib.rs | 5 ++--- runtime/polkadot/src/lib.rs | 5 ++--- runtime/rococo/src/lib.rs | 5 ++--- runtime/test-runtime/src/lib.rs | 5 ++--- scripts/ci/gitlab/lingua.dic | 1 + 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index d0dd7708b941..dd287a1f78db 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -37,9 +37,8 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*}; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, - inclusion as parachains_inclusion, initializer as parachains_initializer, - origin as parachains_origin, paras as parachains_paras, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, + initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c96778cc3e88..e0f805ac9f53 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -28,9 +28,8 @@ use runtime_common::{ use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, - inclusion as parachains_inclusion, initializer as parachains_initializer, - origin as parachains_origin, paras as parachains_paras, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, + initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 7db15baafc35..40bafad5ab1a 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -68,9 +68,8 @@ use sp_version::RuntimeVersion; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, - inclusion as parachains_inclusion, initializer as parachains_initializer, - origin as parachains_origin, paras as parachains_paras, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, + initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index bcbb4447d15a..5a2ac393851d 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -26,9 +26,8 @@ use sp_std::{collections::btree_map::BTreeMap, prelude::*}; use polkadot_runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, - inclusion as parachains_inclusion, initializer as parachains_initializer, - origin as parachains_origin, paras as parachains_paras, + dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, + initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, runtime_api_impl::v2 as runtime_impl, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, diff --git a/scripts/ci/gitlab/lingua.dic b/scripts/ci/gitlab/lingua.dic index 8be00d55c494..2c71564cbf51 100644 --- a/scripts/ci/gitlab/lingua.dic +++ b/scripts/ci/gitlab/lingua.dic @@ -51,6 +51,7 @@ Debian/M decodable/MS decrement deduplicated +deduplication deinitializing dequeue/SD dequeuing From 62ff14f1e5688c2925c7362544fbe1addb8a0198 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 17:52:35 +0200 Subject: [PATCH 19/75] simplify interfaces and resolve some TODOs --- runtime/parachains/src/disputes/slashing.rs | 192 ++++++-------------- runtime/westend/src/lib.rs | 2 +- 2 files changed, 60 insertions(+), 134 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 4f7152417f04..82fda2c2f1c7 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -159,18 +159,42 @@ where } } +impl ForInvalidOffence { + fn new( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validator_set_count: u32, + offender: KeyOwnerIdentification, + ) -> Self { + let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); + Self { time_slot, validator_set_count, offenders: vec![offender] } + } +} + +impl AgainstValidOffence { + fn new( + session_index: SessionIndex, + candidate_hash: CandidateHash, + validator_set_count: u32, + offender: KeyOwnerIdentification, + ) -> Self { + let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); + Self { time_slot, validator_set_count, offenders: vec![offender] } + } +} + /// This type implements `PunishValidators`. -pub struct SlashValidatorsForDisputes { - _phantom: sp_std::marker::PhantomData<(C, R)>, +pub struct SlashValidatorsForDisputes { + _phantom: sp_std::marker::PhantomData, } -impl Default for SlashValidatorsForDisputes { +impl Default for SlashValidatorsForDisputes { fn default() -> Self { Self { _phantom: Default::default() } } } -impl SlashValidatorsForDisputes, R> +impl SlashValidatorsForDisputes> where T: Config + crate::session_info::Config, { @@ -203,19 +227,9 @@ where } } -impl super::SlashingHandler for SlashValidatorsForDisputes, R> +impl super::SlashingHandler for SlashValidatorsForDisputes> where - T: Config + crate::session_info::Config, - // TODO: use HandleReports instead? - R: ReportOffence< - AccountId, - IdentificationTuple, - ForInvalidOffence>, - > + ReportOffence< - AccountId, - IdentificationTuple, - AgainstValidOffence>, - >, + T: Config> + crate::session_info::Config, { fn punish_for_invalid( session_index: SessionIndex, @@ -231,10 +245,7 @@ where let account_keys = crate::session_info::Pallet::::account_keys(session_index); let account_ids = match account_keys { Some(account_keys) => account_keys, - None => { - // TODO: warn - return - }, + None => return, // can not really happen }; let winners: Winners = winners .into_iter() @@ -245,8 +256,9 @@ where if let Some((offenders, validator_set_count)) = maybe { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = ForInvalidOffence { validator_set_count, time_slot, offenders }; - // TODO: log error? - let _ = R::report_offence(winners, offence); + // This is the first time we report an offence for this dispute, + // so it is not a duplicate + let _ = T::HandleReports::report_for_invalid_offence(winners, offence); return } @@ -268,10 +280,7 @@ where let account_keys = crate::session_info::Pallet::::account_keys(session_index); let account_ids = match account_keys { Some(account_keys) => account_keys, - None => { - // TODO: warn - return - }, + None => return, // can not really happen }; let winners: Winners = winners .into_iter() @@ -282,8 +291,9 @@ where if let Some((offenders, validator_set_count)) = maybe { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = AgainstValidOffence { validator_set_count, time_slot, offenders }; - // TODO: log error? - let _ = R::report_offence(winners, offence); + // This is the first time we report an offence for this dispute, + // so it is not a duplicate + let _ = T::HandleReports::report_against_valid_offence(winners, offence); return } @@ -330,96 +340,34 @@ pub struct DisputeProof { pub type Losers = BTreeSet; pub type Winners = Vec>; -pub trait SlashingOffence: Offence { - /// Create a new dispute offence using the given details. - fn new( - session_index: SessionIndex, - candidate_hash: CandidateHash, - validator_set_count: u32, - offender: KeyOwnerIdentification, - ) -> Self; - - /// Create a new dispute offence time slot. - fn new_time_slot(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self::TimeSlot; -} - -impl SlashingOffence - for ForInvalidOffence -where - KeyOwnerIdentification: Clone, -{ - fn new( - session_index: SessionIndex, - candidate_hash: CandidateHash, - validator_set_count: u32, - offender: KeyOwnerIdentification, - ) -> Self { - let time_slot = Self::new_time_slot(session_index, candidate_hash); - Self { time_slot, validator_set_count, offenders: vec![offender] } - } - - fn new_time_slot(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self::TimeSlot { - DisputesTimeSlot { session_index, candidate_hash } - } -} - -impl SlashingOffence - for AgainstValidOffence -where - KeyOwnerIdentification: Clone, -{ - fn new( - session_index: SessionIndex, - candidate_hash: CandidateHash, - validator_set_count: u32, - offender: KeyOwnerIdentification, - ) -> Self { - let time_slot = Self::new_time_slot(session_index, candidate_hash); - Self { time_slot, validator_set_count, offenders: vec![offender] } - } - - fn new_time_slot(session_index: SessionIndex, candidate_hash: CandidateHash) -> Self::TimeSlot { - DisputesTimeSlot { session_index, candidate_hash } - } -} - -// TODO: does it need to be that generic? +// TODO: docs pub trait HandleReports { - /// The offence type used for reporting offences on valid reports for disputes - /// lost about a valid candidate. - type OffenceForInvalid: SlashingOffence; - - /// The offence type used for reporting offences on valid reports for disputes - /// lost about an invalid candidate. - type OffenceAgainstValid: SlashingOffence; - /// The longevity, in blocks, that the offence report is valid for. When using the staking /// pallet this should be equal to the bonding duration (in blocks, not eras). type ReportLongevity: Get; - /// Report a for valid offence. - // TODO: generic over reporter type? + /// Report a `for valid` offence. fn report_for_invalid_offence( reporters: Vec>, - offence: Self::OffenceForInvalid, + offence: ForInvalidOffence, ) -> Result<(), OffenceError>; /// Report an against invalid offence. fn report_against_valid_offence( reporters: Vec>, - offence: Self::OffenceAgainstValid, + offence: AgainstValidOffence, ) -> Result<(), OffenceError>; /// Returns true if the offenders at the given time slot has already been reported. fn is_known_for_invalid_offence( offenders: &[T::KeyOwnerIdentification], - time_slot: &>::TimeSlot, + time_slot: &DisputesTimeSlot, ) -> bool; /// Returns true if the offenders at the given time slot has already been reported. fn is_known_against_valid_offence( offenders: &[T::KeyOwnerIdentification], - time_slot: &>::TimeSlot, + time_slot: &DisputesTimeSlot, ) -> bool; /// Create and dispatch a slashing report extrinsic. @@ -431,34 +379,32 @@ pub trait HandleReports { } impl HandleReports for () { - type OffenceForInvalid = ForInvalidOffence; - type OffenceAgainstValid = AgainstValidOffence; type ReportLongevity = (); fn report_for_invalid_offence( _reporters: Vec>, - _offence: Self::OffenceForInvalid, + _offence: ForInvalidOffence, ) -> Result<(), OffenceError> { Ok(()) } fn report_against_valid_offence( _reporters: Vec>, - _offence: Self::OffenceAgainstValid, + _offence: AgainstValidOffence, ) -> Result<(), OffenceError> { Ok(()) } fn is_known_for_invalid_offence( _offenders: &[T::KeyOwnerIdentification], - _time_slot: &>::TimeSlot, + _time_slot: &DisputesTimeSlot, ) -> bool { true } fn is_known_against_valid_offence( _offenders: &[T::KeyOwnerIdentification], - _time_slot: &>::TimeSlot, + _time_slot: &DisputesTimeSlot, ) -> bool { true } @@ -491,11 +437,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + crate::disputes::Config { - // type Event: From> + IsType<::Event>; - /// The proof of key ownership, used for validating slashing reports. /// The proof must include the session index and validator count of the - /// session at which the equivocation occurred. + /// session at which the offence occurred. type KeyOwnerProof: Parameter + GetSessionNumber + GetValidatorCount; /// The identification of a key owner, used when reporting slashes. @@ -634,7 +578,7 @@ pub mod pallet { let winners = >::get(&session_index, &candidate_hash) .unwrap_or_default(); - let offence = >::OffenceForInvalid::new( + let offence = ForInvalidOffence::new( session_index, candidate_hash, validator_set_count, @@ -659,7 +603,7 @@ pub mod pallet { .unwrap_or_default(); // submit an offence report - let offence = >::OffenceAgainstValid::new( + let offence = AgainstValidOffence::new( session_index, candidate_hash, validator_set_count, @@ -783,30 +727,16 @@ fn is_known_offence( // check if the offence has already been reported, // and if so then we can discard the report. let is_known_offence = match dispute_proof.kind { - SlashingOffenceKind::ForInvalid => { - let time_slot = - >::OffenceForInvalid::new_time_slot( - dispute_proof.time_slot.session_index, - dispute_proof.time_slot.candidate_hash, - ); - + SlashingOffenceKind::ForInvalid => >::is_known_for_invalid_offence( &[offender], - &time_slot, - ) - }, - SlashingOffenceKind::AgainstValid => { - let time_slot = - >::OffenceAgainstValid::new_time_slot( - dispute_proof.time_slot.session_index, - dispute_proof.time_slot.candidate_hash, - ); - + &dispute_proof.time_slot, + ), + SlashingOffenceKind::AgainstValid => >::is_known_against_valid_offence( &[offender], - &time_slot, - ) - }, + &dispute_proof.time_slot, + ), }; if is_known_offence { @@ -841,22 +771,18 @@ where >, L: Get, { - type OffenceForInvalid = ForInvalidOffence; - - type OffenceAgainstValid = AgainstValidOffence; - type ReportLongevity = L; fn report_for_invalid_offence( reporters: Vec>, - offence: Self::OffenceForInvalid, + offence: ForInvalidOffence, ) -> Result<(), OffenceError> { R::report_offence(reporters, offence) } fn report_against_valid_offence( reporters: Vec>, - offence: Self::OffenceAgainstValid, + offence: AgainstValidOffence, ) -> Result<(), OffenceError> { R::report_offence(reporters, offence) } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index d510ce673e00..1a924dc74525 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -941,7 +941,7 @@ impl assigned_slots::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; + type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } From 4db3ab8ce8dc582f2ee78bda2bf54cc730f73228 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 18:48:33 +0200 Subject: [PATCH 20/75] resolve some more TODOs --- runtime/parachains/src/disputes/slashing.rs | 53 +++++++++++++++++---- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 82fda2c2f1c7..42a6cbee5ca6 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -15,6 +15,19 @@ // along with Polkadot. If not, see . //! Dispute slashing types for the substrate offences pallet. +//! +//! The implementation relies on the `offences` pallet and +//! looks like a hybrid of `im-online` and `grandpa` equivocation handlers. +//! Meaning, we submit an `offence` for the concluded disputes about +//! the current session candidate directly from the runtime. +//! If, however, the dispute is about past session, we record pending +//! slashes on chain, without FullIdentification of the offenders. +//! Later on, a block producer can submit an unsigned transaction with +//! `KeyOwnershipProof` of an offender and submit it to the runtime +//! to produce an offence. +//! The reason for this separation is that we do not want to rely on +//! `FullIdentification` to be available on chain for the past sessions +//! because it is quite heavy. use crate::{ initializer::SessionChangeNotification, @@ -336,11 +349,14 @@ pub struct DisputeProof { pub validator_id: ValidatorId, } -// TODO: docs +/// Indices of the validators who lost a dispute and are pending slashes. pub type Losers = BTreeSet; +/// `AccountId`s of the validators who were on the winning side of a dispute. pub type Winners = Vec>; -// TODO: docs +/// A trait that defines methods to report an offence +/// (after the slashing report has been validated) and for submitting a +/// transaction to report a slash (from an offchain context). pub trait HandleReports { /// The longevity, in blocks, that the offence report is valid for. When using the staking /// pallet this should be equal to the bonding duration (in blocks, not eras). @@ -653,9 +669,26 @@ impl Pallet { let old_session = notification.session_index - config.dispute_period - 1; - // TODO: warn if there were pending slashes? - >::remove_prefix(old_session, None); - >::remove_prefix(old_session, None); + match >::remove_prefix(old_session, None) { + sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { + log::warn!( + target: LOG_TARGET, + "No slashing for {} validators that lost a ForInvalid dispute", + x + ); + }, + _ => {}, + } + match >::remove_prefix(old_session, None) { + sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { + log::warn!( + target: LOG_TARGET, + "No slashing for {} validators that lost a AgainstValid dispute", + x + ); + }, + _ => {}, + } >::remove_prefix(old_session, None); >::remove_prefix(old_session, None); } @@ -746,7 +779,11 @@ fn is_known_offence( } } -// TODO: docs +/// Actual `HandleReports` implemention. +/// +/// When configured properly, should be instantiated with +/// `T::KeyOwnerIdentification, Offences, ReportLongevity` +/// parameters. pub struct SlashingReportHandler { _phantom: sp_std::marker::PhantomData<(I, R, L)>, } @@ -827,14 +864,14 @@ where match SubmitTransaction::>::submit_unsigned_transaction(call.into()) { Ok(()) => log::info!( target: LOG_TARGET, - "Submitted dispute slashing report, session: {}, validator: {}, kind: {:?}", + "Submitted dispute slashing report, session({}), index({}), kind({:?})", session_index, validator_index, kind, ), Err(()) => log::error!( target: LOG_TARGET, - "Error submitting dispute slashing report, session: {}, validator: {}, kind: {:?}", + "Error submitting dispute slashing report, session({}), index({}), kind({:?})", session_index, validator_index, kind, From 02c069d88ece0cfbf1f31614e90fa200c4d35296 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 17 May 2022 18:55:20 +0200 Subject: [PATCH 21/75] minor typos --- runtime/parachains/src/disputes/slashing.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 42a6cbee5ca6..0616aac0978d 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -14,14 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -//! Dispute slashing types for the substrate offences pallet. +//! Dispute slashing pallet. //! //! The implementation relies on the `offences` pallet and //! looks like a hybrid of `im-online` and `grandpa` equivocation handlers. //! Meaning, we submit an `offence` for the concluded disputes about //! the current session candidate directly from the runtime. -//! If, however, the dispute is about past session, we record pending -//! slashes on chain, without FullIdentification of the offenders. +//! If, however, the dispute is about a past session, we record pending +//! slashes on chain, without `FullIdentification` of the offenders. //! Later on, a block producer can submit an unsigned transaction with //! `KeyOwnershipProof` of an offender and submit it to the runtime //! to produce an offence. @@ -673,7 +673,7 @@ impl Pallet { sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { log::warn!( target: LOG_TARGET, - "No slashing for {} validators that lost a ForInvalid dispute", + "No slashing for {} validators that lost a `ForInvalid` dispute", x ); }, @@ -683,7 +683,7 @@ impl Pallet { sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { log::warn!( target: LOG_TARGET, - "No slashing for {} validators that lost a AgainstValid dispute", + "No slashing for {} validators that lost an `AgainstValid` dispute", x ); }, From 6fc8f5f2f8119c2d1834b758907d39268909d597 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 18 May 2022 15:49:24 +0200 Subject: [PATCH 22/75] move slashing into a folder --- runtime/parachains/src/disputes/{slashing.rs => slashing/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename runtime/parachains/src/disputes/{slashing.rs => slashing/mod.rs} (100%) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing/mod.rs similarity index 100% rename from runtime/parachains/src/disputes/slashing.rs rename to runtime/parachains/src/disputes/slashing/mod.rs From 7f3ae2049de237fb9496600fa28c9e4cd6ca30af Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 18 May 2022 16:15:06 +0200 Subject: [PATCH 23/75] remove unnecessary clone --- runtime/parachains/src/disputes/slashing/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing/mod.rs b/runtime/parachains/src/disputes/slashing/mod.rs index 0616aac0978d..597c07573e70 100644 --- a/runtime/parachains/src/disputes/slashing/mod.rs +++ b/runtime/parachains/src/disputes/slashing/mod.rs @@ -548,7 +548,7 @@ pub mod pallet { // check the membership proof to extract the offender's id let key = (primitives::v2::PARACHAIN_KEY_TYPE_ID, dispute_proof.validator_id.clone()); - let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof.clone()) + let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof) .ok_or(Error::::InvalidKeyOwnershipProof)?; // check that `validator_index` matches `validator_id` From 13c7c8446a3434afb440230fcd4e3937baecd5d3 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 18 May 2022 17:16:07 +0200 Subject: [PATCH 24/75] fix validator_set_count calculation --- .../parachains/src/disputes/slashing/mod.rs | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing/mod.rs b/runtime/parachains/src/disputes/slashing/mod.rs index 597c07573e70..933c6bb8c86e 100644 --- a/runtime/parachains/src/disputes/slashing/mod.rs +++ b/runtime/parachains/src/disputes/slashing/mod.rs @@ -211,20 +211,19 @@ impl SlashValidatorsForDisputes> where T: Config + crate::session_info::Config, { - /// If in the current session, returns the identified validators - /// along with the validator set count for that session. `None` otherwise. + /// If in the current session, returns the identified validators. + /// `None` otherwise. fn maybe_identify_validators( session_index: SessionIndex, account_ids: &[AccountId], validators: impl IntoIterator, - ) -> Option<(Vec>, u32)> { + ) -> Option>> { // We use `ValidatorSet::session_index` and not `shared::Pallet::session_index()` // because at the first block of a new era, the `IdentificationOf` of a validator // in the previous session might be missing, while `shared` pallet would return // the same session index as being updated at the end of the block. let current_session = T::ValidatorSet::session_index(); if session_index == current_session { - let validator_set_count = account_ids.len() as u32; let fully_identified = validators .into_iter() .flat_map(|i| account_ids.get(i.0 as usize).cloned()) @@ -234,7 +233,7 @@ where ).map(|full_id| (id, full_id)) }) .collect::>>(); - return Some((fully_identified, validator_set_count)) + return Some(fully_identified) } None } @@ -260,17 +259,23 @@ where Some(account_keys) => account_keys, None => return, // can not really happen }; + let session_info = crate::session_info::Pallet::::session_info(session_index); + let session_info = match session_info { + Some(info) => info, + None => return, // can not really happen + }; + let validator_set_count = session_info.discovery_keys.len() as u32; let winners: Winners = winners .into_iter() .filter_map(|i| account_ids.get(i.0 as usize).cloned()) .collect(); let maybe = Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); - if let Some((offenders, validator_set_count)) = maybe { + if let Some(offenders) = maybe { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = ForInvalidOffence { validator_set_count, time_slot, offenders }; // This is the first time we report an offence for this dispute, - // so it is not a duplicate + // so it is not a duplicate. let _ = T::HandleReports::report_for_invalid_offence(winners, offence); return } @@ -295,17 +300,23 @@ where Some(account_keys) => account_keys, None => return, // can not really happen }; + let session_info = crate::session_info::Pallet::::session_info(session_index); + let session_info = match session_info { + Some(info) => info, + None => return, // can not really happen + }; + let validator_set_count = session_info.discovery_keys.len() as u32; let winners: Winners = winners .into_iter() .filter_map(|i| account_ids.get(i.0 as usize).cloned()) .collect(); let maybe = Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); - if let Some((offenders, validator_set_count)) = maybe { + if let Some(offenders) = maybe { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); let offence = AgainstValidOffence { validator_set_count, time_slot, offenders }; // This is the first time we report an offence for this dispute, - // so it is not a duplicate + // so it is not a duplicate. let _ = T::HandleReports::report_against_valid_offence(winners, offence); return } From 5c9828966208998b89b38357958ba8b8f2c80891 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 18 May 2022 17:21:09 +0200 Subject: [PATCH 25/75] introduce ValidatorSetCount --- .../parachains/src/disputes/slashing/mod.rs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing/mod.rs b/runtime/parachains/src/disputes/slashing/mod.rs index 933c6bb8c86e..e6ba2331c67b 100644 --- a/runtime/parachains/src/disputes/slashing/mod.rs +++ b/runtime/parachains/src/disputes/slashing/mod.rs @@ -72,14 +72,16 @@ impl DisputesTimeSlot { } } +/// Number of validators (not only parachain) in a session. +type ValidatorSetCount = u32; + /// An offence that is filed when a series of validators lost a dispute /// about an invalid candidate. #[derive(RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] pub struct ForInvalidOffence { /// The size of the validator set in that session. - /// Note: this includes not only parachain validators. - pub validator_set_count: u32, + pub validator_set_count: ValidatorSetCount, /// Should be unique per dispute. pub time_slot: DisputesTimeSlot, /// Staking information about the validators that lost the dispute @@ -103,7 +105,7 @@ where self.time_slot.session_index } - fn validator_set_count(&self) -> u32 { + fn validator_set_count(&self) -> ValidatorSetCount { self.validator_set_count } @@ -117,7 +119,7 @@ where DisableStrategy::Always } - fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + fn slash_fraction(_offenders: u32, _: ValidatorSetCount) -> Perbill { Perbill::from_percent(100) } } @@ -130,8 +132,7 @@ where #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] pub struct AgainstValidOffence { /// The size of the validator set in that session. - /// Note: this includes not only parachain validators. - pub validator_set_count: u32, + pub validator_set_count: ValidatorSetCount, /// Should be unique per dispute. pub time_slot: DisputesTimeSlot, /// Staking information about the validators that lost the dispute @@ -155,7 +156,7 @@ where self.time_slot.session_index } - fn validator_set_count(&self) -> u32 { + fn validator_set_count(&self) -> ValidatorSetCount { self.validator_set_count } @@ -167,7 +168,7 @@ where DisableStrategy::Never } - fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + fn slash_fraction(_offenders: u32, _: ValidatorSetCount) -> Perbill { Perbill::from_percent(1) } } @@ -176,7 +177,7 @@ impl ForInvalidOffence { fn new( session_index: SessionIndex, candidate_hash: CandidateHash, - validator_set_count: u32, + validator_set_count: ValidatorSetCount, offender: KeyOwnerIdentification, ) -> Self { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); @@ -188,7 +189,7 @@ impl AgainstValidOffence { fn new( session_index: SessionIndex, candidate_hash: CandidateHash, - validator_set_count: u32, + validator_set_count: ValidatorSetCount, offender: KeyOwnerIdentification, ) -> Self { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); @@ -264,7 +265,7 @@ where Some(info) => info, None => return, // can not really happen }; - let validator_set_count = session_info.discovery_keys.len() as u32; + let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; let winners: Winners = winners .into_iter() .filter_map(|i| account_ids.get(i.0 as usize).cloned()) @@ -305,7 +306,7 @@ where Some(info) => info, None => return, // can not really happen }; - let validator_set_count = session_info.discovery_keys.len() as u32; + let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; let winners: Winners = winners .into_iter() .filter_map(|i| account_ids.get(i.0 as usize).cloned()) @@ -445,12 +446,12 @@ impl HandleReports for () { } pub trait WeightInfo { - fn report_dispute_lost(validator_count: u32) -> Weight; + fn report_dispute_lost(validator_count: ValidatorSetCount) -> Weight; } pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { - fn report_dispute_lost(_validator_count: u32) -> Weight { + fn report_dispute_lost(_validator_count: ValidatorSetCount) -> Weight { 0 } } @@ -572,7 +573,7 @@ pub mod pallet { Error::::ValidatorIndexIdMismatch ); // number of all validators (not only parachain) in the session - info.discovery_keys.len() as u32 + info.discovery_keys.len() as ValidatorSetCount } else { return Err(Error::::InvalidSessionIndex.into()) }; From 8263d16c8c69dab88fa971a097d7c89e942a0bf0 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 18 May 2022 18:29:44 +0200 Subject: [PATCH 26/75] store ValidatorSetCount --- runtime/parachains/src/disputes.rs | 6 +- .../parachains/src/disputes/slashing/mod.rs | 77 +++++++++++-------- runtime/parachains/src/initializer.rs | 6 +- runtime/parachains/src/mock.rs | 2 +- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 5b926ba32cc6..6286a8e78c7a 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -16,7 +16,7 @@ //! Runtime component for handling disputes of parachain candidates. -use crate::{configuration, initializer::SessionChangeNotification, session_info}; +use crate::{configuration, initializer::{SessionChangeNotification, ValidatorSetCount}, session_info}; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; use frame_support::{ensure, traits::Get, weights::Weight}; use frame_system::pallet_prelude::*; @@ -88,7 +88,7 @@ pub trait SlashingHandler { fn initializer_finalize(); /// Called by the initializer to note that a new session has started. - fn initializer_on_new_session(notification: &SessionChangeNotification); + fn initializer_on_new_session(session_index: SessionIndex, count: ValidatorSetCount); } impl SlashingHandler for () { @@ -114,7 +114,7 @@ impl SlashingHandler for () { fn initializer_finalize() {} - fn initializer_on_new_session(_notification: &SessionChangeNotification) {} + fn initializer_on_new_session(_: SessionIndex, _: ValidatorSetCount) {} } /// Binary discriminator to determine if the expensive signature diff --git a/runtime/parachains/src/disputes/slashing/mod.rs b/runtime/parachains/src/disputes/slashing/mod.rs index e6ba2331c67b..8d76aa22b2d8 100644 --- a/runtime/parachains/src/disputes/slashing/mod.rs +++ b/runtime/parachains/src/disputes/slashing/mod.rs @@ -30,7 +30,7 @@ //! because it is quite heavy. use crate::{ - initializer::SessionChangeNotification, + initializer::ValidatorSetCount, session_info::{AccountId, IdentificationTuple}, }; use frame_support::{ @@ -50,7 +50,7 @@ use sp_runtime::{ }; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::offence::{DisableStrategy, Kind, Offence, OffenceError, ReportOffence}; -use sp_std::{collections::btree_set::BTreeSet, prelude::*}; +use sp_std::{collections::btree_map::{BTreeMap, Entry}, prelude::*}; const LOG_TARGET: &str = "runtime::slashing"; @@ -72,9 +72,6 @@ impl DisputesTimeSlot { } } -/// Number of validators (not only parachain) in a session. -type ValidatorSetCount = u32; - /// An offence that is filed when a series of validators lost a dispute /// about an invalid candidate. #[derive(RuntimeDebug, TypeInfo)] @@ -250,7 +247,7 @@ where losers: impl IntoIterator, winners: impl IntoIterator, ) { - let losers: Losers = losers.into_iter().collect(); + let losers: Vec = losers.into_iter().collect(); if losers.is_empty() { // Nothing to do return @@ -281,6 +278,9 @@ where return } + let losers: Losers = losers.into_iter() + .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) + .collect(); >::insert(session_index, candidate_hash, losers); >::insert(session_index, candidate_hash, winners); } @@ -291,7 +291,7 @@ where losers: impl IntoIterator, winners: impl IntoIterator, ) { - let losers: Losers = losers.into_iter().collect(); + let losers: Vec = losers.into_iter().collect(); if losers.is_empty() { // Nothing to do return @@ -322,6 +322,9 @@ where return } + let losers: Losers = losers.into_iter() + .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) + .collect(); >::insert(session_index, candidate_hash, losers); >::insert(session_index, candidate_hash, winners); } @@ -334,8 +337,8 @@ where Pallet::::initializer_finalize() } - fn initializer_on_new_session(notification: &SessionChangeNotification) { - Pallet::::initializer_on_new_session(notification) + fn initializer_on_new_session(session_index: SessionIndex, count: ValidatorSetCount) { + Pallet::::initializer_on_new_session(session_index, count) } } @@ -361,8 +364,8 @@ pub struct DisputeProof { pub validator_id: ValidatorId, } -/// Indices of the validators who lost a dispute and are pending slashes. -pub type Losers = BTreeSet; +/// Indices and keys of the validators who lost a dispute and are pending slashes. +pub type Losers = BTreeMap; /// `AccountId`s of the validators who were on the winning side of a dispute. pub type Winners = Vec>; @@ -513,6 +516,15 @@ pub mod pallet { Winners, >; + /// `ValidatorSetCount` per session. + #[pallet::storage] + pub(super) type ValidatorSetCounts = StorageMap< + _, + Twox64Concat, + SessionIndex, + ValidatorSetCount, + >; + /// Indices of the validators pending "against valid" dispute slashes. #[pallet::storage] pub(super) type PendingAgainstValidLosers = @@ -563,20 +575,9 @@ pub mod pallet { let offender = T::KeyOwnerProofSystem::check_proof(key, key_owner_proof) .ok_or(Error::::InvalidKeyOwnershipProof)?; - // check that `validator_index` matches `validator_id` let session_index = dispute_proof.time_slot.session_index; - let validator_set_count = - if let Some(info) = crate::session_info::Pallet::::session_info(session_index) { - let i = dispute_proof.validator_index.0 as usize; - ensure!( - info.validators.get(i) == Some(&dispute_proof.validator_id), - Error::::ValidatorIndexIdMismatch - ); - // number of all validators (not only parachain) in the session - info.discovery_keys.len() as ValidatorSetCount - } else { - return Err(Error::::InvalidSessionIndex.into()) - }; + let validator_set_count = >::get(session_index) + .ok_or(Error::::InvalidSessionIndex)?; // check that there is a pending slash for the given // validator index and candidate hash @@ -584,10 +585,18 @@ pub mod pallet { let try_remove = |v: &mut Option| -> Result<(), DispatchError> { let indices = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; - ensure!( - indices.remove(&dispute_proof.validator_index), - Error::::InvalidValidatorIndex, - ); + match indices.entry(dispute_proof.validator_index) { + Entry::Vacant(_) => { + return Err(Error::::InvalidValidatorIndex.into()) + } + // check that `validator_index` matches `validator_id` + Entry::Occupied(e) if e.get() != &dispute_proof.validator_id => { + return Err(Error::::ValidatorIndexIdMismatch.into()) + } + Entry::Occupied(e) => { + e.remove(); // all good + } + } if indices.is_empty() { *v = None; @@ -673,13 +682,18 @@ impl Pallet { fn initializer_finalize() {} /// Called by the initializer to note a new session in the disputes slashing pallet. - fn initializer_on_new_session(notification: &SessionChangeNotification) { + fn initializer_on_new_session( + session_index: SessionIndex, + validator_set_count: ValidatorSetCount, + ) { + >::insert(session_index, validator_set_count); + let config = >::config(); - if notification.session_index <= config.dispute_period + 1 { + if session_index <= config.dispute_period + 1 { return } - let old_session = notification.session_index - config.dispute_period - 1; + let old_session = session_index - config.dispute_period - 1; match >::remove_prefix(old_session, None) { sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { @@ -703,6 +717,7 @@ impl Pallet { } >::remove_prefix(old_session, None); >::remove_prefix(old_session, None); + >::remove(old_session); } } diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index aa817499e56e..5876df3ecb16 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -59,6 +59,9 @@ pub struct SessionChangeNotification { pub session_index: SessionIndex, } +/// Number of validators (not only parachain) in a session. +pub type ValidatorSetCount = u32; + impl> Default for SessionChangeNotification { fn default() -> Self { Self { @@ -242,6 +245,7 @@ impl Pallet { configuration::Pallet::::initializer_on_new_session(&session_index); let new_config = new_config.unwrap_or_else(|| prev_config.clone()); + let validator_set_count = all_validators.len() as ValidatorSetCount; let validators = shared::Pallet::::initializer_on_new_session( session_index, random_seed.clone(), @@ -263,7 +267,7 @@ impl Pallet { inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Pallet::::initializer_on_new_session(¬ification); T::DisputesHandler::initializer_on_new_session(¬ification); - T::SlashingHandler::initializer_on_new_session(¬ification); + T::SlashingHandler::initializer_on_new_session(session_index, validator_set_count); dmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); ump::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); hrmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 32a239f2361c..87c1c8d3e84e 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -277,7 +277,7 @@ impl crate::disputes::SlashingHandler for Test { fn initializer_finalize() {} - fn initializer_on_new_session(_: &initializer::SessionChangeNotification) {} + fn initializer_on_new_session(_: SessionIndex, _: u32) {} } impl crate::scheduler::Config for Test {} From c073e08a98491b6b7296b7aac08747f20a777323 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 18 May 2022 18:38:27 +0200 Subject: [PATCH 27/75] fmt --- runtime/parachains/src/disputes.rs | 6 +++- .../parachains/src/disputes/slashing/mod.rs | 30 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 6286a8e78c7a..b1a55dc0c82a 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -16,7 +16,11 @@ //! Runtime component for handling disputes of parachain candidates. -use crate::{configuration, initializer::{SessionChangeNotification, ValidatorSetCount}, session_info}; +use crate::{ + configuration, + initializer::{SessionChangeNotification, ValidatorSetCount}, + session_info, +}; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; use frame_support::{ensure, traits::Get, weights::Weight}; use frame_system::pallet_prelude::*; diff --git a/runtime/parachains/src/disputes/slashing/mod.rs b/runtime/parachains/src/disputes/slashing/mod.rs index 8d76aa22b2d8..439a27a11664 100644 --- a/runtime/parachains/src/disputes/slashing/mod.rs +++ b/runtime/parachains/src/disputes/slashing/mod.rs @@ -50,7 +50,10 @@ use sp_runtime::{ }; use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::offence::{DisableStrategy, Kind, Offence, OffenceError, ReportOffence}; -use sp_std::{collections::btree_map::{BTreeMap, Entry}, prelude::*}; +use sp_std::{ + collections::btree_map::{BTreeMap, Entry}, + prelude::*, +}; const LOG_TARGET: &str = "runtime::slashing"; @@ -278,7 +281,8 @@ where return } - let losers: Losers = losers.into_iter() + let losers: Losers = losers + .into_iter() .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) .collect(); >::insert(session_index, candidate_hash, losers); @@ -322,7 +326,8 @@ where return } - let losers: Losers = losers.into_iter() + let losers: Losers = losers + .into_iter() .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) .collect(); >::insert(session_index, candidate_hash, losers); @@ -518,12 +523,8 @@ pub mod pallet { /// `ValidatorSetCount` per session. #[pallet::storage] - pub(super) type ValidatorSetCounts = StorageMap< - _, - Twox64Concat, - SessionIndex, - ValidatorSetCount, - >; + pub(super) type ValidatorSetCounts = + StorageMap<_, Twox64Concat, SessionIndex, ValidatorSetCount>; /// Indices of the validators pending "against valid" dispute slashes. #[pallet::storage] @@ -586,16 +587,13 @@ pub mod pallet { let indices = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; match indices.entry(dispute_proof.validator_index) { - Entry::Vacant(_) => { - return Err(Error::::InvalidValidatorIndex.into()) - } + Entry::Vacant(_) => return Err(Error::::InvalidValidatorIndex.into()), // check that `validator_index` matches `validator_id` - Entry::Occupied(e) if e.get() != &dispute_proof.validator_id => { - return Err(Error::::ValidatorIndexIdMismatch.into()) - } + Entry::Occupied(e) if e.get() != &dispute_proof.validator_id => + return Err(Error::::ValidatorIndexIdMismatch.into()), Entry::Occupied(e) => { e.remove(); // all good - } + }, } if indices.is_empty() { From dc3b6de6c42f305f7535e497b783c0b5b50b457e Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 14 Jun 2022 19:29:57 +0200 Subject: [PATCH 28/75] add the benchmark --- runtime/parachains/Cargo.toml | 1 + runtime/parachains/src/disputes.rs | 2 - runtime/parachains/src/lib.rs | 1 + .../parachains/src/slashing/benchmarking.rs | 181 ++++++++++++++++++ .../src/{disputes => }/slashing/mod.rs | 17 +- runtime/test-runtime/src/lib.rs | 3 +- runtime/westend/src/lib.rs | 11 +- runtime/westend/src/weights/mod.rs | 1 + .../weights/runtime_parachains_slashing.rs | 67 +++++++ 9 files changed, 272 insertions(+), 12 deletions(-) create mode 100644 runtime/parachains/src/slashing/benchmarking.rs rename runtime/parachains/src/{disputes => }/slashing/mod.rs (98%) create mode 100644 runtime/westend/src/weights/runtime_parachains_slashing.rs diff --git a/runtime/parachains/Cargo.toml b/runtime/parachains/Cargo.toml index a4b9e52e06f2..a23e1cbd3863 100644 --- a/runtime/parachains/Cargo.toml +++ b/runtime/parachains/Cargo.toml @@ -95,6 +95,7 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", "primitives/runtime-benchmarks", "static_assertions", "sp-application-crypto", diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index b1a55dc0c82a..8492dafb180b 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -43,8 +43,6 @@ use sp_std::{cmp::Ordering, prelude::*}; #[allow(unused_imports)] pub(crate) use self::tests::run_to_block; -pub mod slashing; - #[cfg(test)] mod tests; diff --git a/runtime/parachains/src/lib.rs b/runtime/parachains/src/lib.rs index 2005861a6c4b..8eda8313b514 100644 --- a/runtime/parachains/src/lib.rs +++ b/runtime/parachains/src/lib.rs @@ -37,6 +37,7 @@ pub mod reward_points; pub mod scheduler; pub mod session_info; pub mod shared; +pub mod slashing; pub mod ump; pub mod runtime_api_impl; diff --git a/runtime/parachains/src/slashing/benchmarking.rs b/runtime/parachains/src/slashing/benchmarking.rs new file mode 100644 index 000000000000..ec530f410b03 --- /dev/null +++ b/runtime/parachains/src/slashing/benchmarking.rs @@ -0,0 +1,181 @@ +// Copyright 2021 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . + +use super::*; + +use crate::{initializer, shared, disputes::SlashingHandler}; +use frame_benchmarking::{benchmarks, whitelist_account}; +use frame_system::RawOrigin; +use pallet_staking::testing_utils::create_validators; +use sp_runtime::traits::{One, StaticLookup}; +use frame_support::traits::{OnInitialize, OnFinalize}; +use primitives::v2::{Hash, PARACHAIN_KEY_TYPE_ID}; +use sp_session::MembershipProof; + +// Candidate hash of the disputed candidate. +const CANDIDATE_HASH: CandidateHash = CandidateHash(Hash::zero()); +// Should be bumped once we support more. +const MAX_VALIDATORS: u32 = 1 * 1024; + +pub trait Config: + pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config + + super::Config + shared::Config + initializer::Config +{} + +fn setup_validator_set(n: u32) -> (SessionIndex, MembershipProof, ValidatorId) +where + T: Config, +{ + pallet_staking::ValidatorCount::::put(n); + + let balance_factor = 1000; + // create validators and set random session keys + for (n, who) in create_validators::(n, balance_factor).unwrap().into_iter().enumerate() { + use rand::{RngCore, SeedableRng}; + + let validator = T::Lookup::lookup(who).unwrap(); + let controller = pallet_staking::Pallet::::bonded(validator).unwrap(); + + let keys = { + const NUM_SESSION_KEYS: usize = 6; + const SESSION_KEY_LEN: usize = 32; + let mut keys = [0u8; NUM_SESSION_KEYS * SESSION_KEY_LEN]; + let mut rng = rand_chacha::ChaCha12Rng::seed_from_u64(n as u64); + rng.fill_bytes(&mut keys); + keys + }; + + let keys: T::Keys = Decode::decode(&mut &keys[..]).expect("wrong number of session keys?"); + let proof: Vec = vec![]; + + whitelist_account!(controller); + pallet_session::Pallet::::set_keys( + RawOrigin::Signed(controller).into(), + keys, + proof, + ).expect("session::set_keys should work"); + } + + pallet_session::Pallet::::on_initialize(T::BlockNumber::one()); + initializer::Pallet::::on_initialize(T::BlockNumber::one()); + // skip sessions until the new validator set is enacted + while pallet_session::Pallet::::validators().len() < n as usize { + pallet_session::Pallet::::rotate_session(); + } + initializer::Pallet::::on_finalize(T::BlockNumber::one()); + + let session_index = crate::shared::Pallet::::session_index(); + let session_info = crate::session_info::Pallet::::session_info(session_index); + let session_info = session_info.unwrap(); + let validator_id = session_info.validators[0].clone(); + let key = (PARACHAIN_KEY_TYPE_ID, validator_id.clone()); + let key_owner_proof = pallet_session::historical::Pallet::::prove(key).unwrap(); + + // rotate a session to make sure `key_owner_proof` is historical + initializer::Pallet::::on_initialize(T::BlockNumber::one()); + pallet_session::Pallet::::rotate_session(); + initializer::Pallet::::on_finalize(T::BlockNumber::one()); + + let idx = crate::shared::Pallet::::session_index(); + assert!( + idx > session_index, + "session rotation should work for parachain pallets: {} <= {}", + idx, + session_index, + ); + + (session_index, key_owner_proof, validator_id) +} + +fn setup_dispute( + session_index: SessionIndex, + validator_id: ValidatorId, + n_validators: u32, +) -> DisputeProof +where + T: Config, +{ + let current_session = T::ValidatorSet::session_index(); + assert_ne!(session_index, current_session); + + let validator_index = ValidatorIndex(0); + + let losers = [ + validator_index, + ].into_iter(); + // everyone else wins + let winners = (1..n_validators).map(|i| ValidatorIndex(i)).into_iter(); + + T::SlashingHandler::punish_against_valid( + session_index, + CANDIDATE_HASH, + losers, + winners, + ); + + let losers = >::get(session_index, CANDIDATE_HASH); + assert_eq!(losers.unwrap().len(), 1); + + dispute_proof(session_index, validator_id, validator_index) +} + +fn dispute_proof( + session_index: SessionIndex, + validator_id: ValidatorId, + validator_index: ValidatorIndex, +) -> DisputeProof { + let kind = SlashingOffenceKind::AgainstValid; + let time_slot = DisputesTimeSlot::new(session_index, CANDIDATE_HASH); + + DisputeProof { + time_slot, + kind, + validator_index, + validator_id, + } +} + +benchmarks! { + where_clause { + where T: Config, + } + + // in this setup we have a single `AgainstValid` dispute + // submitted for a past session + report_dispute_lost { + let n in 4..MAX_VALIDATORS; + + let origin = RawOrigin::None.into(); + let (session_index, key_owner_proof, validator_id) = setup_validator_set::(n); + let dispute_proof = setup_dispute::(session_index, validator_id, n); + }: { + let result = Pallet::::report_dispute_lost_unsigned( + origin, + Box::new(dispute_proof), + key_owner_proof, + ); + assert!(result.is_ok()); + } verify { + let losers = >::get(session_index, CANDIDATE_HASH); + assert!(losers.is_none()); + } + + impl_benchmark_test_suite!( + Pallet, + crate::mock::new_test_ext(Default::default()), + crate::mock::Test + ); +} diff --git a/runtime/parachains/src/disputes/slashing/mod.rs b/runtime/parachains/src/slashing/mod.rs similarity index 98% rename from runtime/parachains/src/disputes/slashing/mod.rs rename to runtime/parachains/src/slashing/mod.rs index 439a27a11664..f70d092cc3f0 100644 --- a/runtime/parachains/src/disputes/slashing/mod.rs +++ b/runtime/parachains/src/slashing/mod.rs @@ -32,6 +32,7 @@ use crate::{ initializer::ValidatorSetCount, session_info::{AccountId, IdentificationTuple}, + disputes, }; use frame_support::{ traits::{Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, @@ -57,6 +58,10 @@ use sp_std::{ const LOG_TARGET: &str = "runtime::slashing"; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + /// Timeslots should uniquely identify offences /// and are used for the offence deduplication. #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] @@ -210,7 +215,7 @@ impl Default for SlashValidatorsForDisputes { impl SlashValidatorsForDisputes> where - T: Config + crate::session_info::Config, + T: Config, { /// If in the current session, returns the identified validators. /// `None` otherwise. @@ -240,9 +245,9 @@ where } } -impl super::SlashingHandler for SlashValidatorsForDisputes> +impl disputes::SlashingHandler for SlashValidatorsForDisputes> where - T: Config> + crate::session_info::Config, + T: Config>, { fn punish_for_invalid( session_index: SessionIndex, @@ -686,7 +691,7 @@ impl Pallet { ) { >::insert(session_index, validator_set_count); - let config = >::config(); + let config = >::config(); if session_index <= config.dispute_period + 1 { return } @@ -695,7 +700,7 @@ impl Pallet { match >::remove_prefix(old_session, None) { sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { - log::warn!( + log::debug!( target: LOG_TARGET, "No slashing for {} validators that lost a `ForInvalid` dispute", x @@ -705,7 +710,7 @@ impl Pallet { } match >::remove_prefix(old_session, None) { sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { - log::warn!( + log::debug!( target: LOG_TARGET, "No slashing for {} validators that lost an `AgainstValid` dispute", x diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 5a2ac393851d..1675e2ade020 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -217,8 +217,7 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type Balance = Balance; - type DustRemoval = (); + type Balance = Balance; type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 1a924dc74525..d5d11dc8d2f3 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -49,7 +49,7 @@ use runtime_common::{ }; use runtime_parachains::{ configuration as parachains_configuration, - disputes::{self as parachains_disputes, slashing as parachains_slashing}, + disputes as parachains_disputes, slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, @@ -415,6 +415,11 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { } } +#[cfg(feature = "runtime-benchmarks")] +type Fallback = onchain::UnboundedExecution; +#[cfg(not(feature = "runtime-benchmarks"))] +type Fallback = pallet_election_provider_multi_phase::NoFallback; + impl pallet_election_provider_multi_phase::Config for Runtime { type Event = Event; type Currency = Balances; @@ -437,7 +442,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type OffchainRepeat = OffchainRepeat; type MinerTxPriority = NposSolutionPriority; type DataProvider = Staking; - type Fallback = pallet_election_provider_multi_phase::NoFallback; + type Fallback = Fallback; type GovernanceFallback = onchain::UnboundedExecution; type Solver = SequentialPhragmen< AccountId, @@ -1228,6 +1233,7 @@ mod benches { [runtime_common::slots, Slots] [runtime_parachains::configuration, Configuration] [runtime_parachains::disputes, ParasDisputes] + [runtime_parachains::slashing, ParasSlashing] [runtime_parachains::hrmp, Hrmp] [runtime_parachains::initializer, Initializer] [runtime_parachains::paras, Paras] @@ -1665,6 +1671,7 @@ sp_api::impl_runtime_apis! { impl pallet_election_provider_support_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {} impl pallet_nomination_pools_benchmarking::Config for Runtime {} + impl runtime_parachains::slashing::benchmarking::Config for Runtime {} use xcm::latest::{ AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation, diff --git a/runtime/westend/src/weights/mod.rs b/runtime/westend/src/weights/mod.rs index 90394ea0fd16..77f7055940c9 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -39,6 +39,7 @@ pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; pub mod runtime_parachains_configuration; pub mod runtime_parachains_disputes; +pub mod runtime_parachains_slashing; pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; diff --git a/runtime/westend/src/weights/runtime_parachains_slashing.rs b/runtime/westend/src/weights/runtime_parachains_slashing.rs new file mode 100644 index 000000000000..5d8fd5944fae --- /dev/null +++ b/runtime/westend/src/weights/runtime_parachains_slashing.rs @@ -0,0 +1,67 @@ +// Copyright 2017-2022 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot 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. + +// Polkadot 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 Polkadot. If not, see . +//! Autogenerated weights for `runtime_parachains::slashing` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 2, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/polkadot +// benchmark +// pallet +// --chain=westend-dev +// --steps=50 +// --repeat=2 +// --pallet=runtime_parachains::slashing +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/westend/src/weights/runtime_parachains_slashing.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `runtime_parachains::slashing`. +pub struct WeightInfo(PhantomData); +impl runtime_parachains::slashing::WeightInfo for WeightInfo { + // Storage: Session CurrentIndex (r:1 w:0) + // Storage: Historical HistoricalSessions (r:1 w:0) + // Storage: ParasSlashing ValidatorSetCounts (r:1 w:0) + // Storage: ParasSlashing PendingAgainstValidLosers (r:1 w:1) + // Storage: ParasSlashing ForInvalidWinners (r:1 w:0) + // Storage: Offences ReportsByKindIndex (r:1 w:1) + // Storage: Offences ConcurrentReportsIndex (r:1 w:1) + // Storage: Offences Reports (r:1 w:1) + // Storage: Staking SlashRewardFraction (r:1 w:0) + // Storage: Staking ActiveEra (r:1 w:0) + // Storage: Staking ErasStartSessionIndex (r:1 w:0) + // Storage: Staking EarliestUnappliedSlash (r:1 w:1) + // Storage: Staking Invulnerables (r:1 w:0) + // Storage: Staking ValidatorSlashInEra (r:1 w:0) + fn report_dispute_lost(n: u32, ) -> Weight { + (91_256_000 as Weight) + // Standard Error: 2_000 + .saturating_add((54_000 as Weight).saturating_mul(n as Weight)) + .saturating_add(T::DbWeight::get().reads(14 as Weight)) + .saturating_add(T::DbWeight::get().writes(5 as Weight)) + } +} From 75f256d8a174ca708e2cd4d15968197b4c67dedd Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 14 Jun 2022 19:33:04 +0200 Subject: [PATCH 29/75] fmt --- .../parachains/src/slashing/benchmarking.rs | 42 +++++++------------ runtime/parachains/src/slashing/mod.rs | 3 +- runtime/test-runtime/src/lib.rs | 3 +- runtime/westend/src/lib.rs | 9 ++-- runtime/westend/src/weights/mod.rs | 2 +- 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/runtime/parachains/src/slashing/benchmarking.rs b/runtime/parachains/src/slashing/benchmarking.rs index ec530f410b03..8c25580f4ae7 100644 --- a/runtime/parachains/src/slashing/benchmarking.rs +++ b/runtime/parachains/src/slashing/benchmarking.rs @@ -16,13 +16,13 @@ use super::*; -use crate::{initializer, shared, disputes::SlashingHandler}; +use crate::{disputes::SlashingHandler, initializer, shared}; use frame_benchmarking::{benchmarks, whitelist_account}; +use frame_support::traits::{OnFinalize, OnInitialize}; use frame_system::RawOrigin; use pallet_staking::testing_utils::create_validators; -use sp_runtime::traits::{One, StaticLookup}; -use frame_support::traits::{OnInitialize, OnFinalize}; use primitives::v2::{Hash, PARACHAIN_KEY_TYPE_ID}; +use sp_runtime::traits::{One, StaticLookup}; use sp_session::MembershipProof; // Candidate hash of the disputed candidate. @@ -31,9 +31,14 @@ const CANDIDATE_HASH: CandidateHash = CandidateHash(Hash::zero()); const MAX_VALIDATORS: u32 = 1 * 1024; pub trait Config: - pallet_session::Config + pallet_session::historical::Config + pallet_staking::Config - + super::Config + shared::Config + initializer::Config -{} + pallet_session::Config + + pallet_session::historical::Config + + pallet_staking::Config + + super::Config + + shared::Config + + initializer::Config +{ +} fn setup_validator_set(n: u32) -> (SessionIndex, MembershipProof, ValidatorId) where @@ -62,11 +67,8 @@ where let proof: Vec = vec![]; whitelist_account!(controller); - pallet_session::Pallet::::set_keys( - RawOrigin::Signed(controller).into(), - keys, - proof, - ).expect("session::set_keys should work"); + pallet_session::Pallet::::set_keys(RawOrigin::Signed(controller).into(), keys, proof) + .expect("session::set_keys should work"); } pallet_session::Pallet::::on_initialize(T::BlockNumber::one()); @@ -113,18 +115,11 @@ where let validator_index = ValidatorIndex(0); - let losers = [ - validator_index, - ].into_iter(); + let losers = [validator_index].into_iter(); // everyone else wins let winners = (1..n_validators).map(|i| ValidatorIndex(i)).into_iter(); - T::SlashingHandler::punish_against_valid( - session_index, - CANDIDATE_HASH, - losers, - winners, - ); + T::SlashingHandler::punish_against_valid(session_index, CANDIDATE_HASH, losers, winners); let losers = >::get(session_index, CANDIDATE_HASH); assert_eq!(losers.unwrap().len(), 1); @@ -140,12 +135,7 @@ fn dispute_proof( let kind = SlashingOffenceKind::AgainstValid; let time_slot = DisputesTimeSlot::new(session_index, CANDIDATE_HASH); - DisputeProof { - time_slot, - kind, - validator_index, - validator_id, - } + DisputeProof { time_slot, kind, validator_index, validator_id } } benchmarks! { diff --git a/runtime/parachains/src/slashing/mod.rs b/runtime/parachains/src/slashing/mod.rs index f70d092cc3f0..81ccdaf27bb8 100644 --- a/runtime/parachains/src/slashing/mod.rs +++ b/runtime/parachains/src/slashing/mod.rs @@ -30,9 +30,9 @@ //! because it is quite heavy. use crate::{ + disputes, initializer::ValidatorSetCount, session_info::{AccountId, IdentificationTuple}, - disputes, }; use frame_support::{ traits::{Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, @@ -58,7 +58,6 @@ use sp_std::{ const LOG_TARGET: &str = "runtime::slashing"; - #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 1675e2ade020..5a2ac393851d 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -217,7 +217,8 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type Balance = Balance; type DustRemoval = (); + type Balance = Balance; + type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index d5d11dc8d2f3..7cd06b1342ce 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -48,14 +48,13 @@ use runtime_common::{ BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate, }; use runtime_parachains::{ - configuration as parachains_configuration, - disputes as parachains_disputes, slashing as parachains_slashing, + configuration as parachains_configuration, disputes as parachains_disputes, dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, - runtime_api_impl::v2 as parachains_runtime_api_impl, - scheduler as parachains_scheduler, session_info as parachains_session_info, - shared as parachains_shared, ump as parachains_ump, + runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, + session_info as parachains_session_info, shared as parachains_shared, + slashing as parachains_slashing, ump as parachains_ump, }; use scale_info::TypeInfo; use sp_core::{OpaqueMetadata, RuntimeDebug}; diff --git a/runtime/westend/src/weights/mod.rs b/runtime/westend/src/weights/mod.rs index 77f7055940c9..2d419c3b320a 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -39,10 +39,10 @@ pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; pub mod runtime_parachains_configuration; pub mod runtime_parachains_disputes; -pub mod runtime_parachains_slashing; pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; +pub mod runtime_parachains_slashing; pub mod runtime_parachains_ump; pub mod xcm; From 65851ad3e2efce43bd554f68fe08a88aa08e492a Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 14 Jun 2022 19:33:59 +0200 Subject: [PATCH 30/75] unflatten slashing --- runtime/parachains/src/{slashing/mod.rs => slashing.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename runtime/parachains/src/{slashing/mod.rs => slashing.rs} (100%) diff --git a/runtime/parachains/src/slashing/mod.rs b/runtime/parachains/src/slashing.rs similarity index 100% rename from runtime/parachains/src/slashing/mod.rs rename to runtime/parachains/src/slashing.rs From 2210badc54924996d5153b22eb54a5714eb39fa7 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 14 Jun 2022 20:36:18 +0200 Subject: [PATCH 31/75] post-rebase fixes --- runtime/parachains/src/disputes.rs | 3 +++ runtime/parachains/src/slashing.rs | 29 +++++++---------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 8492dafb180b..003ed51ee01e 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -580,6 +580,8 @@ struct ImportSummary { state: DisputeState, /// Changes to spam slots. Validator index paired with directional change. spam_slot_changes: Vec<(ValidatorIndex, SpamSlotChange)>, + // New participants in the dispute. + new_participants: bitvec::vec::BitVec, /// Validators to slash for being (wrongly) on the AGAINST side. slash_against: Vec, /// Validators to slash for being (wrongly) on the FOR side. @@ -755,6 +757,7 @@ impl DisputeStateImporter { spam_slot_changes, slash_against, slash_for, + new_participants: self.new_participants, new_flags: post_flags - pre_flags, } } diff --git a/runtime/parachains/src/slashing.rs b/runtime/parachains/src/slashing.rs index 81ccdaf27bb8..44b7edd759a8 100644 --- a/runtime/parachains/src/slashing.rs +++ b/runtime/parachains/src/slashing.rs @@ -697,28 +697,13 @@ impl Pallet { let old_session = session_index - config.dispute_period - 1; - match >::remove_prefix(old_session, None) { - sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { - log::debug!( - target: LOG_TARGET, - "No slashing for {} validators that lost a `ForInvalid` dispute", - x - ); - }, - _ => {}, - } - match >::remove_prefix(old_session, None) { - sp_io::KillStorageResult::AllRemoved(x) if x > 0 => { - log::debug!( - target: LOG_TARGET, - "No slashing for {} validators that lost an `AgainstValid` dispute", - x - ); - }, - _ => {}, - } - >::remove_prefix(old_session, None); - >::remove_prefix(old_session, None); + // This should be small, as disputes are rare, so no limit is fine. + const REMOVE_LIMIT: u32 = u32::MAX; + let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); + let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); + let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); + let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); + >::remove(old_session); } } From 6ab6b4898268a90b60ed9b92b1a2b179c364ec8c Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 14 Jun 2022 21:02:25 +0200 Subject: [PATCH 32/75] remove winners eagerly --- runtime/parachains/src/slashing.rs | 33 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/runtime/parachains/src/slashing.rs b/runtime/parachains/src/slashing.rs index 44b7edd759a8..3b3723610dde 100644 --- a/runtime/parachains/src/slashing.rs +++ b/runtime/parachains/src/slashing.rs @@ -587,7 +587,7 @@ pub mod pallet { // check that there is a pending slash for the given // validator index and candidate hash let candidate_hash = dispute_proof.time_slot.candidate_hash; - let try_remove = |v: &mut Option| -> Result<(), DispatchError> { + let try_remove = |v: &mut Option| -> Result { let indices = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; match indices.entry(dispute_proof.validator_index) { @@ -600,22 +600,30 @@ pub mod pallet { }, } - if indices.is_empty() { + let is_empty = if indices.is_empty() { *v = None; - } + true + } else { + false + }; - Ok(()) + Ok(is_empty) }; match dispute_proof.kind { SlashingOffenceKind::ForInvalid => { - >::try_mutate_exists( + let is_empty = >::try_mutate_exists( &session_index, &candidate_hash, try_remove, )?; - let winners = >::get(&session_index, &candidate_hash) - .unwrap_or_default(); + let winners = if is_empty { + >::take(&session_index, &candidate_hash) + .unwrap_or_default() + } else { + >::get(&session_index, &candidate_hash) + .unwrap_or_default() + }; let offence = ForInvalidOffence::new( session_index, @@ -632,14 +640,19 @@ pub mod pallet { .map_err(|_| Error::::DuplicateSlashingReport)?; }, SlashingOffenceKind::AgainstValid => { - >::try_mutate_exists( + let is_empty = >::try_mutate_exists( &session_index, &candidate_hash, try_remove, )?; - let winners = >::get(&session_index, &candidate_hash) - .unwrap_or_default(); + let winners = if is_empty { + >::take(&session_index, &candidate_hash) + .unwrap_or_default() + } else { + >::get(&session_index, &candidate_hash) + .unwrap_or_default() + }; // submit an offence report let offence = AgainstValidOffence::new( From 6a0ddfc0371a715ced4e95b00ded5522fc95c5d6 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 14 Jun 2022 21:54:03 +0200 Subject: [PATCH 33/75] use real slashing weights for westend --- runtime/westend/src/lib.rs | 2 +- .../src/weights/runtime_parachains_slashing.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 7cd06b1342ce..6965005ef516 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -962,7 +962,7 @@ impl parachains_slashing::Config for Runtime { Offences, ReportLongevity, >; - type WeightInfo = parachains_slashing::TestWeightInfo; // TODO + type WeightInfo = weights::runtime_parachains_slashing::WeightInfo; } parameter_types! { diff --git a/runtime/westend/src/weights/runtime_parachains_slashing.rs b/runtime/westend/src/weights/runtime_parachains_slashing.rs index 5d8fd5944fae..60b223290a7a 100644 --- a/runtime/westend/src/weights/runtime_parachains_slashing.rs +++ b/runtime/westend/src/weights/runtime_parachains_slashing.rs @@ -17,6 +17,7 @@ //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2022-06-14, STEPS: `50`, REPEAT: 2, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `redacted`, CPU: `redacted` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: @@ -47,7 +48,7 @@ impl runtime_parachains::slashing::WeightInfo for Weigh // Storage: Historical HistoricalSessions (r:1 w:0) // Storage: ParasSlashing ValidatorSetCounts (r:1 w:0) // Storage: ParasSlashing PendingAgainstValidLosers (r:1 w:1) - // Storage: ParasSlashing ForInvalidWinners (r:1 w:0) + // Storage: ParasSlashing AgainstValidWinners (r:1 w:1) // Storage: Offences ReportsByKindIndex (r:1 w:1) // Storage: Offences ConcurrentReportsIndex (r:1 w:1) // Storage: Offences Reports (r:1 w:1) @@ -57,11 +58,12 @@ impl runtime_parachains::slashing::WeightInfo for Weigh // Storage: Staking EarliestUnappliedSlash (r:1 w:1) // Storage: Staking Invulnerables (r:1 w:0) // Storage: Staking ValidatorSlashInEra (r:1 w:0) + /// The range of component `n` is `[4, 1024]`. fn report_dispute_lost(n: u32, ) -> Weight { - (91_256_000 as Weight) - // Standard Error: 2_000 - .saturating_add((54_000 as Weight).saturating_mul(n as Weight)) + (101_569_000 as Weight) + // Standard Error: 4_000 + .saturating_add((107_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(6 as Weight)) } } From 29376b145e3c9a19055738e7880bf0414dc5a32a Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 17 Jun 2022 13:08:50 +0200 Subject: [PATCH 34/75] remove bench test suite --- runtime/parachains/src/slashing/benchmarking.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/runtime/parachains/src/slashing/benchmarking.rs b/runtime/parachains/src/slashing/benchmarking.rs index 8c25580f4ae7..ed3e2f7235f2 100644 --- a/runtime/parachains/src/slashing/benchmarking.rs +++ b/runtime/parachains/src/slashing/benchmarking.rs @@ -162,10 +162,4 @@ benchmarks! { let losers = >::get(session_index, CANDIDATE_HASH); assert!(losers.is_none()); } - - impl_benchmark_test_suite!( - Pallet, - crate::mock::new_test_ext(Default::default()), - crate::mock::Test - ); } From 4800be1ed29317d6ba136446ee2d421e12e73aa5 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 17 Jun 2022 14:07:00 +0200 Subject: [PATCH 35/75] zombinet: modify disputes test to check for an offence report --- .../functional/0002-parachains-disputes.feature | 3 +++ .../functional/0002-parachains-disputes.toml | 10 ++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/zombienet_tests/functional/0002-parachains-disputes.feature b/zombienet_tests/functional/0002-parachains-disputes.feature index b56cd9b06c89..4ccdeaa85122 100644 --- a/zombienet_tests/functional/0002-parachains-disputes.feature +++ b/zombienet_tests/functional/0002-parachains-disputes.feature @@ -48,6 +48,9 @@ eve: reports parachain_candidate_disputes_total is at least 10 within 15 seconds eve: reports parachain_candidate_dispute_concluded{validity="valid"} is at least 10 within 15 seconds eve: reports parachain_candidate_dispute_concluded{validity="invalid"} is 0 within 15 seconds +# Check there is an offence report +alice: system event contains "There is an offence reported" + # Check lag - approval alice: reports polkadot_parachain_approval_checking_finality_lag is 0 bob: reports polkadot_parachain_approval_checking_finality_lag is 0 diff --git a/zombienet_tests/functional/0002-parachains-disputes.toml b/zombienet_tests/functional/0002-parachains-disputes.toml index dc909726bdae..533c3b490b85 100644 --- a/zombienet_tests/functional/0002-parachains-disputes.toml +++ b/zombienet_tests/functional/0002-parachains-disputes.toml @@ -7,8 +7,8 @@ timeout = 1000 [relaychain] default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "rococo-local" -chain_spec_command = "polkadot build-spec --chain rococo-local --disable-default-bootnode" +chain = "westend-local" +chain_spec_command = "polkadot build-spec --chain westend-local --disable-default-bootnode" default_command = "polkadot" [relaychain.default_resources] @@ -26,12 +26,10 @@ requests = { memory = "2G", cpu = "1" } name = "bob" command = "malus dispute-ancestor --fake-validation approval-invalid" args = [ "--bob", "-lparachain=debug,MALUS=trace"] - + [[relaychain.nodes]] - image = "{{MALUS_IMAGE}}" name = "charlie" - command = "malus dispute-ancestor --fake-validation approval-invalid" - args = [ "--charlie", "-lparachain=debug,MALUS=trace" ] + args = [ "--charlie", "-lparachain=debug" ] [[relaychain.nodes]] name = "dave" From 4c0f83e99fcf5a7319186c92b1f49bbfafac7136 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 17 Jun 2022 14:08:16 +0200 Subject: [PATCH 36/75] zombinet: add a timeout --- zombienet_tests/functional/0002-parachains-disputes.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zombienet_tests/functional/0002-parachains-disputes.feature b/zombienet_tests/functional/0002-parachains-disputes.feature index 4ccdeaa85122..9386e07e209a 100644 --- a/zombienet_tests/functional/0002-parachains-disputes.feature +++ b/zombienet_tests/functional/0002-parachains-disputes.feature @@ -49,7 +49,7 @@ eve: reports parachain_candidate_dispute_concluded{validity="valid"} is at least eve: reports parachain_candidate_dispute_concluded{validity="invalid"} is 0 within 15 seconds # Check there is an offence report -alice: system event contains "There is an offence reported" +alice: system event contains "There is an offence reported" within 60 seconds # Check lag - approval alice: reports polkadot_parachain_approval_checking_finality_lag is 0 From 3086e262436573edc589662d5be49c9a2c733da5 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 20 Jun 2022 12:05:44 +0200 Subject: [PATCH 37/75] add slashing pallet to Rococo --- runtime/rococo/src/lib.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 26b2a972f108..ff746f531d4e 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -72,6 +72,7 @@ use runtime_parachains::{ initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, + slashing as parachains_slashing, }; use bridge_runtime_common::messages::{ @@ -211,6 +212,7 @@ construct_runtime! { Hrmp: parachains_hrmp, ParaSessionInfo: parachains_session_info, ParasDisputes: parachains_disputes, + ParasSlashing: parachains_slashing, // Parachain Onboarding Pallets Registrar: paras_registrar::{Pallet, Call, Storage, Event, Config}, @@ -371,10 +373,27 @@ impl pallet_session::historical::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; - type SlashingHandler = (); + type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } +impl parachains_slashing::Config for Runtime { + type KeyOwnerProofSystem = Historical; + type KeyOwnerProof = + >::Proof; + type KeyOwnerIdentification = >::IdentificationTuple; + type HandleReports = parachains_slashing::SlashingReportHandler< + Self::KeyOwnerIdentification, + Offences, + ReportLongevity, + >; + type WeightInfo = parachains_slashing::TestWeightInfo; +} + + parameter_types! { pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _; } From 677a262f7f306033e9a7d75aab6c2c3cb57fdf9d Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 20 Jun 2022 12:59:40 +0200 Subject: [PATCH 38/75] zombienet: revert back to rococo-local --- zombienet_tests/functional/0002-parachains-disputes.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zombienet_tests/functional/0002-parachains-disputes.toml b/zombienet_tests/functional/0002-parachains-disputes.toml index 533c3b490b85..a0a87d60d4e3 100644 --- a/zombienet_tests/functional/0002-parachains-disputes.toml +++ b/zombienet_tests/functional/0002-parachains-disputes.toml @@ -7,8 +7,8 @@ timeout = 1000 [relaychain] default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" -chain = "westend-local" -chain_spec_command = "polkadot build-spec --chain westend-local --disable-default-bootnode" +chain = "rococo-local" +chain_spec_command = "polkadot build-spec --chain rococo-local --disable-default-bootnode" default_command = "polkadot" [relaychain.default_resources] From fe7495ec6634a1e69e36c0c5537bc98ff637140c Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 20 Jun 2022 12:59:58 +0200 Subject: [PATCH 39/75] fmt --- runtime/rococo/src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index ff746f531d4e..939aa37bbaa5 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -71,8 +71,8 @@ use runtime_parachains::{ dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, - session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, - slashing as parachains_slashing, + session_info as parachains_session_info, shared as parachains_shared, + slashing as parachains_slashing, ump as parachains_ump, }; use bridge_runtime_common::messages::{ @@ -393,7 +393,6 @@ impl parachains_slashing::Config for Runtime { type WeightInfo = parachains_slashing::TestWeightInfo; } - parameter_types! { pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _; } From 461f37f12a942187ff8c8fed3ce179672a117404 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 20 Jun 2022 15:46:58 +0200 Subject: [PATCH 40/75] remove TODOs --- runtime/parachains/src/slashing.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/runtime/parachains/src/slashing.rs b/runtime/parachains/src/slashing.rs index 3b3723610dde..d089b9adaa17 100644 --- a/runtime/parachains/src/slashing.rs +++ b/runtime/parachains/src/slashing.rs @@ -65,9 +65,6 @@ pub mod benchmarking; /// and are used for the offence deduplication. #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] pub struct DisputesTimeSlot { - // TODO: `TimeSlot` docs says it should fit into `u128` - // any proofs? - // The order of these matters for `derive(Ord)`. session_index: SessionIndex, candidate_hash: CandidateHash, @@ -128,8 +125,6 @@ where } } -// TODO: this can include a multiplier to make slashing worse -// and enable disabling /// An offence that is filed when a series of validators lost a dispute /// about an valid candidate. #[derive(RuntimeDebug, TypeInfo)] From bae99120385f2b59253fa9148f6f58b90b9cedaa Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 20 Jun 2022 17:12:53 +0200 Subject: [PATCH 41/75] revert some accidental changes --- runtime/parachains/src/disputes.rs | 4 ++-- runtime/parachains/src/disputes/tests.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index b4e4f417fc23..37758eb34d8a 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -580,12 +580,12 @@ struct ImportSummary { state: DisputeState, /// Changes to spam slots. Validator index paired with directional change. spam_slot_changes: Vec<(ValidatorIndex, SpamSlotChange)>, - // New participants in the dispute. - new_participants: bitvec::vec::BitVec, /// Validators to slash for being (wrongly) on the AGAINST side. slash_against: Vec, /// Validators to slash for being (wrongly) on the FOR side. slash_for: Vec, + // New participants in the dispute. + new_participants: bitvec::vec::BitVec, // Difference in state flags from previous. new_flags: DisputeStateFlags, } diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 1af9cbe91563..50df2e947ceb 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -174,6 +174,7 @@ fn test_import_new_participant_spam_inc() { assert_eq!(summary.spam_slot_changes, vec![(ValidatorIndex(2), SpamSlotChange::Inc)]); assert!(summary.slash_for.is_empty()); assert!(summary.slash_against.is_empty()); + assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0, 0]); } #[test] @@ -206,6 +207,7 @@ fn test_import_prev_participant_spam_dec_confirmed() { ); assert!(summary.slash_for.is_empty()); assert!(summary.slash_against.is_empty()); + assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 0, 0, 0, 0, 0]); assert_eq!(summary.new_flags, DisputeStateFlags::CONFIRMED); } @@ -244,6 +246,7 @@ fn test_import_prev_participant_spam_dec_confirmed_slash_for() { ); assert_eq!(summary.slash_for, vec![ValidatorIndex(0), ValidatorIndex(2)]); assert!(summary.slash_against.is_empty()); + assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 1, 1, 1, 1, 1, 0]); assert_eq!( summary.new_flags, DisputeStateFlags::CONFIRMED | DisputeStateFlags::AGAINST_SUPERMAJORITY, @@ -281,6 +284,7 @@ fn test_import_slash_against() { assert!(summary.spam_slot_changes.is_empty()); assert!(summary.slash_for.is_empty()); assert_eq!(summary.slash_against, vec![ValidatorIndex(1), ValidatorIndex(5)]); + assert_eq!(summary.new_participants, bitvec![u8, BitOrderLsb0; 0, 0, 0, 1, 1, 1, 1, 1]); assert_eq!(summary.new_flags, DisputeStateFlags::FOR_SUPERMAJORITY); } From 15fcf4846efd7dee3a421a4491631e99fb537007 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 21 Jun 2022 21:00:29 +0200 Subject: [PATCH 42/75] slashing is submodule of disputes --- runtime/parachains/src/disputes.rs | 1 + .../parachains/src/{ => disputes}/slashing.rs | 0 .../{ => disputes}/slashing/benchmarking.rs | 0 runtime/parachains/src/lib.rs | 1 - runtime/rococo/src/lib.rs | 8 ++++---- runtime/westend/src/lib.rs | 14 ++++++------- runtime/westend/src/weights/mod.rs | 2 +- ...> runtime_parachains_disputes_slashing.rs} | 20 +++++++++---------- 8 files changed, 23 insertions(+), 23 deletions(-) rename runtime/parachains/src/{ => disputes}/slashing.rs (100%) rename runtime/parachains/src/{ => disputes}/slashing/benchmarking.rs (100%) rename runtime/westend/src/weights/{runtime_parachains_slashing.rs => runtime_parachains_disputes_slashing.rs} (79%) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 37758eb34d8a..47da4bd0962e 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -43,6 +43,7 @@ use sp_std::{cmp::Ordering, prelude::*}; #[allow(unused_imports)] pub(crate) use self::tests::run_to_block; +pub mod slashing; #[cfg(test)] mod tests; diff --git a/runtime/parachains/src/slashing.rs b/runtime/parachains/src/disputes/slashing.rs similarity index 100% rename from runtime/parachains/src/slashing.rs rename to runtime/parachains/src/disputes/slashing.rs diff --git a/runtime/parachains/src/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs similarity index 100% rename from runtime/parachains/src/slashing/benchmarking.rs rename to runtime/parachains/src/disputes/slashing/benchmarking.rs diff --git a/runtime/parachains/src/lib.rs b/runtime/parachains/src/lib.rs index 8eda8313b514..2005861a6c4b 100644 --- a/runtime/parachains/src/lib.rs +++ b/runtime/parachains/src/lib.rs @@ -37,7 +37,6 @@ pub mod reward_points; pub mod scheduler; pub mod session_info; pub mod shared; -pub mod slashing; pub mod ump; pub mod runtime_api_impl; diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 939aa37bbaa5..a0c3609b6ac4 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -68,11 +68,11 @@ use sp_version::RuntimeVersion; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler, - session_info as parachains_session_info, shared as parachains_shared, - slashing as parachains_slashing, ump as parachains_ump, + session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; use bridge_runtime_common::messages::{ diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index c587e499d6c7..72ae855ca864 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -49,12 +49,12 @@ use runtime_common::{ }; use runtime_parachains::{ configuration as parachains_configuration, disputes as parachains_disputes, - dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion, - initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras, + disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp, + inclusion as parachains_inclusion, initializer as parachains_initializer, + origin as parachains_origin, paras as parachains_paras, paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points, runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler, - session_info as parachains_session_info, shared as parachains_shared, - slashing as parachains_slashing, ump as parachains_ump, + session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump, }; use scale_info::TypeInfo; use sp_core::{OpaqueMetadata, RuntimeDebug}; @@ -963,7 +963,7 @@ impl parachains_slashing::Config for Runtime { Offences, ReportLongevity, >; - type WeightInfo = weights::runtime_parachains_slashing::WeightInfo; + type WeightInfo = weights::runtime_parachains_disputes_slashing::WeightInfo; } parameter_types! { @@ -1214,7 +1214,7 @@ mod benches { [runtime_common::slots, Slots] [runtime_parachains::configuration, Configuration] [runtime_parachains::disputes, ParasDisputes] - [runtime_parachains::slashing, ParasSlashing] + [runtime_parachains::disputes::slashing, ParasSlashing] [runtime_parachains::hrmp, Hrmp] [runtime_parachains::initializer, Initializer] [runtime_parachains::paras, Paras] @@ -1652,7 +1652,7 @@ sp_api::impl_runtime_apis! { impl pallet_election_provider_support_benchmarking::Config for Runtime {} impl frame_system_benchmarking::Config for Runtime {} impl pallet_nomination_pools_benchmarking::Config for Runtime {} - impl runtime_parachains::slashing::benchmarking::Config for Runtime {} + impl runtime_parachains::disputes::slashing::benchmarking::Config for Runtime {} use xcm::latest::{ AssetId::*, Fungibility::*, Junctions::*, MultiAsset, MultiAssets, MultiLocation, diff --git a/runtime/westend/src/weights/mod.rs b/runtime/westend/src/weights/mod.rs index 2d419c3b320a..df8b55067efc 100644 --- a/runtime/westend/src/weights/mod.rs +++ b/runtime/westend/src/weights/mod.rs @@ -39,10 +39,10 @@ pub mod runtime_common_paras_registrar; pub mod runtime_common_slots; pub mod runtime_parachains_configuration; pub mod runtime_parachains_disputes; +pub mod runtime_parachains_disputes_slashing; pub mod runtime_parachains_hrmp; pub mod runtime_parachains_initializer; pub mod runtime_parachains_paras; pub mod runtime_parachains_paras_inherent; -pub mod runtime_parachains_slashing; pub mod runtime_parachains_ump; pub mod xcm; diff --git a/runtime/westend/src/weights/runtime_parachains_slashing.rs b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs similarity index 79% rename from runtime/westend/src/weights/runtime_parachains_slashing.rs rename to runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs index 60b223290a7a..5f7ab517c8cf 100644 --- a/runtime/westend/src/weights/runtime_parachains_slashing.rs +++ b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -13,10 +13,10 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -//! Autogenerated weights for `runtime_parachains::slashing` +//! Autogenerated weights for `runtime_parachains::disputes::slashing` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-06-14, STEPS: `50`, REPEAT: 2, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-06-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `redacted`, CPU: `redacted` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 @@ -26,13 +26,13 @@ // pallet // --chain=westend-dev // --steps=50 -// --repeat=2 -// --pallet=runtime_parachains::slashing +// --repeat=20 +// --pallet=runtime_parachains::disputes::slashing // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --header=./file_header.txt -// --output=./runtime/westend/src/weights/runtime_parachains_slashing.rs +// --output=./runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -41,9 +41,9 @@ use frame_support::{traits::Get, weights::Weight}; use sp_std::marker::PhantomData; -/// Weight functions for `runtime_parachains::slashing`. +/// Weight functions for `runtime_parachains::disputes::slashing`. pub struct WeightInfo(PhantomData); -impl runtime_parachains::slashing::WeightInfo for WeightInfo { +impl runtime_parachains::disputes::slashing::WeightInfo for WeightInfo { // Storage: Session CurrentIndex (r:1 w:0) // Storage: Historical HistoricalSessions (r:1 w:0) // Storage: ParasSlashing ValidatorSetCounts (r:1 w:0) @@ -60,9 +60,9 @@ impl runtime_parachains::slashing::WeightInfo for Weigh // Storage: Staking ValidatorSlashInEra (r:1 w:0) /// The range of component `n` is `[4, 1024]`. fn report_dispute_lost(n: u32, ) -> Weight { - (101_569_000 as Weight) - // Standard Error: 4_000 - .saturating_add((107_000 as Weight).saturating_mul(n as Weight)) + (84_424_000 as Weight) + // Standard Error: 0 + .saturating_add((111_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(14 as Weight)) .saturating_add(T::DbWeight::get().writes(6 as Weight)) } From 760bdc7788e2be2b2f164883bd83ed60ef923384 Mon Sep 17 00:00:00 2001 From: Andronik Date: Sat, 30 Jul 2022 15:59:03 +0200 Subject: [PATCH 43/75] Change the log target Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- runtime/parachains/src/disputes/slashing.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index d089b9adaa17..eb60cd4d1583 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -56,7 +56,7 @@ use sp_std::{ prelude::*, }; -const LOG_TARGET: &str = "runtime::slashing"; +const LOG_TARGET: &str = "runtime::parachains::slashing"; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; From f50aa7dafa639f753b6de9c9a3d827ec484da28b Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 1 Aug 2022 14:41:46 +0200 Subject: [PATCH 44/75] wrap comments with rustfmt, more docs, constants --- runtime/parachains/src/disputes.rs | 17 +++- runtime/parachains/src/disputes/slashing.rs | 88 ++++++++++++--------- 2 files changed, 63 insertions(+), 42 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 47da4bd0962e..a6d4546ca763 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -65,9 +65,17 @@ pub enum DisputeResult { } /// Punishment hooks for disputes. +/// +/// Currently, it's not possible to use +/// `>::reward_by_ids` to reward validators in a +/// previous session (era) if they are no longer in the active set. +/// For this reason, we're currently combining slashing and rewarding in one +/// interface. The rewards are distributed from (a fraction of) the slashing +/// pot. pub trait SlashingHandler { - /// Punish a series of validators who were for an invalid parablock. This is expected to be a major - /// punishment. + /// Punish a series of validators who were for an invalid parablock. This is + /// expected to be a major punishment. + /// Also distributes the rewards to `winners` from the slashing pot. fn punish_for_invalid( session: SessionIndex, candidate_hash: CandidateHash, @@ -75,8 +83,9 @@ pub trait SlashingHandler { winners: impl IntoIterator, ); - /// Punish a series of validators who were against a valid parablock. This is expected to be a minor - /// punishment. + /// Punish a series of validators who were against a valid parablock. This + /// is expected to be a minor punishment. + /// Also distributes the rewards to `winners` from the slashing pot. fn punish_against_valid( session: SessionIndex, candidate_hash: CandidateHash, diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index eb60cd4d1583..c64b44b45842 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -58,11 +58,16 @@ use sp_std::{ const LOG_TARGET: &str = "runtime::parachains::slashing"; +// These are constants, but we want to make them configurable +// via `HostConfiguration` in the future. +const SLASH_FOR_INVALID: Perbill = Perbill::from_percent(100); +const SLASH_AGAINST_VALID: Perbill = Perbill::from_percent(1); + #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; -/// Timeslots should uniquely identify offences -/// and are used for the offence deduplication. +/// Timeslots should uniquely identify offences and are used for the offence +/// deduplication. #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] pub struct DisputesTimeSlot { // The order of these matters for `derive(Ord)`. @@ -76,8 +81,8 @@ impl DisputesTimeSlot { } } -/// An offence that is filed when a series of validators lost a dispute -/// about an invalid candidate. +/// An offence that is filed when a series of validators lost a dispute about an +/// invalid candidate. #[derive(RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] pub struct ForInvalidOffence { @@ -121,12 +126,12 @@ where } fn slash_fraction(_offenders: u32, _: ValidatorSetCount) -> Perbill { - Perbill::from_percent(100) + SLASH_FOR_INVALID } } -/// An offence that is filed when a series of validators lost a dispute -/// about an valid candidate. +/// An offence that is filed when a series of validators lost a dispute about an +/// valid candidate. #[derive(RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] pub struct AgainstValidOffence { @@ -168,7 +173,7 @@ where } fn slash_fraction(_offenders: u32, _: ValidatorSetCount) -> Perbill { - Perbill::from_percent(1) + SLASH_AGAINST_VALID } } @@ -211,17 +216,18 @@ impl SlashValidatorsForDisputes> where T: Config, { - /// If in the current session, returns the identified validators. - /// `None` otherwise. + /// If in the current session, returns the identified validators. `None` + /// otherwise. fn maybe_identify_validators( session_index: SessionIndex, account_ids: &[AccountId], validators: impl IntoIterator, ) -> Option>> { - // We use `ValidatorSet::session_index` and not `shared::Pallet::session_index()` - // because at the first block of a new era, the `IdentificationOf` of a validator - // in the previous session might be missing, while `shared` pallet would return - // the same session index as being updated at the end of the block. + // We use `ValidatorSet::session_index` and not + // `shared::Pallet::session_index()` because at the first block of a new era, + // the `IdentificationOf` of a validator in the previous session might be + // missing, while `shared` pallet would return the same session index as being + // updated at the end of the block. let current_session = T::ValidatorSet::session_index(); if session_index == current_session { let fully_identified = validators @@ -354,8 +360,8 @@ pub enum SlashingOffenceKind { AgainstValid, } -/// We store most of the information about a lost dispute on chain. -/// This struct is required to identify and verify it. +/// We store most of the information about a lost dispute on chain. This struct +/// is required to identify and verify it. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct DisputeProof { /// Time slot when the dispute occured. @@ -368,17 +374,19 @@ pub struct DisputeProof { pub validator_id: ValidatorId, } -/// Indices and keys of the validators who lost a dispute and are pending slashes. +/// Indices and keys of the validators who lost a dispute and are pending +/// slashes. pub type Losers = BTreeMap; /// `AccountId`s of the validators who were on the winning side of a dispute. pub type Winners = Vec>; -/// A trait that defines methods to report an offence -/// (after the slashing report has been validated) and for submitting a -/// transaction to report a slash (from an offchain context). +/// A trait that defines methods to report an offence (after the slashing report +/// has been validated) and for submitting a transaction to report a slash (from +/// an offchain context). pub trait HandleReports { - /// The longevity, in blocks, that the offence report is valid for. When using the staking - /// pallet this should be equal to the bonding duration (in blocks, not eras). + /// The longevity, in blocks, that the offence report is valid for. When + /// using the staking pallet this should be equal to the bonding duration + /// (in blocks, not eras). type ReportLongevity: Get; /// Report a `for valid` offence. @@ -393,13 +401,15 @@ pub trait HandleReports { offence: AgainstValidOffence, ) -> Result<(), OffenceError>; - /// Returns true if the offenders at the given time slot has already been reported. + /// Returns true if the offenders at the given time slot has already been + /// reported. fn is_known_for_invalid_offence( offenders: &[T::KeyOwnerIdentification], time_slot: &DisputesTimeSlot, ) -> bool; - /// Returns true if the offenders at the given time slot has already been reported. + /// Returns true if the offenders at the given time slot has already been + /// reported. fn is_known_against_valid_offence( offenders: &[T::KeyOwnerIdentification], time_slot: &DisputesTimeSlot, @@ -480,8 +490,8 @@ pub mod pallet { /// The identification of a key owner, used when reporting slashes. type KeyOwnerIdentification: Parameter; - /// A system for proving ownership of keys, i.e. that a given key was part - /// of a validator set, needed for validating slashing reports. + /// A system for proving ownership of keys, i.e. that a given key was + /// part of a validator set, needed for validating slashing reports. type KeyOwnerProofSystem: KeyOwnerProofSystem< (KeyTypeId, ValidatorId), Proof = Self::KeyOwnerProof, @@ -489,11 +499,11 @@ pub mod pallet { >; /// The slashing report handling subsystem, defines methods to report an - /// offence (after the slashing report has been validated) and for submitting a - /// transaction to report a slash (from an offchain context). - /// NOTE: when enabling slashing report handling (i.e. this type isn't set to - /// `()`) you must use this pallet's `ValidateUnsigned` in the runtime - /// definition. + /// offence (after the slashing report has been validated) and for + /// submitting a transaction to report a slash (from an offchain + /// context). NOTE: when enabling slashing report handling (i.e. this + /// type isn't set to `()`) you must use this pallet's + /// `ValidateUnsigned` in the runtime definition. type HandleReports: HandleReports; /// Weight information for extrinsics in this pallet. @@ -549,7 +559,8 @@ pub mod pallet { InvalidSessionIndex, /// The candidate hash is invalid. InvalidCandidateHash, - /// There is no pending slash for the given validator index and time slot. + /// There is no pending slash for the given validator index and time + /// slot. InvalidValidatorIndex, /// The validator index does not match the validator id. ValidatorIndexIdMismatch, @@ -691,7 +702,8 @@ impl Pallet { /// Called by the initializer to finalize the disputes slashing pallet. fn initializer_finalize() {} - /// Called by the initializer to note a new session in the disputes slashing pallet. + /// Called by the initializer to note a new session in the disputes slashing + /// pallet. fn initializer_on_new_session( session_index: SessionIndex, validator_set_count: ValidatorSetCount, @@ -717,9 +729,10 @@ impl Pallet { } /// Methods for the `ValidateUnsigned` implementation: -/// It restricts calls to `report_dispute_lost_unsigned` to local calls (i.e. extrinsics generated -/// on this node) or that already in a block. This guarantees that only block authors can include -/// unsigned slashing reports. +/// +/// It restricts calls to `report_dispute_lost_unsigned` to local calls (i.e. +/// extrinsics generated on this node) or that already in a block. This +/// guarantees that only block authors can include unsigned slashing reports. impl Pallet { pub fn validate_unsigned(source: TransactionSource, call: &Call) -> TransactionValidity { if let Call::report_dispute_lost_unsigned { dispute_proof, key_owner_proof } = call { @@ -804,8 +817,7 @@ fn is_known_offence( /// Actual `HandleReports` implemention. /// /// When configured properly, should be instantiated with -/// `T::KeyOwnerIdentification, Offences, ReportLongevity` -/// parameters. +/// `T::KeyOwnerIdentification, Offences, ReportLongevity` parameters. pub struct SlashingReportHandler { _phantom: sp_std::marker::PhantomData<(I, R, L)>, } From 248baa57c8027c79ee75dfbd67f3f887eb32b582 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 12:56:55 +0200 Subject: [PATCH 45/75] use Defensive trait --- runtime/parachains/src/disputes/slashing.rs | 23 ++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index c64b44b45842..059a92e206b2 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -35,7 +35,7 @@ use crate::{ session_info::{AccountId, IdentificationTuple}, }; use frame_support::{ - traits::{Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, + traits::{Defensive, Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, weights::{Pays, Weight}, }; use parity_scale_codec::{Decode, Encode}; @@ -62,6 +62,7 @@ const LOG_TARGET: &str = "runtime::parachains::slashing"; // via `HostConfiguration` in the future. const SLASH_FOR_INVALID: Perbill = Perbill::from_percent(100); const SLASH_AGAINST_VALID: Perbill = Perbill::from_percent(1); +const DEFENSIVE_PROOF: &'static str = "disputes module should bail on old session"; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; @@ -201,7 +202,7 @@ impl AgainstValidOffence { } } -/// This type implements `PunishValidators`. +/// This type implements `SlashingHandler`. pub struct SlashValidatorsForDisputes { _phantom: sp_std::marker::PhantomData, } @@ -261,14 +262,11 @@ where return } let account_keys = crate::session_info::Pallet::::account_keys(session_index); - let account_ids = match account_keys { - Some(account_keys) => account_keys, - None => return, // can not really happen - }; + let account_ids = account_keys.defensive_unwrap_or_default(); let session_info = crate::session_info::Pallet::::session_info(session_index); - let session_info = match session_info { + let session_info = match session_info.defensive_proof(DEFENSIVE_PROOF) { Some(info) => info, - None => return, // can not really happen + None => return, }; let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; let winners: Winners = winners @@ -306,14 +304,11 @@ where return } let account_keys = crate::session_info::Pallet::::account_keys(session_index); - let account_ids = match account_keys { - Some(account_keys) => account_keys, - None => return, // can not really happen - }; + let account_ids = account_keys.defensive_unwrap_or_default(); let session_info = crate::session_info::Pallet::::session_info(session_index); - let session_info = match session_info { + let session_info = match session_info.defensive_proof(DEFENSIVE_PROOF) { Some(info) => info, - None => return, // can not really happen + None => return, }; let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; let winners: Winners = winners From b02bcefb616cf4112b48de5a6fb3a501a4319a56 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 13:38:26 +0200 Subject: [PATCH 46/75] cargo update -p sp-io --- Cargo.lock | 556 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 350 insertions(+), 206 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b1b9498a8e3..978ee54e4fd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -423,7 +423,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "beefy-primitives", @@ -459,12 +459,12 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-gadget", "beefy-primitives", "futures", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -479,7 +479,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-primitives", "sp-api", @@ -488,7 +488,7 @@ dependencies = [ [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -1960,7 +1960,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", ] @@ -1978,7 +1978,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -2000,7 +2000,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "Inflector", "chrono", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2078,7 +2078,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bitflags", "frame-metadata", @@ -2136,7 +2136,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2148,7 +2148,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2160,7 +2160,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro2", "quote", @@ -2170,7 +2170,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2193,7 +2193,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -2204,7 +2204,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "log", @@ -2221,7 +2221,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-api", @@ -2245,7 +2245,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "sp-api", @@ -2427,7 +2427,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "chrono", "frame-election-provider-support", @@ -2723,13 +2723,13 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 0.4.8", + "itoa 1.0.1", ] [[package]] @@ -3012,12 +3012,27 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11e017217fcd18da0a25296d3693153dd19c8a6aadab330b3595285d075385d1" dependencies = [ - "jsonrpsee-core", - "jsonrpsee-http-server", - "jsonrpsee-proc-macros", - "jsonrpsee-types", - "jsonrpsee-ws-client", - "jsonrpsee-ws-server", + "jsonrpsee-core 0.14.0", + "jsonrpsee-http-server 0.14.0", + "jsonrpsee-proc-macros 0.14.0", + "jsonrpsee-types 0.14.0", + "jsonrpsee-ws-client 0.14.0", + "jsonrpsee-ws-server 0.14.0", + "tracing", +] + +[[package]] +name = "jsonrpsee" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bd0d559d5e679b1ab2f869b486a11182923863b1b3ee8b421763cdd707b783a" +dependencies = [ + "jsonrpsee-core 0.15.1", + "jsonrpsee-http-server 0.15.1", + "jsonrpsee-proc-macros 0.15.1", + "jsonrpsee-types 0.15.1", + "jsonrpsee-ws-client 0.15.1", + "jsonrpsee-ws-server 0.15.1", "tracing", ] @@ -3029,8 +3044,29 @@ checksum = "ce395539a14d3ad4ec1256fde105abd36a2da25d578a291cabe98f45adfdb111" dependencies = [ "futures-util", "http", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.14.0", + "jsonrpsee-types 0.14.0", + "pin-project", + "rustls-native-certs", + "soketto", + "thiserror", + "tokio", + "tokio-rustls", + "tokio-util 0.7.1", + "tracing", + "webpki-roots", +] + +[[package]] +name = "jsonrpsee-client-transport" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8752740ecd374bcbf8b69f3e80b0327942df76f793f8d4e60d3355650c31fb74" +dependencies = [ + "futures-util", + "http", + "jsonrpsee-core 0.15.1", + "jsonrpsee-types 0.15.1", "pin-project", "rustls-native-certs", "soketto", @@ -3058,7 +3094,38 @@ dependencies = [ "futures-util", "globset", "hyper", - "jsonrpsee-types", + "jsonrpsee-types 0.14.0", + "lazy_static", + "parking_lot 0.12.0", + "rand 0.8.5", + "rustc-hash", + "serde", + "serde_json", + "soketto", + "thiserror", + "tokio", + "tracing", + "unicase", +] + +[[package]] +name = "jsonrpsee-core" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3dc3e9cf2ba50b7b1d7d76a667619f82846caa39e8e8daa8a4962d74acaddca" +dependencies = [ + "anyhow", + "arrayvec 0.7.2", + "async-lock", + "async-trait", + "beef", + "futures-channel", + "futures-timer", + "futures-util", + "globset", + "http", + "hyper", + "jsonrpsee-types 0.15.1", "lazy_static", "parking_lot 0.12.0", "rand 0.8.5", @@ -3069,6 +3136,7 @@ dependencies = [ "thiserror", "tokio", "tracing", + "tracing-futures", "unicase", ] @@ -3081,12 +3149,30 @@ dependencies = [ "futures-channel", "futures-util", "hyper", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.14.0", + "jsonrpsee-types 0.14.0", + "serde", + "serde_json", + "tokio", + "tracing", +] + +[[package]] +name = "jsonrpsee-http-server" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03802f0373a38c2420c70b5144742d800b509e2937edc4afb116434f07120117" +dependencies = [ + "futures-channel", + "futures-util", + "hyper", + "jsonrpsee-core 0.15.1", + "jsonrpsee-types 0.15.1", "serde", "serde_json", "tokio", "tracing", + "tracing-futures", ] [[package]] @@ -3101,6 +3187,18 @@ dependencies = [ "syn", ] +[[package]] +name = "jsonrpsee-proc-macros" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd67957d4280217247588ac86614ead007b301ca2fa9f19c19f880a536f029e3" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "jsonrpsee-types" version = "0.14.0" @@ -3115,15 +3213,41 @@ dependencies = [ "tracing", ] +[[package]] +name = "jsonrpsee-types" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e290bba767401b646812f608c099b922d8142603c9e73a50fb192d3ac86f4a0d" +dependencies = [ + "anyhow", + "beef", + "serde", + "serde_json", + "thiserror", + "tracing", +] + [[package]] name = "jsonrpsee-ws-client" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee043cb5dd0d51d3eb93432e998d5bae797691a7b10ec4a325e036bcdb48c48a" dependencies = [ - "jsonrpsee-client-transport", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-client-transport 0.14.0", + "jsonrpsee-core 0.14.0", + "jsonrpsee-types 0.14.0", +] + +[[package]] +name = "jsonrpsee-ws-client" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee5feddd5188e62ac08fcf0e56478138e581509d4730f3f7be9b57dd402a4ff" +dependencies = [ + "http", + "jsonrpsee-client-transport 0.15.1", + "jsonrpsee-core 0.15.1", + "jsonrpsee-types 0.15.1", ] [[package]] @@ -3134,8 +3258,8 @@ checksum = "2bd2e4d266774a671f8def3794255b28eddd09b18d76e0b913fa439f34588c0a" dependencies = [ "futures-channel", "futures-util", - "jsonrpsee-core", - "jsonrpsee-types", + "jsonrpsee-core 0.14.0", + "jsonrpsee-types 0.14.0", "serde_json", "soketto", "tokio", @@ -3144,6 +3268,26 @@ dependencies = [ "tracing", ] +[[package]] +name = "jsonrpsee-ws-server" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d488ba74fb369e5ab68926feb75a483458b88e768d44319f37e4ecad283c7325" +dependencies = [ + "futures-channel", + "futures-util", + "http", + "jsonrpsee-core 0.15.1", + "jsonrpsee-types 0.15.1", + "serde_json", + "soketto", + "tokio", + "tokio-stream", + "tokio-util 0.7.1", + "tracing", + "tracing-futures", +] + [[package]] name = "k256" version = "0.10.4" @@ -4791,7 +4935,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4805,7 +4949,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -4821,7 +4965,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -4836,7 +4980,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4860,7 +5004,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -4880,7 +5024,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-election-provider-support", "frame-support", @@ -4899,7 +5043,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4914,7 +5058,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-primitives", "frame-support", @@ -4930,7 +5074,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -4953,7 +5097,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4971,7 +5115,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4990,7 +5134,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5007,7 +5151,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5023,7 +5167,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5046,7 +5190,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5059,7 +5203,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5077,7 +5221,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5092,7 +5236,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5115,7 +5259,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5131,7 +5275,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5151,7 +5295,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5168,7 +5312,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5185,7 +5329,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5203,9 +5347,9 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.15.1", "parity-scale-codec", "serde", "sp-api", @@ -5218,7 +5362,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5233,7 +5377,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5250,7 +5394,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5269,7 +5413,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-api", @@ -5279,7 +5423,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5296,7 +5440,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5319,7 +5463,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5335,7 +5479,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5350,7 +5494,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5365,7 +5509,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5381,7 +5525,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5402,7 +5546,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5418,7 +5562,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5432,7 +5576,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5455,7 +5599,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5466,7 +5610,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "sp-arithmetic", @@ -5475,7 +5619,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5489,7 +5633,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5507,7 +5651,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5526,7 +5670,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5542,9 +5686,9 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.15.1", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -5557,7 +5701,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5568,7 +5712,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5585,7 +5729,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5601,7 +5745,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -6887,7 +7031,7 @@ version = "0.9.27" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", - "jsonrpsee", + "jsonrpsee 0.14.0", "pallet-mmr-rpc", "pallet-transaction-payment-rpc", "polkadot-primitives", @@ -8067,10 +8211,10 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "env_logger 0.9.0", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "serde", @@ -8409,7 +8553,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "sp-core", @@ -8420,7 +8564,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -8447,7 +8591,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "futures-timer", @@ -8470,7 +8614,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8486,7 +8630,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -8503,7 +8647,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8514,7 +8658,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "chrono", "clap", @@ -8553,7 +8697,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "fnv", "futures", @@ -8581,7 +8725,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "kvdb", @@ -8606,7 +8750,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -8630,7 +8774,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "fork-tree", @@ -8672,10 +8816,10 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", - "jsonrpsee", + "jsonrpsee 0.15.1", "sc-consensus-babe", "sc-consensus-epochs", "sc-rpc-api", @@ -8694,7 +8838,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8707,7 +8851,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -8732,7 +8876,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "lazy_static", "lru 0.7.7", @@ -8759,7 +8903,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "environmental", "parity-scale-codec", @@ -8776,7 +8920,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -8791,7 +8935,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8811,7 +8955,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ahash", "async-trait", @@ -8852,11 +8996,11 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "finality-grandpa", "futures", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "sc-client-api", @@ -8873,7 +9017,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ansi_term", "futures", @@ -8890,7 +9034,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "hex", @@ -8905,7 +9049,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "asynchronous-codec", @@ -8954,7 +9098,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bitflags", "futures", @@ -8972,7 +9116,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ahash", "futures", @@ -8989,7 +9133,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "libp2p", @@ -9009,7 +9153,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "fork-tree", "futures", @@ -9036,7 +9180,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bytes", "fnv", @@ -9064,7 +9208,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "libp2p", @@ -9077,7 +9221,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9086,11 +9230,11 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "hash-db", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -9116,10 +9260,10 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -9139,10 +9283,10 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "serde_json", "substrate-prometheus-endpoint", @@ -9152,7 +9296,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "directories", @@ -9160,7 +9304,7 @@ dependencies = [ "futures", "futures-timer", "hash-db", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "parity-util-mem", @@ -9219,7 +9363,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -9233,9 +9377,9 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.15.1", "parity-scale-codec", "sc-chain-spec", "sc-client-api", @@ -9252,7 +9396,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "libc", @@ -9271,7 +9415,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "chrono", "futures", @@ -9289,7 +9433,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ansi_term", "atty", @@ -9320,7 +9464,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9331,7 +9475,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "futures-timer", @@ -9357,7 +9501,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "log", @@ -9370,7 +9514,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "futures-timer", @@ -9855,7 +9999,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "log", @@ -9872,7 +10016,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "blake2", "proc-macro-crate", @@ -9884,7 +10028,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -9897,7 +10041,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "integer-sqrt", "num-traits", @@ -9912,7 +10056,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -9925,7 +10069,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "parity-scale-codec", @@ -9937,7 +10081,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-api", @@ -9949,7 +10093,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "log", @@ -9967,7 +10111,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -9986,7 +10130,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "merlin", @@ -10009,7 +10153,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10023,7 +10167,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10036,7 +10180,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "base58", "bitflags", @@ -10082,7 +10226,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "blake2", "byteorder", @@ -10096,7 +10240,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro2", "quote", @@ -10107,7 +10251,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "kvdb", "parking_lot 0.12.0", @@ -10116,7 +10260,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro2", "quote", @@ -10126,7 +10270,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "environmental", "parity-scale-codec", @@ -10137,7 +10281,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "finality-grandpa", "log", @@ -10155,7 +10299,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10169,7 +10313,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bytes", "futures", @@ -10195,7 +10339,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "lazy_static", "sp-core", @@ -10206,7 +10350,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -10223,7 +10367,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "thiserror", "zstd", @@ -10232,7 +10376,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -10247,7 +10391,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10261,7 +10405,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "sp-api", "sp-core", @@ -10271,7 +10415,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "backtrace", "lazy_static", @@ -10281,7 +10425,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "rustc-hash", "serde", @@ -10291,7 +10435,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "either", "hash256-std-hasher", @@ -10313,7 +10457,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10331,7 +10475,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "Inflector", "proc-macro-crate", @@ -10343,7 +10487,7 @@ dependencies = [ [[package]] name = "sp-sandbox" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -10357,7 +10501,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "serde", "serde_json", @@ -10366,7 +10510,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10380,7 +10524,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10391,7 +10535,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "log", @@ -10413,12 +10557,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10431,7 +10575,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "sp-core", @@ -10444,7 +10588,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures-timer", @@ -10460,7 +10604,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-std", @@ -10472,7 +10616,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "sp-api", "sp-runtime", @@ -10481,7 +10625,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "log", @@ -10497,7 +10641,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "memory-db", @@ -10513,7 +10657,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10530,7 +10674,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10541,7 +10685,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-trait-for-tuples", "log", @@ -10589,7 +10733,7 @@ dependencies = [ "frame-support", "frame-system", "futures-util", - "jsonrpsee", + "jsonrpsee 0.14.0", "kusama-runtime", "log", "pallet-balances", @@ -10715,7 +10859,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "platforms", ] @@ -10723,11 +10867,11 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-system-rpc-runtime-api", "futures", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "sc-client-api", @@ -10744,7 +10888,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures-util", "hyper", @@ -10757,9 +10901,9 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "sc-client-api", @@ -10778,7 +10922,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -10804,7 +10948,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "substrate-test-utils-derive", @@ -10814,7 +10958,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10825,7 +10969,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ansi_term", "build-helper", @@ -11539,10 +11683,10 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#494a2883e14a389e1c090475077d0c745fefc6c3" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "clap", - "jsonrpsee", + "jsonrpsee 0.15.1", "log", "parity-scale-codec", "remote-externalities", From e1c87c47cb114b005fcdad439eb28b5fb396095c Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:01:05 +0200 Subject: [PATCH 47/75] merge offence types, remove rewards for now --- runtime/parachains/src/disputes.rs | 12 +- runtime/parachains/src/disputes/slashing.rs | 470 ++++++-------------- runtime/parachains/src/initializer.rs | 3 +- runtime/parachains/src/mock.rs | 4 +- 4 files changed, 151 insertions(+), 338 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index a6d4546ca763..98157180f728 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -18,7 +18,7 @@ use crate::{ configuration, - initializer::{SessionChangeNotification, ValidatorSetCount}, + initializer::SessionChangeNotification, session_info, }; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; @@ -80,7 +80,6 @@ pub trait SlashingHandler { session: SessionIndex, candidate_hash: CandidateHash, losers: impl IntoIterator, - winners: impl IntoIterator, ); /// Punish a series of validators who were against a valid parablock. This @@ -90,7 +89,6 @@ pub trait SlashingHandler { session: SessionIndex, candidate_hash: CandidateHash, losers: impl IntoIterator, - winners: impl IntoIterator, ); /// Called by the initializer to initialize the slashing pallet. @@ -100,7 +98,7 @@ pub trait SlashingHandler { fn initializer_finalize(); /// Called by the initializer to note that a new session has started. - fn initializer_on_new_session(session_index: SessionIndex, count: ValidatorSetCount); + fn initializer_on_new_session(session_index: SessionIndex); } impl SlashingHandler for () { @@ -108,7 +106,6 @@ impl SlashingHandler for () { _: SessionIndex, _: CandidateHash, _: impl IntoIterator, - _: impl IntoIterator, ) { } @@ -116,7 +113,6 @@ impl SlashingHandler for () { _: SessionIndex, _: CandidateHash, _: impl IntoIterator, - _: impl IntoIterator, ) { } @@ -126,7 +122,7 @@ impl SlashingHandler for () { fn initializer_finalize() {} - fn initializer_on_new_session(_: SessionIndex, _: ValidatorSetCount) {} + fn initializer_on_new_session(_: SessionIndex) {} } /// Binary discriminator to determine if the expensive signature @@ -1245,7 +1241,6 @@ impl Pallet { session, candidate_hash, summary.slash_against, - summary.state.validators_for.iter_ones().map(|i| ValidatorIndex(i as _)), ); // an invalid candidate, according to 2/3. Punish those on the 'for' side. @@ -1253,7 +1248,6 @@ impl Pallet { session, candidate_hash, summary.slash_for, - summary.state.validators_against.iter_ones().map(|i| ValidatorIndex(i as _)), ); } diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 059a92e206b2..b86b994fd280 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -82,11 +82,10 @@ impl DisputesTimeSlot { } } -/// An offence that is filed when a series of validators lost a dispute about an -/// invalid candidate. +/// An offence that is filed when a series of validators lost a dispute. #[derive(RuntimeDebug, TypeInfo)] #[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] -pub struct ForInvalidOffence { +pub struct SlashingOffence { /// The size of the validator set in that session. pub validator_set_count: ValidatorSetCount, /// Should be unique per dispute. @@ -94,62 +93,19 @@ pub struct ForInvalidOffence { /// Staking information about the validators that lost the dispute /// needed for slashing. pub offenders: Vec, -} - -impl Offence for ForInvalidOffence -where - Offender: Clone, -{ - const ID: Kind = *b"disputes:invalid"; - - type TimeSlot = DisputesTimeSlot; - - fn offenders(&self) -> Vec { - self.offenders.clone() - } - - fn session_index(&self) -> SessionIndex { - self.time_slot.session_index - } - - fn validator_set_count(&self) -> ValidatorSetCount { - self.validator_set_count - } - - fn time_slot(&self) -> Self::TimeSlot { - self.time_slot.clone() - } - - fn disable_strategy(&self) -> DisableStrategy { - // The default is `DisableStrategy::DisableWhenSlashed` - // which is true for this offence type, but we're being explicit - DisableStrategy::Always - } + /// What fraction of the total exposure that should be slashed for + /// this offence. + pub slash_fraction: Perbill, + /// Whether the candidate was valid or invalid. + pub kind: SlashingOffenceKind, - fn slash_fraction(_offenders: u32, _: ValidatorSetCount) -> Perbill { - SLASH_FOR_INVALID - } } -/// An offence that is filed when a series of validators lost a dispute about an -/// valid candidate. -#[derive(RuntimeDebug, TypeInfo)] -#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))] -pub struct AgainstValidOffence { - /// The size of the validator set in that session. - pub validator_set_count: ValidatorSetCount, - /// Should be unique per dispute. - pub time_slot: DisputesTimeSlot, - /// Staking information about the validators that lost the dispute - /// needed for slashing. - pub offenders: Vec, -} - -impl Offence for AgainstValidOffence +impl Offence for SlashingOffence where Offender: Clone, { - const ID: Kind = *b"disputes:valid::"; + const ID: Kind = *b"disputes:slashin"; type TimeSlot = DisputesTimeSlot; @@ -170,35 +126,32 @@ where } fn disable_strategy(&self) -> DisableStrategy { - DisableStrategy::Never - } - - fn slash_fraction(_offenders: u32, _: ValidatorSetCount) -> Perbill { - SLASH_AGAINST_VALID + match self.kind { + SlashingOffenceKind::ForInvalid => DisableStrategy::Always, + // in the future we might change it based on number of disputes initiated + SlashingOffenceKind::AgainstValid => DisableStrategy::Never, + } } -} -impl ForInvalidOffence { - fn new( - session_index: SessionIndex, - candidate_hash: CandidateHash, - validator_set_count: ValidatorSetCount, - offender: KeyOwnerIdentification, - ) -> Self { - let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); - Self { time_slot, validator_set_count, offenders: vec![offender] } + fn slash_fraction(&self, _offenders: u32) -> Perbill { + self.slash_fraction } } -impl AgainstValidOffence { +impl SlashingOffence { fn new( session_index: SessionIndex, candidate_hash: CandidateHash, validator_set_count: ValidatorSetCount, - offender: KeyOwnerIdentification, + offenders: Vec, + kind: SlashingOffenceKind, ) -> Self { let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); - Self { time_slot, validator_set_count, offenders: vec![offender] } + let slash_fraction = match kind { + SlashingOffenceKind::ForInvalid => SLASH_FOR_INVALID, + SlashingOffenceKind::AgainstValid => SLASH_AGAINST_VALID, + }; + Self { time_slot, validator_set_count, offenders, slash_fraction, kind } } } @@ -215,7 +168,7 @@ impl Default for SlashValidatorsForDisputes { impl SlashValidatorsForDisputes> where - T: Config, + T: Config>, { /// If in the current session, returns the identified validators. `None` /// otherwise. @@ -244,17 +197,12 @@ where } None } -} -impl disputes::SlashingHandler for SlashValidatorsForDisputes> -where - T: Config>, -{ - fn punish_for_invalid( + fn do_punish( session_index: SessionIndex, candidate_hash: CandidateHash, + kind: SlashingOffenceKind, losers: impl IntoIterator, - winners: impl IntoIterator, ) { let losers: Vec = losers.into_iter().collect(); if losers.is_empty() { @@ -269,69 +217,55 @@ where None => return, }; let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; - let winners: Winners = winners - .into_iter() - .filter_map(|i| account_ids.get(i.0 as usize).cloned()) - .collect(); let maybe = Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); if let Some(offenders) = maybe { - let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); - let offence = ForInvalidOffence { validator_set_count, time_slot, offenders }; + let offence = SlashingOffence::new( + session_index, + candidate_hash, + validator_set_count, + offenders, + kind, + ); + let reporter = None; // This is the first time we report an offence for this dispute, // so it is not a duplicate. - let _ = T::HandleReports::report_for_invalid_offence(winners, offence); + let _ = T::HandleReports::report_offence(reporter, offence); return } - let losers: Losers = losers + let keys = losers .into_iter() .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) .collect(); - >::insert(session_index, candidate_hash, losers); - >::insert(session_index, candidate_hash, winners); + let unapplied = PendingSlashes { + keys, + kind, + }; + >::insert(session_index, candidate_hash, unapplied); } +} - fn punish_against_valid( +impl disputes::SlashingHandler for SlashValidatorsForDisputes> +where + T: Config>, +{ + fn punish_for_invalid( session_index: SessionIndex, candidate_hash: CandidateHash, losers: impl IntoIterator, - winners: impl IntoIterator, ) { - let losers: Vec = losers.into_iter().collect(); - if losers.is_empty() { - // Nothing to do - return - } - let account_keys = crate::session_info::Pallet::::account_keys(session_index); - let account_ids = account_keys.defensive_unwrap_or_default(); - let session_info = crate::session_info::Pallet::::session_info(session_index); - let session_info = match session_info.defensive_proof(DEFENSIVE_PROOF) { - Some(info) => info, - None => return, - }; - let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; - let winners: Winners = winners - .into_iter() - .filter_map(|i| account_ids.get(i.0 as usize).cloned()) - .collect(); - let maybe = - Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); - if let Some(offenders) = maybe { - let time_slot = DisputesTimeSlot::new(session_index, candidate_hash); - let offence = AgainstValidOffence { validator_set_count, time_slot, offenders }; - // This is the first time we report an offence for this dispute, - // so it is not a duplicate. - let _ = T::HandleReports::report_against_valid_offence(winners, offence); - return - } + let kind = SlashingOffenceKind::ForInvalid; + Self::do_punish(session_index, candidate_hash, kind, losers); + } - let losers: Losers = losers - .into_iter() - .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) - .collect(); - >::insert(session_index, candidate_hash, losers); - >::insert(session_index, candidate_hash, winners); + fn punish_against_valid( + session_index: SessionIndex, + candidate_hash: CandidateHash, + losers: impl IntoIterator, + ) { + let kind = SlashingOffenceKind::AgainstValid; + Self::do_punish(session_index, candidate_hash, kind, losers); } fn initializer_initialize(now: T::BlockNumber) -> Weight { @@ -342,8 +276,8 @@ where Pallet::::initializer_finalize() } - fn initializer_on_new_session(session_index: SessionIndex, count: ValidatorSetCount) { - Pallet::::initializer_on_new_session(session_index, count) + fn initializer_on_new_session(session_index: SessionIndex) { + Pallet::::initializer_on_new_session(session_index) } } @@ -369,11 +303,15 @@ pub struct DisputeProof { pub validator_id: ValidatorId, } -/// Indices and keys of the validators who lost a dispute and are pending -/// slashes. -pub type Losers = BTreeMap; -/// `AccountId`s of the validators who were on the winning side of a dispute. -pub type Winners = Vec>; +/// Slashes that are waiting to be applied once we have validator key identification. +#[derive(Encode, Decode, RuntimeDebug, TypeInfo)] +pub struct PendingSlashes { + /// Indices and keys of the validators who lost a dispute and are pending + /// slashes. + pub keys: BTreeMap, + /// The dispute outcome. + pub kind: SlashingOffenceKind, +} /// A trait that defines methods to report an offence (after the slashing report /// has been validated) and for submitting a transaction to report a slash (from @@ -385,30 +323,20 @@ pub trait HandleReports { type ReportLongevity: Get; /// Report a `for valid` offence. - fn report_for_invalid_offence( - reporters: Vec>, - offence: ForInvalidOffence, - ) -> Result<(), OffenceError>; - - /// Report an against invalid offence. - fn report_against_valid_offence( - reporters: Vec>, - offence: AgainstValidOffence, + fn report_offence( + reporter: Option>, + offence: SlashingOffence, ) -> Result<(), OffenceError>; /// Returns true if the offenders at the given time slot has already been /// reported. - fn is_known_for_invalid_offence( + fn is_known_offence( offenders: &[T::KeyOwnerIdentification], time_slot: &DisputesTimeSlot, ) -> bool; - /// Returns true if the offenders at the given time slot has already been - /// reported. - fn is_known_against_valid_offence( - offenders: &[T::KeyOwnerIdentification], - time_slot: &DisputesTimeSlot, - ) -> bool; + /// Fetch the current block author id, if defined. + fn block_author() -> Option>; /// Create and dispatch a slashing report extrinsic. /// This should be called offchain. @@ -421,28 +349,14 @@ pub trait HandleReports { impl HandleReports for () { type ReportLongevity = (); - fn report_for_invalid_offence( - _reporters: Vec>, - _offence: ForInvalidOffence, + fn report_offence( + _reporter: Option>, + _offence: SlashingOffence, ) -> Result<(), OffenceError> { Ok(()) } - fn report_against_valid_offence( - _reporters: Vec>, - _offence: AgainstValidOffence, - ) -> Result<(), OffenceError> { - Ok(()) - } - - fn is_known_for_invalid_offence( - _offenders: &[T::KeyOwnerIdentification], - _time_slot: &DisputesTimeSlot, - ) -> bool { - true - } - - fn is_known_against_valid_offence( + fn is_known_offence( _offenders: &[T::KeyOwnerIdentification], _time_slot: &DisputesTimeSlot, ) -> bool { @@ -455,6 +369,10 @@ impl HandleReports for () { ) -> DispatchResult { Ok(()) } + + fn block_author() -> Option> { + None + } } pub trait WeightInfo { @@ -509,43 +427,16 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(_); - /// Indices of the validators pending "for invalid" dispute slashes. + /// Validators pending dispute slashes. #[pallet::storage] - pub(super) type PendingForInvalidLosers = - StorageDoubleMap<_, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, Losers>; - - /// Indices of the validators who won in "for invalid" disputes. - #[pallet::storage] - pub(super) type ForInvalidWinners = StorageDoubleMap< - _, - Twox64Concat, - SessionIndex, - Blake2_128Concat, - CandidateHash, - Winners, - >; + pub(super) type UnappliedSlashes = + StorageDoubleMap<_, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, PendingSlashes>; /// `ValidatorSetCount` per session. #[pallet::storage] pub(super) type ValidatorSetCounts = StorageMap<_, Twox64Concat, SessionIndex, ValidatorSetCount>; - /// Indices of the validators pending "against valid" dispute slashes. - #[pallet::storage] - pub(super) type PendingAgainstValidLosers = - StorageDoubleMap<_, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, Losers>; - - /// Indices of the validators who won in "against valid" disputes. - #[pallet::storage] - pub(super) type AgainstValidWinners = StorageDoubleMap< - _, - Twox64Concat, - SessionIndex, - Blake2_128Concat, - CandidateHash, - Winners, - >; - #[pallet::error] pub enum Error { /// The key ownership proof is invalid. @@ -582,94 +473,56 @@ pub mod pallet { .ok_or(Error::::InvalidKeyOwnershipProof)?; let session_index = dispute_proof.time_slot.session_index; - let validator_set_count = >::get(session_index) - .ok_or(Error::::InvalidSessionIndex)?; + let validator_set_count = crate::session_info::Pallet::::session_info(session_index) + .ok_or(Error::::InvalidSessionIndex)? + .discovery_keys.len() as ValidatorSetCount; // check that there is a pending slash for the given // validator index and candidate hash let candidate_hash = dispute_proof.time_slot.candidate_hash; - let try_remove = |v: &mut Option| -> Result { - let indices = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; + let try_remove = |v: &mut Option| -> Result<(), DispatchError> { + let pending = v.as_mut().ok_or(Error::::InvalidCandidateHash)?; + if pending.kind != dispute_proof.kind { + return Err(Error::::InvalidCandidateHash.into()) + } - match indices.entry(dispute_proof.validator_index) { + match pending.keys.entry(dispute_proof.validator_index) { Entry::Vacant(_) => return Err(Error::::InvalidValidatorIndex.into()), // check that `validator_index` matches `validator_id` Entry::Occupied(e) if e.get() != &dispute_proof.validator_id => return Err(Error::::ValidatorIndexIdMismatch.into()), Entry::Occupied(e) => { - e.remove(); // all good + e.remove(); // the report is correct }, } - let is_empty = if indices.is_empty() { + // if the last validator is slashed for this dispute, clean up the storage + if pending.keys.is_empty() { *v = None; - true - } else { - false - }; + } - Ok(is_empty) + Ok(()) }; - match dispute_proof.kind { - SlashingOffenceKind::ForInvalid => { - let is_empty = >::try_mutate_exists( - &session_index, - &candidate_hash, - try_remove, - )?; - - let winners = if is_empty { - >::take(&session_index, &candidate_hash) - .unwrap_or_default() - } else { - >::get(&session_index, &candidate_hash) - .unwrap_or_default() - }; - - let offence = ForInvalidOffence::new( - session_index, - candidate_hash, - validator_set_count, - offender, - ); - // We can't really submit a duplicate report - // unless there's a bug. - >::report_for_invalid_offence( - winners, offence, - ) - .map_err(|_| Error::::DuplicateSlashingReport)?; - }, - SlashingOffenceKind::AgainstValid => { - let is_empty = >::try_mutate_exists( - &session_index, - &candidate_hash, - try_remove, - )?; - - let winners = if is_empty { - >::take(&session_index, &candidate_hash) - .unwrap_or_default() - } else { - >::get(&session_index, &candidate_hash) - .unwrap_or_default() - }; - - // submit an offence report - let offence = AgainstValidOffence::new( - session_index, - candidate_hash, - validator_set_count, - offender, - ); - // We can't really submit a duplicate report - // unless there's a bug. - >::report_against_valid_offence( - winners, offence, - ) - .map_err(|_| Error::::DuplicateSlashingReport)?; - }, - } + >::try_mutate_exists( + &session_index, + &candidate_hash, + try_remove, + )?; + + let offence = SlashingOffence::new( + session_index, + candidate_hash, + validator_set_count, + vec![offender], + dispute_proof.kind, + ); + + let block_author = >::block_author(); + >::report_offence( + block_author, offence, + ) + .map_err(|_| Error::::DuplicateSlashingReport)?; Ok(Pays::No.into()) } @@ -699,11 +552,9 @@ impl Pallet { /// Called by the initializer to note a new session in the disputes slashing /// pallet. - fn initializer_on_new_session( - session_index: SessionIndex, - validator_set_count: ValidatorSetCount, - ) { - >::insert(session_index, validator_set_count); + fn initializer_on_new_session(session_index: SessionIndex) { + // This should be small, as disputes are limited by spam slots, so no limit is fine. + const REMOVE_LIMIT: u32 = u32::MAX; let config = >::config(); if session_index <= config.dispute_period + 1 { @@ -711,15 +562,7 @@ impl Pallet { } let old_session = session_index - config.dispute_period - 1; - - // This should be small, as disputes are rare, so no limit is fine. - const REMOVE_LIMIT: u32 = u32::MAX; - let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); - let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); - let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); - let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); - - >::remove(old_session); + let _ = >::clear_prefix(old_session, REMOVE_LIMIT, None); } } @@ -789,18 +632,10 @@ fn is_known_offence( // check if the offence has already been reported, // and if so then we can discard the report. - let is_known_offence = match dispute_proof.kind { - SlashingOffenceKind::ForInvalid => - >::is_known_for_invalid_offence( - &[offender], - &dispute_proof.time_slot, - ), - SlashingOffenceKind::AgainstValid => - >::is_known_against_valid_offence( - &[offender], - &dispute_proof.time_slot, - ), - }; + let is_known_offence = >::is_known_offence( + &[offender], + &dispute_proof.time_slot, + ); if is_known_offence { Err(InvalidTransaction::Stale.into()) @@ -825,53 +660,34 @@ impl Default for SlashingReportHandler { impl HandleReports for SlashingReportHandler where - T: Config + frame_system::offchain::SendTransactionTypes>, + T: Config + + frame_system::offchain::SendTransactionTypes> + + pallet_authorship::Config, R: ReportOffence< - AccountId, - T::KeyOwnerIdentification, - ForInvalidOffence, - > + ReportOffence< - AccountId, - T::KeyOwnerIdentification, - AgainstValidOffence, - >, + AccountId, + T::KeyOwnerIdentification, + SlashingOffence, + >, L: Get, { type ReportLongevity = L; - fn report_for_invalid_offence( - reporters: Vec>, - offence: ForInvalidOffence, - ) -> Result<(), OffenceError> { - R::report_offence(reporters, offence) - } - - fn report_against_valid_offence( - reporters: Vec>, - offence: AgainstValidOffence, + fn report_offence( + reporter: Option>, + offence: SlashingOffence, ) -> Result<(), OffenceError> { + let reporters = reporter.into_iter().collect(); R::report_offence(reporters, offence) } - fn is_known_for_invalid_offence( - offenders: &[T::KeyOwnerIdentification], - time_slot: &DisputesTimeSlot, - ) -> bool { - , - T::KeyOwnerIdentification, - ForInvalidOffence, - >>::is_known_offence(offenders, time_slot) - } - - fn is_known_against_valid_offence( + fn is_known_offence( offenders: &[T::KeyOwnerIdentification], time_slot: &DisputesTimeSlot, ) -> bool { , T::KeyOwnerIdentification, - AgainstValidOffence, + SlashingOffence, >>::is_known_offence(offenders, time_slot) } @@ -909,4 +725,10 @@ where Ok(()) } + + fn block_author() -> Option> { + // TODO + // >::author() + None + } } diff --git a/runtime/parachains/src/initializer.rs b/runtime/parachains/src/initializer.rs index 5876df3ecb16..a5634bf48419 100644 --- a/runtime/parachains/src/initializer.rs +++ b/runtime/parachains/src/initializer.rs @@ -245,7 +245,6 @@ impl Pallet { configuration::Pallet::::initializer_on_new_session(&session_index); let new_config = new_config.unwrap_or_else(|| prev_config.clone()); - let validator_set_count = all_validators.len() as ValidatorSetCount; let validators = shared::Pallet::::initializer_on_new_session( session_index, random_seed.clone(), @@ -267,7 +266,7 @@ impl Pallet { inclusion::Pallet::::initializer_on_new_session(¬ification); session_info::Pallet::::initializer_on_new_session(¬ification); T::DisputesHandler::initializer_on_new_session(¬ification); - T::SlashingHandler::initializer_on_new_session(session_index, validator_set_count); + T::SlashingHandler::initializer_on_new_session(session_index); dmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); ump::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); hrmp::Pallet::::initializer_on_new_session(¬ification, &outgoing_paras); diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 87c1c8d3e84e..a07c2c8a551f 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -256,7 +256,6 @@ impl crate::disputes::SlashingHandler for Test { session: SessionIndex, _: CandidateHash, losers: impl IntoIterator, - _winners: impl IntoIterator, ) { PUNISH_VALIDATORS_FOR.with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) } @@ -265,7 +264,6 @@ impl crate::disputes::SlashingHandler for Test { session: SessionIndex, _: CandidateHash, losers: impl IntoIterator, - _winners: impl IntoIterator, ) { PUNISH_VALIDATORS_AGAINST .with(|r| r.borrow_mut().push((session, losers.into_iter().collect()))) @@ -277,7 +275,7 @@ impl crate::disputes::SlashingHandler for Test { fn initializer_finalize() {} - fn initializer_on_new_session(_: SessionIndex, _: u32) {} + fn initializer_on_new_session(_: SessionIndex) {} } impl crate::scheduler::Config for Test {} From b5314904a5839a631b311b4b6fac2633d198e0ab Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:02:49 +0200 Subject: [PATCH 48/75] cargo update -p sp-io --- Cargo.lock | 528 ++++++++++++++++++++--------------------------------- 1 file changed, 198 insertions(+), 330 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd6142b63028..a670594f5c37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -423,7 +423,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "beefy-primitives", @@ -459,12 +459,12 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-gadget", "beefy-primitives", "futures", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -479,7 +479,7 @@ dependencies = [ [[package]] name = "beefy-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-primitives", "sp-api", @@ -488,7 +488,7 @@ dependencies = [ [[package]] name = "beefy-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -1960,7 +1960,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", ] @@ -1978,7 +1978,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -2000,7 +2000,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "Inflector", "chrono", @@ -2051,7 +2051,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2078,7 +2078,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -2106,7 +2106,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bitflags", "frame-metadata", @@ -2136,7 +2136,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "Inflector", "frame-support-procedural-tools", @@ -2148,7 +2148,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2160,7 +2160,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro2", "quote", @@ -2170,7 +2170,7 @@ dependencies = [ [[package]] name = "frame-support-test" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-support-test-pallet", @@ -2193,7 +2193,7 @@ dependencies = [ [[package]] name = "frame-support-test-pallet" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -2204,7 +2204,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "log", @@ -2221,7 +2221,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-api", @@ -2245,7 +2245,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "sp-api", @@ -2427,7 +2427,7 @@ dependencies = [ [[package]] name = "generate-bags" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "chrono", "frame-election-provider-support", @@ -3012,49 +3012,13 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bd0d559d5e679b1ab2f869b486a11182923863b1b3ee8b421763cdd707b783a" dependencies = [ - "jsonrpsee-core 0.14.0", - "jsonrpsee-http-server 0.14.0", - "jsonrpsee-proc-macros 0.14.0", - "jsonrpsee-types 0.14.0", - "jsonrpsee-ws-client 0.14.0", - "jsonrpsee-ws-server 0.14.0", - "tracing", -] - -[[package]] -name = "jsonrpsee" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd0d559d5e679b1ab2f869b486a11182923863b1b3ee8b421763cdd707b783a" -dependencies = [ - "jsonrpsee-core 0.15.1", - "jsonrpsee-http-server 0.15.1", - "jsonrpsee-proc-macros 0.15.1", - "jsonrpsee-types 0.15.1", - "jsonrpsee-ws-client 0.15.1", - "jsonrpsee-ws-server 0.15.1", - "tracing", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8752740ecd374bcbf8b69f3e80b0327942df76f793f8d4e60d3355650c31fb74" -dependencies = [ - "futures-util", - "http", - "jsonrpsee-core 0.14.0", - "jsonrpsee-types 0.14.0", - "pin-project", - "rustls-native-certs", - "soketto", - "thiserror", - "tokio", - "tokio-rustls", - "tokio-util 0.7.1", + "jsonrpsee-core", + "jsonrpsee-http-server", + "jsonrpsee-proc-macros", + "jsonrpsee-types", + "jsonrpsee-ws-client", + "jsonrpsee-ws-server", "tracing", - "webpki-roots", ] [[package]] @@ -3065,8 +3029,8 @@ checksum = "8752740ecd374bcbf8b69f3e80b0327942df76f793f8d4e60d3355650c31fb74" dependencies = [ "futures-util", "http", - "jsonrpsee-core 0.15.1", - "jsonrpsee-types 0.15.1", + "jsonrpsee-core", + "jsonrpsee-types", "pin-project", "rustls-native-certs", "soketto", @@ -3095,39 +3059,7 @@ dependencies = [ "globset", "http", "hyper", - "jsonrpsee-types 0.14.0", - "lazy_static", - "parking_lot 0.12.0", - "rand 0.8.5", - "rustc-hash", - "serde", - "serde_json", - "soketto", - "thiserror", - "tokio", - "tracing", - "tracing-futures", - "unicase", -] - -[[package]] -name = "jsonrpsee-core" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3dc3e9cf2ba50b7b1d7d76a667619f82846caa39e8e8daa8a4962d74acaddca" -dependencies = [ - "anyhow", - "arrayvec 0.7.2", - "async-lock", - "async-trait", - "beef", - "futures-channel", - "futures-timer", - "futures-util", - "globset", - "http", - "hyper", - "jsonrpsee-types 0.15.1", + "jsonrpsee-types", "lazy_static", "parking_lot 0.12.0", "rand 0.8.5", @@ -3151,26 +3083,8 @@ dependencies = [ "futures-channel", "futures-util", "hyper", - "jsonrpsee-core 0.14.0", - "jsonrpsee-types 0.14.0", - "serde", - "serde_json", - "tokio", - "tracing", - "tracing-futures", -] - -[[package]] -name = "jsonrpsee-http-server" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03802f0373a38c2420c70b5144742d800b509e2937edc4afb116434f07120117" -dependencies = [ - "futures-channel", - "futures-util", - "hyper", - "jsonrpsee-core 0.15.1", - "jsonrpsee-types 0.15.1", + "jsonrpsee-core", + "jsonrpsee-types", "serde", "serde_json", "tokio", @@ -3190,32 +3104,6 @@ dependencies = [ "syn", ] -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd67957d4280217247588ac86614ead007b301ca2fa9f19c19f880a536f029e3" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "jsonrpsee-types" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e290bba767401b646812f608c099b922d8142603c9e73a50fb192d3ac86f4a0d" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "jsonrpsee-types" version = "0.15.1" @@ -3262,26 +3150,6 @@ dependencies = [ "tracing-futures", ] -[[package]] -name = "jsonrpsee-ws-server" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d488ba74fb369e5ab68926feb75a483458b88e768d44319f37e4ecad283c7325" -dependencies = [ - "futures-channel", - "futures-util", - "http", - "jsonrpsee-core 0.15.1", - "jsonrpsee-types 0.15.1", - "serde_json", - "soketto", - "tokio", - "tokio-stream", - "tokio-util 0.7.1", - "tracing", - "tracing-futures", -] - [[package]] name = "k256" version = "0.10.4" @@ -4929,7 +4797,7 @@ checksum = "20448fd678ec04e6ea15bbe0476874af65e98a01515d667aa49f1434dc44ebf4" [[package]] name = "pallet-assets" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4943,7 +4811,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -4959,7 +4827,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -4974,7 +4842,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -4998,7 +4866,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5018,7 +4886,7 @@ dependencies = [ [[package]] name = "pallet-bags-list-remote-tests" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-election-provider-support", "frame-support", @@ -5037,7 +4905,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5052,7 +4920,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-primitives", "frame-support", @@ -5068,7 +4936,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "beefy-merkle-tree", "beefy-primitives", @@ -5091,7 +4959,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5109,7 +4977,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5128,7 +4996,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5145,7 +5013,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5161,7 +5029,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5184,7 +5052,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5197,7 +5065,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5215,7 +5083,7 @@ dependencies = [ [[package]] name = "pallet-gilt" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5230,7 +5098,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5253,7 +5121,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5269,7 +5137,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5289,7 +5157,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5306,7 +5174,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5323,7 +5191,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ckb-merkle-mountain-range", "frame-benchmarking", @@ -5341,9 +5209,9 @@ dependencies = [ [[package]] name = "pallet-mmr-rpc" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee 0.15.1", + "jsonrpsee", "parity-scale-codec", "serde", "sp-api", @@ -5356,7 +5224,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5371,7 +5239,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5388,7 +5256,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5407,7 +5275,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-api", @@ -5417,7 +5285,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5434,7 +5302,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5457,7 +5325,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5473,7 +5341,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5488,7 +5356,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5503,7 +5371,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5519,7 +5387,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5540,7 +5408,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5556,7 +5424,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5570,7 +5438,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5593,7 +5461,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5604,7 +5472,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "sp-arithmetic", @@ -5613,7 +5481,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5627,7 +5495,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5645,7 +5513,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5664,7 +5532,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-support", "frame-system", @@ -5680,9 +5548,9 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee 0.15.1", + "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", "parity-scale-codec", "sp-api", @@ -5695,7 +5563,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5706,7 +5574,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5723,7 +5591,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -5739,7 +5607,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-benchmarking", "frame-support", @@ -7025,7 +6893,7 @@ version = "0.9.27" dependencies = [ "beefy-gadget", "beefy-gadget-rpc", - "jsonrpsee 0.14.0", + "jsonrpsee", "pallet-mmr-rpc", "pallet-transaction-payment-rpc", "polkadot-primitives", @@ -8205,10 +8073,10 @@ dependencies = [ [[package]] name = "remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "env_logger 0.9.0", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "serde", @@ -8547,7 +8415,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "sp-core", @@ -8558,7 +8426,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -8585,7 +8453,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "futures-timer", @@ -8608,7 +8476,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -8624,7 +8492,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-trait-for-tuples", "memmap2 0.5.0", @@ -8641,7 +8509,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8652,7 +8520,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "chrono", "clap", @@ -8691,7 +8559,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "fnv", "futures", @@ -8719,7 +8587,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "kvdb", @@ -8744,7 +8612,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -8768,7 +8636,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "fork-tree", @@ -8810,10 +8678,10 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", - "jsonrpsee 0.15.1", + "jsonrpsee", "sc-consensus-babe", "sc-consensus-epochs", "sc-rpc-api", @@ -8832,7 +8700,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "fork-tree", "parity-scale-codec", @@ -8845,7 +8713,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -8870,7 +8738,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "lazy_static", "lru 0.7.7", @@ -8897,7 +8765,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "environmental", "parity-scale-codec", @@ -8914,7 +8782,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -8929,7 +8797,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "cfg-if 1.0.0", "libc", @@ -8949,7 +8817,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ahash", "async-trait", @@ -8990,11 +8858,11 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "finality-grandpa", "futures", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "sc-client-api", @@ -9011,7 +8879,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ansi_term", "futures", @@ -9028,7 +8896,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "hex", @@ -9043,7 +8911,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "asynchronous-codec", @@ -9092,7 +8960,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bitflags", "futures", @@ -9110,7 +8978,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ahash", "futures", @@ -9127,7 +8995,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "libp2p", @@ -9147,7 +9015,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "fork-tree", "futures", @@ -9174,7 +9042,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bytes", "fnv", @@ -9202,7 +9070,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "libp2p", @@ -9215,7 +9083,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9224,11 +9092,11 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "hash-db", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -9254,10 +9122,10 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "parking_lot 0.12.0", @@ -9277,10 +9145,10 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "serde_json", "substrate-prometheus-endpoint", @@ -9290,7 +9158,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "directories", @@ -9298,7 +9166,7 @@ dependencies = [ "futures", "futures-timer", "hash-db", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "parity-util-mem", @@ -9357,7 +9225,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -9371,9 +9239,9 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee 0.15.1", + "jsonrpsee", "parity-scale-codec", "sc-chain-spec", "sc-client-api", @@ -9390,7 +9258,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "libc", @@ -9409,7 +9277,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "chrono", "futures", @@ -9427,7 +9295,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ansi_term", "atty", @@ -9458,7 +9326,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9469,7 +9337,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "futures-timer", @@ -9495,7 +9363,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "log", @@ -9508,7 +9376,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "futures-timer", @@ -9993,7 +9861,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "log", @@ -10010,7 +9878,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "blake2", "proc-macro-crate", @@ -10022,7 +9890,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10035,7 +9903,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "integer-sqrt", "num-traits", @@ -10050,7 +9918,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10063,7 +9931,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "parity-scale-codec", @@ -10075,7 +9943,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-api", @@ -10087,7 +9955,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "log", @@ -10105,7 +9973,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -10124,7 +9992,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "merlin", @@ -10147,7 +10015,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10161,7 +10029,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10174,7 +10042,7 @@ dependencies = [ [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "base58", "bitflags", @@ -10220,7 +10088,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "blake2", "byteorder", @@ -10234,7 +10102,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro2", "quote", @@ -10245,7 +10113,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "kvdb", "parking_lot 0.12.0", @@ -10254,7 +10122,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro2", "quote", @@ -10264,7 +10132,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "environmental", "parity-scale-codec", @@ -10275,7 +10143,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "finality-grandpa", "log", @@ -10293,7 +10161,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -10307,7 +10175,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bytes", "futures", @@ -10333,7 +10201,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "lazy_static", "sp-core", @@ -10344,7 +10212,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -10361,7 +10229,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "thiserror", "zstd", @@ -10370,7 +10238,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -10385,7 +10253,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10399,7 +10267,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "sp-api", "sp-core", @@ -10409,7 +10277,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "backtrace", "lazy_static", @@ -10419,7 +10287,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "rustc-hash", "serde", @@ -10429,7 +10297,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "either", "hash256-std-hasher", @@ -10451,7 +10319,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -10469,7 +10337,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "Inflector", "proc-macro-crate", @@ -10481,7 +10349,7 @@ dependencies = [ [[package]] name = "sp-sandbox" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "parity-scale-codec", @@ -10495,7 +10363,7 @@ dependencies = [ [[package]] name = "sp-serializer" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "serde", "serde_json", @@ -10504,7 +10372,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10518,7 +10386,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "scale-info", @@ -10529,7 +10397,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "log", @@ -10551,12 +10419,12 @@ dependencies = [ [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10569,7 +10437,7 @@ dependencies = [ [[package]] name = "sp-tasks" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "log", "sp-core", @@ -10582,7 +10450,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures-timer", @@ -10598,7 +10466,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "sp-std", @@ -10610,7 +10478,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "sp-api", "sp-runtime", @@ -10619,7 +10487,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "log", @@ -10635,7 +10503,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "hash-db", "memory-db", @@ -10651,7 +10519,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-serde", "parity-scale-codec", @@ -10668,7 +10536,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -10679,7 +10547,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "impl-trait-for-tuples", "log", @@ -10727,7 +10595,7 @@ dependencies = [ "frame-support", "frame-system", "futures-util", - "jsonrpsee 0.14.0", + "jsonrpsee", "kusama-runtime", "log", "pallet-balances", @@ -10853,7 +10721,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "platforms", ] @@ -10861,11 +10729,11 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "frame-system-rpc-runtime-api", "futures", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "sc-client-api", @@ -10882,7 +10750,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures-util", "hyper", @@ -10895,9 +10763,9 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "sc-client-api", @@ -10916,7 +10784,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "async-trait", "futures", @@ -10942,7 +10810,7 @@ dependencies = [ [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "futures", "substrate-test-utils-derive", @@ -10952,7 +10820,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10963,7 +10831,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "ansi_term", "build-helper", @@ -11677,10 +11545,10 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#862dbbc1c16a17b33e0e619b0e996b608a1c5069" +source = "git+https://github.com/paritytech/substrate?branch=master#744eda47f545e31083ee722abb3a286f91a7f98d" dependencies = [ "clap", - "jsonrpsee 0.15.1", + "jsonrpsee", "log", "parity-scale-codec", "remote-externalities", From 454874f1e84325e15ac4d5d92899209486b70f49 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:06:26 +0200 Subject: [PATCH 49/75] benchmark fixes --- .../src/disputes/slashing/benchmarking.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs index ed3e2f7235f2..78648da544ef 100644 --- a/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -114,15 +114,12 @@ where assert_ne!(session_index, current_session); let validator_index = ValidatorIndex(0); - let losers = [validator_index].into_iter(); - // everyone else wins - let winners = (1..n_validators).map(|i| ValidatorIndex(i)).into_iter(); - T::SlashingHandler::punish_against_valid(session_index, CANDIDATE_HASH, losers, winners); + T::SlashingHandler::punish_against_valid(session_index, CANDIDATE_HASH, losers); - let losers = >::get(session_index, CANDIDATE_HASH); - assert_eq!(losers.unwrap().len(), 1); + let unapplied = >::get(session_index, CANDIDATE_HASH); + assert_eq!(unapplied.unwrap().keys.len(), 1); dispute_proof(session_index, validator_id, validator_index) } @@ -159,7 +156,7 @@ benchmarks! { ); assert!(result.is_ok()); } verify { - let losers = >::get(session_index, CANDIDATE_HASH); - assert!(losers.is_none()); + let unapplied = >::get(session_index, CANDIDATE_HASH); + assert!(unapplied.is_none()); } } From c0db743441d64ec53699f3e1c2abfc7420a81db9 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:06:51 +0200 Subject: [PATCH 50/75] fmt --- runtime/parachains/src/disputes.rs | 12 ++----- runtime/parachains/src/disputes/slashing.rs | 35 +++++++++------------ 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 98157180f728..f8e8941ac39e 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -16,11 +16,7 @@ //! Runtime component for handling disputes of parachain candidates. -use crate::{ - configuration, - initializer::SessionChangeNotification, - session_info, -}; +use crate::{configuration, initializer::SessionChangeNotification, session_info}; use bitvec::{bitvec, order::Lsb0 as BitOrderLsb0}; use frame_support::{ensure, traits::Get, weights::Weight}; use frame_system::pallet_prelude::*; @@ -1244,11 +1240,7 @@ impl Pallet { ); // an invalid candidate, according to 2/3. Punish those on the 'for' side. - T::SlashingHandler::punish_for_invalid( - session, - candidate_hash, - summary.slash_for, - ); + T::SlashingHandler::punish_for_invalid(session, candidate_hash, summary.slash_for); } >::insert(&session, &candidate_hash, &summary.state); diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index b86b994fd280..bda6f4fa14c8 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -98,7 +98,6 @@ pub struct SlashingOffence { pub slash_fraction: Perbill, /// Whether the candidate was valid or invalid. pub kind: SlashingOffenceKind, - } impl Offence for SlashingOffence @@ -238,10 +237,7 @@ where .into_iter() .filter_map(|i| session_info.validators.get(i.0 as usize).cloned().map(|id| (i, id))) .collect(); - let unapplied = PendingSlashes { - keys, - kind, - }; + let unapplied = PendingSlashes { keys, kind }; >::insert(session_index, candidate_hash, unapplied); } } @@ -429,8 +425,14 @@ pub mod pallet { /// Validators pending dispute slashes. #[pallet::storage] - pub(super) type UnappliedSlashes = - StorageDoubleMap<_, Twox64Concat, SessionIndex, Blake2_128Concat, CandidateHash, PendingSlashes>; + pub(super) type UnappliedSlashes = StorageDoubleMap< + _, + Twox64Concat, + SessionIndex, + Blake2_128Concat, + CandidateHash, + PendingSlashes, + >; /// `ValidatorSetCount` per session. #[pallet::storage] @@ -475,7 +477,8 @@ pub mod pallet { let session_index = dispute_proof.time_slot.session_index; let validator_set_count = crate::session_info::Pallet::::session_info(session_index) .ok_or(Error::::InvalidSessionIndex)? - .discovery_keys.len() as ValidatorSetCount; + .discovery_keys + .len() as ValidatorSetCount; // check that there is a pending slash for the given // validator index and candidate hash @@ -504,11 +507,7 @@ pub mod pallet { Ok(()) }; - >::try_mutate_exists( - &session_index, - &candidate_hash, - try_remove, - )?; + >::try_mutate_exists(&session_index, &candidate_hash, try_remove)?; let offence = SlashingOffence::new( session_index, @@ -519,10 +518,8 @@ pub mod pallet { ); let block_author = >::block_author(); - >::report_offence( - block_author, offence, - ) - .map_err(|_| Error::::DuplicateSlashingReport)?; + >::report_offence(block_author, offence) + .map_err(|_| Error::::DuplicateSlashingReport)?; Ok(Pays::No.into()) } @@ -660,9 +657,7 @@ impl Default for SlashingReportHandler { impl HandleReports for SlashingReportHandler where - T: Config + - frame_system::offchain::SendTransactionTypes> + - pallet_authorship::Config, + T: Config + frame_system::offchain::SendTransactionTypes> + pallet_authorship::Config, R: ReportOffence< AccountId, T::KeyOwnerIdentification, From 9fb1e38e42cfbedfb9323b1b093f8acb1f980cde Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:09:42 +0200 Subject: [PATCH 51/75] unused var --- runtime/parachains/src/disputes/slashing/benchmarking.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs index 78648da544ef..ca3be0efe1ca 100644 --- a/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -105,7 +105,6 @@ where fn setup_dispute( session_index: SessionIndex, validator_id: ValidatorId, - n_validators: u32, ) -> DisputeProof where T: Config, @@ -147,7 +146,7 @@ benchmarks! { let origin = RawOrigin::None.into(); let (session_index, key_owner_proof, validator_id) = setup_validator_set::(n); - let dispute_proof = setup_dispute::(session_index, validator_id, n); + let dispute_proof = setup_dispute::(session_index, validator_id); }: { let result = Pallet::::report_dispute_lost_unsigned( origin, From 9c84b2217ce2b13debbff6d3d496564c591e520b Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:21:50 +0200 Subject: [PATCH 52/75] fix block_author impl --- runtime/parachains/src/disputes/slashing.rs | 20 +++++++++---------- .../src/disputes/slashing/benchmarking.rs | 5 +---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index bda6f4fa14c8..6efe471abc51 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -320,7 +320,7 @@ pub trait HandleReports { /// Report a `for valid` offence. fn report_offence( - reporter: Option>, + reporter: Option, offence: SlashingOffence, ) -> Result<(), OffenceError>; @@ -332,7 +332,7 @@ pub trait HandleReports { ) -> bool; /// Fetch the current block author id, if defined. - fn block_author() -> Option>; + fn block_author() -> Option; /// Create and dispatch a slashing report extrinsic. /// This should be called offchain. @@ -346,7 +346,7 @@ impl HandleReports for () { type ReportLongevity = (); fn report_offence( - _reporter: Option>, + _reporter: Option, _offence: SlashingOffence, ) -> Result<(), OffenceError> { Ok(()) @@ -366,7 +366,7 @@ impl HandleReports for () { Ok(()) } - fn block_author() -> Option> { + fn block_author() -> Option { None } } @@ -659,7 +659,7 @@ impl HandleReports for SlashingReportHandler> + pallet_authorship::Config, R: ReportOffence< - AccountId, + T::AccountId, T::KeyOwnerIdentification, SlashingOffence, >, @@ -668,7 +668,7 @@ where type ReportLongevity = L; fn report_offence( - reporter: Option>, + reporter: Option, offence: SlashingOffence, ) -> Result<(), OffenceError> { let reporters = reporter.into_iter().collect(); @@ -680,7 +680,7 @@ where time_slot: &DisputesTimeSlot, ) -> bool { , + T::AccountId, T::KeyOwnerIdentification, SlashingOffence, >>::is_known_offence(offenders, time_slot) @@ -721,9 +721,7 @@ where Ok(()) } - fn block_author() -> Option> { - // TODO - // >::author() - None + fn block_author() -> Option { + >::author() } } diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs index ca3be0efe1ca..dd094976887e 100644 --- a/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -102,10 +102,7 @@ where (session_index, key_owner_proof, validator_id) } -fn setup_dispute( - session_index: SessionIndex, - validator_id: ValidatorId, -) -> DisputeProof +fn setup_dispute(session_index: SessionIndex, validator_id: ValidatorId) -> DisputeProof where T: Config, { From 19b7c6bba86081348493da2d9dd800affcff2885 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:35:00 +0200 Subject: [PATCH 53/75] ressurect RewardValidators trait --- runtime/kusama/src/lib.rs | 1 + runtime/parachains/src/disputes.rs | 20 ++++++++++++++++++++ runtime/parachains/src/mock.rs | 1 + runtime/polkadot/src/lib.rs | 1 + runtime/rococo/src/lib.rs | 1 + runtime/test-runtime/src/lib.rs | 1 + runtime/westend/src/lib.rs | 1 + 7 files changed, 26 insertions(+) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index bfc08c586951..a8edfe104498 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1315,6 +1315,7 @@ impl parachains_initializer::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; + type RewardValidators = (); type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index f8e8941ac39e..758a19279b7c 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -60,6 +60,19 @@ pub enum DisputeResult { Invalid, } +/// Reward hooks for disputes. +pub trait RewardValidators { + // Give each validator a reward, likely small, for participating in the dispute. + fn reward_dispute_statement( + session: SessionIndex, + validators: impl IntoIterator, + ); +} + +impl RewardValidators for () { + fn reward_dispute_statement(_: SessionIndex, _: impl IntoIterator) {} +} + /// Punishment hooks for disputes. /// /// Currently, it's not possible to use @@ -429,6 +442,7 @@ pub mod pallet { pub trait Config: frame_system::Config + configuration::Config + session_info::Config { type Event: From> + IsType<::Event>; + type RewardValidators: RewardValidators; type SlashingHandler: SlashingHandler; /// Weight information for extrinsics in this pallet. @@ -1230,6 +1244,12 @@ impl Pallet { } } + // Reward statements. + T::RewardValidators::reward_dispute_statement( + session, + summary.new_participants.iter_ones().map(|i| ValidatorIndex(i as _)), + ); + // Slash participants on a losing side. { // a valid candidate, according to 2/3. Punish those on the 'against' side. diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index a07c2c8a551f..f6bc396518a0 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -242,6 +242,7 @@ impl crate::hrmp::Config for Test { impl crate::disputes::Config for Test { type Event = Event; + type RewardValidators = (); type SlashingHandler = Self; type WeightInfo = crate::disputes::TestWeightInfo; } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index a2f0d7799233..7a30647f5929 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1298,6 +1298,7 @@ impl parachains_initializer::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; + type RewardValidators = (); type SlashingHandler = (); type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index c226e1ef6da0..9b9170d34df3 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -356,6 +356,7 @@ impl pallet_session::historical::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; + type RewardValidators = (); type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } diff --git a/runtime/test-runtime/src/lib.rs b/runtime/test-runtime/src/lib.rs index 7bc761659eb1..feaddfd80931 100644 --- a/runtime/test-runtime/src/lib.rs +++ b/runtime/test-runtime/src/lib.rs @@ -485,6 +485,7 @@ impl parachains_inclusion::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; + type RewardValidators = (); type SlashingHandler = (); type WeightInfo = parachains_disputes::TestWeightInfo; } diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 9dd565c556f3..f108ce0cad63 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -947,6 +947,7 @@ impl assigned_slots::Config for Runtime { impl parachains_disputes::Config for Runtime { type Event = Event; + type RewardValidators = (); type SlashingHandler = parachains_slashing::SlashValidatorsForDisputes; type WeightInfo = weights::runtime_parachains_disputes::WeightInfo; } From 784e65e8745da53687c34c1a4730f5ddaf4ec9ef Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 3 Aug 2022 18:43:28 +0200 Subject: [PATCH 54/75] remove outdated comment --- runtime/parachains/src/disputes.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 758a19279b7c..66de9d36d198 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -74,13 +74,6 @@ impl RewardValidators for () { } /// Punishment hooks for disputes. -/// -/// Currently, it's not possible to use -/// `>::reward_by_ids` to reward validators in a -/// previous session (era) if they are no longer in the active set. -/// For this reason, we're currently combining slashing and rewarding in one -/// interface. The rewards are distributed from (a fraction of) the slashing -/// pot. pub trait SlashingHandler { /// Punish a series of validators who were for an invalid parablock. This is /// expected to be a major punishment. From c22a94301b0ef7966efb29aa06ff7011da6be030 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 5 Aug 2022 12:36:54 +0200 Subject: [PATCH 55/75] more module docs --- runtime/parachains/src/disputes/slashing.rs | 36 +++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 6efe471abc51..540f16633934 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -16,18 +16,32 @@ //! Dispute slashing pallet. //! -//! The implementation relies on the `offences` pallet and -//! looks like a hybrid of `im-online` and `grandpa` equivocation handlers. -//! Meaning, we submit an `offence` for the concluded disputes about -//! the current session candidate directly from the runtime. -//! If, however, the dispute is about a past session, we record pending +//! Once a dispute is concluded, we want to slash validators +//! who were on the wrong side of the dispute. The slashing amount +//! depends on whether the candidate was valid (small) or invalid (big). +//! In addition to that, we might want to kick out the validators from the +//! active set. +//! +//! The `offences` pallet from Substrate provides us with a way to do both. +//! Current, the interface expects us to provide staking information +//! including nominator exposure in order to submit an offence. +//! +//! Normally, we'd able to fetch this information from the runtime as soon as +//! the dispute is concluded. This is also what `im-online` pallet does. +//! However, since a dispute can conclude several sessions after the candidate +//! was backed (see `dispute_period` in `HostConfiguration`), we can't rely on +//! this information be available in the context of the current block. The +//! `babe` and `grandpa` equivocation handlers also have to deal +//! with this problem. +//! +//! Our implementation looks like a hybrid of `im-online` and `grandpa` +//! equivocation handlers. Meaning, we submit an `offence` for the concluded +//! disputes about the current session candidate directly from the runtime. +//! If, however, the dispute is about a past session, we record unapplied //! slashes on chain, without `FullIdentification` of the offenders. //! Later on, a block producer can submit an unsigned transaction with //! `KeyOwnershipProof` of an offender and submit it to the runtime //! to produce an offence. -//! The reason for this separation is that we do not want to rely on -//! `FullIdentification` to be available on chain for the past sessions -//! because it is quite heavy. use crate::{ disputes, @@ -299,7 +313,8 @@ pub struct DisputeProof { pub validator_id: ValidatorId, } -/// Slashes that are waiting to be applied once we have validator key identification. +/// Slashes that are waiting to be applied once we have validator key +/// identification. #[derive(Encode, Decode, RuntimeDebug, TypeInfo)] pub struct PendingSlashes { /// Indices and keys of the validators who lost a dispute and are pending @@ -550,7 +565,8 @@ impl Pallet { /// Called by the initializer to note a new session in the disputes slashing /// pallet. fn initializer_on_new_session(session_index: SessionIndex) { - // This should be small, as disputes are limited by spam slots, so no limit is fine. + // This should be small, as disputes are limited by spam slots, so no limit is + // fine. const REMOVE_LIMIT: u32 = u32::MAX; let config = >::config(); From 884d9d89270baab6a33613dcf77cdecf4c48b40b Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 5 Aug 2022 12:53:16 +0200 Subject: [PATCH 56/75] introduce BenchmarkingConfig --- runtime/parachains/src/disputes/slashing.rs | 14 ++++++++++++++ .../src/disputes/slashing/benchmarking.rs | 4 +--- runtime/rococo/src/lib.rs | 1 + runtime/westend/src/lib.rs | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 540f16633934..9f934a2d215d 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -81,6 +81,17 @@ const DEFENSIVE_PROOF: &'static str = "disputes module should bail on old sessio #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; +/// The benchmarking configuration. +pub trait BenchmarkingConfiguration { + const MAX_VALIDATORS: u32; +} + +pub struct BenchConfig; + +impl BenchmarkingConfiguration for BenchConfig { + const MAX_VALIDATORS: u32 = M; +} + /// Timeslots should uniquely identify offences and are used for the offence /// deduplication. #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Encode, Decode, TypeInfo, RuntimeDebug)] @@ -432,6 +443,9 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + + /// Benchmarking configuration. + type BenchmarkingConfig: BenchmarkingConfiguration; } #[pallet::pallet] diff --git a/runtime/parachains/src/disputes/slashing/benchmarking.rs b/runtime/parachains/src/disputes/slashing/benchmarking.rs index dd094976887e..2a21c3a0f62b 100644 --- a/runtime/parachains/src/disputes/slashing/benchmarking.rs +++ b/runtime/parachains/src/disputes/slashing/benchmarking.rs @@ -27,8 +27,6 @@ use sp_session::MembershipProof; // Candidate hash of the disputed candidate. const CANDIDATE_HASH: CandidateHash = CandidateHash(Hash::zero()); -// Should be bumped once we support more. -const MAX_VALIDATORS: u32 = 1 * 1024; pub trait Config: pallet_session::Config @@ -139,7 +137,7 @@ benchmarks! { // in this setup we have a single `AgainstValid` dispute // submitted for a past session report_dispute_lost { - let n in 4..MAX_VALIDATORS; + let n in 4..<::BenchmarkingConfig as BenchmarkingConfiguration>::MAX_VALIDATORS; let origin = RawOrigin::None.into(); let (session_index, key_owner_proof, validator_id) = setup_validator_set::(n); diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 9b9170d34df3..af785d02b96e 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -375,6 +375,7 @@ impl parachains_slashing::Config for Runtime { ReportLongevity, >; type WeightInfo = parachains_slashing::TestWeightInfo; + type BenchmarkingConfig = parachains_slashing::BenchConfig<100>; } parameter_types! { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index f108ce0cad63..eff2c6916fe2 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -966,6 +966,7 @@ impl parachains_slashing::Config for Runtime { ReportLongevity, >; type WeightInfo = weights::runtime_parachains_disputes_slashing::WeightInfo; + type BenchmarkingConfig = parachains_slashing::BenchConfig<300>; } parameter_types! { From 7101379f72e2fd65559a984638b589c910d65fab Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 5 Aug 2022 12:56:12 +0200 Subject: [PATCH 57/75] typo fix --- runtime/parachains/src/disputes/slashing.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 9f934a2d215d..bf0fe28aa3e3 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -23,7 +23,7 @@ //! active set. //! //! The `offences` pallet from Substrate provides us with a way to do both. -//! Current, the interface expects us to provide staking information +//! Currently, the interface expects us to provide staking information //! including nominator exposure in order to submit an offence. //! //! Normally, we'd able to fetch this information from the runtime as soon as From ce879df66d398c0a54a3a43addffa6185d6256ac Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 5 Aug 2022 13:00:27 +0200 Subject: [PATCH 58/75] teach spellcheck unapplied --- scripts/ci/gitlab/lingua.dic | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci/gitlab/lingua.dic b/scripts/ci/gitlab/lingua.dic index 2c71564cbf51..267d877bb953 100644 --- a/scripts/ci/gitlab/lingua.dic +++ b/scripts/ci/gitlab/lingua.dic @@ -283,6 +283,7 @@ typesystem ubuntu/M UDP UI +unapplied unassign unconcluded unfinalize/B From 7d5171c28a6bf848b522db23571f6a090027e928 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 31 Aug 2022 14:39:30 +0200 Subject: [PATCH 59/75] use Weight::new() --- runtime/parachains/src/disputes.rs | 2 +- runtime/parachains/src/disputes/slashing.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index ed00e29ed280..688fcfb71a04 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -119,7 +119,7 @@ impl SlashingHandler for () { } fn initializer_initialize(_now: BlockNumber) -> Weight { - 0 + Weight::new() } fn initializer_finalize() {} diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index bf0fe28aa3e3..401b763141c7 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -404,7 +404,7 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn report_dispute_lost(_validator_count: ValidatorSetCount) -> Weight { - 0 + Weight::new() } } @@ -570,7 +570,7 @@ pub mod pallet { impl Pallet { /// Called by the initializer to initialize the disputes slashing module. fn initializer_initialize(_now: T::BlockNumber) -> Weight { - 0 + Weight::new() } /// Called by the initializer to finalize the disputes slashing pallet. From b436249a0fdd91d1ad399102e75b65948ad93970 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 31 Aug 2022 14:40:35 +0200 Subject: [PATCH 60/75] fix mocking rewards --- runtime/parachains/src/disputes/tests.rs | 18 +++++++++++++++++- runtime/parachains/src/mock.rs | 14 ++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/runtime/parachains/src/disputes/tests.rs b/runtime/parachains/src/disputes/tests.rs index 50df2e947ceb..4d8ac714cb7b 100644 --- a/runtime/parachains/src/disputes/tests.rs +++ b/runtime/parachains/src/disputes/tests.rs @@ -20,7 +20,7 @@ use crate::{ disputes::DisputesHandler, mock::{ new_test_ext, AccountId, AllPalletsWithSystem, Initializer, MockGenesisConfig, System, - Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, + Test, PUNISH_VALIDATORS_AGAINST, PUNISH_VALIDATORS_FOR, REWARD_VALIDATORS, }, }; use assert_matches::assert_matches; @@ -1266,6 +1266,22 @@ fn test_provide_multi_dispute_success_and_other() { Pallet::::note_included(4, candidate_hash.clone(), 4); assert_eq!(SpamSlots::::get(4), Some(vec![0, 0, 0, 0, 0, 0, 0])); + // Ensure the `reward_validator` function was correctly called + assert_eq!( + REWARD_VALIDATORS.with(|r| r.borrow().clone()), + vec![ + (3, vec![ValidatorIndex(0), ValidatorIndex(2)]), + (4, vec![ValidatorIndex(2), ValidatorIndex(3)]), + (3, vec![ValidatorIndex(3)]), + (3, vec![ValidatorIndex(5)]), + (5, vec![ValidatorIndex(2), ValidatorIndex(5)]), + (3, vec![ValidatorIndex(6)]), + (5, vec![ValidatorIndex(6)]), + (5, vec![ValidatorIndex(0), ValidatorIndex(1), ValidatorIndex(4)]), + (3, vec![ValidatorIndex(1), ValidatorIndex(4)]), + ], + ); + // Ensure punishment against is called assert_eq!( PUNISH_VALIDATORS_AGAINST.with(|r| r.borrow().clone()), diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index c5470ec4bfa5..0bd0edea2857 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -242,16 +242,26 @@ impl crate::hrmp::Config for Test { impl crate::disputes::Config for Test { type Event = Event; - type RewardValidators = (); + type RewardValidators = Self; type SlashingHandler = Self; type WeightInfo = crate::disputes::TestWeightInfo; } thread_local! { + pub static REWARD_VALIDATORS: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_FOR: RefCell)>> = RefCell::new(Vec::new()); pub static PUNISH_VALIDATORS_AGAINST: RefCell)>> = RefCell::new(Vec::new()); } +impl crate::disputes::RewardValidators for Test { + fn reward_dispute_statement( + session: SessionIndex, + validators: impl IntoIterator, + ) { + REWARD_VALIDATORS.with(|r| r.borrow_mut().push((session, validators.into_iter().collect()))) + } +} + impl crate::disputes::SlashingHandler for Test { fn punish_for_invalid( session: SessionIndex, @@ -271,7 +281,7 @@ impl crate::disputes::SlashingHandler for Test { } fn initializer_initialize(_now: BlockNumber) -> Weight { - 0 + Weight::new() } fn initializer_finalize() {} From 397046eeedf7d27904cb18c895231ab581b47f42 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 31 Aug 2022 14:48:34 +0200 Subject: [PATCH 61/75] use RefTimeWeight --- .../weights/runtime_parachains_disputes_slashing.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs index 5f7ab517c8cf..4b6e1830939d 100644 --- a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs +++ b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -38,7 +38,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{traits::Get, weights::{RefTimeWeight, Weight}}; use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::disputes::slashing`. @@ -60,10 +60,10 @@ impl runtime_parachains::disputes::slashing::WeightInfo // Storage: Staking ValidatorSlashInEra (r:1 w:0) /// The range of component `n` is `[4, 1024]`. fn report_dispute_lost(n: u32, ) -> Weight { - (84_424_000 as Weight) + Weight::from_ref_time(84_424_000 as RefTimeWeight) // Standard Error: 0 - .saturating_add((111_000 as Weight).saturating_mul(n as Weight)) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time((111_000 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + .saturating_add(T::DbWeight::get().reads(14 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) } } From 18965e355e5ad4939f83d2385d09e0235355f11d Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Wed, 31 Aug 2022 13:22:58 +0000 Subject: [PATCH 62/75] ".git/.scripts/bench-bot.sh" runtime westend-dev runtime_parachains::disputes::slashing --- .../runtime_parachains_disputes_slashing.rs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs index 4b6e1830939d..6d5b3d6d2be9 100644 --- a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs +++ b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -16,21 +16,22 @@ //! Autogenerated weights for `runtime_parachains::disputes::slashing` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-06-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `redacted`, CPU: `redacted` +//! DATE: 2022-08-31, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024 // Executed Command: -// target/release/polkadot +// /home/benchbot/cargo_target_dir/production/polkadot // benchmark // pallet -// --chain=westend-dev // --steps=50 // --repeat=20 -// --pallet=runtime_parachains::disputes::slashing // --extrinsic=* // --execution=wasm // --wasm-execution=compiled +// --heap-pages=4096 +// --pallet=runtime_parachains::disputes::slashing +// --chain=westend-dev // --header=./file_header.txt // --output=./runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -46,24 +47,24 @@ pub struct WeightInfo(PhantomData); impl runtime_parachains::disputes::slashing::WeightInfo for WeightInfo { // Storage: Session CurrentIndex (r:1 w:0) // Storage: Historical HistoricalSessions (r:1 w:0) - // Storage: ParasSlashing ValidatorSetCounts (r:1 w:0) - // Storage: ParasSlashing PendingAgainstValidLosers (r:1 w:1) - // Storage: ParasSlashing AgainstValidWinners (r:1 w:1) + // Storage: ParaSessionInfo Sessions (r:1 w:0) + // Storage: ParasSlashing UnappliedSlashes (r:1 w:1) + // Storage: Authorship Author (r:1 w:0) + // Storage: System Digest (r:1 w:0) // Storage: Offences ReportsByKindIndex (r:1 w:1) // Storage: Offences ConcurrentReportsIndex (r:1 w:1) // Storage: Offences Reports (r:1 w:1) // Storage: Staking SlashRewardFraction (r:1 w:0) // Storage: Staking ActiveEra (r:1 w:0) // Storage: Staking ErasStartSessionIndex (r:1 w:0) - // Storage: Staking EarliestUnappliedSlash (r:1 w:1) // Storage: Staking Invulnerables (r:1 w:0) // Storage: Staking ValidatorSlashInEra (r:1 w:0) - /// The range of component `n` is `[4, 1024]`. + /// The range of component `n` is `[4, 300]`. fn report_dispute_lost(n: u32, ) -> Weight { - Weight::from_ref_time(84_424_000 as RefTimeWeight) - // Standard Error: 0 - .saturating_add(Weight::from_ref_time((111_000 as RefTimeWeight).saturating_mul(n as RefTimeWeight))) + Weight::from_ref_time(97_366_000 as RefTimeWeight) + // Standard Error: 2_000 + .saturating_add(Weight::from_ref_time(467_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) .saturating_add(T::DbWeight::get().reads(14 as RefTimeWeight)) - .saturating_add(T::DbWeight::get().writes(6 as RefTimeWeight)) + .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } } From 7269e1830021be2f5276634548a21cddb9bc2909 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 31 Aug 2022 15:28:11 +0200 Subject: [PATCH 63/75] refactor maybe_identify_validators --- runtime/parachains/src/disputes/slashing.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 401b763141c7..53a63d0187ea 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -43,11 +43,7 @@ //! `KeyOwnershipProof` of an offender and submit it to the runtime //! to produce an offence. -use crate::{ - disputes, - initializer::ValidatorSetCount, - session_info::{AccountId, IdentificationTuple}, -}; +use crate::{disputes, initializer::ValidatorSetCount, session_info::IdentificationTuple}; use frame_support::{ traits::{Defensive, Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, weights::{Pays, Weight}, @@ -198,7 +194,6 @@ where /// otherwise. fn maybe_identify_validators( session_index: SessionIndex, - account_ids: &[AccountId], validators: impl IntoIterator, ) -> Option>> { // We use `ValidatorSet::session_index` and not @@ -208,6 +203,9 @@ where // updated at the end of the block. let current_session = T::ValidatorSet::session_index(); if session_index == current_session { + let account_keys = crate::session_info::Pallet::::account_keys(session_index); + let account_ids = account_keys.defensive_unwrap_or_default(); + let fully_identified = validators .into_iter() .flat_map(|i| account_ids.get(i.0 as usize).cloned()) @@ -233,17 +231,14 @@ where // Nothing to do return } - let account_keys = crate::session_info::Pallet::::account_keys(session_index); - let account_ids = account_keys.defensive_unwrap_or_default(); let session_info = crate::session_info::Pallet::::session_info(session_index); let session_info = match session_info.defensive_proof(DEFENSIVE_PROOF) { Some(info) => info, None => return, }; - let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; - let maybe = - Self::maybe_identify_validators(session_index, &account_ids, losers.iter().cloned()); + let maybe = Self::maybe_identify_validators(session_index, losers.iter().cloned()); if let Some(offenders) = maybe { + let validator_set_count = session_info.discovery_keys.len() as ValidatorSetCount; let offence = SlashingOffence::new( session_index, candidate_hash, From 399e0e6532fae898544e76e5075f81753ca58d6b Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 31 Aug 2022 16:03:14 +0200 Subject: [PATCH 64/75] no more ticket in disguise --- runtime/parachains/src/disputes/slashing.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 53a63d0187ea..0192b8251e25 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -148,7 +148,8 @@ where fn disable_strategy(&self) -> DisableStrategy { match self.kind { SlashingOffenceKind::ForInvalid => DisableStrategy::Always, - // in the future we might change it based on number of disputes initiated + // in the future we might change it based on number of disputes initiated: + // SlashingOffenceKind::AgainstValid => DisableStrategy::Never, } } From 89fb5ed3413adb18043f9437323ff0f4be99dcc1 Mon Sep 17 00:00:00 2001 From: Andronik Date: Wed, 31 Aug 2022 17:35:37 +0200 Subject: [PATCH 65/75] remove outdated comments --- runtime/parachains/src/disputes.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 688fcfb71a04..4bcaf8a7cc37 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -77,7 +77,6 @@ impl RewardValidators for () { pub trait SlashingHandler { /// Punish a series of validators who were for an invalid parablock. This is /// expected to be a major punishment. - /// Also distributes the rewards to `winners` from the slashing pot. fn punish_for_invalid( session: SessionIndex, candidate_hash: CandidateHash, @@ -86,7 +85,6 @@ pub trait SlashingHandler { /// Punish a series of validators who were against a valid parablock. This /// is expected to be a minor punishment. - /// Also distributes the rewards to `winners` from the slashing pot. fn punish_against_valid( session: SessionIndex, candidate_hash: CandidateHash, From 4f34bd7c9d24450c06c38a7864be7e49f71e1e52 Mon Sep 17 00:00:00 2001 From: Andronik Date: Thu, 1 Sep 2022 16:32:10 +0200 Subject: [PATCH 66/75] lower against valid to 0.1% --- runtime/parachains/src/disputes/slashing.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 0192b8251e25..b998239ce405 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -71,7 +71,7 @@ const LOG_TARGET: &str = "runtime::parachains::slashing"; // These are constants, but we want to make them configurable // via `HostConfiguration` in the future. const SLASH_FOR_INVALID: Perbill = Perbill::from_percent(100); -const SLASH_AGAINST_VALID: Perbill = Perbill::from_percent(1); +const SLASH_AGAINST_VALID: Perbill = Perbill::from_rational(1, 1_000); const DEFENSIVE_PROOF: &'static str = "disputes module should bail on old session"; #[cfg(feature = "runtime-benchmarks")] From 0d9978711f8ec9a746a5e1c45e8ffbe7c75e7b5c Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Thu, 1 Sep 2022 14:46:59 -0300 Subject: [PATCH 67/75] bump zombienet version for debug --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91ac364a8a06..a3b4e4821bd2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -792,6 +792,7 @@ zombienet-tests-parachains-disputes-garbage-candidate: - job: publish-malus-image variables: GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" + ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.2.58" before_script: - echo "Zombie-net Tests Config" - echo "${ZOMBIENET_IMAGE_NAME}" From 9223d71a397431ddc75eb8bb1bf4b04ecc7d447d Mon Sep 17 00:00:00 2001 From: Andronik Date: Thu, 1 Sep 2022 20:38:07 +0200 Subject: [PATCH 68/75] use from_perthousand --- runtime/parachains/src/disputes/slashing.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index b998239ce405..631aff62ae23 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -71,7 +71,7 @@ const LOG_TARGET: &str = "runtime::parachains::slashing"; // These are constants, but we want to make them configurable // via `HostConfiguration` in the future. const SLASH_FOR_INVALID: Perbill = Perbill::from_percent(100); -const SLASH_AGAINST_VALID: Perbill = Perbill::from_rational(1, 1_000); +const SLASH_AGAINST_VALID: Perbill = Perbill::from_perthousand(1); const DEFENSIVE_PROOF: &'static str = "disputes module should bail on old session"; #[cfg(feature = "runtime-benchmarks")] From 655fe9856d866c105bfa4a195f9b6726e0a7acb9 Mon Sep 17 00:00:00 2001 From: Andronik Date: Thu, 1 Sep 2022 21:03:19 +0200 Subject: [PATCH 69/75] post-merge fixes --- runtime/parachains/src/disputes.rs | 2 +- runtime/parachains/src/disputes/slashing.rs | 4 ++-- runtime/parachains/src/mock.rs | 2 +- .../src/weights/runtime_parachains_disputes_slashing.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/parachains/src/disputes.rs b/runtime/parachains/src/disputes.rs index 65f3cee622bb..7fffa001bffe 100644 --- a/runtime/parachains/src/disputes.rs +++ b/runtime/parachains/src/disputes.rs @@ -117,7 +117,7 @@ impl SlashingHandler for () { } fn initializer_initialize(_now: BlockNumber) -> Weight { - Weight::new() + Weight::zero() } fn initializer_finalize() {} diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 631aff62ae23..afd032bec52d 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -400,7 +400,7 @@ pub trait WeightInfo { pub struct TestWeightInfo; impl WeightInfo for TestWeightInfo { fn report_dispute_lost(_validator_count: ValidatorSetCount) -> Weight { - Weight::new() + Weight::zero() } } @@ -566,7 +566,7 @@ pub mod pallet { impl Pallet { /// Called by the initializer to initialize the disputes slashing module. fn initializer_initialize(_now: T::BlockNumber) -> Weight { - Weight::new() + Weight::zero() } /// Called by the initializer to finalize the disputes slashing pallet. diff --git a/runtime/parachains/src/mock.rs b/runtime/parachains/src/mock.rs index 762b6646dab7..1fc03098ce50 100644 --- a/runtime/parachains/src/mock.rs +++ b/runtime/parachains/src/mock.rs @@ -281,7 +281,7 @@ impl crate::disputes::SlashingHandler for Test { } fn initializer_initialize(_now: BlockNumber) -> Weight { - Weight::new() + Weight::zero() } fn initializer_finalize() {} diff --git a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs index 6d5b3d6d2be9..679e827f0896 100644 --- a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs +++ b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -63,7 +63,7 @@ impl runtime_parachains::disputes::slashing::WeightInfo fn report_dispute_lost(n: u32, ) -> Weight { Weight::from_ref_time(97_366_000 as RefTimeWeight) // Standard Error: 2_000 - .saturating_add(Weight::from_ref_time(467_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight)) + .saturating_add(Weight::from_ref_time(467_000 as RefTimeWeight).saturating_mul(n as RefTimeWeight)) .saturating_add(T::DbWeight::get().reads(14 as RefTimeWeight)) .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) } From c5472c98010b52340318ba798e7af82e2ce73680 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 2 Sep 2022 21:18:20 +0200 Subject: [PATCH 70/75] another day, another Weight changes --- .../weights/runtime_parachains_disputes_slashing.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs index 679e827f0896..868be3969728 100644 --- a/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs +++ b/runtime/westend/src/weights/runtime_parachains_disputes_slashing.rs @@ -39,7 +39,7 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use frame_support::{traits::Get, weights::{RefTimeWeight, Weight}}; +use frame_support::{traits::Get, weights::Weight}; use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::disputes::slashing`. @@ -61,10 +61,10 @@ impl runtime_parachains::disputes::slashing::WeightInfo // Storage: Staking ValidatorSlashInEra (r:1 w:0) /// The range of component `n` is `[4, 300]`. fn report_dispute_lost(n: u32, ) -> Weight { - Weight::from_ref_time(97_366_000 as RefTimeWeight) + Weight::from_ref_time(97_366_000 as u64) // Standard Error: 2_000 - .saturating_add(Weight::from_ref_time(467_000 as RefTimeWeight).saturating_mul(n as RefTimeWeight)) - .saturating_add(T::DbWeight::get().reads(14 as RefTimeWeight)) - .saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight)) + .saturating_add(Weight::from_ref_time(467_000 as u64).saturating_mul(n as u64)) + .saturating_add(T::DbWeight::get().reads(14 as u64)) + .saturating_add(T::DbWeight::get().writes(4 as u64)) } } From 6e5f372cb82a33dec486394e609940dbdc135ea8 Mon Sep 17 00:00:00 2001 From: Andronik Date: Fri, 2 Sep 2022 21:25:17 +0200 Subject: [PATCH 71/75] Revert "bump zombienet version for debug" This reverts commit 0d9978711f8ec9a746a5e1c45e8ffbe7c75e7b5c. --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a3b4e4821bd2..91ac364a8a06 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -792,7 +792,6 @@ zombienet-tests-parachains-disputes-garbage-candidate: - job: publish-malus-image variables: GH_DIR: "https://github.com/paritytech/polkadot/tree/${CI_COMMIT_SHORT_SHA}/zombienet_tests/functional" - ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.2.58" before_script: - echo "Zombie-net Tests Config" - echo "${ZOMBIENET_IMAGE_NAME}" From 7bf295ad261371c6bf07a73129399d4ed4801897 Mon Sep 17 00:00:00 2001 From: Andronik Date: Mon, 5 Sep 2022 12:41:44 +0200 Subject: [PATCH 72/75] do not reward block authors --- runtime/parachains/src/disputes/slashing.rs | 24 ++++----------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index afd032bec52d..21a0e2ac2141 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -247,10 +247,9 @@ where offenders, kind, ); - let reporter = None; // This is the first time we report an offence for this dispute, // so it is not a duplicate. - let _ = T::HandleReports::report_offence(reporter, offence); + let _ = T::HandleReports::report_offence(offence); return } @@ -342,7 +341,6 @@ pub trait HandleReports { /// Report a `for valid` offence. fn report_offence( - reporter: Option, offence: SlashingOffence, ) -> Result<(), OffenceError>; @@ -353,9 +351,6 @@ pub trait HandleReports { time_slot: &DisputesTimeSlot, ) -> bool; - /// Fetch the current block author id, if defined. - fn block_author() -> Option; - /// Create and dispatch a slashing report extrinsic. /// This should be called offchain. fn submit_unsigned_slashing_report( @@ -368,7 +363,6 @@ impl HandleReports for () { type ReportLongevity = (); fn report_offence( - _reporter: Option, _offence: SlashingOffence, ) -> Result<(), OffenceError> { Ok(()) @@ -387,10 +381,6 @@ impl HandleReports for () { ) -> DispatchResult { Ok(()) } - - fn block_author() -> Option { - None - } } pub trait WeightInfo { @@ -542,8 +532,7 @@ pub mod pallet { dispute_proof.kind, ); - let block_author = >::block_author(); - >::report_offence(block_author, offence) + >::report_offence(offence) .map_err(|_| Error::::DuplicateSlashingReport)?; Ok(Pays::No.into()) @@ -683,7 +672,7 @@ impl Default for SlashingReportHandler { impl HandleReports for SlashingReportHandler where - T: Config + frame_system::offchain::SendTransactionTypes> + pallet_authorship::Config, + T: Config + frame_system::offchain::SendTransactionTypes>, R: ReportOffence< T::AccountId, T::KeyOwnerIdentification, @@ -694,10 +683,9 @@ where type ReportLongevity = L; fn report_offence( - reporter: Option, offence: SlashingOffence, ) -> Result<(), OffenceError> { - let reporters = reporter.into_iter().collect(); + let reporters = Vec::new(); R::report_offence(reporters, offence) } @@ -746,8 +734,4 @@ where Ok(()) } - - fn block_author() -> Option { - >::author() - } } From cd9aeb81a19c3c2a0526cb857012cdff2f28f238 Mon Sep 17 00:00:00 2001 From: Andronik Date: Tue, 6 Sep 2022 16:31:18 +0200 Subject: [PATCH 73/75] fix outdated comment --- runtime/parachains/src/disputes/slashing.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index 21a0e2ac2141..d8bc0b343eca 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -339,7 +339,7 @@ pub trait HandleReports { /// (in blocks, not eras). type ReportLongevity: Get; - /// Report a `for valid` offence. + /// Report an offence. fn report_offence( offence: SlashingOffence, ) -> Result<(), OffenceError>; From b453b1af5abb6504e0f8eb95fbbf549e8a9f6418 Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Mon, 19 Sep 2022 15:28:14 -0300 Subject: [PATCH 74/75] use Pays from frame_support::dispatch::Pays --- runtime/parachains/src/disputes/slashing.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/parachains/src/disputes/slashing.rs b/runtime/parachains/src/disputes/slashing.rs index d8bc0b343eca..fd6708de6ba0 100644 --- a/runtime/parachains/src/disputes/slashing.rs +++ b/runtime/parachains/src/disputes/slashing.rs @@ -45,9 +45,11 @@ use crate::{disputes, initializer::ValidatorSetCount, session_info::IdentificationTuple}; use frame_support::{ + dispatch::Pays, traits::{Defensive, Get, KeyOwnerProofSystem, ValidatorSet, ValidatorSetWithIdentification}, - weights::{Pays, Weight}, + weights::Weight, }; + use parity_scale_codec::{Decode, Encode}; use primitives::v2::{CandidateHash, SessionIndex, ValidatorId, ValidatorIndex}; use scale_info::TypeInfo; From 65da4730f401f4f2412ca00b9c987ba7fc68bd02 Mon Sep 17 00:00:00 2001 From: Javier Viola Date: Tue, 20 Sep 2022 07:10:16 -0300 Subject: [PATCH 75/75] add timeout to is up --- .../0003-deregister-register-validator-smoke.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature b/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature index 90fa4ef9d711..6a79c4cb071d 100644 --- a/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature +++ b/zombienet_tests/smoke/0003-deregister-register-validator-smoke.feature @@ -2,10 +2,10 @@ Description: Deregister / Register Validator Smoke Network: ./0003-deregister-register-validator-smoke.toml Creds: config -alice: is up -bob: is up -charlie: is up -dave: is up +alice: is up within 30 seconds +bob: is up within 30 seconds +charlie: is up within 30 seconds +dave: is up within 30 seconds # ensure is in the validator set dave: reports polkadot_node_is_parachain_validator is 1 within 240 secs