[testnet] Remove Wococo stuff from BridgeHubRococo/AssetHubRococo (#2300)

Rococo<>Wococo bridge is replaced by Rococo<Westend bridge, so this PR
removes unneeded code.

- [x] update bridges subtree after
https://github.com/paritytech/parity-bridges-common/pull/2692

---------

Co-authored-by: command-bot <>
Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
This commit is contained in:
Branislav Kontur
2023-11-15 16:40:07 +01:00
committed by GitHub
parent 824b782390
commit f4bb17cc86
92 changed files with 967 additions and 6394 deletions
@@ -16,9 +16,8 @@
use super::{
AccountId, AllPalletsWithSystem, Assets, Authorship, Balance, Balances, BaseDeliveryFee,
FeeAssetId, ForeignAssets, ForeignAssetsInstance, ParachainInfo, ParachainSystem, PolkadotXcm,
PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeFlavor, RuntimeOrigin,
ToRococoXcmRouter, ToWestendXcmRouter, ToWococoXcmRouter, TransactionByteFee,
TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
PoolAssets, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, ToWestendXcmRouter,
TransactionByteFee, TrustBackedAssetsInstance, WeightToFee, XcmpQueue,
};
use assets_common::{
local_and_foreign_assets::MatchesLocalAndForeignAssetsMultiLocation,
@@ -26,7 +25,7 @@ use assets_common::{
};
use frame_support::{
match_types, parameter_types,
traits::{ConstU32, Contains, Equals, Everything, Get, Nothing, PalletInfoAccess},
traits::{ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
@@ -61,8 +60,8 @@ use xcm_executor::{traits::WithOriginFilter, XcmExecutor};
use cumulus_primitives_core::ParaId;
parameter_types! {
pub storage Flavor: RuntimeFlavor = RuntimeFlavor::default();
pub const TokenLocation: MultiLocation = MultiLocation::parent();
pub const RelayNetwork: NetworkId = NetworkId::Rococo;
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub UniversalLocation: InteriorMultiLocation =
X2(GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into()));
@@ -79,22 +78,6 @@ parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}
/// Adapter for resolving `NetworkId` based on `pub storage Flavor: RuntimeFlavor`.
pub struct RelayNetwork;
impl Get<Option<NetworkId>> for RelayNetwork {
fn get() -> Option<NetworkId> {
Some(Self::get())
}
}
impl Get<NetworkId> for RelayNetwork {
fn get() -> NetworkId {
match Flavor::get() {
RuntimeFlavor::Rococo => NetworkId::Rococo,
RuntimeFlavor::Wococo => NetworkId::Wococo,
}
}
}
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
/// `Transact` in order to determine the dispatch Origin.
@@ -285,8 +268,7 @@ impl Contains<RuntimeCall> for SafeCallFilter {
if items.iter().all(|(k, _)| k.eq(&bridging::XcmBridgeHubRouterByteFee::key())) ||
items
.iter()
.all(|(k, _)| k.eq(&bridging::XcmBridgeHubRouterBaseFee::key())) ||
items.iter().all(|(k, _)| k.eq(&Flavor::key())) =>
.all(|(k, _)| k.eq(&bridging::XcmBridgeHubRouterBaseFee::key())) =>
return true,
_ => (),
};
@@ -475,12 +457,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_uniques::Call::set_collection_max_supply { .. } |
pallet_uniques::Call::set_price { .. } |
pallet_uniques::Call::buy_item { .. }
) | RuntimeCall::ToWococoXcmRouter(
pallet_xcm_bridge_hub_router::Call::report_bridge_status { .. }
) | RuntimeCall::ToWestendXcmRouter(
pallet_xcm_bridge_hub_router::Call::report_bridge_status { .. }
) | RuntimeCall::ToRococoXcmRouter(
pallet_xcm_bridge_hub_router::Call::report_bridge_status { .. }
)
)
}
@@ -572,11 +550,7 @@ impl xcm_executor::Config for XcmConfig {
// as reserve locations (we trust the Bridge Hub to relay the message that a reserve is being
// held). Asset Hub may _act_ as a reserve location for ROC and assets created
// under `pallet-assets`. Users must use teleport where allowed (e.g. ROC with the Relay Chain).
type IsReserve = (
bridging::to_wococo::IsTrustedBridgedReserveLocationForConcreteAsset,
bridging::to_westend::IsTrustedBridgedReserveLocationForConcreteAsset,
bridging::to_rococo::IsTrustedBridgedReserveLocationForConcreteAsset,
);
type IsReserve = (bridging::to_westend::IsTrustedBridgedReserveLocationForConcreteAsset,);
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
@@ -627,11 +601,7 @@ impl xcm_executor::Config for XcmConfig {
XcmFeeToAccount<Self::AssetTransactor, AccountId, TreasuryAccount>,
>;
type MessageExporter = ();
type UniversalAliases = (
bridging::to_wococo::UniversalAliases,
bridging::to_rococo::UniversalAliases,
bridging::to_westend::UniversalAliases,
);
type UniversalAliases = (bridging::to_westend::UniversalAliases,);
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
@@ -656,15 +626,9 @@ type LocalXcmRouter = (
/// queues.
pub type XcmRouter = WithUniqueTopic<(
LocalXcmRouter,
// Router which wraps and sends xcm to BridgeHub to be delivered to the Wococo
// GlobalConsensus
ToWococoXcmRouter,
// Router which wraps and sends xcm to BridgeHub to be delivered to the Westend
// GlobalConsensus
ToWestendXcmRouter,
// Router which wraps and sends xcm to BridgeHub to be delivered to the Rococo
// GlobalConsensus
ToRococoXcmRouter,
)>;
impl pallet_xcm::Config for Runtime {
@@ -731,7 +695,7 @@ impl<SelfParaId>
pallet_asset_conversion::BenchmarkHelper<MultiLocation, sp_std::boxed::Box<MultiLocation>>
for BenchmarkMultiLocationConverter<SelfParaId>
where
SelfParaId: Get<ParaId>,
SelfParaId: frame_support::traits::Get<ParaId>,
{
fn asset_id(asset_id: u32) -> MultiLocation {
MultiLocation {
@@ -754,7 +718,7 @@ pub mod bridging {
use assets_common::matching;
use sp_std::collections::btree_set::BTreeSet;
// common/shared parameters for Wococo/Rococo
// common/shared parameters
parameter_types! {
/// Base price of every byte of the Rococo -> Westend message. Can be adjusted via
/// governance `set_storage` call.
@@ -775,10 +739,7 @@ pub mod bridging {
/// governance `set_storage` call.
pub storage XcmBridgeHubRouterByteFee: Balance = TransactionByteFee::get();
pub SiblingBridgeHubParaId: u32 = match Flavor::get() {
RuntimeFlavor::Rococo => bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
RuntimeFlavor::Wococo => bp_bridge_hub_wococo::BRIDGE_HUB_WOCOCO_PARACHAIN_ID,
};
pub SiblingBridgeHubParaId: u32 = bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID;
pub SiblingBridgeHub: MultiLocation = MultiLocation::new(1, X1(Parachain(SiblingBridgeHubParaId::get())));
/// Router expects payment with this `AssetId`.
/// (`AssetId` has to be aligned with `BridgeTable`)
@@ -786,90 +747,12 @@ pub mod bridging {
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> =
sp_std::vec::Vec::new().into_iter()
.chain(to_wococo::BridgeTable::get())
.chain(to_westend::BridgeTable::get())
.chain(to_rococo::BridgeTable::get())
.collect();
}
pub type NetworkExportTable = xcm_builder::NetworkExportTable<BridgeTable>;
pub mod to_wococo {
use super::*;
parameter_types! {
pub SiblingBridgeHubWithBridgeHubWococoInstance: MultiLocation = MultiLocation::new(
1,
X2(
Parachain(SiblingBridgeHubParaId::get()),
PalletInstance(bp_bridge_hub_rococo::WITH_BRIDGE_ROCOCO_TO_WOCOCO_MESSAGES_PALLET_INDEX)
)
);
pub const WococoNetwork: NetworkId = NetworkId::Wococo;
pub AssetHubWococo: MultiLocation = MultiLocation::new(2, X2(GlobalConsensus(WococoNetwork::get()), Parachain(bp_asset_hub_wococo::ASSET_HUB_WOCOCO_PARACHAIN_ID)));
pub WocLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(WococoNetwork::get())));
pub WocFromAssetHubWococo: (MultiAssetFilter, MultiLocation) = (
Wild(AllOf { fun: WildFungible, id: Concrete(WocLocation::get()) }),
AssetHubWococo::get()
);
/// Set up exporters configuration.
/// `Option<MultiAsset>` represents static "base fee" which is used for total delivery fee calculation.
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
NetworkExportTableItem::new(
WococoNetwork::get(),
Some(sp_std::vec![
AssetHubWococo::get().interior.split_global().expect("invalid configuration for AssetHubWococo").1,
]),
SiblingBridgeHub::get(),
// base delivery fee to local `BridgeHub`
Some((
XcmBridgeHubRouterFeeAssetId::get(),
XcmBridgeHubRouterBaseFee::get(),
).into())
)
];
/// Universal aliases
pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter(
sp_std::vec![
(SiblingBridgeHubWithBridgeHubWococoInstance::get(), GlobalConsensus(WococoNetwork::get()))
]
);
}
impl Contains<(MultiLocation, Junction)> for UniversalAliases {
fn contains(alias: &(MultiLocation, Junction)) -> bool {
UniversalAliases::get().contains(alias)
}
}
/// Trusted reserve locations filter for `xcm_executor::Config::IsReserve`.
/// Locations from which the runtime accepts reserved assets.
pub type IsTrustedBridgedReserveLocationForConcreteAsset =
matching::IsTrustedBridgedReserveLocationForConcreteAsset<
UniversalLocation,
(
// allow receive WOC from AssetHubWococo
xcm_builder::Case<WocFromAssetHubWococo>,
// and nothing else
),
>;
impl Contains<RuntimeCall> for ToWococoXcmRouter {
fn contains(call: &RuntimeCall) -> bool {
matches!(
call,
RuntimeCall::ToWococoXcmRouter(
pallet_xcm_bridge_hub_router::Call::report_bridge_status { .. }
)
)
}
}
}
pub mod to_westend {
use super::*;
@@ -946,82 +829,6 @@ pub mod bridging {
}
}
pub mod to_rococo {
use super::*;
parameter_types! {
pub SiblingBridgeHubWithBridgeHubRococoInstance: MultiLocation = MultiLocation::new(
1,
X2(
Parachain(SiblingBridgeHubParaId::get()),
PalletInstance(bp_bridge_hub_wococo::WITH_BRIDGE_WOCOCO_TO_ROCOCO_MESSAGES_PALLET_INDEX)
)
);
pub const RococoNetwork: NetworkId = NetworkId::Rococo;
pub AssetHubRococo: MultiLocation = MultiLocation::new(2, X2(GlobalConsensus(RococoNetwork::get()), Parachain(bp_asset_hub_rococo::ASSET_HUB_ROCOCO_PARACHAIN_ID)));
pub RocLocation: MultiLocation = MultiLocation::new(2, X1(GlobalConsensus(RococoNetwork::get())));
pub RocFromAssetHubRococo: (MultiAssetFilter, MultiLocation) = (
Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) }),
AssetHubRococo::get()
);
/// Set up exporters configuration.
/// `Option<MultiAsset>` represents static "base fee" which is used for total delivery fee calculation.
pub BridgeTable: sp_std::vec::Vec<NetworkExportTableItem> = sp_std::vec![
NetworkExportTableItem::new(
RococoNetwork::get(),
Some(sp_std::vec![
AssetHubRococo::get().interior.split_global().expect("invalid configuration for AssetHubRococo").1,
]),
SiblingBridgeHub::get(),
// base delivery fee to local `BridgeHub`
Some((
XcmBridgeHubRouterFeeAssetId::get(),
XcmBridgeHubRouterBaseFee::get(),
).into())
)
];
/// Universal aliases
pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter(
sp_std::vec![
(SiblingBridgeHubWithBridgeHubRococoInstance::get(), GlobalConsensus(RococoNetwork::get()))
]
);
}
impl Contains<(MultiLocation, Junction)> for UniversalAliases {
fn contains(alias: &(MultiLocation, Junction)) -> bool {
UniversalAliases::get().contains(alias)
}
}
/// Reserve locations filter for `xcm_executor::Config::IsReserve`.
/// Locations from which the runtime accepts reserved assets.
pub type IsTrustedBridgedReserveLocationForConcreteAsset =
matching::IsTrustedBridgedReserveLocationForConcreteAsset<
UniversalLocation,
(
// allow receive ROC from AssetHubRococo
xcm_builder::Case<RocFromAssetHubRococo>,
// and nothing else
),
>;
impl Contains<RuntimeCall> for ToRococoXcmRouter {
fn contains(call: &RuntimeCall) -> bool {
matches!(
call,
RuntimeCall::ToRococoXcmRouter(
pallet_xcm_bridge_hub_router::Call::report_bridge_status { .. }
)
)
}
}
}
/// Benchmarks helper for bridging configuration.
#[cfg(feature = "runtime-benchmarks")]
pub struct BridgingBenchmarksHelper;