Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
80e32eb
add `force_set_active_config`
rphmeier Apr 8, 2021
c459ded
add parachains modules to Westend
rphmeier Apr 8, 2021
ed5b2d2
add parachains modules to Kusama runtime
rphmeier Apr 8, 2021
28e3190
use real runtime API impl
rphmeier Apr 8, 2021
f4c704b
add module indices and remove auctions, crowdloan
rphmeier Apr 8, 2021
e67e2ef
add benchmarks
rphmeier Apr 8, 2021
78ab034
remove previous migrations and add host configuration set migration
rphmeier Apr 8, 2021
9d05f14
make compile
shawntabrizi Apr 8, 2021
402543d
Merge branch 'master' into rh-parachains-runtime
shawntabrizi Apr 8, 2021
5386cc1
Add Call Filter for Registrar and Slots except Root
shawntabrizi Apr 8, 2021
c154e4a
cargo run --release --features=runtime-benchmarks -- benchmark --chai…
Apr 9, 2021
11b38cb
Merge remote-tracking branch 'origin/master' into rh-parachains-runtime
Apr 9, 2021
0dcf7b7
cargo run --release --features=runtime-benchmarks -- benchmark --chai…
Apr 9, 2021
d77a6bc
Merge remote-tracking branch 'origin/master' into rh-parachains-runtime
Apr 9, 2021
6679514
Merge remote-tracking branch 'origin/master' into rh-parachains-runtime
Apr 10, 2021
763afc6
Merge branch 'master' into rh-parachains-runtime
shawntabrizi Apr 10, 2021
803caa5
fix build
shawntabrizi Apr 10, 2021
52bcdbd
update `add_benchmark`
shawntabrizi Apr 10, 2021
b9da81e
cargo run --release --features=runtime-benchmarks -- benchmark --chai…
Apr 10, 2021
7b071c0
cargo run --release --features=runtime-benchmarks -- benchmark --chai…
Apr 10, 2021
ff1c2e9
Merge remote-tracking branch 'origin/master' into rh-parachains-runtime
Apr 10, 2021
b2b0d76
cargo run --release --features=runtime-benchmarks -- benchmark --chai…
Apr 10, 2021
38ff27f
cargo run --release --features=runtime-benchmarks -- benchmark --chai…
Apr 10, 2021
0f42d70
fix weights
shawntabrizi Apr 10, 2021
d2e3b56
tweak more constants
rphmeier Apr 23, 2021
f30463a
Merge remote-tracking branch 'origin/master' into rh-parachains-runtime
gavofyork Apr 30, 2021
475766e
Fix up the kusama runtime
gavofyork Apr 30, 2021
b30ae1f
Westend runtime fixups
gavofyork Apr 30, 2021
d3998db
Fix MMR & Beefy for westend
gavofyork Apr 30, 2021
5f85021
Fixes
gavofyork Apr 30, 2021
9f97f01
fix tests
shawntabrizi Apr 30, 2021
07573d6
Update runtime/polkadot/src/constants.rs
gavofyork May 1, 2021
aa33fd4
Update runtime/westend/src/lib.rs
gavofyork May 1, 2021
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
Prev Previous commit
Next Next commit
add parachains modules to Kusama runtime
  • Loading branch information
rphmeier committed Apr 8, 2021
commit ed5b2d213e1ca4067d28c00514a4ca10044f5c1d
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
223 changes: 213 additions & 10 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,40 @@ 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,
claims, SlowAdjustingFeeUpdate, CurrencyToVote, paras_registrar, xcm_sender, auctions,
crowdloan, slots,
impls::DealWithFees,
BlockHashCount, RocksDbWeight, BlockWeights, BlockLength, OffchainSolutionWeightLimit,
ParachainSessionKeyPlaceholder, AssignmentSessionKeyPlaceholder,
};

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;
Comment on lines +40 to +52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also just be use runtime_parachains as parachains;. it's fewer lines and you get the slightly more semantic parachains::origin rather than parachains_origin.


use xcm::v0::{MultiLocation, NetworkId};
use xcm_builder::{
AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation,
CurrencyAdapter as XcmCurrencyAdapter, ChildParachainAsNative,
SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, LocationInverter,
IsConcrete, FixedWeightBounds, FixedRateOfConcreteFungible,
};

