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
4 changes: 0 additions & 4 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Genesi
pallet_sudo: westend::SudoConfig {
key: endowed_accounts[0].clone(),
},
//TODO: Don't use default.
Copy link
Member

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.

parachains_configuration: Default::default(),
}
}
Expand Down Expand Up @@ -652,7 +651,6 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisC
},
pallet_vesting: kusama::VestingConfig { vesting: vec![] },
pallet_treasury: Default::default(),
// TODO: Don't use default;
parachains_configuration: Default::default(),
}
}
Expand Down Expand Up @@ -1291,7 +1289,6 @@ pub fn kusama_testnet_genesis(
},
pallet_vesting: kusama::VestingConfig { vesting: vec![] },
pallet_treasury: Default::default(),
// TODO: Don't use default.
parachains_configuration: Default::default(),
}
}
Expand Down Expand Up @@ -1376,7 +1373,6 @@ pub fn westend_testnet_genesis(
pallet_authority_discovery: westend::AuthorityDiscoveryConfig { keys: vec![] },
pallet_vesting: westend::VestingConfig { vesting: vec![] },
pallet_sudo: westend::SudoConfig { key: root_key },
// TODO: Don't use default.
parachains_configuration: Default::default(),
}
}
Expand Down
16 changes: 4 additions & 12 deletions runtime/kusama/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

@gavofyork gavofyork Apr 30, 2021

Choose a reason for hiding this comment

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

Removed the questionable DOLLARS to leave the (slightly more vague) CENTS and GRAND.

Copy link
Member

Choose a reason for hiding this comment

The 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);
Expand Down
96 changes: 56 additions & 40 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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::{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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>,
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! {
/// 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
Expand All @@ -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;
Expand All @@ -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 = ();
}

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ parameter_types! {
pub const Ancestry: MultiLocation = MultiLocation::Null;
}

pub type LocationConverter = (
pub type SovereignAccountOf = (
ChildParachainConvertsVia<ParaId, AccountId>,
AccountId32Aliases<RococoNetwork, AccountId>,
);
Expand All @@ -576,13 +576,13 @@ pub type LocalAssetTransactor =
// Use this currency when it is a fungible asset matching the given location or name:
IsConcrete<RocLocation>,
// 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,
>;

type LocalOriginConverter = (
SovereignSignedViaLocation<LocationConverter, Origin>,
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
ChildParachainAsNative<parachains_origin::Origin, Origin>,
SignedAccountId32AsNative<RococoNetwork, Origin>,
ChildSystemParachainAsSuperuser<ParaId, Origin>,
Expand Down
12 changes: 11 additions & 1 deletion xcm/xcm-builder/src/barriers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use sp_std::{result::Result, marker::PhantomData};
use xcm::v0::{Xcm, Order, MultiLocation};
use xcm::v0::{Xcm, Order, MultiLocation, Junction};
use frame_support::{ensure, traits::Contains, weights::Weight};
use xcm_executor::traits::{OnResponse, ShouldExecute};
use polkadot_parachain::primitives::IsSystem;

pub struct TakeWeightCredit;
impl ShouldExecute for TakeWeightCredit {
Expand Down Expand Up @@ -72,6 +73,15 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowUnpaidExecutionFrom<T> {
}
}

pub struct IsChildSystemParachain<ParaId>(PhantomData<ParaId>);
impl<
ParaId: IsSystem + From<u32>,
> Contains<MultiLocation> for IsChildSystemParachain<ParaId> {
fn contains(l: &MultiLocation) -> bool {
matches!(l, MultiLocation::X1(Junction::Parachain(id)) if ParaId::from(*id).is_system())
}
}

pub struct AllowKnownQueryResponses<ResponseHandler>(PhantomData<ResponseHandler>);
impl<ResponseHandler: OnResponse> ShouldExecute for AllowKnownQueryResponses<ResponseHandler> {
fn should_execute<Call>(
Expand Down
1 change: 1 addition & 0 deletions xcm/xcm-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub use origin_conversion::{
mod barriers;
pub use barriers::{
TakeWeightCredit, AllowUnpaidExecutionFrom, AllowTopLevelPaidExecutionFrom, AllowKnownQueryResponses,
IsChildSystemParachain,
};

mod currency_adapter;
Expand Down