From 23acda118bc43035a5b93fbb3faf3fed4b5d53d0 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 9 Nov 2021 18:11:17 +0100 Subject: [PATCH 1/3] align the different Statemint runtimes so they are more similar in structure --- polkadot-parachains/statemine/src/lib.rs | 75 +++++++++++------------- polkadot-parachains/statemint/src/lib.rs | 6 +- polkadot-parachains/westmint/src/lib.rs | 30 +++++----- 3 files changed, 51 insertions(+), 60 deletions(-) diff --git a/polkadot-parachains/statemine/src/lib.rs b/polkadot-parachains/statemine/src/lib.rs index a3df590063a..35e8dd34d5e 100644 --- a/polkadot-parachains/statemine/src/lib.rs +++ b/polkadot-parachains/statemine/src/lib.rs @@ -43,7 +43,7 @@ use codec::{Decode, Encode, MaxEncodedLen}; use constants::{currency::*, fee::WeightToFee}; use frame_support::{ construct_runtime, match_type, parameter_types, - traits::{Contains, Everything, InstanceFilter, Nothing}, + traits::{Everything, InstanceFilter, Nothing}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight}, DispatchClass, IdentityFee, Weight, @@ -127,16 +127,9 @@ parameter_types! { pub const SS58Prefix: u8 = 2; } -pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(_c: &Call) -> bool { - true - } -} - // Configure FRAME pallets to include in runtime. impl frame_system::Config for Runtime { - type BaseCallFilter = BaseFilter; + type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type AccountId = AccountId; @@ -253,34 +246,6 @@ impl pallet_assets::Config for Runtime { type WeightInfo = weights::pallet_assets::WeightInfo; } -parameter_types! { - pub const ClassDeposit: Balance = UNITS; // 1 UNIT deposit to create asset class - pub const InstanceDeposit: Balance = UNITS / 100; // 1/100 UNIT deposit to create asset instance - pub const KeyLimit: u32 = 32; // Max 32 bytes per key - pub const ValueLimit: u32 = 64; // Max 64 bytes per value - pub const UniquesMetadataDepositBase: Balance = deposit(1, 129); - pub const AttributeDepositBase: Balance = deposit(1, 0); - pub const DepositPerByte: Balance = deposit(0, 1); - pub const UniquesStringLimit: u32 = 128; -} - -impl pallet_uniques::Config for Runtime { - type Event = Event; - type ClassId = u32; - type InstanceId = u32; - type Currency = Balances; - type ForceOrigin = AssetsForceOrigin; - type ClassDeposit = ClassDeposit; - type InstanceDeposit = InstanceDeposit; - type MetadataDepositBase = UniquesMetadataDepositBase; - type AttributeDepositBase = AttributeDepositBase; - type DepositPerByte = DepositPerByte; - type StringLimit = UniquesStringLimit; - type KeyLimit = KeyLimit; - type ValueLimit = ValueLimit; - type WeightInfo = weights::pallet_uniques::WeightInfo; -} - parameter_types! { // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes. pub const DepositBase: Balance = deposit(1, 88); @@ -345,7 +310,7 @@ pub enum ProxyType { AssetOwner, /// Asset manager. Can execute calls related to asset management. AssetManager, - // Collator selection proxy. Can execute calls related to collator selection mechanism. + /// Collator selection proxy. Can execute calls related to collator selection mechanism. Collator, } impl Default for ProxyType { @@ -528,7 +493,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognised. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when @@ -566,8 +531,8 @@ match_type! { pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, + // Parent and its exec plurality get free execution AllowUnpaidExecutionFrom, - // ^^^ Parent and its exec plurality get free execution // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. @@ -578,7 +543,6 @@ pub struct XcmConfig; impl Config for XcmConfig { type Call = Call; type XcmSender = XcmRouter; - // How to withdraw and deposit an asset. type AssetTransactor = AssetTransactors; type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = NativeAsset; @@ -622,7 +586,6 @@ impl pallet_xcm::Config for Runtime { type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } @@ -710,6 +673,34 @@ impl pallet_asset_tx_payment::Config for Runtime { >; } +parameter_types! { + pub const ClassDeposit: Balance = UNITS; // 1 UNIT deposit to create asset class + pub const InstanceDeposit: Balance = UNITS / 100; // 1/100 UNIT deposit to create asset instance + pub const KeyLimit: u32 = 32; // Max 32 bytes per key + pub const ValueLimit: u32 = 64; // Max 64 bytes per value + pub const UniquesMetadataDepositBase: Balance = deposit(1, 129); + pub const AttributeDepositBase: Balance = deposit(1, 0); + pub const DepositPerByte: Balance = deposit(0, 1); + pub const UniquesStringLimit: u32 = 128; +} + +impl pallet_uniques::Config for Runtime { + type Event = Event; + type ClassId = u32; + type InstanceId = u32; + type Currency = Balances; + type ForceOrigin = AssetsForceOrigin; + type ClassDeposit = ClassDeposit; + type InstanceDeposit = InstanceDeposit; + type MetadataDepositBase = UniquesMetadataDepositBase; + type AttributeDepositBase = AttributeDepositBase; + type DepositPerByte = DepositPerByte; + type StringLimit = UniquesStringLimit; + type KeyLimit = KeyLimit; + type ValueLimit = ValueLimit; + type WeightInfo = weights::pallet_uniques::WeightInfo; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where diff --git a/polkadot-parachains/statemint/src/lib.rs b/polkadot-parachains/statemint/src/lib.rs index bd20705fef1..5240c2bab05 100644 --- a/polkadot-parachains/statemint/src/lib.rs +++ b/polkadot-parachains/statemint/src/lib.rs @@ -322,7 +322,7 @@ pub enum ProxyType { AssetOwner, /// Asset manager. Can execute calls related to asset management. AssetManager, - // Collator selection proxy. Can execute calls related to collator selection mechanism. + /// Collator selection proxy. Can execute calls related to collator selection mechanism. Collator, } impl Default for ProxyType { @@ -505,7 +505,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for // foreign chains who want to have a local sovereign account on this chain which they control. SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when // recognised. RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when @@ -543,8 +543,8 @@ match_type! { pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, + // Parent and its exec plurality get free execution AllowUnpaidExecutionFrom, - // ^^^ Parent and its exec plurality get free execution // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. diff --git a/polkadot-parachains/westmint/src/lib.rs b/polkadot-parachains/westmint/src/lib.rs index b111f3f730e..cc36ec6a9dd 100644 --- a/polkadot-parachains/westmint/src/lib.rs +++ b/polkadot-parachains/westmint/src/lib.rs @@ -213,13 +213,6 @@ impl pallet_transaction_payment::Config for Runtime { type OperationalFeeMultiplier = OperationalFeeMultiplier; } -impl pallet_sudo::Config for Runtime { - type Event = Event; - type Call = Call; -} - -pub type AssetsForceOrigin = EnsureRoot; - parameter_types! { pub const AssetDeposit: Balance = 1 * UNITS; // 1 WND deposit to create asset pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT; @@ -230,6 +223,8 @@ parameter_types! { pub const MetadataDepositPerByte: Balance = deposit(0, 1); } +pub type AssetsForceOrigin = EnsureRoot; + impl pallet_assets::Config for Runtime { type Event = Event; type Balance = Balance; @@ -300,7 +295,7 @@ parameter_types! { pub enum ProxyType { /// Fully permissioned proxy. Can execute any call on behalf of _proxied_. Any, - /// Can execute any call that does not transfer funds, including asset transfers. + /// Can execute any call that does not transfer funds or assets. NonTransfer, /// Proxy with the ability to reject time-delay proxy announcements. CancelProxy, @@ -516,17 +511,16 @@ parameter_types! { } match_type! { - pub type ParentOrParentsPlurality: impl Contains = { - MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { .. }) } + pub type ParentFilter: impl Contains = { + MultiLocation { parents: 1, interior: Here } }; } pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, - AllowUnpaidExecutionFrom, - // ^^^ Parent & its plurality gets free execution + // Free execution for Parent (relay) + AllowUnpaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. @@ -580,7 +574,6 @@ impl pallet_xcm::Config for Runtime { type LocationInverter = LocationInverter; type Origin = Origin; type Call = Call; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; } @@ -637,10 +630,12 @@ parameter_types! { pub const MaxInvulnerables: u32 = 100; } +pub type CollatorSelectionUpdateOrigin = EnsureRoot; + impl pallet_collator_selection::Config for Runtime { type Event = Event; type Currency = Balances; - type UpdateOrigin = EnsureRoot; + type UpdateOrigin = CollatorSelectionUpdateOrigin; type PotId = PotId; type MaxCandidates = MaxCandidates; type MinCandidates = MinCandidates; @@ -689,6 +684,11 @@ impl pallet_uniques::Config for Runtime { type WeightInfo = weights::pallet_uniques::WeightInfo; } +impl pallet_sudo::Config for Runtime { + type Event = Event; + type Call = Call; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where From b09bfc6eadd93edbd32eaa2e0836e2a06f1a7539 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 9 Nov 2021 18:16:44 +0100 Subject: [PATCH 2/3] align Unpaid Execution filter --- polkadot-parachains/westmint/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/polkadot-parachains/westmint/src/lib.rs b/polkadot-parachains/westmint/src/lib.rs index cc36ec6a9dd..5bf6ee36001 100644 --- a/polkadot-parachains/westmint/src/lib.rs +++ b/polkadot-parachains/westmint/src/lib.rs @@ -511,16 +511,17 @@ parameter_types! { } match_type! { - pub type ParentFilter: impl Contains = { - MultiLocation { parents: 1, interior: Here } + pub type ParentOrParentsExecutivePlurality: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } }; } pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, - // Free execution for Parent (relay) - AllowUnpaidExecutionFrom, + // Parent and its exec plurality get free execution + AllowUnpaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK. From 21bd21bdfa523a8d08c06b7d35f9792e19cdd2e1 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 9 Nov 2021 18:21:07 +0100 Subject: [PATCH 3/3] revert changes to Unpaid execution filter for Westmint --- polkadot-parachains/westmint/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/polkadot-parachains/westmint/src/lib.rs b/polkadot-parachains/westmint/src/lib.rs index 5bf6ee36001..fda0c72458c 100644 --- a/polkadot-parachains/westmint/src/lib.rs +++ b/polkadot-parachains/westmint/src/lib.rs @@ -511,17 +511,17 @@ parameter_types! { } match_type! { - pub type ParentOrParentsExecutivePlurality: impl Contains = { + pub type ParentOrParentsPlurality: impl Contains = { MultiLocation { parents: 1, interior: Here } | - MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } + MultiLocation { parents: 1, interior: X1(Plurality { .. }) } }; } pub type Barrier = ( TakeWeightCredit, AllowTopLevelPaidExecutionFrom, - // Parent and its exec plurality get free execution - AllowUnpaidExecutionFrom, + // Parent and its plurality get free execution + AllowUnpaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, // Subscriptions for version tracking are OK.