From 853d17dc5392b4e6749d1cbb815b15263993090c Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 19 Mar 2024 16:47:18 +0100 Subject: [PATCH] Move `CreateAssetDeposit` around --- Cargo.lock | 2 ++ .../asset-hub-kusama/primitives/Cargo.toml | 4 ++++ .../asset-hub-kusama/primitives/src/lib.rs | 5 +++++ .../asset-hubs/asset-hub-kusama/src/lib.rs | 8 ++++++++ .../asset-hub-kusama/tests/snowbridge.rs | 19 +++---------------- .../asset-hub-polkadot/primitives/Cargo.toml | 4 ++++ .../asset-hub-polkadot/primitives/src/lib.rs | 5 +++++ .../asset-hubs/asset-hub-polkadot/src/lib.rs | 8 ++++++++ .../asset-hub-polkadot/tests/snowbridge.rs | 19 +++---------------- .../bridge-hub-kusama/primitives/src/lib.rs | 3 --- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 6 ++---- .../bridge-hub-polkadot/primitives/src/lib.rs | 3 --- .../bridge-hub-polkadot/src/lib.rs | 6 ++---- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f12a66e2f3..40acd6e470 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1227,6 +1227,7 @@ dependencies = [ "scale-info", "sp-std", "staging-xcm", + "system-parachains-constants", ] [[package]] @@ -1239,6 +1240,7 @@ dependencies = [ "scale-info", "sp-std", "staging-xcm", + "system-parachains-constants", ] [[package]] diff --git a/system-parachains/asset-hubs/asset-hub-kusama/primitives/Cargo.toml b/system-parachains/asset-hubs/asset-hub-kusama/primitives/Cargo.toml index 102c205335..81aa14b93b 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/primitives/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-kusama/primitives/Cargo.toml @@ -11,6 +11,9 @@ license.workspace = true codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } +# Local +system-parachains-constants = { path = "../../../constants", default-features = false } + # Bridge Dependencies bp-xcm-bridge-hub-router = { default-features = false , version = "0.7.0" } @@ -29,5 +32,6 @@ std = [ "frame-support/std", "scale-info/std", "sp-std/std", + "system-parachains-constants/std", "xcm/std" ] diff --git a/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs index cce3b111bf..3112b297dc 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/primitives/src/lib.rs @@ -24,6 +24,8 @@ use xcm::prelude::*; pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; +use system_parachains_constants::kusama::currency::UNITS; + /// `AssetHubKusama` Runtime `Call` enum. /// /// The enum represents a subset of possible `Call`s we can send to `AssetHubKusama` chain. @@ -48,6 +50,9 @@ frame_support::parameter_types! { pub CongestedMessage: Xcm<()> = build_congestion_message(true).into(); /// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested. pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into(); + + /// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub. + pub const CreateForeignAssetDeposit: u128 = UNITS / 10; } fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec> { diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index 8229748360..8070b827bf 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -1764,4 +1764,12 @@ mod tests { let parachain_tbf = TransactionByteFee::get(); assert_eq!(relay_tbf / 10, parachain_tbf); } + + #[test] + fn create_foreign_asset_deposit_is_equal_to_asset_hub_foreign_asset_pallet_deposit() { + assert_eq!( + bp_asset_hub_kusama::CreateForeignAssetDeposit::get(), + ForeignAssetsAssetDeposit::get() + ); + } } diff --git a/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs b/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs index 4d37f99f74..0d8e946e83 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs @@ -15,28 +15,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -use asset_hub_kusama_runtime::{ - xcm_config::bridging::{ - to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, - SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, - }, - ForeignAssetsAssetDeposit, +use asset_hub_kusama_runtime::xcm_config::bridging::{ + to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, + SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, }; use sp_core::H160; use sp_std::prelude::*; use xcm::prelude::*; use xcm_builder::{ExporterFor, NetworkExportTable}; -/// Tests that the EthereumInboundQueue CreateAssetDeposit on BridgeHub is larger than the -/// ForeignAssets AssetDeposit config on AssetHub. -#[test] -fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit() { - assert!( - bp_bridge_hub_kusama::snowbridge::CreateAssetDeposit::get() >= - ForeignAssetsAssetDeposit::get() - ); -} - #[test] fn network_export_table_works() { sp_io::TestExternalities::default().execute_with(|| { diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/primitives/Cargo.toml b/system-parachains/asset-hubs/asset-hub-polkadot/primitives/Cargo.toml index 8fd8267b69..a91d4846d8 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/primitives/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-polkadot/primitives/Cargo.toml @@ -11,6 +11,9 @@ license.workspace = true codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive", "max-encoded-len"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } +# Local +system-parachains-constants = { path = "../../../constants", default-features = false } + # Bridge Dependencies bp-xcm-bridge-hub-router = { default-features = false , version = "0.7.0" } @@ -29,5 +32,6 @@ std = [ "frame-support/std", "scale-info/std", "sp-std/std", + "system-parachains-constants/std", "xcm/std" ] diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs index 023454b710..1573499291 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/primitives/src/lib.rs @@ -24,6 +24,8 @@ use xcm::prelude::*; pub use bp_xcm_bridge_hub_router::XcmBridgeHubRouterCall; +use system_parachains_constants::polkadot::currency::UNITS; + /// `AssetHubPolkadot` Runtime `Call` enum. /// /// The enum represents a subset of possible `Call`s we can send to `AssetHubPolkadot` chain. @@ -48,6 +50,9 @@ frame_support::parameter_types! { pub CongestedMessage: Xcm<()> = build_congestion_message(true).into(); /// Message that is sent to the sibling Kusama Asset Hub when the with-Polkadot bridge becomes uncongested. pub UncongestedMessage: Xcm<()> = build_congestion_message(false).into(); + + /// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub. + pub const CreateForeignAssetDeposit: u128 = 10 * UNITS; } fn build_congestion_message(is_congested: bool) -> sp_std::vec::Vec> { diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index 39399b2100..9b4ef06108 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -1721,4 +1721,12 @@ mod tests { let parachain_tbf = TransactionByteFee::get(); assert_eq!(relay_tbf / 10, parachain_tbf); } + + #[test] + fn create_foreign_asset_deposit_is_equal_to_asset_hub_foreign_asset_pallet_deposit() { + assert_eq!( + bp_asset_hub_polkadot::CreateForeignAssetDeposit::get(), + ForeignAssetsAssetDeposit::get() + ); + } } diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs b/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs index a4927cac42..77f7054726 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs @@ -15,28 +15,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -use asset_hub_polkadot_runtime::{ - xcm_config::bridging::{ - to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, - SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, - }, - ForeignAssetsAssetDeposit, +use asset_hub_polkadot_runtime::xcm_config::bridging::{ + to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, + SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, }; use sp_core::H160; use sp_std::prelude::*; use xcm::prelude::*; use xcm_builder::{ExporterFor, NetworkExportTable}; -/// Tests that the EthereumInboundQueue CreateAssetDeposit on BridgeHub is larger than the -/// ForeignAssets AssetDeposit config on AssetHub. -#[test] -fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit() { - assert!( - bp_bridge_hub_polkadot::snowbridge::CreateAssetDeposit::get() >= - ForeignAssetsAssetDeposit::get() - ); -} - #[test] fn network_export_table_works() { sp_io::TestExternalities::default().execute_with(|| { diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs index 5f0ca1f9b6..f24fbaae31 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/src/lib.rs @@ -161,7 +161,6 @@ fn convert_from_udot_to_uksm(price_in_udot: Balance) -> Balance { pub mod snowbridge { use crate::Balance; use frame_support::parameter_types; - use kusama_runtime_constants::currency::UNITS; use snowbridge_core::{PricingParameters, Rewards, U256}; use sp_runtime::FixedU128; use xcm::latest::NetworkId; @@ -169,8 +168,6 @@ pub mod snowbridge { parameter_types! { /// Should match the `ForeignAssets::create` index on Asset Hub. pub const CreateAssetCall: [u8;2] = [53, 0]; - /// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub. - pub const CreateAssetDeposit: u128 = UNITS / 10; /// The pallet index of the Ethereum inbound queue pallet in the Bridge Hub runtime. pub const InboundQueuePalletInstance: u8 = 80; /// Default pricing parameters used to calculate bridging fees. Initialized to unit values, diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index a7dc80393a..1c04ad1d62 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -27,9 +27,7 @@ pub mod bridge_to_polkadot_config; mod weights; pub mod xcm_config; -use bp_bridge_hub_kusama::snowbridge::{ - CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, Parameters, -}; +use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, InboundQueuePalletInstance, Parameters}; use bridge_hub_common::message_queue::{ AggregateMessageOrigin, NarrowOriginToSibling, ParaIdToSibling, }; @@ -564,7 +562,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { type Helper = Runtime; type MessageConverter = MessageToXcm< CreateAssetCall, - CreateAssetDeposit, + bp_asset_hub_kusama::CreateForeignAssetDeposit, InboundQueuePalletInstance, AccountId, Balance, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs index 08d13349d4..62675bb0b1 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/src/lib.rs @@ -152,7 +152,6 @@ fn convert_from_uksm_to_udot(price_in_uksm: Balance) -> Balance { pub mod snowbridge { use crate::Balance; use frame_support::parameter_types; - use polkadot_runtime_constants::currency::UNITS; use snowbridge_core::{PricingParameters, Rewards, U256}; use sp_runtime::FixedU128; use xcm::latest::NetworkId; @@ -160,8 +159,6 @@ pub mod snowbridge { parameter_types! { /// Should match the `ForeignAssets::create` index on Asset Hub. pub const CreateAssetCall: [u8;2] = [53, 0]; - /// Should match the `AssetDeposit` of the `ForeignAssets` pallet on Asset Hub. - pub const CreateAssetDeposit: u128 = 10 * UNITS; /// The pallet index of the Ethereum inbound queue pallet in the Bridge Hub runtime. pub const InboundQueuePalletInstance: u8 = 80; /// Default pricing parameters used to calculate bridging fees. Initialized to unit values, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index f8c36c91f7..f4f3df924c 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -27,9 +27,7 @@ pub mod bridge_to_kusama_config; mod weights; pub mod xcm_config; -use bp_bridge_hub_kusama::snowbridge::{ - CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, Parameters, -}; +use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, InboundQueuePalletInstance, Parameters}; use bridge_hub_common::message_queue::{ AggregateMessageOrigin, NarrowOriginToSibling, ParaIdToSibling, }; @@ -565,7 +563,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { type Helper = Runtime; type MessageConverter = MessageToXcm< CreateAssetCall, - CreateAssetDeposit, + bp_asset_hub_polkadot::CreateForeignAssetDeposit, InboundQueuePalletInstance, AccountId, Balance,