Skip to content

Commit

Permalink
Merge branch 'main' into bko-collectives-constants-todo
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr authored Mar 11, 2024
2 parents 8a453ab + e42821d commit 908f860
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
echo "Flags: $EXTRA_FLAGS"
./try-runtime \
RUST_LOG=runtime=DEBUG ./try-runtime \
--runtime $RUNTIME_BLOB_PATH \
on-runtime-upgrade --checks=pre-and-post \
$EXTRA_FLAGS \
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
0022-adopt-encointer-runtime.md) ([polkadot-fellows/runtimes#80](https://github.com/polkadot-fellows/runtimes/pull/80))
- Feature for enabling debug prints in the Polkadot and Kusama runtime ([polkadot-fellows/runtimes#85](https://github.com/polkadot-fellows/runtimes/pull/85))
- Added new "Wish for Change" track ([polkadot-fellows/runtimes#184](https://github.com/polkadot-fellows/runtimes/pull/184))
- Enable Coretime and on-demand on Kusama ([polkadot-fellows/runtimes#159](https://github.com/polkadot-fellows/runtimes/pull/159)
- Enable Coretime and on-demand on Kusama ([polkadot-fellows/runtimes#159](https://github.com/polkadot-fellows/runtimes/pull/159))
- Refund any leases that are not migrated to Coretime (have holes in them/have not yet started) ([polkadot-fellows/runtimes#206](https://github.com/polkadot-fellows/runtimes/pull/206))
- Enable Elastic Scaling node side feature for Kusama ([polkadot-fellows/runtimes#205](https://github.com/polkadot-fellows/runtimes/pull/205))
- Cancel Parachain Auctions ([polkadot-fellows/runtimes#215](https://github.com/polkadot-fellows/runtimes/pull/215))

### Changed

Expand All @@ -23,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Deprecate the `xcm::body::TREASURER_INDEX` constant and use the standard `Treasury` variant from the `xcm::BodyId` type instead ([polkadot-fellows/runtimes#149](https://github.com/polkadot-fellows/runtimes/pull/149))
- Bump parachains runtime API to v9 in Kusama to enable the `node_features` function [polkadot-fellows/runtimes#194](https://github.com/polkadot-fellows/runtimes/pull/194)
- Bump parachains runtime API to v10 in Kusama to enable the `approval-voting-params` function [polkadot-fellows/runtimes#204](https://github.com/polkadot-fellows/runtimes/pull/204)
- Use Relay Chain's Treasury Pallet account as a destination for XCM fees on System Parachain ([polkadot-fellows/runtimes#191](https://github.com/polkadot-fellows/runtimes/pull/191))

### Removed

Expand Down
71 changes: 68 additions & 3 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ impl parachains_paras::Config for Runtime {
type QueueFootprinter = ParaInclusion;
type NextSessionRotation = Babe;
type OnNewHead = Registrar;
type AssignCoretime = ();
type AssignCoretime = CoretimeAssignmentProvider;
}

parameter_types! {
Expand Down Expand Up @@ -1745,6 +1745,11 @@ pub type Migrations = (migrations::Unreleased, migrations::Permanent);
#[allow(deprecated, missing_docs)]
pub mod migrations {
use super::*;
use frame_support::traits::OnRuntimeUpgrade;
use frame_system::RawOrigin;
use pallet_scheduler::WeightInfo as SchedulerWeightInfo;
use runtime_common::auctions::WeightInfo as AuctionsWeightInfo;
use runtime_parachains::configuration::WeightInfo;
#[cfg(feature = "try-runtime")]
use sp_core::crypto::ByteArray;

Expand All @@ -1759,8 +1764,19 @@ pub mod migrations {
if lease.is_empty() {
return None
}
// Lease not yet started, ignore:
// Lease not yet started/or having holes, refund (coretime can't handle this):
if lease.iter().any(Option::is_none) {
if let Err(err) = slots::Pallet::<Runtime>::clear_all_leases(
frame_system::RawOrigin::Root.into(),
para,
) {
log::error!(
target: "runtime",
"Clearing lease for para: {:?} failed, with error: {:?}",
para,
err
);
};
return None
}
let (index, _) =
Expand All @@ -1769,6 +1785,18 @@ pub mod migrations {
}
}

/// Enable the elastic scaling node side feature.
///
/// This is required for Coretime to ensure the relay chain processes parachains that are
/// assigned to multiple cores.
pub struct EnableElasticScalingNodeFeature;
impl OnRuntimeUpgrade for EnableElasticScalingNodeFeature {
fn on_runtime_upgrade() -> Weight {
let _ = Configuration::set_node_feature(RawOrigin::Root.into(), 1, true);
weights::runtime_parachains_configuration::WeightInfo::<Runtime>::set_node_feature()
}
}

parameter_types! {
pub const ImOnlinePalletName: &'static str = "ImOnline";
}
Expand All @@ -1778,7 +1806,7 @@ pub mod migrations {
pub struct UpgradeSessionKeys;
const UPGRADE_SESSION_KEYS_FROM_SPEC: u32 = 1001002;

impl frame_support::traits::OnRuntimeUpgrade for UpgradeSessionKeys {
impl OnRuntimeUpgrade for UpgradeSessionKeys {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
if System::last_runtime_upgrade_spec_version() > UPGRADE_SESSION_KEYS_FROM_SPEC {
Expand Down Expand Up @@ -1849,6 +1877,41 @@ pub mod migrations {
}
}

/// Cancel all ongoing auctions.
///
/// Any leases that come into existence after coretime was launched will not be served. Yet,
/// any ongoing auctions must be cancelled.
///
/// Safety:
///
/// - After coretime is launched, there are no auctions anymore. So if this forgotten to
/// be removed after the runtime upgrade, running this again on the next one is harmless.
/// - I am assuming scheduler `TaskName`s are unique, so removal of the scheduled entry
/// multiple times should also be fine.
pub struct CancelAuctions;
impl OnRuntimeUpgrade for CancelAuctions {
fn on_runtime_upgrade() -> Weight {
if let Err(err) = Auctions::cancel_auction(frame_system::RawOrigin::Root.into()) {
log::debug!(target: "runtime", "Cancelling auctions failed: {:?}", err);
}
// Cancel scheduled auction as well:
if let Err(err) = Scheduler::cancel_named(
pallet_custom_origins::Origin::AuctionAdmin.into(),
[
0x5c, 0x68, 0xbf, 0x0c, 0x2d, 0x11, 0x04, 0x91, 0x6b, 0xa5, 0xa4, 0xde, 0xe6,
0xb8, 0x14, 0xe8, 0x2b, 0x27, 0x93, 0x78, 0x4c, 0xb6, 0xe7, 0x69, 0x04, 0x00,
0x1a, 0x59, 0x49, 0xc1, 0x63, 0xb1,
],
) {
log::debug!(target: "runtime", "Cancelling scheduled auctions failed: {:?}", err);
}
weights::runtime_common_auctions::WeightInfo::<Runtime>::cancel_auction()
.saturating_add(weights::pallet_scheduler::WeightInfo::<Runtime>::cancel_named(
<Runtime as pallet_scheduler::Config>::MaxScheduledPerBlock::get(),
))
}
}

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
pallet_nomination_pools::migration::versioned::V7ToV8<Runtime>,
Expand All @@ -1865,13 +1928,15 @@ pub mod migrations {
crate::xcm_config::XcmRouter,
GetLegacyLeaseImpl,
>,
EnableElasticScalingNodeFeature,
// Upgrade `SessionKeys` to exclude `ImOnline`
UpgradeSessionKeys,
// Remove `im-online` pallet on-chain storage
frame_support::migrations::RemovePallet<
ImOnlinePalletName,
<Runtime as frame_system::Config>::DbWeight,
>,
CancelAuctions,
);

/// Migrations/checks that do not need to be versioned and can run on every update.
Expand Down
12 changes: 10 additions & 2 deletions system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ use xcm_builder::{
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use xcm_executor::{
traits::{ConvertLocation, WithOriginFilter},
XcmExecutor,
};

parameter_types! {
pub const KsmLocation: Location = Location::parent();
Expand All @@ -73,6 +76,11 @@ parameter_types! {
pub const FellowshipLocation: Location = Location::parent();
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(kusama_runtime_constants::TREASURY_PALLET_ID)).into();
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
// Test [`crate::tests::treasury_pallet_account_not_none`] ensures that the result of location
// conversion is not `None`.
pub RelayTreasuryPalletAccount: AccountId =
LocationToAccountId::convert_location(&RelayTreasuryLocation::get())
.unwrap_or(TreasuryAccount::get());
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -562,7 +570,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetExchanger = ();
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
XcmFeeToAccount<Self::AssetTransactor, AccountId, TreasuryAccount>,
XcmFeeToAccount<Self::AssetTransactor, AccountId, RelayTreasuryPalletAccount>,
>;
type MessageExporter = ();
type UniversalAliases = bridging::to_polkadot::UniversalAliases;
Expand Down
14 changes: 11 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 @@ -21,8 +21,8 @@ use asset_hub_kusama_runtime::{
xcm_config::{
bridging::{self, XcmBridgeHubRouterFeeAssetId},
AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount,
ForeignCreatorsSovereignAccountOf, KsmLocation, LocationToAccountId, TreasuryAccount,
TrustBackedAssetsPalletLocation, XcmConfig,
ForeignCreatorsSovereignAccountOf, KsmLocation, LocationToAccountId, RelayTreasuryLocation,
RelayTreasuryPalletAccount, TrustBackedAssetsPalletLocation, XcmConfig,
},
AllPalletsWithoutSystem, AssetDeposit, Assets, Balances, ExistentialDeposit, ForeignAssets,
ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem,
Expand Down Expand Up @@ -717,7 +717,7 @@ fn limited_reserve_transfer_assets_for_native_asset_to_asset_hub_polkadot_works(
bridging_to_asset_hub_polkadot,
WeightLimit::Unlimited,
Some(XcmBridgeHubRouterFeeAssetId::get()),
Some(TreasuryAccount::get()),
Some(RelayTreasuryPalletAccount::get()),
)
}

Expand Down Expand Up @@ -923,3 +923,11 @@ fn change_xcm_bridge_hub_router_byte_fee_by_governance_works() {
},
)
}

#[test]
fn treasury_pallet_account_not_none() {
assert_eq!(
RelayTreasuryPalletAccount::get(),
LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap()
)
}
12 changes: 10 additions & 2 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ use xcm_builder::{
TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin,
WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use xcm_executor::{
traits::{ConvertLocation, WithOriginFilter},
XcmExecutor,
};

parameter_types! {
pub const DotLocation: Location = Location::parent();
Expand All @@ -66,6 +69,11 @@ parameter_types! {
pub const GovernanceLocation: Location = Location::parent();
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(polkadot_runtime_constants::TREASURY_PALLET_ID)).into();
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
// Test [`crate::tests::treasury_pallet_account_not_none`] ensures that the result of location
// conversion is not `None`.
pub RelayTreasuryPalletAccount: AccountId =
LocationToAccountId::convert_location(&RelayTreasuryLocation::get())
.unwrap_or(TreasuryAccount::get());
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -527,7 +535,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetExchanger = ();
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
XcmFeeToAccount<Self::AssetTransactor, AccountId, TreasuryAccount>,
XcmFeeToAccount<Self::AssetTransactor, AccountId, RelayTreasuryPalletAccount>,
>;
type MessageExporter = ();
type UniversalAliases = bridging::to_kusama::UniversalAliases;
Expand Down
14 changes: 11 additions & 3 deletions system-parachains/asset-hubs/asset-hub-polkadot/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use asset_hub_polkadot_runtime::{
xcm_config::{
bridging::{self, XcmBridgeHubRouterFeeAssetId},
AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount, DotLocation,
ForeignCreatorsSovereignAccountOf, LocationToAccountId, TreasuryAccount,
TrustBackedAssetsPalletLocation, XcmConfig,
ForeignCreatorsSovereignAccountOf, LocationToAccountId, RelayTreasuryLocation,
RelayTreasuryPalletAccount, TrustBackedAssetsPalletLocation, XcmConfig,
},
AllPalletsWithoutSystem, AssetDeposit, Assets, Balances, ExistentialDeposit, ForeignAssets,
ForeignAssetsInstance, MetadataDepositBase, MetadataDepositPerByte, ParachainSystem,
Expand Down Expand Up @@ -731,7 +731,7 @@ fn limited_reserve_transfer_assets_for_native_asset_to_asset_hub_kusama_works()
bridging_to_asset_hub_kusama,
WeightLimit::Unlimited,
Some(XcmBridgeHubRouterFeeAssetId::get()),
Some(TreasuryAccount::get()),
Some(RelayTreasuryPalletAccount::get()),
)
}

Expand Down Expand Up @@ -935,3 +935,11 @@ fn change_xcm_bridge_hub_router_byte_fee_by_governance_works() {
},
)
}

#[test]
fn treasury_pallet_account_not_none() {
assert_eq!(
RelayTreasuryPalletAccount::get(),
LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap()
)
}
20 changes: 18 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ use xcm_builder::{
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use xcm_executor::{
traits::{ConvertLocation, WithOriginFilter},
XcmExecutor,
};

parameter_types! {
pub const KsmRelayLocation: Location = Location::parent();
Expand All @@ -63,6 +66,11 @@ parameter_types! {
pub const FellowshipLocation: Location = Location::parent();
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(kusama_runtime_constants::TREASURY_PALLET_ID)).into();
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
// Test [`crate::tests::treasury_pallet_account_not_none`] ensures that the result of location
// conversion is not `None`.
pub RelayTreasuryPalletAccount: AccountId =
LocationToAccountId::convert_location(&RelayTreasuryLocation::get())
.unwrap_or(TreasuryAccount::get());
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -266,7 +274,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetExchanger = ();
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
XcmFeeToAccount<Self::AssetTransactor, AccountId, TreasuryAccount>,
XcmFeeToAccount<Self::AssetTransactor, AccountId, RelayTreasuryPalletAccount>,
>;
type MessageExporter = ToBridgeHubPolkadotHaulBlobExporter;
type UniversalAliases = Nothing;
Expand Down Expand Up @@ -326,3 +334,11 @@ impl cumulus_pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}

#[test]
fn treasury_pallet_account_not_none() {
assert_eq!(
RelayTreasuryPalletAccount::get(),
LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap()
)
}
14 changes: 13 additions & 1 deletion system-parachains/bridge-hubs/bridge-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use bridge_hub_kusama_runtime::{
RequiredStakeForStakeAndSlash, WithBridgeHubPolkadotMessageBridge,
WithBridgeHubPolkadotMessagesInstance, XCM_LANE_FOR_ASSET_HUB_KUSAMA_TO_ASSET_HUB_POLKADOT,
},
xcm_config::{KsmRelayLocation, RelayNetwork, XcmConfig},
xcm_config::{
KsmRelayLocation, LocationToAccountId, RelayNetwork, RelayTreasuryLocation,
RelayTreasuryPalletAccount, XcmConfig,
},
AllPalletsWithoutSystem, BridgeRejectObsoleteHeadersAndMessages, Executive, ExistentialDeposit,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, SessionKeys,
SignedExtra, TransactionPayment, UncheckedExtrinsic, SLOT_DURATION,
Expand All @@ -42,6 +45,7 @@ use system_parachains_constants::kusama::{
consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, fee::WeightToFee,
};
use xcm::latest::prelude::*;
use xcm_executor::traits::ConvertLocation;

// Para id of sibling chain used in tests.
pub const SIBLING_PARACHAIN_ID: u32 = 1000;
Expand Down Expand Up @@ -360,6 +364,14 @@ pub fn can_calculate_fee_for_complex_message_confirmation_transaction() {
)
}

#[test]
fn treasury_pallet_account_not_none() {
assert_eq!(
RelayTreasuryPalletAccount::get(),
LocationToAccountId::convert_location(&RelayTreasuryLocation::get()).unwrap()
)
}

use sp_runtime::Perbill;

// TODO:(PR#159): remove when `[email protected]` bump (https://github.com/polkadot-fellows/runtimes/issues/186)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ use xcm_builder::{
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use xcm_executor::{
traits::{ConvertLocation, WithOriginFilter},
XcmExecutor,
};

parameter_types! {
pub const DotRelayLocation: Location = Location::parent();
Expand All @@ -64,6 +67,11 @@ parameter_types! {
pub const GovernanceLocation: Location = Location::parent();
pub RelayTreasuryLocation: Location = (Parent, PalletInstance(polkadot_runtime_constants::TREASURY_PALLET_ID)).into();
pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating();
// Test [`crate::tests::treasury_pallet_account_not_none`] ensures that the result of location
// conversion is not `None`.
pub RelayTreasuryPalletAccount: AccountId =
LocationToAccountId::convert_location(&RelayTreasuryLocation::get())
.unwrap_or(TreasuryAccount::get());
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
Expand Down Expand Up @@ -285,7 +293,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetExchanger = ();
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
XcmFeeToAccount<Self::AssetTransactor, AccountId, TreasuryAccount>,
XcmFeeToAccount<Self::AssetTransactor, AccountId, RelayTreasuryPalletAccount>,
>;
type MessageExporter = ToBridgeHubKusamaHaulBlobExporter;
type UniversalAliases = Nothing;
Expand Down
Loading

0 comments on commit 908f860

Please sign in to comment.