Unverified Commit 2dd52cc8 authored by Kian Paimani's avatar Kian Paimani Committed by GitHub
Browse files

companion for substrate/pull/6132 (#1159)

* companion for https://github.com/paritytech/substrate/pull/6132



* Fix more tests

* upsub

* Bump

* Update runtime/common/src/lib.rs
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>

* remove cleanup

* Update runtime/westend/src/lib.rs

* Apply suggestions from code review

* Fix build
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
parent fc839a0b
Pipeline #94360 failed with stages
in 6 minutes and 3 seconds
This diff is collapsed.
......@@ -11,6 +11,7 @@ log = { version = "0.3.9", optional = true }
rustc-hex = { version = "2.0.1", default-features = false }
serde = { version = "1.0.102", default-features = false }
serde_derive = { version = "1.0.102", optional = true }
static_assertions = "1.1.0"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
......
......@@ -684,7 +684,7 @@ mod tests {
}
parameter_types!{
pub const Prefix: &'static [u8] = b"Pay RUSTs to the TEST account:";
pub Prefix: &'static [u8] = b"Pay RUSTs to the TEST account:";
}
impl Trait for Test {
......
......@@ -38,7 +38,7 @@ use frame_support::{
parameter_types, traits::{Currency, Filter},
weights::{Weight, constants::WEIGHT_PER_SECOND},
};
use static_assertions::const_assert;
pub use frame_support::weights::constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
#[cfg(feature = "std")]
......@@ -56,15 +56,17 @@ use sp_runtime::traits::Dispatchable;
pub type NegativeImbalance<T> = <balances::Module<T> as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
const AVERAGE_ON_INITIALIZE_WEIGHT: Perbill = Perbill::from_percent(10);
parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()
.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();
pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()
.saturating_sub(AVERAGE_ON_INITIALIZE_WEIGHT) * MaximumBlockWeight::get();
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
}
const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());
/// Apply a given filter to transactions.
pub struct TransactionCallFilter<T: Filter<Call>, Call>(PhantomData<(T, Call)>);
......
......@@ -1811,7 +1811,7 @@ mod tests {
}
parameter_types! {
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
}
impl offences::Trait for Test {
......
......@@ -35,7 +35,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, PerThing,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
curve::PiecewiseLinear,
traits::{
......@@ -85,7 +85,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 2,
spec_version: 1064,
impl_version: 0,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
......@@ -190,10 +190,16 @@ impl balances::Trait for Runtime {
parameter_types! {
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
}
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
const_assert!(
TargetBlockFullness::get().deconstruct() <
(AvailableBlockRatio::get().deconstruct() as <Perquintill as PerThing>::Inner)
* (<Perquintill as PerThing>::ACCURACY / <Perbill as PerThing>::ACCURACY as <Perquintill as PerThing>::Inner)
);
impl transaction_payment::Trait for Runtime {
type Currency = Balances;
type OnTransactionPayment = DealWithFees;
......@@ -368,18 +374,17 @@ impl collective::Trait<CouncilCollective> for Runtime {
type MaxProposals = CouncilMaxProposals;
}
const DESIRED_MEMBERS: u32 = 17;
parameter_types! {
pub const CandidacyBond: Balance = 1 * DOLLARS;
pub const VotingBond: Balance = 5 * CENTS;
/// Daily council elections.
pub const TermDuration: BlockNumber = 24 * HOURS;
pub const DesiredMembers: u32 = DESIRED_MEMBERS;
pub const DesiredMembers: u32 = 17;
pub const DesiredRunnersUp: u32 = 7;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
}
// Make sure that there are no more than MAX_MEMBERS members elected via phragmen.
const_assert!(DESIRED_MEMBERS <= collective::MAX_MEMBERS);
const_assert!(DesiredMembers::get() <= collective::MAX_MEMBERS);
impl elections_phragmen::Trait for Runtime {
type Event = Event;
......@@ -455,7 +460,7 @@ impl treasury::Trait for Runtime {
}
parameter_types! {
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
}
impl offences::Trait for Runtime {
......@@ -507,8 +512,8 @@ impl grandpa::Trait for Runtime {
}
parameter_types! {
pub const WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub const ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
pub WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
}
impl finality_tracker::Trait for Runtime {
......@@ -648,7 +653,7 @@ impl slots::Trait for Runtime {
}
parameter_types! {
pub const Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
pub Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
}
impl claims::Trait for Runtime {
......
......@@ -36,7 +36,7 @@ use primitives::{
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, PerThing,
transaction_validity::{
TransactionValidity, TransactionSource, TransactionPriority,
},
......@@ -213,10 +213,16 @@ impl balances::Trait for Runtime {
parameter_types! {
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
}
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
const_assert!(
TargetBlockFullness::get().deconstruct() <
(AvailableBlockRatio::get().deconstruct() as <Perquintill as PerThing>::Inner)
* (<Perquintill as PerThing>::ACCURACY / <Perbill as PerThing>::ACCURACY as <Perquintill as PerThing>::Inner)
);
impl transaction_payment::Trait for Runtime {
type Currency = Balances;
type OnTransactionPayment = DealWithFees;
......@@ -390,19 +396,18 @@ impl collective::Trait<CouncilCollective> for Runtime {
type MaxProposals = CouncilMaxProposals;
}
const DESIRED_MEMBERS: u32 = 13;
parameter_types! {
pub const CandidacyBond: Balance = 100 * DOLLARS;
pub const VotingBond: Balance = 5 * DOLLARS;
/// Weekly council elections initially, later monthly.
pub const TermDuration: BlockNumber = 7 * DAYS;
/// 13 members initially, to be increased to 23 eventually.
pub const DesiredMembers: u32 = DESIRED_MEMBERS;
pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 20;
pub const ElectionsPhragmenModuleId: LockIdentifier = *b"phrelect";
}
// Make sure that there are no more than MAX_MEMBERS members elected via phragmen.
const_assert!(DESIRED_MEMBERS <= collective::MAX_MEMBERS);
const_assert!(DesiredMembers::get() <= collective::MAX_MEMBERS);
impl elections_phragmen::Trait for Runtime {
type Event = Event;
......@@ -478,7 +483,7 @@ impl treasury::Trait for Runtime {
}
parameter_types! {
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
}
impl offences::Trait for Runtime {
......@@ -530,8 +535,8 @@ impl grandpa::Trait for Runtime {
}
parameter_types! {
pub const WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub const ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
pub WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
}
impl finality_tracker::Trait for Runtime {
......@@ -673,7 +678,7 @@ impl slots::Trait for Runtime {
}
parameter_types! {
pub const Prefix: &'static [u8] = b"Pay DOTs to the Polkadot account:";
pub Prefix: &'static [u8] = b"Pay DOTs to the Polkadot account:";
}
impl claims::Trait for Runtime {
......
......@@ -200,7 +200,6 @@ impl balances::Trait for Runtime {
parameter_types! {
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
}
......@@ -424,7 +423,7 @@ impl system::offchain::SigningTypes for Runtime {
}
parameter_types! {
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
}
impl offences::Trait for Runtime {
......@@ -465,7 +464,7 @@ impl slots::Trait for Runtime {
}
parameter_types! {
pub const Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
pub Prefix: &'static [u8] = b"Pay KSMs to the Kusama account:";
}
impl claims::Trait for Runtime {
......
......@@ -13,6 +13,7 @@ rustc-hex = { version = "2.0.1", default-features = false }
serde = { version = "1.0.102", default-features = false }
serde_derive = { version = "1.0.102", optional = true }
smallvec = "1.4.0"
static_assertions = "1.1.0"
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
......
......@@ -21,6 +21,7 @@
#![recursion_limit="256"]
use sp_std::prelude::*;
use static_assertions::const_assert;
use codec::{Encode, Decode};
use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
......@@ -34,7 +35,7 @@ use runtime_common::{attestations, parachains, registrar,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Perbill, Perquintill, curve::PiecewiseLinear,
ApplyExtrinsicResult, KeyTypeId, Perbill, Perquintill, curve::PiecewiseLinear, PerThing,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
......@@ -179,10 +180,16 @@ impl balances::Trait for Runtime {
parameter_types! {
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
}
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
const_assert!(
TargetBlockFullness::get().deconstruct() <
(AvailableBlockRatio::get().deconstruct() as <Perquintill as PerThing>::Inner)
* (<Perquintill as PerThing>::ACCURACY / <Perbill as PerThing>::ACCURACY as <Perquintill as PerThing>::Inner)
);
impl transaction_payment::Trait for Runtime {
type Currency = Balances;
type OnTransactionPayment = ToAuthor<Runtime>;
......@@ -309,7 +316,7 @@ parameter_types! {
}
parameter_types! {
pub const OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
}
impl offences::Trait for Runtime {
......@@ -361,8 +368,8 @@ impl grandpa::Trait for Runtime {
}
parameter_types! {
pub const WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub const ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
pub WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
pub ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
}
impl finality_tracker::Trait for Runtime {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment