Skip to content

Commit

Permalink
Maybe can generate weights
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleyOlson64 committed Nov 30, 2023
1 parent f736918 commit 531dbb1
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions polkadot/runtime/common/src/coretime/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
#![cfg(feature = "runtime-benchmarks")]

use super::{Pallet, *};
use crate::coretime;
use assigner_bulk::MAX_ASSIGNMENTS_PER_SCHEDULE;
use frame_benchmarking::v2::*;
use frame_system::RawOrigin;
//use frame_system::RawOrigin;
//use xcm::latest::prelude::*;
//use pallet_xcm::Origin;

#[benchmarks]
mod benchmarks {
Expand All @@ -31,10 +33,27 @@ mod benchmarks {
fn assign_core(s: Linear<0, MAX_ASSIGNMENTS_PER_SCHEDULE>) {
// Setup
let caller: <T as frame_system::Config>::AccountId = whitelisted_caller();
// TODO: Construct a proper Xcm broker parachain message origin
// let broker_id: u32 = 1004;
// let broker_origin = <T as Config>::XcmPallet::Origin::Xcm(MultiLocation { parents: 0,
// interior: X1(Parachain(broker_id)) });
// TODO: This value is copied from BROKER_ID in rococo runtime constants.
// Perhaps provide it in a more future proof way if worth the extra
// dependency.
let broker_id: u32 = 1004;
/*let broker_origin: <T as frame_system::Config>::RuntimeOrigin = RuntimeOrigin {
caller: Origin::Xcm(MultiLocation { parents: 0, interior: X1(Parachain(broker_id)) }),
RawOrigin::Signed(caller.into())
}*/
let successful_origin: T::RuntimeOrigin =
<<T as coretime::Config>::ExternalBrokerOrigin as EnsureOrigin<_>>::try_successful_origin()
.expect("EnsureBrokerOrigin has no successful origin required for the test");
// Maybe use this kind of stuff to modify the origin after constructing via try_successful_origin
/*fn try_origin(outer: O) -> Result<Self::Success, O> {
outer.try_with_caller(|caller| {
caller.try_into().and_then(|o| match o {
Origin::Xcm(location) if F::contains(&location) => Ok(location),
Origin::Xcm(location) => Err(Origin::Xcm(location).into()),
o => Err(o.into()),
})
})
}*/

// Use valid assignment set with maximum number of assignments to maximize work
let assignments: Vec<(CoreAssignment, PartsOf57600)> = vec![576u16; s as usize]
Expand All @@ -45,7 +64,7 @@ mod benchmarks {

#[extrinsic_call]
_(
RawOrigin::Signed(caller.into()),
successful_origin as T::RuntimeOrigin,
CoreIndex(0),
BlockNumberFor::<T>::from(5u32),
assignments,
Expand Down

0 comments on commit 531dbb1

Please sign in to comment.