Skip to content

Commit

Permalink
fix(system-parachains/bridge-hub-kusama): fix benchmarking configurat…
Browse files Browse the repository at this point in the history
…ion for `LanesManager`
  • Loading branch information
pandres95 committed Nov 1, 2024
1 parent fc2b098 commit 267a863
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,27 +273,28 @@ where
{
use pallet_xcm_bridge_hub::{Bridge, BridgeId, BridgeState};
use sp_runtime::traits::Zero;
use sp_std::boxed::Box;
use xcm::VersionedInteriorLocation;

// insert bridge metadata
let lane_id = with;
let sibling_parachain = Location::new(1, [Parachain(sibling_para_id)]);
let universal_source = [GlobalConsensus(Westend), Parachain(sibling_para_id)].into();
let universal_destination = [GlobalConsensus(Rococo), Parachain(2075)].into();
let universal_source = [GlobalConsensus(Kusama), Parachain(sibling_para_id)].into();
let universal_destination = [GlobalConsensus(Polkadot), Parachain(2075)].into();
let bridge_id = BridgeId::new(&universal_source, &universal_destination);

// insert only bridge metadata, because the benchmarks create lanes
pallet_xcm_bridge_hub::Bridges::<R, XBHI>::insert(
bridge_id,
Bridge {
bridge_origin_relative_location: Box::new(sibling_parachain.clone().into()),
bridge_origin_universal_location: Box::new(VersionedInteriorLocation::from(
universal_source.clone(),
)),
bridge_destination_universal_location: Box::new(VersionedInteriorLocation::from(
universal_destination,
)),
bridge_origin_relative_location: sp_std::boxed::Box::new(
sibling_parachain.clone().into(),
),
bridge_origin_universal_location: sp_std::boxed::Box::new(
VersionedInteriorLocation::from(universal_source.clone()),
),
bridge_destination_universal_location: sp_std::boxed::Box::new(
VersionedInteriorLocation::from(universal_destination),
),
state: BridgeState::Opened,
bridge_owner_account: C::convert_location(&sibling_parachain).expect("valid AccountId"),
deposit: Zero::zero(),
Expand Down
10 changes: 8 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,8 @@ impl_runtime_apis! {
impl BridgeMessagesConfig<bridge_to_polkadot_config::WithBridgeHubPolkadotMessagesInstance> for Runtime {
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
let bench_lane_id = <Self as BridgeMessagesConfig<bridge_to_polkadot_config::WithBridgeHubPolkadotMessagesInstance>>::bench_lane_id();
let bridged_chain_id = bridge_to_polkadot_config::BridgeHubPolkadotChainId::get();
use bp_runtime::Chain;
let bridged_chain_id =<Self as pallet_bridge_messages::Config<bridge_to_polkadot_config::WithBridgeHubPolkadotMessagesInstance>>::BridgedChain::ID;
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(
relayer,
bp_relayers::RewardsAccountParams::new(
Expand All @@ -1267,11 +1268,16 @@ impl_runtime_apis! {
use cumulus_primitives_core::XcmpMessageSource;
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
let universal_source = bridge_to_polkadot_config::open_bridge_for_benchmarks::<
Runtime,
bridge_to_polkadot_config::XcmOverBridgeHubPolkadotInstance,
xcm_config::LocationToAccountId,
>(params.lane, 42);
prepare_message_proof_from_parachain::<
Runtime,
bridge_to_polkadot_config::BridgeGrandpaPolkadotInstance,
bridge_to_polkadot_config::WithBridgeHubPolkadotMessagesInstance,
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Kusama), Parachain(42)].into()))
>(params, generate_xcm_builder_bridge_message_sample(universal_source))
}

fn prepare_message_delivery_proof(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,27 +272,28 @@ where
{
use pallet_xcm_bridge_hub::{Bridge, BridgeId, BridgeState};
use sp_runtime::traits::Zero;
use sp_std::boxed::Box;
use xcm::VersionedInteriorLocation;

// insert bridge metadata
let lane_id = with;
let sibling_parachain = Location::new(1, [Parachain(sibling_para_id)]);
let universal_source = [GlobalConsensus(Westend), Parachain(sibling_para_id)].into();
let universal_destination = [GlobalConsensus(Rococo), Parachain(2075)].into();
let universal_source = [GlobalConsensus(Polkadot), Parachain(sibling_para_id)].into();
let universal_destination = [GlobalConsensus(Kusama), Parachain(2075)].into();
let bridge_id = BridgeId::new(&universal_source, &universal_destination);

// insert only bridge metadata, because the benchmarks create lanes
pallet_xcm_bridge_hub::Bridges::<R, XBHI>::insert(
bridge_id,
Bridge {
bridge_origin_relative_location: Box::new(sibling_parachain.clone().into()),
bridge_origin_universal_location: Box::new(VersionedInteriorLocation::from(
universal_source.clone(),
)),
bridge_destination_universal_location: Box::new(VersionedInteriorLocation::from(
universal_destination,
)),
bridge_origin_relative_location: sp_std::boxed::Box::new(
sibling_parachain.clone().into(),
),
bridge_origin_universal_location: sp_std::boxed::Box::new(
VersionedInteriorLocation::from(universal_source.clone()),
),
bridge_destination_universal_location: sp_std::boxed::Box::new(
VersionedInteriorLocation::from(universal_destination),
),
state: BridgeState::Opened,
bridge_owner_account: C::convert_location(&sibling_parachain).expect("valid AccountId"),
deposit: Zero::zero(),
Expand Down
10 changes: 8 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,8 @@ impl_runtime_apis! {
impl BridgeMessagesConfig<bridge_to_kusama_config::WithBridgeHubKusamaMessagesInstance> for Runtime {
fn is_relayer_rewarded(relayer: &Self::AccountId) -> bool {
let bench_lane_id = <Self as BridgeMessagesConfig<bridge_to_kusama_config::WithBridgeHubKusamaMessagesInstance>>::bench_lane_id();
let bridged_chain_id = bridge_to_kusama_config::BridgeHubKusamaChainId::get();
use bp_runtime::Chain;
let bridged_chain_id =<Self as pallet_bridge_messages::Config<bridge_to_kusama_config::WithBridgeHubKusamaMessagesInstance>>::BridgedChain::ID;
pallet_bridge_relayers::Pallet::<Runtime>::relayer_reward(
relayer,
bp_relayers::RewardsAccountParams::new(
Expand All @@ -1285,11 +1286,16 @@ impl_runtime_apis! {
use cumulus_primitives_core::XcmpMessageSource;
assert!(XcmpQueue::take_outbound_messages(usize::MAX).is_empty());
ParachainSystem::open_outbound_hrmp_channel_for_benchmarks_or_tests(42.into());
let universal_source = bridge_to_kusama_config::open_bridge_for_benchmarks::<
Runtime,
bridge_to_kusama_config::XcmOverBridgeHubKusamaInstance,
xcm_config::LocationToAccountId,
>(params.lane, 42);
prepare_message_proof_from_parachain::<
Runtime,
bridge_to_kusama_config::BridgeGrandpaKusamaInstance,
bridge_to_kusama_config::WithBridgeHubKusamaMessagesInstance,
>(params, generate_xcm_builder_bridge_message_sample([GlobalConsensus(Polkadot), Parachain(42)].into()))
>(params, generate_xcm_builder_bridge_message_sample(universal_source))
}

fn prepare_message_delivery_proof(
Expand Down

0 comments on commit 267a863

Please sign in to comment.