Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

companion for substrate/pull/6132 #1159

Merged
merged 10 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
971 changes: 557 additions & 414 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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());

kianenigma marked this conversation as resolved.
Show resolved Hide resolved
/// Apply a given filter to transactions.
pub struct TransactionCallFilter<T: Filter<Call>, Call>(PhantomData<(T, Call)>);
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
25 changes: 15 additions & 10 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
25 changes: 15 additions & 10 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -72,7 +72,7 @@ pub use sp_runtime::BuildStorage;
pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
pub use parachains::Call as ParachainsCall;
use parachains::Call as ParachainsCall;
kianenigma marked this conversation as resolved.
Show resolved Hide resolved

/// Constant values used within the runtime.
pub mod constants;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
pub use parachains::Call as ParachainsCall;
use parachains::Call as ParachainsCall;

/// Constant values used within the runtime.
pub mod constants;
Expand Down Expand Up @@ -200,7 +201,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);
}

Expand Down Expand Up @@ -424,7 +424,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 {
Expand Down Expand Up @@ -465,7 +465,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 {
Expand Down
1 change: 1 addition & 0 deletions runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
19 changes: 13 additions & 6 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -66,7 +67,7 @@ pub use sp_runtime::BuildStorage;
pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
pub use parachains::Call as ParachainsCall;
use parachains::Call as ParachainsCall;
kianenigma marked this conversation as resolved.
Show resolved Hide resolved

/// Constant values used within the runtime.
pub mod constants;
Expand Down Expand Up @@ -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!(
kianenigma marked this conversation as resolved.
Show resolved Hide resolved
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>;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down