Add parachains modules to Westend and Kusama runtimes (#2854)

* add `force_set_active_config`

* add parachains modules to Westend

* add parachains modules to Kusama runtime

* use real runtime API impl

* add module indices and remove auctions, crowdloan

* add benchmarks

* remove previous migrations and add host configuration set migration

* make compile

* Add Call Filter for Registrar and Slots except Root

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=slots --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=paras_registrar --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/

* fix build

* update `add_benchmark`

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::paras_registrar --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_paras_registrar.rs

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_common::slots --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_common_slots.rs

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::paras_registrar --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_paras_registrar.rs

* cargo run --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_common::slots --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_common_slots.rs

* fix weights

* tweak more constants

* Fix up the kusama runtime

* Westend runtime fixups

* Fix MMR & Beefy for westend

* Fixes

* fix tests

* Update runtime/polkadot/src/constants.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update runtime/westend/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
Co-authored-by: Gav Wood <gavin@parity.io>
This commit is contained in:
Robert Habermeier
2021-05-01 11:36:11 -04:00
committed by GitHub
parent 99b10213a0
commit 2d18b26151
21 changed files with 1134 additions and 234 deletions
+10
View File
@@ -78,8 +78,13 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", b
hex-literal = { version = "0.3.1", optional = true }
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
runtime-parachains = { package = "polkadot-runtime-parachains", path = "../parachains", default-features = false }
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
xcm = { package = "xcm", path = "../../xcm", default-features = false }
xcm-executor = { package = "xcm-executor", path = "../../xcm/xcm-executor", default-features = false }
xcm-builder = { package = "xcm-builder", path = "../../xcm/xcm-builder", default-features = false }
[dev-dependencies]
hex-literal = "0.3.1"
libsecp256k1 = "0.3.5"
@@ -154,10 +159,14 @@ std = [
"babe-primitives/std",
"sp-session/std",
"runtime-common/std",
"runtime-parachains/std",
"frame-try-runtime/std",
"sp-npos-elections/std",
"beefy-primitives/std",
"pallet-mmr-primitives/std",
"xcm/std",
"xcm-executor/std",
"xcm-builder/std",
]
runtime-benchmarks = [
"runtime-common/runtime-benchmarks",
@@ -191,6 +200,7 @@ runtime-benchmarks = [
"pallet-session-benchmarking",
"frame-system-benchmarking",
"hex-literal",
"xcm-builder/runtime-benchmarks",
]
try-runtime = [
"frame-executive/try-runtime",
+18 -15
View File
@@ -18,35 +18,28 @@
pub mod currency {
use primitives::v0::Balance;
pub const DOTS: Balance = 1_000_000_000_000;
pub const DOLLARS: Balance = DOTS / 300;
pub const CENTS: Balance = DOLLARS / 100;
pub const UNITS: Balance = 1_000_000_000_000;
pub const CENTS: Balance = UNITS / 30_000;
pub const GRAND: Balance = CENTS * 100_000;
pub const MILLICENTS: Balance = CENTS / 1_000;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 20 * DOLLARS + (bytes as Balance) * 100 * MILLICENTS
items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS
}
}
/// Time and blocks.
pub mod time {
use primitives::v0::{Moment, BlockNumber};
// Kusama & mainnet
pub const MILLISECS_PER_BLOCK: Moment = 6000;
// Testnet
// pub const MILLISECS_PER_BLOCK: Moment = 1000;
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
// Kusama
pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = 1 * HOURS;
// Mainnet
// pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = 4 * HOURS;
// Testnet
// pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = 10 * MINUTES;
// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
pub const WEEKS: BlockNumber = DAYS * 7;
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
@@ -92,20 +85,30 @@ pub mod fee {
}
}
/// Parachains-related.
pub mod paras {
/// Maximum parachain code blob size.
pub const MAX_CODE_SIZE: u32 = 10 * 1024 * 1024;
/// Maximum parachain head size.
pub const MAX_HEAD_SIZE: u32 = 20 * 1024;
/// Maximum PoV size.
pub const MAX_POV_SIZE: u32 = 5 * 1024 * 1024;
}
#[cfg(test)]
mod tests {
use frame_support::weights::WeightToFeePolynomial;
use runtime_common::{MAXIMUM_BLOCK_WEIGHT, ExtrinsicBaseWeight};
use super::fee::WeightToFee;
use super::currency::{CENTS, DOLLARS, MILLICENTS};
use super::currency::{CENTS, MILLICENTS};
#[test]
// This function tests that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight is correct
fn full_block_fee_is_correct() {
// A full block should cost 16 DOLLARS
// A full block should cost 1,600 CENTS
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::calc(&MAXIMUM_BLOCK_WEIGHT);
let y = 16 * DOLLARS;
let y = 16 * 100 * CENTS;
assert!(x.max(y) - x.min(y) < MILLICENTS);
}
+326 -57
View File
@@ -27,17 +27,39 @@ use sp_core::u32_trait::{_1, _2, _3, _5};
use parity_scale_codec::{Encode, Decode};
use primitives::v1::{
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt,
CoreState, GroupRotationInfo, Hash, Id, Moment, Nonce, OccupiedCoreAssumption,
CoreState, GroupRotationInfo, Hash, Id as ParaId, Moment, Nonce, OccupiedCoreAssumption,
PersistedValidationData, Signature, ValidationCode, ValidatorId, ValidatorIndex,
InboundDownwardMessage, InboundHrmpMessage, SessionInfo,
};
use runtime_common::{
claims, SlowAdjustingFeeUpdate, CurrencyToVote,
impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength,
OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
claims, SlowAdjustingFeeUpdate, CurrencyToVote, paras_registrar, xcm_sender, slots, impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength, OffchainSolutionWeightLimit, OffchainSolutionLengthLimit,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder, ToAuthor,
};
use runtime_parachains::origin as parachains_origin;
use runtime_parachains::configuration as parachains_configuration;
use runtime_parachains::shared as parachains_shared;
use runtime_parachains::inclusion as parachains_inclusion;
use runtime_parachains::paras_inherent as parachains_paras_inherent;
use runtime_parachains::initializer as parachains_initializer;
use runtime_parachains::session_info as parachains_session_info;
use runtime_parachains::paras as parachains_paras;
use runtime_parachains::dmp as parachains_dmp;
use runtime_parachains::ump as parachains_ump;
use runtime_parachains::hrmp as parachains_hrmp;
use runtime_parachains::scheduler as parachains_scheduler;
use runtime_parachains::reward_points as parachains_reward_points;
use runtime_parachains::runtime_api_impl::v1 as parachains_runtime_api_impl;
use xcm::v0::{MultiLocation, NetworkId};
use xcm_builder::{
AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation, CurrencyAdapter as XcmCurrencyAdapter,
ChildParachainAsNative, SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, LocationInverter, IsConcrete,
FixedWeightBounds, TakeWeightCredit, AllowTopLevelPaidExecutionFrom,
AllowUnpaidExecutionFrom, IsChildSystemParachain, UsingComponents,
};
use xcm_executor::XcmExecutor;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill,
@@ -58,7 +80,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, RuntimeDebug, PalletId,
traits::{KeyOwnerProofSystem, Randomness, LockIdentifier, Filter, InstanceFilter},
traits::{KeyOwnerProofSystem, Randomness, LockIdentifier, Filter, InstanceFilter, All},
weights::Weight,
};
use frame_system::{EnsureRoot, EnsureOneOf};
@@ -79,7 +101,7 @@ pub use pallet_balances::Call as BalancesCall;
/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*, fee::*};
use constants::{time::*, currency::*, fee::*, paras::*};
// Weights used in the runtime.
mod weights;
@@ -118,11 +140,14 @@ pub fn native_version() -> NativeVersion {
}
}
/// Avoid processing transactions from slots and parachain registrar.
/// Avoid processing transactions from slots and parachain registrar except by root.
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
fn filter(_: &Call) -> bool {
true
fn filter(c: &Call) -> bool {
!matches!(c,
Call::Registrar(..) |
Call::Slots(..)
)
}
}
@@ -213,7 +238,7 @@ impl pallet_babe::Config for Runtime {
}
parameter_types! {
pub const IndexDeposit: Balance = 1 * DOLLARS;
pub const IndexDeposit: Balance = 100 * CENTS;
}
impl pallet_indices::Config for Runtime {
@@ -409,7 +434,7 @@ parameter_types! {
pub const LaunchPeriod: BlockNumber = 7 * DAYS;
pub const VotingPeriod: BlockNumber = 7 * DAYS;
pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS;
pub const MinimumDeposit: Balance = 1 * DOLLARS;
pub const MinimumDeposit: Balance = 100 * CENTS;
pub const EnactmentPeriod: BlockNumber = 8 * DAYS;
pub const CooloffPeriod: BlockNumber = 7 * DAYS;
// One cent: $10,000 / MB
@@ -487,7 +512,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
}
parameter_types! {
pub const CandidacyBond: Balance = 1 * DOLLARS;
pub const CandidacyBond: Balance = 100 * CENTS;
// 1 storage item created, key size is 32 bytes, value size is 16+16.
pub const VotingBondBase: Balance = deposit(1, 64);
// additional data per vote is 32 bytes (account id).
@@ -553,21 +578,21 @@ impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 20 * DOLLARS;
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
pub const SpendPeriod: BlockNumber = 6 * DAYS;
pub const Burn: Permill = Permill::from_perthousand(2);
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
pub const TipReportDepositBase: Balance = 100 * CENTS;
pub const DataDepositPerByte: Balance = 1 * CENTS;
pub const BountyDepositBase: Balance = 1 * DOLLARS;
pub const BountyDepositBase: Balance = 100 * CENTS;
pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
pub const MaximumReasonLength: u32 = 16384;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: Balance = 2 * DOLLARS;
pub const BountyValueMinimum: Balance = 200 * CENTS;
pub const MaxApprovals: u32 = 100;
}
@@ -738,9 +763,9 @@ impl claims::Config for Runtime {
parameter_types! {
// Minimum 100 bytes/KSM deposited (1 CENT/byte)
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
pub const BasicDeposit: Balance = 1000 * CENTS; // 258 bytes on-chain
pub const FieldDeposit: Balance = 250 * CENTS; // 66 bytes on-chain
pub const SubAccountDeposit: Balance = 2 * DOLLARS; // 53 bytes on-chain
pub const SubAccountDeposit: Balance = 200 * CENTS; // 53 bytes on-chain
pub const MaxSubAccounts: u32 = 100;
pub const MaxAdditionalFields: u32 = 100;
pub const MaxRegistrars: u32 = 20;
@@ -786,10 +811,10 @@ impl pallet_multisig::Config for Runtime {
}
parameter_types! {
pub const ConfigDepositBase: Balance = 5 * DOLLARS;
pub const ConfigDepositBase: Balance = 500 * CENTS;
pub const FriendDepositFactor: Balance = 50 * CENTS;
pub const MaxFriends: u16 = 9;
pub const RecoveryDeposit: Balance = 5 * DOLLARS;
pub const RecoveryDeposit: Balance = 500 * CENTS;
}
impl pallet_recovery::Config for Runtime {
@@ -803,11 +828,11 @@ impl pallet_recovery::Config for Runtime {
}
parameter_types! {
pub const CandidateDeposit: Balance = 10 * DOLLARS;
pub const WrongSideDeduction: Balance = 2 * DOLLARS;
pub const CandidateDeposit: Balance = 1000 * CENTS;
pub const WrongSideDeduction: Balance = 200 * CENTS;
pub const MaxStrikes: u32 = 10;
pub const RotationPeriod: BlockNumber = 7 * DAYS;
pub const PeriodSpend: Balance = 500 * DOLLARS;
pub const PeriodSpend: Balance = 50000 * CENTS;
pub const MaxLockDuration: BlockNumber = 36 * 30 * DAYS;
pub const ChallengePeriod: BlockNumber = 7 * DAYS;
pub const MaxCandidateIntake: u32 = 1;
@@ -833,7 +858,7 @@ impl pallet_society::Config for Runtime {
}
parameter_types! {
pub const MinVestedTransfer: Balance = 1 * DOLLARS;
pub const MinVestedTransfer: Balance = 100 * CENTS;
}
impl pallet_vesting::Config for Runtime {
@@ -962,6 +987,168 @@ impl pallet_proxy::Config for Runtime {
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}
impl parachains_origin::Config for Runtime {}
impl parachains_configuration::Config for Runtime {}
impl parachains_shared::Config for Runtime {}
impl parachains_session_info::Config for Runtime {}
impl parachains_inclusion::Config for Runtime {
type Event = Event;
type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints<Runtime>;
}
impl parachains_paras::Config for Runtime {
type Origin = Origin;
type Event = Event;
}
parameter_types! {
pub const FirstMessageFactorPercent: u64 = 100;
}
impl parachains_ump::Config for Runtime {
type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Call>;
type FirstMessageFactorPercent = FirstMessageFactorPercent;
}
impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime {
type Event = Event;
type Origin = Origin;
type Currency = Balances;
}
impl parachains_paras_inherent::Config for Runtime {}
impl parachains_scheduler::Config for Runtime {}
impl parachains_initializer::Config for Runtime {
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
type ForceOrigin = EnsureRoot<AccountId>;
}
parameter_types! {
pub const ParaDeposit: Balance = deposit(10, MAX_CODE_SIZE + MAX_HEAD_SIZE);
pub const MaxCodeSize: u32 = MAX_CODE_SIZE;
pub const MaxHeadSize: u32 = MAX_HEAD_SIZE;
}
impl paras_registrar::Config for Runtime {
type Event = Event;
type Origin = Origin;
type Currency = Balances;
type OnSwap = Slots;
type ParaDeposit = ParaDeposit;
type DataDepositPerByte = DataDepositPerByte;
type MaxCodeSize = MaxCodeSize;
type MaxHeadSize = MaxHeadSize;
type WeightInfo = weights::runtime_common_paras_registrar::WeightInfo<Runtime>;
}
parameter_types! {
// 6 weeks
pub const LeasePeriod: BlockNumber = 6 * WEEKS;
}
impl slots::Config for Runtime {
type Event = Event;
type Currency = Balances;
type Registrar = Registrar;
type LeasePeriod = LeasePeriod;
type WeightInfo = weights::runtime_common_slots::WeightInfo<Runtime>;
}
parameter_types! {
/// The location of the KSM token, from the context of this chain. Since this token is native to this
/// chain, we make it synonymous with it and thus it is the `Null` location, which means "equivalent to
/// the context".
pub const KsmLocation: MultiLocation = MultiLocation::Null;
/// The Kusama network ID. This is named.
pub const KusamaNetwork: NetworkId = NetworkId::Kusama;
/// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since
/// Kusama is a top-level relay-chain, there is no ancestry.
pub const Ancestry: MultiLocation = MultiLocation::Null;
}
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
/// the sovereign account controlled by a location.
pub type SovereignAccountOf = (
// We can convert a child parachain using the standard `AccountId` conversion.
ChildParachainConvertsVia<ParaId, AccountId>,
// We can directly alias an `AccountId32` into a local account.
AccountId32Aliases<KusamaNetwork, AccountId>,
);
/// Our asset transactor. This is what allows us to interest with the runtime facilities from the point of
/// view of XCM-only concepts like `MultiLocation` and `MultiAsset`.
///
/// Ours is only aware of the Balances pallet, which is mapped to `KsmLocation`.
pub type LocalAssetTransactor =
XcmCurrencyAdapter<
// Use this currency:
Balances,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<KsmLocation>,
// We can convert the MultiLocations with our converter above:
SovereignAccountOf,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
>;
/// The means that we convert an the XCM message origin location into a local dispatch origin.
type LocalOriginConverter = (
// A `Signed` origin of the sovereign account that the original location controls.
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
// A child parachain, natively expressed, has the `Parachain` origin.
ChildParachainAsNative<parachains_origin::Origin, Origin>,
// The AccountId32 location type can be expressed natively as a `Signed` origin.
SignedAccountId32AsNative<KusamaNetwork, Origin>,
// A system child parachain, expressed as a Superuser, converts to the `Root` origin.
ChildSystemParachainAsSuperuser<ParaId, Origin>,
);
parameter_types! {
/// The amount of weight an XCM operation takes. This is a safe overestimate.
pub const BaseXcmWeight: Weight = 1_000_000_000;
}
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our
/// individual routers.
pub type XcmRouter = (
// Only one router so far - use DMP to communicate with child parachains.
xcm_sender::ChildParachainRouter<Runtime>,
);
/// The barriers one of which must be passed for an XCM message to be executed.
pub type Barrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
// Messages coming from system parachains need not pay for execution.
AllowUnpaidExecutionFrom<IsChildSystemParachain<ParaId>>,
);
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
type IsReserve = ();
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
// The weight trader piggybacks on the existing transaction-fee conversion logic.
type Trader = UsingComponents<WeightToFee, KsmLocation, AccountId, Balances, ToAuthor<Runtime>>;
type ResponseHandler = ();
}
construct_runtime! {
pub enum Runtime where
Block = Block,
@@ -1033,6 +1220,24 @@ construct_runtime! {
// Election pallet. Only works with staking, but placed here to maintain indices.
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 37,
// Parachains pallets. Start indices at 50 to leave room.
ParachainsOrigin: parachains_origin::{Pallet, Origin} = 50,
ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>} = 51,
ParasShared: parachains_shared::{Pallet, Call, Storage} = 52,
ParasInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>} = 53,
ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent} = 54,
ParasScheduler: parachains_scheduler::{Pallet, Call, Storage} = 55,
Paras: parachains_paras::{Pallet, Call, Storage, Event} = 56,
ParasInitializer: parachains_initializer::{Pallet, Call, Storage} = 57,
ParasDmp: parachains_dmp::{Pallet, Call, Storage} = 58,
ParasUmp: parachains_ump::{Pallet, Call, Storage} = 59,
ParasHrmp: parachains_hrmp::{Pallet, Call, Storage, Event} = 60,
ParasSessionInfo: parachains_session_info::{Pallet, Call, Storage} = 61,
// Parachain Onboarding Pallets. Start indices at 70 to leave room.
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>} = 70,
Slots: slots::{Pallet, Call, Storage, Event<T>} = 71,
}
}
@@ -1042,6 +1247,57 @@ impl pallet_babe::migrations::BabePalletPrefix for Runtime {
}
}
pub struct ParachainHostConfigurationMigration;
impl frame_support::traits::OnRuntimeUpgrade for ParachainHostConfigurationMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
let config = parachains_configuration::HostConfiguration {
max_code_size: MaxCodeSize::get(),
max_head_data_size: MaxHeadSize::get(),
max_upward_queue_count: 10,
max_upward_queue_size: 50 * 1024,
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 10,
hrmp_max_message_num_per_candidate: 10,
validation_upgrade_frequency: 1 * DAYS,
validation_upgrade_delay: EPOCH_DURATION_IN_SLOTS,
max_pov_size: MAX_POV_SIZE,
max_downward_message_size: 50 * 1024,
preferred_dispatchable_upward_messages_step_weight: 0,
hrmp_max_parachain_outbound_channels: 10,
hrmp_max_parathread_outbound_channels: 0,
hrmp_open_request_ttl: 2,
hrmp_sender_deposit: deposit(1004, 100 * 1024),
hrmp_recipient_deposit: deposit(1004, 100 * 1024),
hrmp_channel_max_capacity: 1000,
hrmp_channel_max_total_size: 100 * 1024,
hrmp_max_parachain_inbound_channels: 10,
hrmp_max_parathread_inbound_channels: 0,
hrmp_channel_max_message_size: 100 * 1024,
code_retention_period: 2 * DAYS,
parathread_cores: 0,
parathread_retries: 0,
group_rotation_frequency: 1 * MINUTES,
chain_availability_period: 1 * MINUTES,
thread_availability_period: 1 * MINUTES,
scheduling_lookahead: 1,
max_validators_per_core: Some(5),
max_validators: Some(200),
dispute_period: 6,
dispute_post_conclusion_acceptance_period: 1 * HOURS,
dispute_max_spam_slots: 2,
dispute_conclusion_by_time_out_period: 1 * HOURS,
no_show_slots: 2,
n_delay_tranches: 89,
zeroth_delay_tranche_width: 0,
needed_approvals: 30,
relay_vrf_modulo_samples: 1,
};
ParachainsConfiguration::force_set_active_config(config);
RocksDbWeight::get().writes(1)
}
}
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
@@ -1071,7 +1327,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(),
ParachainHostConfigurationMigration,
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
@@ -1140,66 +1396,75 @@ sp_api::impl_runtime_apis! {
impl primitives::v1::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<ValidatorId> {
Vec::new()
parachains_runtime_api_impl::validators::<Runtime>()
}
fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
(Vec::new(), GroupRotationInfo { session_start_block: 0, group_rotation_frequency: 0, now: 0 })
parachains_runtime_api_impl::validator_groups::<Runtime>()
}
fn availability_cores() -> Vec<CoreState<Hash, BlockNumber>> {
Vec::new()
parachains_runtime_api_impl::availability_cores::<Runtime>()
}
fn persisted_validation_data(_: Id, _: OccupiedCoreAssumption)
fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<PersistedValidationData<Hash, BlockNumber>> {
None
parachains_runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
}
fn check_validation_outputs(
_: Id,
_: primitives::v1::CandidateCommitments,
para_id: ParaId,
outputs: primitives::v1::CandidateCommitments,
) -> bool {
false
parachains_runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
}
fn session_index_for_child() -> SessionIndex {
0
parachains_runtime_api_impl::session_index_for_child::<Runtime>()
}
fn session_info(_: SessionIndex) -> Option<SessionInfo> {
None
fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<ValidationCode> {
parachains_runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
}
fn validation_code(_: Id, _: OccupiedCoreAssumption) -> Option<ValidationCode> {
None
fn historical_validation_code(para_id: ParaId, context_height: BlockNumber)
-> Option<ValidationCode>
{
parachains_runtime_api_impl::historical_validation_code::<Runtime>(para_id, context_height)
}
fn historical_validation_code(_: Id, _: BlockNumber) -> Option<ValidationCode> {
None
}
fn candidate_pending_availability(_: Id) -> Option<CommittedCandidateReceipt<Hash>> {
None
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
parachains_runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
}
fn candidate_events() -> Vec<CandidateEvent<Hash>> {
Vec::new()
parachains_runtime_api_impl::candidate_events::<Runtime, _>(|ev| {
match ev {
Event::parachains_inclusion(ev) => {
Some(ev)
}
_ => None,
}
})
}
fn dmq_contents(
_recipient: Id,
) -> Vec<InboundDownwardMessage<BlockNumber>> {
Vec::new()
fn session_info(index: SessionIndex) -> Option<SessionInfo> {
parachains_runtime_api_impl::session_info::<Runtime>(index)
}
fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
parachains_runtime_api_impl::dmq_contents::<Runtime>(recipient)
}
fn inbound_hrmp_channels_contents(
_recipient: Id
) -> BTreeMap<Id, Vec<InboundHrmpMessage<BlockNumber>>> {
BTreeMap::new()
recipient: ParaId
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
parachains_runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
}
fn validation_code_by_hash(_hash: Hash) -> Option<ValidationCode> {
None
fn validation_code_by_hash(hash: Hash) -> Option<ValidationCode> {
parachains_runtime_api_impl::validation_code_by_hash::<Runtime>(hash)
}
}
@@ -1322,7 +1587,7 @@ sp_api::impl_runtime_apis! {
impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
fn authorities() -> Vec<AuthorityDiscoveryId> {
AuthorityDiscovery::authorities()
parachains_runtime_api_impl::relevant_authority_ids::<Runtime>()
}
}
@@ -1400,7 +1665,11 @@ sp_api::impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);
// Polkadot
// NOTE: Make sure to prefix these `runtime_common::` so that path resolves correctly
// in the generated file.
add_benchmark!(params, batches, runtime_common::claims, Claims);
add_benchmark!(params, batches, runtime_common::slots, Slots);
add_benchmark!(params, batches, runtime_common::paras_registrar, Registrar);
// Substrate
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_bounties, Bounties);
@@ -37,3 +37,5 @@ pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod runtime_common_claims;
pub mod runtime_common_paras_registrar;
pub mod runtime_common_slots;
@@ -0,0 +1,66 @@
// Copyright 2017-2020 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 <http://www.gnu.org/licenses/>.
//! Autogenerated weights for runtime_common::paras_registrar
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-04-10, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128
// Executed Command:
// target/release/polkadot
// benchmark
// --chain=kusama-dev
// --steps=50
// --repeat=20
// --pallet=runtime_common::paras_registrar
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/runtime_common_paras_registrar.rs
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;
/// Weight functions for runtime_common::paras_registrar.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_common::paras_registrar::WeightInfo for WeightInfo<T> {
fn register() -> Weight {
(8_427_766_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn force_register() -> Weight {
(8_394_534_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn deregister() -> Weight {
(88_992_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn swap() -> Weight {
(69_480_000 as Weight)
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
}
@@ -0,0 +1,74 @@
// Copyright 2017-2020 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 <http://www.gnu.org/licenses/>.
//! Autogenerated weights for runtime_common::slots
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
//! DATE: 2021-04-10, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128
// Executed Command:
// target/release/polkadot
// benchmark
// --chain=kusama-dev
// --steps=50
// --repeat=20
// --pallet=runtime_common::slots
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/runtime_common_slots.rs
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;
/// Weight functions for runtime_common::slots.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_common::slots::WeightInfo for WeightInfo<T> {
fn force_lease() -> Weight {
(49_464_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn manage_lease_period_start(c: u32, t: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 21_000
.saturating_add((18_456_000 as Weight).saturating_mul(c as Weight))
// Standard Error: 21_000
.saturating_add((37_487_000 as Weight).saturating_mul(t as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(c as Weight)))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(t as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(c as Weight)))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(t as Weight)))
}
fn clear_all_leases() -> Weight {
(211_951_000 as Weight)
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(9 as Weight))
}
fn trigger_onboard() -> Weight {
(45_003_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
}