use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill,
Expand Down Expand Up @@ -956,6 +980,163 @@ 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;
}

impl parachains_ump::Config for Runtime {
type UmpSink = crate::parachains_ump::XcmSink<XcmConfig>;
}

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 = 5 * DOLLARS;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

pub const MaxCodeSize: u32 = 10 * 1024 * 1024; // 10 MB
pub const MaxHeadSize: u32 = 20 * 1024; // 20 KB
}

impl paras_registrar::Config for Runtime {
type Event = Event;
type Origin = Origin;
type Currency = Balances;
type OnSwap = (Crowdloan, Slots);
type ParaDeposit = ParaDeposit;
type DataDepositPerByte = DataDepositPerByte;
type MaxCodeSize = MaxCodeSize;
type MaxHeadSize = MaxHeadSize;
type WeightInfo = paras_registrar::TestWeightInfo;
}

parameter_types! {
pub const EndingPeriod: BlockNumber = 6 * HOURS;
pub const SampleLength: BlockNumber = 1;
}

impl auctions::Config for Runtime {
type Event = Event;
type Leaser = Slots;
type Registrar = Registrar;
type EndingPeriod = EndingPeriod;
type SampleLength = SampleLength;
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
type InitiateOrigin = EnsureRoot<AccountId>;
type WeightInfo = auctions::TestWeightInfo;
}

parameter_types! {
pub const LeasePeriod: BlockNumber = 28 * DAYS;
}

impl slots::Config for Runtime {
type Event = Event;
type Currency = Balances;
type Registrar = Registrar;
type LeasePeriod = LeasePeriod;
type WeightInfo = slots::TestWeightInfo;
}

parameter_types! {
pub const CrowdloanId: ModuleId = ModuleId(*b"py/cfund");
pub const SubmissionDeposit: Balance = 100 * DOLLARS;
pub const MinContribution: Balance = 1 * DOLLARS;
pub const RetirementPeriod: BlockNumber = 6 * HOURS;
pub const RemoveKeysLimit: u32 = 500;
// Allow 32 bytes for an additional memo to a crowdloan.
pub const MaxMemoLength: u8 = 32;
}

impl crowdloan::Config for Runtime {
type Event = Event;
type ModuleId = CrowdloanId;
type SubmissionDeposit = SubmissionDeposit;
type MinContribution = MinContribution;
type RemoveKeysLimit = RemoveKeysLimit;
type Registrar = Registrar;
type Auctioneer = Auctions;
type MaxMemoLength = MaxMemoLength;
type WeightInfo = crowdloan::TestWeightInfo;
}

parameter_types! {
pub const KusamaLocation: MultiLocation = MultiLocation::Null;
pub const KusamaNetwork: NetworkId = NetworkId::Polkadot;
pub const Ancestry: MultiLocation = MultiLocation::Null;
}

pub type LocationConverter = (
ChildParachainConvertsVia<ParaId, AccountId>,
AccountId32Aliases<KusamaNetwork, AccountId>,
);

pub type LocalAssetTransactor =
XcmCurrencyAdapter<
// Use this currency:
Balances,
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<KusamaLocation>,
// We can convert the MultiLocations with our converter above:
LocationConverter,
// Our chain's account ID type (we can't get away without mentioning it explicitly):
AccountId,
>;

type LocalOriginConverter = (
SovereignSignedViaLocation<LocationConverter, Origin>,
ChildParachainAsNative<parachains_origin::Origin, Origin>,
SignedAccountId32AsNative<KusamaNetwork, Origin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this right now?

We seems we will not use it with statemint, so imo better to exclude it for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statemint won't be a system parachain

);

parameter_types! {
pub const BaseXcmWeight: Weight = 100_000;
pub const KusamaFee: (MultiLocation, u128) = (KusamaLocation::get(), 1 * CENTS);
}

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type XcmSender = xcm_sender::RelayChainXcmSender<Runtime>;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
type IsReserve = ();
type IsTeleporter = ();
type LocationInverter = LocationInverter<Ancestry>;
type Barrier = ();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AllowPaidFromParachains, probably

type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
type Trader = FixedRateOfConcreteFungible<KusamaFee>;
type ResponseHandler = ();
}

