From f415d55bef4da2313d218b24e5370e4923f21189 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 5 Nov 2024 10:33:19 +0100 Subject: [PATCH] Cleanup primitives/consts --- Cargo.lock | 12 --------- .../chains/chain-asset-hub-rococo/Cargo.toml | 15 +---------- .../chains/chain-asset-hub-rococo/src/lib.rs | 26 ------------------- .../chains/chain-asset-hub-westend/Cargo.toml | 15 +---------- .../chains/chain-asset-hub-westend/src/lib.rs | 26 ------------------- .../chains/chain-bridge-hub-rococo/src/lib.rs | 6 +++++ .../chain-bridge-hub-westend/src/lib.rs | 6 +++++ .../xcm-bridge-hub-router/src/lib.rs | 11 +------- 8 files changed, 15 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6bf1e8b576d09..ac4ab6e9e948c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1862,22 +1862,10 @@ dependencies = [ [[package]] name = "bp-asset-hub-rococo" version = "0.4.0" -dependencies = [ - "bp-xcm-bridge-hub-router", - "frame-support", - "parity-scale-codec", - "scale-info", -] [[package]] name = "bp-asset-hub-westend" version = "0.3.0" -dependencies = [ - "bp-xcm-bridge-hub-router", - "frame-support", - "parity-scale-codec", - "scale-info", -] [[package]] name = "bp-beefy" diff --git a/bridges/chains/chain-asset-hub-rococo/Cargo.toml b/bridges/chains/chain-asset-hub-rococo/Cargo.toml index 363a869048aae..7a83bba874819 100644 --- a/bridges/chains/chain-asset-hub-rococo/Cargo.toml +++ b/bridges/chains/chain-asset-hub-rococo/Cargo.toml @@ -14,20 +14,7 @@ exclude-from-umbrella = true workspace = true [dependencies] -codec = { workspace = true } -scale-info = { features = ["derive"], workspace = true } - -# Substrate Dependencies -frame-support = { workspace = true } - -# Bridge Dependencies -bp-xcm-bridge-hub-router = { workspace = true } [features] default = ["std"] -std = [ - "bp-xcm-bridge-hub-router/std", - "codec/std", - "frame-support/std", - "scale-info/std", -] +std = [] diff --git a/bridges/chains/chain-asset-hub-rococo/src/lib.rs b/bridges/chains/chain-asset-hub-rococo/src/lib.rs index de2e9ae856d1f..3504be9bb0f8d 100644 --- a/bridges/chains/chain-asset-hub-rococo/src/lib.rs +++ b/bridges/chains/chain-asset-hub-rococo/src/lib.rs @@ -18,31 +18,5 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode}; -use scale_info::TypeInfo; - -pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; - -/// `AssetHubRococo` Runtime `Call` enum. -/// -/// The enum represents a subset of possible `Call`s we can send to `AssetHubRococo` chain. -/// Ideally this code would be auto-generated from metadata, because we want to -/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s. -/// -/// All entries here (like pretty much in the entire file) must be kept in sync with -/// `AssetHubRococo` `construct_runtime`, so that we maintain SCALE-compatibility. -#[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum Call { - /// `ToWestendXcmRouter` bridge pallet. - #[codec(index = 45)] - ToWestendXcmRouter(XcmBridgeHubRouterCall), -} - -frame_support::parameter_types! { - /// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`. - pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144); -} - /// Identifier of AssetHubRococo in the Rococo relay chain. pub const ASSET_HUB_ROCOCO_PARACHAIN_ID: u32 = 1000; diff --git a/bridges/chains/chain-asset-hub-westend/Cargo.toml b/bridges/chains/chain-asset-hub-westend/Cargo.toml index 430d9b6116cfc..ad8d2778a4bcb 100644 --- a/bridges/chains/chain-asset-hub-westend/Cargo.toml +++ b/bridges/chains/chain-asset-hub-westend/Cargo.toml @@ -14,20 +14,7 @@ exclude-from-umbrella = true workspace = true [dependencies] -codec = { workspace = true } -scale-info = { features = ["derive"], workspace = true } - -# Substrate Dependencies -frame-support = { workspace = true } - -# Bridge Dependencies -bp-xcm-bridge-hub-router = { workspace = true } [features] default = ["std"] -std = [ - "bp-xcm-bridge-hub-router/std", - "codec/std", - "frame-support/std", - "scale-info/std", -] +std = [] diff --git a/bridges/chains/chain-asset-hub-westend/src/lib.rs b/bridges/chains/chain-asset-hub-westend/src/lib.rs index 9de1c88098942..c21bdff45934a 100644 --- a/bridges/chains/chain-asset-hub-westend/src/lib.rs +++ b/bridges/chains/chain-asset-hub-westend/src/lib.rs @@ -18,31 +18,5 @@ #![cfg_attr(not(feature = "std"), no_std)] -use codec::{Decode, Encode}; -use scale_info::TypeInfo; - -pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; - -/// `AssetHubWestend` Runtime `Call` enum. -/// -/// The enum represents a subset of possible `Call`s we can send to `AssetHubWestend` chain. -/// Ideally this code would be auto-generated from metadata, because we want to -/// avoid depending directly on the ENTIRE runtime just to get the encoding of `Dispatchable`s. -/// -/// All entries here (like pretty much in the entire file) must be kept in sync with -/// `AssetHubWestend` `construct_runtime`, so that we maintain SCALE-compatibility. -#[allow(clippy::large_enum_variant)] -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub enum Call { - /// `ToRococoXcmRouter` bridge pallet. - #[codec(index = 34)] - ToRococoXcmRouter(XcmBridgeHubRouterCall), -} - -frame_support::parameter_types! { - /// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`. - pub const XcmBridgeHubRouterTransactCallMaxWeight: frame_support::weights::Weight = frame_support::weights::Weight::from_parts(200_000_000, 6144); -} - /// Identifier of AssetHubWestend in the Westend relay chain. pub const ASSET_HUB_WESTEND_PARACHAIN_ID: u32 = 1000; diff --git a/bridges/chains/chain-bridge-hub-rococo/src/lib.rs b/bridges/chains/chain-bridge-hub-rococo/src/lib.rs index fda6a5f0b722e..6fed418752185 100644 --- a/bridges/chains/chain-bridge-hub-rococo/src/lib.rs +++ b/bridges/chains/chain-bridge-hub-rococo/src/lib.rs @@ -123,3 +123,9 @@ pub enum RuntimeCall { #[codec(index = 52)] XcmOverBridgeHubWestend(bp_xcm_bridge_hub::XcmBridgeHubCall), } + +// TODO: remove when xcm:v5 +frame_support::parameter_types! { + /// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`. + pub const XcmBridgeHubRouterTransactCallMaxWeight: Weight = Weight::from_parts(1_000_000_000, 1024*8); +} \ No newline at end of file diff --git a/bridges/chains/chain-bridge-hub-westend/src/lib.rs b/bridges/chains/chain-bridge-hub-westend/src/lib.rs index e941b58402382..39899daa7610d 100644 --- a/bridges/chains/chain-bridge-hub-westend/src/lib.rs +++ b/bridges/chains/chain-bridge-hub-westend/src/lib.rs @@ -112,3 +112,9 @@ pub enum RuntimeCall { #[codec(index = 45)] XcmOverBridgeHubRococo(bp_xcm_bridge_hub::XcmBridgeHubCall), } + +// TODO: remove when xcm:v5 +frame_support::parameter_types! { + /// Some sane weight to execute `xcm::Transact(pallet-xcm-bridge-hub-router::Call::report_bridge_status)`. + pub const XcmBridgeHubRouterTransactCallMaxWeight: Weight = Weight::from_parts(1_000_000_000, 1024*8); +} \ No newline at end of file diff --git a/bridges/primitives/xcm-bridge-hub-router/src/lib.rs b/bridges/primitives/xcm-bridge-hub-router/src/lib.rs index a87bec8e227ee..ef58c6338f365 100644 --- a/bridges/primitives/xcm-bridge-hub-router/src/lib.rs +++ b/bridges/primitives/xcm-bridge-hub-router/src/lib.rs @@ -20,7 +20,7 @@ use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; use scale_info::TypeInfo; -use sp_core::{H256, sp_std::fmt::Debug}; +use sp_core::sp_std::fmt::Debug; use sp_runtime::{FixedU128, RuntimeDebug}; use xcm::latest::prelude::{Location, NetworkId, InteriorLocation}; @@ -56,12 +56,3 @@ impl ResolveBridgeId for () { None } } - -/// A minimized version of `pallet-xcm-bridge-hub-router::Call` that can be used without a runtime. -#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -#[allow(non_camel_case_types)] -pub enum XcmBridgeHubRouterCall { - /// `pallet-xcm-bridge-hub-router::Call::report_bridge_status` - #[codec(index = 0)] - report_bridge_status { bridge_id: H256, is_congested: bool }, -}