Skip to content

Commit

Permalink
feat(system-parachains/coretime): Configure Coretime Kusama
Browse files Browse the repository at this point in the history
- `XcmFeeToAccount` -> `SendXcmFeeToAccount`
- add possibility to inject non-authorities session-keys in genesis (SDK #5078)
- Coretime auto-renew (SDK #4424)
- Mock Weights
  • Loading branch information
pandres95 committed Oct 21, 2024
1 parent 98ca108 commit ca9e89d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub fn genesis() -> Storage {
)
})
.collect(),
// TODO: Any keys to add here?
non_authority_keys: vec![],
},
polkadot_xcm: coretime_kusama_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
22 changes: 19 additions & 3 deletions system-parachains/coretime/coretime-kusama/src/coretime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ use frame_support::{
};
use frame_system::Pallet as System;
use kusama_runtime_constants::{system_parachain::coretime, time::DAYS as RELAY_DAYS};
use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf};
use pallet_broker::{
CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf, TaskId,
};
use parachains_common::{AccountId, Balance};
use sp_runtime::traits::AccountIdConversion;
use sp_runtime::traits::{AccountIdConversion, MaybeConvert};
use xcm::latest::prelude::*;
use xcm_executor::traits::TransactAsset;
use xcm_config::LocationToAccountId;
use xcm_executor::traits::{ConvertLocation, TransactAsset};

/// A type containing the encoding of the coretime pallet in the Relay chain runtime. Used to
/// construct any remote calls. The codec index must correspond to the index of `Coretime` in the
Expand Down Expand Up @@ -320,6 +323,15 @@ parameter_types! {
pub const BrokerPalletId: PalletId = PalletId(*b"py/broke");
}

pub struct SovereignAccountOf;
impl MaybeConvert<TaskId, AccountId> for SovereignAccountOf {
fn maybe_convert(id: TaskId) -> Option<AccountId> {
// Currently all tasks are parachains
let location = Location::new(1, [Parachain(id)]);
LocationToAccountId::convert_location(&location)
}
}

impl pallet_broker::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
Expand All @@ -332,5 +344,9 @@ impl pallet_broker::Config for Runtime {
type WeightInfo = weights::pallet_broker::WeightInfo<Runtime>;
type PalletId = BrokerPalletId;
type AdminOrigin = EnsureRoot<AccountId>;
type SovereignAccountOf = SovereignAccountOf;
// Roughly 1.5 years with a period of 28 days(~ish)
// TODO: @szegoo, can you help checking this value?
type MaxAutoRenewals = ConstU32<20>;
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ fn coretime_kusama_genesis(
)
})
.collect(),
// TODO: Any keys to add here?
non_authority_keys: vec![],
},
"polkadotXcm": {
"safeXcmVersion": Some(SAFE_XCM_VERSION),
Expand Down

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

6 changes: 3 additions & 3 deletions system-parachains/coretime/coretime-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ use xcm_builder::{
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribeTerminus, EnsureXcmOrigin,
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
XcmFeeManagerFromComponents, XcmFeeToAccount,
XcmFeeManagerFromComponents,
};
use xcm_executor::{traits::ConvertLocation, XcmExecutor};

Expand Down Expand Up @@ -221,7 +221,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetExchanger = ();
type FeeManager = XcmFeeManagerFromComponents<
WaivedLocations,
XcmFeeToAccount<Self::AssetTransactor, AccountId, RelayTreasuryPalletAccount>,
SendXcmFeeToAccount<Self::AssetTransactor, RelayTreasuryPalletAccount>,
>;
type MessageExporter = ();
type UniversalAliases = Nothing;
Expand Down

0 comments on commit ca9e89d

Please sign in to comment.