Skip to content

Commit

Permalink
benchmark fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden authored and claravanstaden committed Nov 30, 2023
1 parent 42537e8 commit f5ea599
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
17 changes: 16 additions & 1 deletion cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ impl pallet_xcm_bridge_hub_router::Config<ToWestendXcmRouterInstance> for Runtim

/// XCM router instance to BridgeHub with bridging capabilities for `Ethereum` global
/// consensus with dynamic fees and back-pressure.
pub type ToEthereumXcmRouterInstance = pallet_assets::Instance4;
pub type ToEthereumXcmRouterInstance = pallet_xcm_bridge_hub_router::Instance4;
impl pallet_xcm_bridge_hub_router::Config<ToEthereumXcmRouterInstance> for Runtime {
type WeightInfo = weights::pallet_xcm_bridge_hub_router::WeightInfo<Runtime>;

Expand Down Expand Up @@ -1030,6 +1030,7 @@ mod benches {
[pallet_collator_selection, CollatorSelection]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[pallet_xcm_bridge_hub_router, ToWestend]
[pallet_xcm_bridge_hub_router, ToEthereum]
// XCM
[pallet_xcm, PalletXcmExtrinsiscsBenchmark::<Runtime>]
// NOTE: Make sure you point to the individual modules below.
Expand Down Expand Up @@ -1369,6 +1370,20 @@ impl_runtime_apis! {
}
}

impl XcmBridgeHubRouterConfig<ToEthereumXcmRouterInstance> for Runtime {
fn make_congested() {
cumulus_pallet_xcmp_queue::bridging::suspend_channel_for_benchmarks::<Runtime>(
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
);
}
fn ensure_bridged_target_destination() -> MultiLocation {
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(
xcm_config::bridging::SiblingBridgeHubParaId::get().into()
);
xcm_config::bridging::to_ethereum::EthereumLocation::get()
}
}

use xcm::latest::prelude::*;
use xcm_config::{TokenLocation, MaxAssetsIntoHolding};
use pallet_xcm_benchmarks::asset_instance_from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,8 @@ impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
cumulus_primitives_core::AggregateMessageOrigin,
>;
type MessageProcessor =
pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ use frame_system::{
EnsureRoot,
};

#[cfg(not(feature = "runtime-benchmarks"))]
use bridge_hub_common::BridgeHubMessageRouter;
use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
Expand All @@ -76,7 +78,6 @@ use xcm::VersionedMultiLocation;
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};

use bp_runtime::HeaderId;
use bridge_hub_common::BridgeHubMessageRouter;

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,8 @@ impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_message_queue::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
cumulus_primitives_core::AggregateMessageOrigin,
>;
type MessageProcessor =
pallet_message_queue::mock_helpers::NoopMessageProcessor<AggregateMessageOrigin>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
Expand Down
9 changes: 9 additions & 0 deletions cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,12 @@ impl cumulus_pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
}

/// Simple conversion of `u32` into an `AssetId` for use in benchmarking.
pub struct XcmBenchmarkHelper;
#[cfg(feature = "runtime-benchmarks")]
impl pallet_assets::BenchmarkHelper<MultiLocation> for XcmBenchmarkHelper {
fn create_asset_id_parameter(id: u32) -> MultiLocation {
MultiLocation { parents: 1, interior: X1(Parachain(id)) }
}
}

0 comments on commit f5ea599

Please sign in to comment.