-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add parachains modules to Westend and Kusama runtimes #2854
Changes from 1 commit
80e32eb
c459ded
ed5b2d2
28e3190
f4c704b
e67e2ef
78ab034
9d05f14
402543d
5386cc1
c154e4a
11b38cb
0dcf7b7
d77a6bc
6679514
763afc6
803caa5
52bcdbd
b9da81e
7b071c0
ff1c2e9
b2b0d76
38ff27f
0f42d70
d2e3b56
f30463a
475766e
b30ae1f
d3998db
5f85021
9f97f01
07573d6
aa33fd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,30 +18,22 @@ | |
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the questionable
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not everywhere though? (still in Polkadot, Rococo, and Test-Runtime) |
||
| 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,9 @@ use primitives::v1::{ | |
| InboundDownwardMessage, InboundHrmpMessage, SessionInfo, | ||
| }; | ||
| use runtime_common::{ | ||
| claims, SlowAdjustingFeeUpdate, CurrencyToVote, paras_registrar, xcm_sender, slots, | ||
| 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; | ||
|
|
@@ -55,12 +53,11 @@ 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, FixedRateOfConcreteFungible, | ||
| AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation, CurrencyAdapter as XcmCurrencyAdapter, | ||
| ChildParachainAsNative, SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, LocationInverter, IsConcrete, | ||
| FixedWeightBounds, TakeWeightCredit, AllowTopLevelPaidExecutionFrom, | ||
| AllowUnpaidExecutionFrom, IsChildSystemParachain, UsingComponents, | ||
| }; | ||
| use xcm_executor::XcmExecutor; | ||
| use sp_runtime::{ | ||
|
|
@@ -105,6 +102,7 @@ pub use pallet_balances::Call as BalancesCall; | |
| /// Constant values used within the runtime. | ||
| pub mod constants; | ||
| use constants::{time::*, currency::*, fee::*, paras::*}; | ||
| use frame_support::traits::All; | ||
|
|
||
| // Weights used in the runtime. | ||
| mod weights; | ||
|
|
@@ -241,7 +239,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 { | ||
|
|
@@ -437,7 +435,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 | ||
|
|
@@ -515,7 +513,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). | ||
|
|
@@ -581,21 +579,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; | ||
| } | ||
|
|
||
|
|
@@ -766,9 +764,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; | ||
|
|
@@ -814,10 +812,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 { | ||
|
|
@@ -831,11 +829,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; | ||
|
|
@@ -861,7 +859,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 { | ||
|
|
@@ -1066,38 +1064,57 @@ impl slots::Config for Runtime { | |
| } | ||
|
|
||
| parameter_types! { | ||
| pub const KusamaLocation: MultiLocation = MultiLocation::Null; | ||
| /// 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; | ||
| } | ||
|
|
||
| pub type LocationConverter = ( | ||
| /// 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<KusamaLocation>, | ||
| IsConcrete<KsmLocation>, | ||
| // We can convert the MultiLocations with our converter above: | ||
| LocationConverter, | ||
| 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 = ( | ||
| SovereignSignedViaLocation<LocationConverter, Origin>, | ||
| // 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>, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Statemint won't be a system parachain |
||
| ); | ||
|
|
||
| parameter_types! { | ||
| /// The amount of weight an XCM operation takes. This is a safe overestimate. | ||
| pub const BaseXcmWeight: Weight = 1_000_000_000; | ||
| pub const KusamaFee: (MultiLocation, u128) = (KusamaLocation::get(), 1 * CENTS); | ||
| } | ||
|
|
||
| /// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our | ||
|
|
@@ -1107,16 +1124,14 @@ pub type XcmRouter = ( | |
| xcm_sender::ChildParachainRouter<Runtime>, | ||
| ); | ||
|
|
||
| pub struct All<T>(sp_std::marker::PhantomData<T>); | ||
| impl<T: Ord> frame_support::traits::Contains<T> for All<T> { | ||
| fn contains(_: &T) -> bool { true } | ||
| fn sorted_members() -> Vec<T> { vec![] } | ||
| } | ||
|
|
||
| use xcm_builder::{TakeWeightCredit, AllowTopLevelPaidExecutionFrom}; | ||
| /// 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; | ||
|
|
@@ -1130,7 +1145,8 @@ impl xcm_executor::Config for XcmConfig { | |
| type LocationInverter = LocationInverter<Ancestry>; | ||
| type Barrier = Barrier; | ||
| type Weigher = FixedWeightBounds<BaseXcmWeight, Call>; | ||
| type Trader = FixedRateOfConcreteFungible<KusamaFee>; | ||
| // The weight trader piggybacks on the existing transaction-fee conversion logic. | ||
| type Trader = UsingComponents<WeightToFee, KsmLocation, AccountId, Balances, ToAuthor<Runtime>>; | ||
| type ResponseHandler = (); | ||
| } | ||
|
|
||
|
|
@@ -1244,7 +1260,7 @@ impl frame_support::traits::OnRuntimeUpgrade for ParachainHostConfigurationMigra | |
| 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_BLOCKS, | ||
| 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, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the default here seems as good as anything else.