Skip to content

Commit 4b4a252

Browse files
committed
feat(system-parachains/coretime): Configure Coretime Polkadot
- `XcmFeeToAccount` -> `SendXcmFeeToAccount` - add possibility to inject non-authorities session-keys in genesis (SDK #5078) - Coretime auto-renew (SDK #4424) - Mock Weights
1 parent ca9e89d commit 4b4a252

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

integration-tests/emulated/chains/parachains/coretime/coretime-polkadot/src/genesis.rs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ pub fn genesis() -> Storage {
5252
)
5353
})
5454
.collect(),
55+
// TODO: Any keys to add here?
56+
non_authority_keys: vec![],
5557
},
5658
polkadot_xcm: coretime_polkadot_runtime::PolkadotXcmConfig {
5759
safe_xcm_version: Some(SAFE_XCM_VERSION),

system-parachains/coretime/coretime-polkadot/src/coretime.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ use frame_support::{
2828
weights::constants::{WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MICROS},
2929
};
3030
use frame_system::Pallet as System;
31-
use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf};
31+
use pallet_broker::{
32+
CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf, TaskId,
33+
};
3234
use parachains_common::{AccountId, Balance};
3335
use polkadot_runtime_constants::{system_parachain::coretime, time::DAYS as RELAY_DAYS};
34-
use sp_runtime::traits::AccountIdConversion;
36+
use sp_runtime::traits::{AccountIdConversion, MaybeConvert};
3537
use xcm::latest::prelude::*;
36-
use xcm_executor::traits::TransactAsset;
38+
use xcm_config::LocationToAccountId;
39+
use xcm_executor::traits::{ConvertLocation, TransactAsset};
3740

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

329+
pub struct SovereignAccountOf;
330+
impl MaybeConvert<TaskId, AccountId> for SovereignAccountOf {
331+
fn maybe_convert(id: TaskId) -> Option<AccountId> {
332+
// Currently all tasks are parachains
333+
let location = Location::new(1, [Parachain(id)]);
334+
LocationToAccountId::convert_location(&location)
335+
}
336+
}
337+
326338
impl pallet_broker::Config for Runtime {
327339
type RuntimeEvent = RuntimeEvent;
328340
type Currency = Balances;
@@ -335,5 +347,9 @@ impl pallet_broker::Config for Runtime {
335347
type WeightInfo = weights::pallet_broker::WeightInfo<Runtime>;
336348
type PalletId = BrokerPalletId;
337349
type AdminOrigin = EnsureRoot<AccountId>;
350+
type SovereignAccountOf = SovereignAccountOf;
351+
// Roughly 1.5 years with a period of 28 days(~ish)
352+
// TODO: @szegoo, can you help checking this value?
353+
type MaxAutoRenewals = ConstU32<20>;
338354
type PriceAdapter = pallet_broker::CenterTargetPrice<Balance>;
339355
}

system-parachains/coretime/coretime-polkadot/src/genesis_config_presets.rs

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ fn coretime_polkadot_genesis(
5858
)
5959
})
6060
.collect(),
61+
// TODO: Any keys to add here?
62+
non_authority_keys: vec![],
6163
},
6264
"polkadotXcm": {
6365
"safeXcmVersion": Some(SAFE_XCM_VERSION),

system-parachains/coretime/coretime-polkadot/src/weights/pallet_broker.rs

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

system-parachains/coretime/coretime-polkadot/src/xcm_config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ use xcm_builder::{
4040
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain,
4141
DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribeTerminus, EnsureXcmOrigin,
4242
FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete,
43-
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
43+
NonFungibleAdapter, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SendXcmFeeToAccount,
4444
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
4545
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
4646
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
47-
XcmFeeManagerFromComponents, XcmFeeToAccount,
47+
XcmFeeManagerFromComponents,
4848
};
4949
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
5050

@@ -244,7 +244,7 @@ impl xcm_executor::Config for XcmConfig {
244244
type AssetExchanger = ();
245245
type FeeManager = XcmFeeManagerFromComponents<
246246
WaivedLocations,
247-
XcmFeeToAccount<Self::AssetTransactor, AccountId, RelayTreasuryPalletAccount>,
247+
SendXcmFeeToAccount<Self::AssetTransactor, RelayTreasuryPalletAccount>,
248248
>;
249249
type MessageExporter = ();
250250
type UniversalAliases = Nothing;

0 commit comments

Comments
 (0)