mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
parachains_coretime: Expose MaxXCMTransactWeight (#4189)
This should be configured on the runtime level and not somewhere inside the pallet. --------- Co-authored-by: Adrian Catangiu <adrian@parity.io> Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
@@ -222,7 +222,7 @@ mod v_coretime {
|
||||
mask: CoreMask::complete(),
|
||||
assignment: CoreAssignment::Task(p.into()),
|
||||
}]);
|
||||
mk_coretime_call(crate::coretime::CoretimeCalls::Reserve(schedule))
|
||||
mk_coretime_call::<T>(crate::coretime::CoretimeCalls::Reserve(schedule))
|
||||
});
|
||||
|
||||
let leases = lease_holding.into_iter().filter_map(|p| {
|
||||
@@ -243,14 +243,14 @@ mod v_coretime {
|
||||
let round_up = if valid_until % TIME_SLICE_PERIOD > 0 { 1 } else { 0 };
|
||||
let time_slice = valid_until / TIME_SLICE_PERIOD + TIME_SLICE_PERIOD * round_up;
|
||||
log::trace!(target: "coretime-migration", "Sending of lease holding para {:?}, valid_until: {:?}, time_slice: {:?}", p, valid_until, time_slice);
|
||||
Some(mk_coretime_call(crate::coretime::CoretimeCalls::SetLease(p.into(), time_slice)))
|
||||
Some(mk_coretime_call::<T>(crate::coretime::CoretimeCalls::SetLease(p.into(), time_slice)))
|
||||
});
|
||||
|
||||
let core_count: u16 = configuration::ActiveConfig::<T>::get()
|
||||
.scheduler_params
|
||||
.num_cores
|
||||
.saturated_into();
|
||||
let set_core_count = iter::once(mk_coretime_call(
|
||||
let set_core_count = iter::once(mk_coretime_call::<T>(
|
||||
crate::coretime::CoretimeCalls::NotifyCoreCount(core_count),
|
||||
));
|
||||
|
||||
@@ -261,7 +261,7 @@ mod v_coretime {
|
||||
}]);
|
||||
// Reserved cores will come before lease cores, so cores will change their assignments
|
||||
// when coretime chain sends us their assign_core calls -> Good test.
|
||||
mk_coretime_call(crate::coretime::CoretimeCalls::Reserve(schedule))
|
||||
mk_coretime_call::<T>(crate::coretime::CoretimeCalls::Reserve(schedule))
|
||||
});
|
||||
|
||||
let message_content = iter::once(Instruction::UnpaidExecution {
|
||||
|
||||
@@ -110,6 +110,11 @@ pub mod pallet {
|
||||
/// Something that provides the weight of this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
type SendXcm: SendXcm;
|
||||
|
||||
/// Maximum weight for any XCM transact call that should be executed on the coretime chain.
|
||||
///
|
||||
/// Basically should be `max_weight(set_leases, reserve, notify_core_count)`.
|
||||
type MaxXcmTransactWeight: Get<Weight>;
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
@@ -225,7 +230,7 @@ impl<T: Config> Pallet<T> {
|
||||
weight_limit: WeightLimit::Unlimited,
|
||||
check_origin: None,
|
||||
},
|
||||
mk_coretime_call(crate::coretime::CoretimeCalls::NotifyCoreCount(core_count)),
|
||||
mk_coretime_call::<T>(crate::coretime::CoretimeCalls::NotifyCoreCount(core_count)),
|
||||
]);
|
||||
if let Err(err) = send_xcm::<T::SendXcm>(
|
||||
Location::new(0, [Junction::Parachain(T::BrokerId::get())]),
|
||||
@@ -244,7 +249,7 @@ impl<T: Config> Pallet<T> {
|
||||
weight_limit: WeightLimit::Unlimited,
|
||||
check_origin: None,
|
||||
},
|
||||
mk_coretime_call(crate::coretime::CoretimeCalls::SwapLeases(one, other)),
|
||||
mk_coretime_call::<T>(crate::coretime::CoretimeCalls::SwapLeases(one, other)),
|
||||
]);
|
||||
if let Err(err) = send_xcm::<T::SendXcm>(
|
||||
Location::new(0, [Junction::Parachain(T::BrokerId::get())]),
|
||||
@@ -261,12 +266,10 @@ impl<T: Config> OnNewSession<BlockNumberFor<T>> for Pallet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn mk_coretime_call(call: crate::coretime::CoretimeCalls) -> Instruction<()> {
|
||||
fn mk_coretime_call<T: Config>(call: crate::coretime::CoretimeCalls) -> Instruction<()> {
|
||||
Instruction::Transact {
|
||||
origin_kind: OriginKind::Superuser,
|
||||
// Largest call is set_lease with 1526 byte:
|
||||
// Longest call is reserve() with 31_000_000
|
||||
require_weight_at_most: Weight::from_parts(170_000_000, 20_000),
|
||||
require_weight_at_most: T::MaxXcmTransactWeight::get(),
|
||||
call: BrokerRuntimePallets::Broker(call).encode().into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,6 +387,7 @@ impl assigner_coretime::Config for Test {}
|
||||
|
||||
parameter_types! {
|
||||
pub const BrokerId: u32 = 10u32;
|
||||
pub MaxXcmTransactWeight: Weight = Weight::from_parts(10_000_000, 10_000);
|
||||
}
|
||||
|
||||
impl coretime::Config for Test {
|
||||
@@ -396,6 +397,7 @@ impl coretime::Config for Test {
|
||||
type BrokerId = BrokerId;
|
||||
type WeightInfo = crate::coretime::TestWeightInfo;
|
||||
type SendXcm = DummyXcmSender;
|
||||
type MaxXcmTransactWeight = MaxXcmTransactWeight;
|
||||
}
|
||||
|
||||
pub struct DummyXcmSender;
|
||||
|
||||
@@ -1057,6 +1057,7 @@ impl parachains_scheduler::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
pub const BrokerId: u32 = BROKER_ID;
|
||||
pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
|
||||
}
|
||||
|
||||
impl coretime::Config for Runtime {
|
||||
@@ -1066,6 +1067,7 @@ impl coretime::Config for Runtime {
|
||||
type BrokerId = BrokerId;
|
||||
type WeightInfo = weights::runtime_parachains_coretime::WeightInfo<Runtime>;
|
||||
type SendXcm = crate::xcm_config::XcmRouter;
|
||||
type MaxXcmTransactWeight = MaxXcmTransactWeight;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -1188,6 +1188,7 @@ impl parachains_scheduler::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
pub const BrokerId: u32 = BROKER_ID;
|
||||
pub MaxXcmTransactWeight: Weight = Weight::from_parts(200_000_000, 20_000);
|
||||
}
|
||||
|
||||
impl coretime::Config for Runtime {
|
||||
@@ -1197,6 +1198,7 @@ impl coretime::Config for Runtime {
|
||||
type BrokerId = BrokerId;
|
||||
type WeightInfo = weights::runtime_parachains_coretime::WeightInfo<Runtime>;
|
||||
type SendXcm = crate::xcm_config::XcmRouter;
|
||||
type MaxXcmTransactWeight = MaxXcmTransactWeight;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
title: "polkadot_runtime_parachains::coretime: Expose `MaxXcmTransactWeight`"
|
||||
|
||||
doc:
|
||||
- audience: Runtime Dev
|
||||
description: |
|
||||
Expose `MaxXcmTransactWeight` via the `Config` trait. This exposes the
|
||||
possibility for runtime implementors to set the maximum weight required
|
||||
for the calls on the coretime chain. Basically it needs to be set to
|
||||
`max_weight(set_leases, reserve, notify_core_count)` where `set_leases`
|
||||
etc are the calls on the coretime chain. This ensures that these XCM
|
||||
transact calls send by the relay chain coretime pallet to the coretime
|
||||
chain can be dispatched.
|
||||
|
||||
crates:
|
||||
- name: polkadot-runtime-parachains
|
||||
bump: major
|
||||
Reference in New Issue
Block a user