diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 53de2aa885fe..babb711723bd 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -71,8 +71,6 @@ use frame_system::{ }; use bp_runtime::HeaderId; -#[cfg(not(feature = "runtime-benchmarks"))] -use bridge_hub_common::BridgeHubMessageRouter; use bridge_hub_common::{ message_queue::{NarrowOriginToSibling, ParaIdToSibling}, AggregateMessageOrigin, @@ -102,17 +100,9 @@ use parachains_common::{ use polkadot_runtime_common::prod_or_fast; #[cfg(feature = "runtime-benchmarks")] -use crate::xcm_config::benchmark_helpers::DoNothingRouter; -#[cfg(feature = "runtime-benchmarks")] -use snowbridge_beacon_primitives::CompactExecutionHeader; -#[cfg(feature = "runtime-benchmarks")] -use snowbridge_core::RingBufferMap; -#[cfg(feature = "runtime-benchmarks")] -pub use snowbridge_ethereum_beacon_client::ExecutionHeaderBuffer; -#[cfg(feature = "runtime-benchmarks")] -use snowbridge_inbound_queue::BenchmarkHelper; -#[cfg(feature = "runtime-benchmarks")] -use sp_core::H256; +use benchmark_helpers::DoNothingRouter; +#[cfg(not(feature = "runtime-benchmarks"))] +use bridge_hub_common::BridgeHubMessageRouter; /// The address format for describing accounts. pub type Address = MultiAddress; @@ -521,9 +511,40 @@ parameter_types! { } #[cfg(feature = "runtime-benchmarks")] -impl BenchmarkHelper for Runtime { - fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) { - >::insert(block_hash, header); +pub mod benchmark_helpers { + use crate::{EthereumBeaconClient, Runtime, RuntimeOrigin}; + use codec::Encode; + use snowbridge_beacon_primitives::CompactExecutionHeader; + use snowbridge_inbound_queue::BenchmarkHelper; + use sp_core::H256; + use xcm::latest::{MultiAssets, MultiLocation, SendError, SendResult, SendXcm, Xcm, XcmHash}; + + impl BenchmarkHelper for Runtime { + fn initialize_storage(block_hash: H256, header: CompactExecutionHeader) { + EthereumBeaconClient::store_execution_header(block_hash, header, 0, H256::default()) + } + } + + pub struct DoNothingRouter; + impl SendXcm for DoNothingRouter { + type Ticket = Xcm<()>; + + fn validate( + _dest: &mut Option, + xcm: &mut Option>, + ) -> SendResult { + Ok((xcm.clone().unwrap(), MultiAssets::new())) + } + fn deliver(xcm: Xcm<()>) -> Result { + let hash = xcm.using_encoded(sp_io::hashing::blake2_256); + Ok(hash) + } + } + + impl snowbridge_system::BenchmarkHelper for () { + fn make_xcm_origin(location: MultiLocation) -> RuntimeOrigin { + RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location)) + } } } @@ -624,13 +645,6 @@ impl snowbridge_ethereum_beacon_client::Config for Runtime { type WeightInfo = weights::snowbridge_ethereum_beacon_client::WeightInfo; } -#[cfg(feature = "runtime-benchmarks")] -impl snowbridge_system::BenchmarkHelper for () { - fn make_xcm_origin(location: xcm::latest::MultiLocation) -> RuntimeOrigin { - RuntimeOrigin::from(pallet_xcm::Origin::Xcm(location)) - } -} - impl snowbridge_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type OutboundQueue = EthereumOutboundQueue; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index fc97a3ed89a6..e569b0f7f1a3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -492,22 +492,3 @@ impl, FeeHandler: HandleFee> FeeManager FeeHandler::handle_fee(fee, context, reason); } } - -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmark_helpers { - use crate::{MultiAssets, MultiLocation, SendError, SendResult, SendXcm, Xcm, XcmHash}; - - pub struct DoNothingRouter; - impl SendXcm for DoNothingRouter { - type Ticket = (); - fn validate( - _dest: &mut Option, - _msg: &mut Option>, - ) -> SendResult<()> { - Ok(((), MultiAssets::new())) - } - fn deliver(_: ()) -> Result { - Ok([0; 32]) - } - } -}