Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parachains_coretime: Expose MaxXCMTransactWeight #4189

Merged
merged 6 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions polkadot/runtime/parachains/src/coretime/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand All @@ -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),
));

Expand All @@ -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 {
Expand Down
15 changes: 9 additions & 6 deletions polkadot/runtime/parachains/src/coretime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
}

#[pallet::event]
Expand Down Expand Up @@ -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())]),
Expand All @@ -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())]),
Expand All @@ -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(),
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
call: BrokerRuntimePallets::Broker(call).encode().into(),
}
}
2 changes: 2 additions & 0 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
}

impl coretime::Config for Runtime {
Expand All @@ -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;
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
}

parameter_types! {
Expand Down
2 changes: 2 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set lease has three reads and a write, independent of the ref time of the actual function on that runtime that already means a ref_time of 175_000_000. Is it worth leaving a bit more of a buffer to account for fluctuations in benchmarking on top of this?

acatangiu marked this conversation as resolved.
Show resolved Hide resolved
}

impl coretime::Config for Runtime {
Expand All @@ -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;
acatangiu marked this conversation as resolved.
Show resolved Hide resolved
}

parameter_types! {
Expand Down
Loading