Skip to content

Commit

Permalink
feat(system-parachains/coretime): Configure Coretime Polkadot
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 ced1c89 commit f08d159
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 @@ -52,6 +52,8 @@ pub fn genesis() -> Storage {
)
})
.collect(),
// TODO: Any keys to add here?
non_authority_keys: vec![],
},
polkadot_xcm: coretime_polkadot_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
22 changes: 19 additions & 3 deletions system-parachains/coretime/coretime-polkadot/src/coretime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ use frame_support::{
weights::constants::{WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MICROS},
};
use frame_system::Pallet as System;
use pallet_broker::{CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf};
use pallet_broker::{
CoreAssignment, CoreIndex, CoretimeInterface, PartsOf57600, RCBlockNumberOf, TaskId,
};
use parachains_common::{AccountId, Balance};
use polkadot_runtime_constants::{system_parachain::coretime, time::DAYS as RELAY_DAYS};
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 @@ -323,6 +326,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 @@ -335,5 +347,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_polkadot_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.

Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,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 @@ -244,7 +244,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 f08d159

Please sign in to comment.