Skip to content

Commit

Permalink
Add kusama and polkadot SP constants (#115)
Browse files Browse the repository at this point in the history
This PR brings the Kusama and Polkadot constants for System Parachains
into the control of the Fellowship.

Following up on paritytech/polkadot-sdk#2620 and
paired with paritytech/polkadot-sdk#2666.

Types are still used from the `parachains-common` crate, but constants
are moved into a new crate `system-parachains-constants` in this repo.

The re-exports `pub use parachains_common as common` in both asset hubs
and collectives have been removed. This is a breaking change for anybody
using them in this way, but these should be directly imported from
`parachains-common`. This should be noted on the changelog.

---------

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
  • Loading branch information
3 people authored Jan 4, 2024
1 parent 4422084 commit 923f6c1
Show file tree
Hide file tree
Showing 27 changed files with 433 additions and 38 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 8 additions & 7 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 2 additions & 0 deletions system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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",
Expand Down
13 changes: 8 additions & 5 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 2 additions & 0 deletions system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
2 changes: 2 additions & 0 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
8 changes: 5 additions & 3 deletions system-parachains/collectives/collectives-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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};

Expand Down
Loading

0 comments on commit 923f6c1

Please sign in to comment.