construct_runtime! {
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -1027,6 +1208,26 @@ 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.
ParachainsOrigin: parachains_origin::{Pallet, Origin},
ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
ParasShared: parachains_shared::{Pallet, Call, Storage},
ParasInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>},
ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent},
ParasScheduler: parachains_scheduler::{Pallet, Call, Storage},
Paras: parachains_paras::{Pallet, Call, Storage, Event},
ParasInitializer: parachains_initializer::{Pallet, Call, Storage},
ParasDmp: parachains_dmp::{Pallet, Call, Storage},
ParasUmp: parachains_ump::{Pallet, Call, Storage},
ParasHrmp: parachains_hrmp::{Pallet, Call, Storage, Event},
ParasSessionInfo: parachains_session_info::{Pallet, Call, Storage},

// Parachain Onboarding Pallets
Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>},
Auctions: auctions::{Pallet, Call, Storage, Event<T>},
Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>},
Slots: slots::{Pallet, Call, Storage, Event<T>},
}
}

Expand Down Expand Up @@ -1079,6 +1280,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
// TODO [now]: migrate to new host configuration
(BabeEpochConfigMigrations, KillOffchainPhragmenStorageTest),
>;
/// The payload being signed in the transactions.
Expand Down Expand Up @@ -1159,6 +1361,7 @@ sp_api::impl_runtime_apis! {
}
}

// TODO [now]: use parachains runtime API impl
impl primitives::v1::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<ValidatorId> {
Vec::new()
Expand All @@ -1172,12 +1375,12 @@ sp_api::impl_runtime_apis! {
Vec::new()
}

fn persisted_validation_data(_: Id, _: OccupiedCoreAssumption)
fn persisted_validation_data(_: ParaId, _: OccupiedCoreAssumption)
-> Option<PersistedValidationData<Hash, BlockNumber>> {
None
}
fn check_validation_outputs(
_: Id,
_: ParaId,
_: primitives::v1::CandidateCommitments,
) -> bool {
false
Expand All @@ -1191,15 +1394,15 @@ sp_api::impl_runtime_apis! {
None
}

fn validation_code(_: Id, _: OccupiedCoreAssumption) -> Option<ValidationCode> {
fn validation_code(_: ParaId, _: OccupiedCoreAssumption) -> Option<ValidationCode> {
None
}

fn historical_validation_code(_: Id, _: BlockNumber) -> Option<ValidationCode> {
fn historical_validation_code(_: ParaId, _: BlockNumber) -> Option<ValidationCode> {
None
}

fn candidate_pending_availability(_: Id) -> Option<CommittedCandidateReceipt<Hash>> {
fn candidate_pending_availability(_: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
None
}

Expand All @@ -1208,14 +1411,14 @@ sp_api::impl_runtime_apis! {
}

fn dmq_contents(
_recipient: Id,
_recipient: ParaId,
) -> Vec<InboundDownwardMessage<BlockNumber>> {
Vec::new()
}

fn inbound_hrmp_channels_contents(
_recipient: Id
) -> BTreeMap<Id, Vec<InboundHrmpMessage<BlockNumber>>> {
_recipient: ParaId
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
BTreeMap::new()
}

Expand Down
4 changes: 4 additions & 0 deletions runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ std = [
"babe-primitives/std",
"sp-session/std",
"runtime-common/std",
"runtime-parachains/std",
"frame-try-runtime/std",
"sp-npos-elections/std",
"xcm/std",
"xcm-executor/std",
"xcm-builder/std",
]
runtime-benchmarks = [
"runtime-common/runtime-benchmarks",
Expand Down
3 changes: 2 additions & 1 deletion runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ construct_runtime! {
Beefy: pallet_beefy::{Pallet, Config<T>, Storage} = 29,
MmrLeaf: mmr_common::{Pallet, Storage} = 30,

// Parachains modules.
// Parachains pallets.
ParachainsOrigin: parachains_origin::{Pallet, Origin},
ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
ParasShared: parachains_shared::{Pallet, Call, Storage},
Expand Down Expand Up @@ -1128,6 +1128,7 @@ sp_api::impl_runtime_apis! {
}
}

// TODO [now]: use parachains runtime API impl
impl primitives::v1::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<ValidatorId> {
Vec::new()
Expand Down