diff --git a/Cargo.lock b/Cargo.lock index e59cb4ac97..046fe1d689 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -619,6 +619,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "system-parachains-constants", ] [[package]] @@ -710,6 +711,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "system-parachains-constants", ] [[package]] @@ -1369,6 +1371,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "system-parachains-constants", ] [[package]] @@ -1433,6 +1436,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "system-parachains-constants", ] [[package]] @@ -1936,6 +1940,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "system-parachains-constants", ] [[package]] @@ -4007,6 +4012,7 @@ dependencies = [ "staging-xcm-builder", "staging-xcm-executor", "substrate-wasm-builder", + "system-parachains-constants", ] [[package]] @@ -11988,6 +11994,20 @@ dependencies = [ "libc", ] +[[package]] +name = "system-parachains-constants" +version = "1.0.0" +dependencies = [ + "frame-support", + "kusama-runtime-constants", + "parachains-common", + "polkadot-core-primitives", + "polkadot-primitives", + "polkadot-runtime-constants", + "smallvec", + "sp-runtime", +] + [[package]] name = "tap" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 1062ab77cf..8baf12752c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ members = [ "system-parachains/bridge-hubs/bridge-hub-kusama", "system-parachains/bridge-hubs/bridge-hub-polkadot", "system-parachains/collectives/collectives-polkadot", + "system-parachains/constants", "system-parachains/gluttons/glutton-kusama", "integration-tests/emulated/assets/asset-hub-kusama", "integration-tests/emulated/assets/asset-hub-polkadot", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml index c7abca8d60..b5e514e71f 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml @@ -81,6 +81,7 @@ cumulus-primitives-utility = { default-features = false , version = "0.4.0" } pallet-collator-selection = { default-features = false , version = "6.0.0" } parachain-info = { package = "staging-parachain-info", default-features = false , version = "0.4.0" } parachains-common = { default-features = false , version = "4.0.0" } +system-parachains-constants = { path = "../../constants", default-features = false } assets-common = { default-features = false , version = "0.4.0" } [dev-dependencies] @@ -223,6 +224,7 @@ std = [ "sp-version/std", "sp-weights/std", "substrate-wasm-builder", + "system-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index 1d03f75a01..45baa5a16e 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -67,15 +67,16 @@ use frame_system::{ }; use pallet_asset_conversion_tx_payment::AssetConversionAdapter; use pallet_nfts::PalletFeatures; -pub use parachains_common as common; use parachains_common::{ - impls::DealWithFees, - kusama::{consensus::*, currency::*, fee::WeightToFee}, - AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, Hash, Header, Nonce, - Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, - NORMAL_DISPATCH_RATIO, SLOT_DURATION, + impls::DealWithFees, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, + Hash, Header, Nonce, Signature, }; use sp_runtime::RuntimeDebug; +use system_parachains_constants::{ + kusama::{consensus::*, currency::*, fee::WeightToFee}, + AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, + SLOT_DURATION, +}; use xcm::opaque::v3::MultiLocation; use xcm_config::{ FellowshipLocation, ForeignAssetsConvertedConcreteId, GovernanceLocation, KsmLocation, @@ -1483,9 +1484,9 @@ fn ensure_key_ss58() { mod tests { use super::*; use crate::{CENTS, MILLICENTS}; - use parachains_common::kusama::fee; use sp_runtime::traits::Zero; use sp_weights::WeightToFee; + use system_parachains_constants::kusama::fee; /// We can fit at least 1000 transfers in a block. #[test] diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs index 7b836886d0..1f9eb0acad 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs @@ -36,10 +36,10 @@ use parachains_common::{ AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem, RelayOrOtherSystemParachains, }, - TREASURY_PALLET_ID, }; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs b/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs index 20477cb24e..f207fb83de 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs @@ -34,10 +34,9 @@ use frame_support::{ traits::fungibles::InspectEnumerable, weights::{Weight, WeightToFee as WeightToFeeT}, }; -use parachains_common::{ - kusama::fee::WeightToFee, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, -}; +use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}; use sp_runtime::traits::MaybeEquivalence; +use system_parachains_constants::kusama::fee::WeightToFee; use xcm::latest::prelude::*; use xcm_executor::traits::{Identity, JustTry, WeightTrader}; diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml b/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml index a3125308b7..0b626126ed 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml @@ -76,6 +76,7 @@ cumulus-primitives-utility = { default-features = false , version = "0.4.0" } pallet-collator-selection = { default-features = false , version = "6.0.0" } parachain-info = { package = "staging-parachain-info", default-features = false , version = "0.4.0" } parachains-common = { default-features = false , version = "4.0.0" } +system-parachains-constants = { path = "../../constants", default-features = false } assets-common = { default-features = false , version = "0.4.0" } [dev-dependencies] @@ -204,6 +205,7 @@ std = [ "sp-version/std", "sp-weights/std", "substrate-wasm-builder", + "system-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index 2c62e27069..8dc01e93e3 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -98,15 +98,18 @@ use frame_system::{ EnsureRoot, EnsureSigned, }; use pallet_nfts::PalletFeatures; -pub use parachains_common as common; use parachains_common::{ impls::{AssetsToBlockAuthor, DealWithFees}, - polkadot::{consensus::*, currency::*, fee::WeightToFee}, AccountId, AssetHubPolkadotAuraId as AuraId, AssetIdForTrustBackedAssets, Balance, BlockNumber, - Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, - NORMAL_DISPATCH_RATIO, SLOT_DURATION, + Hash, Header, Nonce, Signature, }; + use sp_runtime::RuntimeDebug; +use system_parachains_constants::{ + polkadot::{consensus::*, currency::*, fee::WeightToFee}, + AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, + SLOT_DURATION, +}; use xcm_config::{ DotLocation, FellowshipLocation, ForeignAssetsConvertedConcreteId, GovernanceLocation, TrustBackedAssetsConvertedConcreteId, XcmConfig, XcmOriginToTransactDispatchOrigin, @@ -1317,9 +1320,9 @@ cumulus_pallet_parachain_system::register_validate_block! { mod tests { use super::*; use crate::{CENTS, MILLICENTS}; - use parachains_common::polkadot::fee; use sp_runtime::traits::Zero; use sp_weights::WeightToFee; + use system_parachains_constants::polkadot::fee; /// We can fit at least 1000 transfers in a block. #[test] diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs index 01604814c1..8d5b6339b7 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs @@ -31,11 +31,11 @@ use parachains_common::{ AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem, RelayOrOtherSystemParachains, }, - TREASURY_PALLET_ID, }; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_constants::system_parachain; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs b/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs index 5af2c63c18..c56381e099 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs @@ -35,10 +35,10 @@ use frame_support::{ weights::{Weight, WeightToFee as WeightToFeeT}, }; use parachains_common::{ - polkadot::fee::WeightToFee, AccountId, AssetHubPolkadotAuraId as AuraId, - AssetIdForTrustBackedAssets, Balance, + AccountId, AssetHubPolkadotAuraId as AuraId, AssetIdForTrustBackedAssets, Balance, }; use sp_runtime::traits::MaybeEquivalence; +use system_parachains_constants::polkadot::fee::WeightToFee; use xcm::latest::prelude::*; use xcm_executor::traits::{Identity, JustTry, WeightTrader}; diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml index ed7d2bf1f1..cecd47bb88 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -74,6 +74,7 @@ cumulus-primitives-utility = { default-features = false , version = "0.4.0" } pallet-collator-selection = { default-features = false , version = "6.0.0" } parachain-info = { package = "staging-parachain-info", default-features = false , version = "0.4.0" } parachains-common = { default-features = false , version = "4.0.0" } +system-parachains-constants = { path = "../../constants", default-features = false } [dev-dependencies] bridge-hub-test-utils = { version = "0.4.0" } @@ -133,6 +134,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "system-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index 32675645b1..d8ae0d3f08 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -68,10 +68,11 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ - impls::DealWithFees, + impls::DealWithFees, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, +}; +use system_parachains_constants::{ kusama::{consensus::*, currency::*, fee::WeightToFee}, - AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, - HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, + AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; // XCM Imports diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index 6e917c05d6..a448ffeadc 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -29,10 +29,10 @@ use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains}, - TREASURY_PALLET_ID, }; use polkadot_parachain_primitives::primitives::Sibling; use sp_runtime::traits::AccountIdConversion; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs index 893524e12f..54ebc96a7a 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs @@ -20,7 +20,8 @@ pub use bridge_hub_kusama_runtime::{ }; use codec::Decode; use frame_support::parameter_types; -use parachains_common::{kusama::fee::WeightToFee, AccountId, AuraId}; +use parachains_common::{AccountId, AuraId}; +use system_parachains_constants::kusama::fee::WeightToFee; const ALICE: [u8; 32] = [1u8; 32]; diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml index 2e74c27c78..46aef5b926 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml @@ -74,6 +74,7 @@ cumulus-primitives-utility = { default-features = false , version = "0.4.0" } pallet-collator-selection = { default-features = false , version = "6.0.0" } parachain-info = { package = "staging-parachain-info", default-features = false , version = "0.4.0" } parachains-common = { default-features = false , version = "4.0.0" } +system-parachains-constants = { path = "../../constants", default-features = false } [dev-dependencies] bridge-hub-test-utils = { version = "0.4.0" } @@ -133,6 +134,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "system-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 039c9aa76a..425cd1fe20 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -69,10 +69,11 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ - impls::DealWithFees, + impls::DealWithFees, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, +}; +use system_parachains_constants::{ polkadot::{consensus::*, currency::*, fee::WeightToFee}, - AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, - HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, + AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; // XCM Imports use xcm::prelude::*; diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 17d7c177ac..472eba4ce7 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -28,11 +28,11 @@ use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains}, - TREASURY_PALLET_ID, }; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_constants::system_parachain; use sp_runtime::traits::AccountIdConversion; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs index 0be87bd46f..1529f77025 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/tests.rs @@ -20,7 +20,8 @@ pub use bridge_hub_polkadot_runtime::{ }; use codec::Decode; use frame_support::parameter_types; -use parachains_common::{polkadot::fee::WeightToFee, AccountId, AuraId}; +use parachains_common::{AccountId, AuraId}; +use system_parachains_constants::polkadot::fee::WeightToFee; const ALICE: [u8; 32] = [1u8; 32]; diff --git a/system-parachains/collectives/collectives-polkadot/Cargo.toml b/system-parachains/collectives/collectives-polkadot/Cargo.toml index c54e7352be..d45f676231 100644 --- a/system-parachains/collectives/collectives-polkadot/Cargo.toml +++ b/system-parachains/collectives/collectives-polkadot/Cargo.toml @@ -80,6 +80,7 @@ cumulus-primitives-utility = { default-features = false , version = "0.4.0" } pallet-collator-selection = { default-features = false , version = "6.0.0" } parachain-info = { package = "staging-parachain-info", default-features = false , version = "0.4.0" } parachains-common = { default-features = false , version = "4.0.0" } +system-parachains-constants = { path = "../../constants", default-features = false } [build-dependencies] substrate-wasm-builder = { optional = true , version = "14.0.0" } @@ -94,8 +95,8 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", - "pallet-asset-rate/runtime-benchmarks", "pallet-alliance/runtime-benchmarks", + "pallet-asset-rate/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-collective/runtime-benchmarks", @@ -127,8 +128,8 @@ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "frame-try-runtime/try-runtime", - "pallet-asset-rate/try-runtime", "pallet-alliance/try-runtime", + "pallet-asset-rate/try-runtime", "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", @@ -170,8 +171,8 @@ std = [ "frame-system/std", "frame-try-runtime?/std", "log/std", - "pallet-asset-rate/std", "pallet-alliance/std", + "pallet-asset-rate/std", "pallet-aura/std", "pallet-authorship/std", "pallet-balances/std", @@ -214,6 +215,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "substrate-wasm-builder", + "system-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm/std", diff --git a/system-parachains/collectives/collectives-polkadot/src/fellowship/mod.rs b/system-parachains/collectives/collectives-polkadot/src/fellowship/mod.rs index 230d40585b..8a5885e476 100644 --- a/system-parachains/collectives/collectives-polkadot/src/fellowship/mod.rs +++ b/system-parachains/collectives/collectives-polkadot/src/fellowship/mod.rs @@ -38,7 +38,6 @@ pub use origins::{ }; use pallet_ranked_collective::EnsureOfRank; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use parachains_common::polkadot::account; use polkadot_runtime_common::impls::{ LocatableAssetConverter, VersionedLocatableAsset, VersionedMultiLocationConverter, }; @@ -48,6 +47,7 @@ use sp_core::{ConstU128, ConstU32}; use sp_runtime::traits::{ AccountIdConversion, ConstU16, ConvertToValue, IdentityLookup, Replace, TakeFirst, }; +use system_parachains_constants::polkadot::account; use xcm::latest::BodyId; use xcm_builder::{AliasesIntoAccountId32, LocatableAssetId, PayOverXcm}; diff --git a/system-parachains/collectives/collectives-polkadot/src/lib.rs b/system-parachains/collectives/collectives-polkadot/src/lib.rs index 89bda923a3..1a0e82c052 100644 --- a/system-parachains/collectives/collectives-polkadot/src/lib.rs +++ b/system-parachains/collectives/collectives-polkadot/src/lib.rs @@ -77,15 +77,15 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; -pub use parachains_common as common; use parachains_common::{ - impls::DealWithFees, + impls::DealWithFees, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature, +}; +use sp_runtime::RuntimeDebug; +use system_parachains_constants::{ polkadot::{account::*, consensus::*, currency::*, fee::WeightToFee}, - AccountId, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; -use sp_runtime::RuntimeDebug; use xcm_config::{ GovernanceLocation, TreasurerBodyId, XcmConfig, XcmOriginToTransactDispatchOrigin, }; diff --git a/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs b/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs index ced66b2c5d..0047b40aec 100644 --- a/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs +++ b/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs @@ -28,11 +28,11 @@ use pallet_xcm::XcmPassthrough; use parachains_common::{ impls::ToStakingPot, xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains}, - TREASURY_PALLET_ID, }; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_constants::{system_parachain, xcm as xcm_constants}; use sp_runtime::traits::AccountIdConversion; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/constants/Cargo.toml b/system-parachains/constants/Cargo.toml new file mode 100644 index 0000000000..20bd904bf3 --- /dev/null +++ b/system-parachains/constants/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "system-parachains-constants" +description = "Common constants for System Parachains runtimes" +repository.workspace = true +version.workspace = true +authors.workspace = true +edition.workspace = true +license.workspace = true + +[dependencies] +smallvec = "1.8.0" + +frame-support = { default-features = false , version = "25.0.0" } +kusama-runtime-constants = { path = "../../relay/kusama/constants", default-features = false} +parachains-common = { default-features = false , version = "4.0.0" } +polkadot-core-primitives = { default-features = false, version = "4.0.0"} +polkadot-primitives = { default-features = false , version = "4.0.0" } +polkadot-runtime-constants = { path = "../../relay/polkadot/constants", default-features = false} +sp-runtime = { default-features = false , version = "28.0.0" } + +[features] +default = [ "std" ] +std = [ + "frame-support/std", + "kusama-runtime-constants/std", + "parachains-common/std", + "polkadot-core-primitives/std", + "polkadot-primitives/std", + "polkadot-runtime-constants/std", + "sp-runtime/std", +] diff --git a/system-parachains/constants/src/kusama.rs b/system-parachains/constants/src/kusama.rs new file mode 100644 index 0000000000..3ae72f6514 --- /dev/null +++ b/system-parachains/constants/src/kusama.rs @@ -0,0 +1,123 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// Consensus-related. +pub mod consensus { + /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included + /// into the relay chain. + pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; + /// How many parachain blocks are processed by the relay chain per parent. Limits the + /// number of blocks authored per slot. + pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; + /// Relay chain slot duration, in milliseconds. + pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; +} + +/// Constants relating to KSM. +pub mod currency { + use polkadot_core_primitives::Balance; + + /// The existential deposit. 1/10th of the relay deposit. + pub const EXISTENTIAL_DEPOSIT: Balance = + kusama_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; + + pub const UNITS: Balance = 1_000_000_000_000; + pub const QUID: Balance = UNITS / 30; + pub const CENTS: Balance = QUID / 100; + pub const GRAND: Balance = QUID * 1_000; + pub const MILLICENTS: Balance = CENTS / 1_000; + + /// Deposit for stored data. 1/100th of the relay deposit. + pub const fn deposit(items: u32, bytes: u32) -> Balance { + kusama_runtime_constants::currency::deposit(items, bytes) / 100 + } +} + +/// Constants related to Kusama fee payment. +pub mod fee { + use frame_support::{ + pallet_prelude::Weight, + weights::{ + constants::ExtrinsicBaseWeight, FeePolynomial, WeightToFeeCoefficient, + WeightToFeeCoefficients, WeightToFeePolynomial, + }, + }; + use polkadot_core_primitives::Balance; + use smallvec::smallvec; + pub use sp_runtime::Perbill; + + /// The block saturation level. Fees will be updates based on this value. + pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the + /// node's balance type. + /// + /// This should typically create a mapping between the following ranges: + /// - [0, MAXIMUM_BLOCK_WEIGHT] + /// - [Balance::min, Balance::max] + /// + /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: + /// - Setting it to `0` will essentially disable the weight fee. + /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. + pub struct WeightToFee; + impl frame_support::weights::WeightToFee for WeightToFee { + type Balance = Balance; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + let time_poly: FeePolynomial = RefTimeToFee::polynomial().into(); + let proof_poly: FeePolynomial = ProofSizeToFee::polynomial().into(); + + // Take the maximum instead of the sum to charge by the more scarce resource. + time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size())) + } + } + + /// Maps the reference time component of `Weight` to a fee. + pub struct RefTimeToFee; + impl WeightToFeePolynomial for RefTimeToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + // In Kusama, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: + // The standard system parachain configuration is 1/10 of that, as in 1/100 CENT. + let p = super::currency::CENTS; + let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); + + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } + } + + /// Maps the proof size component of `Weight` to a fee. + pub struct ProofSizeToFee; + impl WeightToFeePolynomial for ProofSizeToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + // Map 10kb proof to 1 CENT. + let p = super::currency::CENTS; + let q = 10_000; + + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } + } +} diff --git a/system-parachains/constants/src/lib.rs b/system-parachains/constants/src/lib.rs new file mode 100644 index 0000000000..d0d320d968 --- /dev/null +++ b/system-parachains/constants/src/lib.rs @@ -0,0 +1,57 @@ +// Copyright (C) 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 . + +#![cfg_attr(not(feature = "std"), no_std)] + +pub mod kusama; +pub mod polkadot; + +use frame_support::{ + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, + PalletId, +}; +pub use parachains_common::BlockNumber; +use sp_runtime::Perbill; + +/// This determines the average expected block time that we are targeting. Blocks will be +/// produced at a minimum duration defined by `SLOT_DURATION`. `SLOT_DURATION` is picked up by +/// `pallet_timestamp` which is in turn picked up by `pallet_aura` to implement `fn +/// slot_duration()`. +/// +/// Change this to adjust the block time. +pub const MILLISECS_PER_BLOCK: u64 = 12000; +pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + +// Time is measured by 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; + +/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is +/// used to limit the maximal weight of a single extrinsic. +pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by +/// Operational extrinsics. +pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + +/// We allow for 0.5 seconds of compute with a 6 second average block time. +pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( + WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + polkadot_primitives::MAX_POV_SIZE as u64, +); + +/// Treasury pallet id of the local chain, used to convert into AccountId +pub const TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry"); diff --git a/system-parachains/constants/src/polkadot.rs b/system-parachains/constants/src/polkadot.rs new file mode 100644 index 0000000000..dfca992715 --- /dev/null +++ b/system-parachains/constants/src/polkadot.rs @@ -0,0 +1,144 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// Universally recognized accounts. +pub mod account { + use frame_support::PalletId; + + /// Polkadot treasury pallet id, used to convert into AccountId + pub const POLKADOT_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/trsry"); + /// Alliance pallet ID. + /// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury. + pub const ALLIANCE_PALLET_ID: PalletId = PalletId(*b"py/allia"); + /// Referenda pallet ID. + /// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury. + pub const REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/refer"); + /// Ambassador Referenda pallet ID. + /// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury. + pub const AMBASSADOR_REFERENDA_PALLET_ID: PalletId = PalletId(*b"py/amref"); + /// Identity pallet ID. + /// Used as a temporary place to deposit a slashed imbalance before teleporting to the Treasury. + pub const IDENTITY_PALLET_ID: PalletId = PalletId(*b"py/ident"); + /// Fellowship treasury pallet ID + pub const FELLOWSHIP_TREASURY_PALLET_ID: PalletId = PalletId(*b"py/feltr"); +} + +/// Consensus-related. +pub mod consensus { + /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included + /// into the relay chain. + pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; + /// How many parachain blocks are processed by the relay chain per parent. Limits the + /// number of blocks authored per slot. + pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; + /// Relay chain slot duration, in milliseconds. + pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; +} + +/// Constants relating to DOT. +pub mod currency { + use polkadot_core_primitives::Balance; + + /// The existential deposit. + pub const EXISTENTIAL_DEPOSIT: Balance = + polkadot_runtime_constants::currency::EXISTENTIAL_DEPOSIT / 10; + + pub const UNITS: Balance = 10_000_000_000; + pub const DOLLARS: Balance = UNITS; // 10_000_000_000 + pub const GRAND: Balance = DOLLARS * 1_000; // 10_000_000_000_000 + pub const CENTS: Balance = DOLLARS / 100; // 100_000_000 + pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000 + + pub const fn deposit(items: u32, bytes: u32) -> Balance { + polkadot_runtime_constants::currency::deposit(items, bytes) / 100 + } +} + +/// Constants related to Polkadot fee payment. +pub mod fee { + use frame_support::{ + pallet_prelude::Weight, + weights::{ + constants::ExtrinsicBaseWeight, FeePolynomial, WeightToFeeCoefficient, + WeightToFeeCoefficients, WeightToFeePolynomial, + }, + }; + use polkadot_core_primitives::Balance; + use smallvec::smallvec; + pub use sp_runtime::Perbill; + + /// The block saturation level. Fees will be updates based on this value. + pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + + /// Handles converting a weight scalar to a fee value, based on the scale and granularity of the + /// node's balance type. + /// + /// This should typically create a mapping between the following ranges: + /// - [0, MAXIMUM_BLOCK_WEIGHT] + /// - [Balance::min, Balance::max] + /// + /// Yet, it can be used for any other sort of change to weight-fee. Some examples being: + /// - Setting it to `0` will essentially disable the weight fee. + /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. + pub struct WeightToFee; + impl frame_support::weights::WeightToFee for WeightToFee { + type Balance = Balance; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + let time_poly: FeePolynomial = RefTimeToFee::polynomial().into(); + let proof_poly: FeePolynomial = ProofSizeToFee::polynomial().into(); + + // Take the maximum instead of the sum to charge by the more scarce resource. + time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size())) + } + } + + /// Maps the reference time component of `Weight` to a fee. + pub struct RefTimeToFee; + impl WeightToFeePolynomial for RefTimeToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + // In Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: + // The standard system parachain configuration is 1/10 of that, as in 1/100 CENT. + let p = super::currency::CENTS; + let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); + + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } + } + + /// Maps the proof size component of `Weight` to a fee. + pub struct ProofSizeToFee; + impl WeightToFeePolynomial for ProofSizeToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + // Map 10kb proof to 1 CENT. + let p = super::currency::CENTS; + let q = 10_000; + + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } + } +} diff --git a/system-parachains/gluttons/glutton-kusama/Cargo.toml b/system-parachains/gluttons/glutton-kusama/Cargo.toml index f86a9159d1..1399159633 100644 --- a/system-parachains/gluttons/glutton-kusama/Cargo.toml +++ b/system-parachains/gluttons/glutton-kusama/Cargo.toml @@ -46,6 +46,7 @@ cumulus-pallet-xcm = { default-features = false , version = "0.4.0" } cumulus-primitives-core = { default-features = false , version = "0.4.0" } parachain-info = { package = "staging-parachain-info", default-features = false , version = "0.4.0" } parachains-common = { default-features = false , version = "4.0.0" } +system-parachains-constants = { path = "../../constants", default-features = false } [build-dependencies] substrate-wasm-builder = { version = "14.0.0" } @@ -94,6 +95,7 @@ std = [ "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", + "system-parachains-constants/std", "xcm-builder/std", "xcm-executor/std", "xcm/std",