From fb7a5d4015032108a400bb4df7ff55e23f6bfec8 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 19 Mar 2024 15:46:28 +0100 Subject: [PATCH 1/4] Constants moving around --- Cargo.lock | 5 ++--- .../tests/bridges/bridge-hub-kusama/Cargo.toml | 1 - .../bridge-hub-kusama/src/tests/snowbridge.rs | 5 +++-- .../tests/bridges/bridge-hub-polkadot/Cargo.toml | 1 - .../bridge-hub-polkadot/src/tests/snowbridge.rs | 5 +++-- .../asset-hubs/asset-hub-kusama/src/lib.rs | 8 ++++++-- .../asset-hubs/asset-hub-kusama/src/xcm_config.rs | 5 +++-- .../asset-hubs/asset-hub-kusama/tests/snowbridge.rs | 3 +-- .../asset-hubs/asset-hub-polkadot/src/lib.rs | 8 ++++++-- .../asset-hubs/asset-hub-polkadot/src/xcm_config.rs | 5 +++-- .../asset-hub-polkadot/tests/snowbridge.rs | 3 +-- .../bridge-hub-kusama/primitives/Cargo.toml | 5 ++++- .../bridge-hub-kusama/primitives/src/lib.rs | 6 ++++++ .../src/bridge_to_ethereum_config.rs | 2 +- .../bridge-hubs/bridge-hub-kusama/src/xcm_config.rs | 3 ++- .../bridge-hub-polkadot/primitives/Cargo.toml | 5 ++++- .../bridge-hub-polkadot/primitives/src/lib.rs | 6 ++++++ .../src/bridge_to_ethereum_config.rs | 2 +- .../bridge-hub-polkadot/src/xcm_config.rs | 3 ++- .../bridge-hub-polkadot/tests/snowbridge.rs | 2 +- system-parachains/constants/Cargo.toml | 2 -- system-parachains/constants/src/kusama.rs | 13 ------------- system-parachains/constants/src/polkadot.rs | 13 ------------- 23 files changed, 55 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17b28a3a00..f12a66e2f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1271,6 +1271,7 @@ dependencies = [ "sp-api", "sp-runtime", "sp-std", + "staging-xcm", "system-parachains-constants", ] @@ -1288,6 +1289,7 @@ dependencies = [ "sp-api", "sp-runtime", "sp-std", + "staging-xcm", "system-parachains-constants", ] @@ -1536,7 +1538,6 @@ dependencies = [ "sp-runtime", "staging-xcm", "staging-xcm-executor", - "system-parachains-constants", ] [[package]] @@ -1687,7 +1688,6 @@ dependencies = [ "sp-runtime", "staging-xcm", "staging-xcm-executor", - "system-parachains-constants", ] [[package]] @@ -14625,7 +14625,6 @@ dependencies = [ "polkadot-runtime-constants", "smallvec", "sp-runtime", - "staging-xcm", ] [[package]] diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/Cargo.toml b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/Cargo.toml index 0fa2d98188..79ffee0a22 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/Cargo.toml +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/Cargo.toml @@ -42,7 +42,6 @@ asset-hub-kusama-runtime = { path = "../../../../../system-parachains/asset-hubs integration-tests-helpers = { path = "../../../helpers" } kusama-polkadot-system-emulated-network = { path = "../../../networks/kusama-polkadot-system" } kusama-system-emulated-network = { path = "../../../networks/kusama-system" } -system-parachains-constants = { path = "../../../../../system-parachains/constants" } # Snowbridge snowbridge-beacon-primitives = { version = "0.1.0" } diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs index a48b3fcb06..e83d602a9b 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs @@ -13,7 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. use crate::*; -use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::BridgeHubEthereumBaseFee; +use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::{ + BridgeHubEthereumBaseFee, EthereumNetwork, +}; use bp_bridge_hub_kusama::snowbridge::{ CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, }; @@ -42,7 +44,6 @@ use snowbridge_router_primitives::inbound::{ }; use sp_core::{H160, H256}; use sp_runtime::{DispatchError::Token, TokenError::FundsUnavailable}; -use system_parachains_constants::kusama::snowbridge::EthereumNetwork; const INITIAL_FUND: u128 = 5_000_000_000 * KUSAMA_ED; const CHAIN_ID: u64 = 1; diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/Cargo.toml b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/Cargo.toml index dc2889c6f3..4e07741e5c 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/Cargo.toml +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/Cargo.toml @@ -42,7 +42,6 @@ asset-hub-polkadot-runtime = { path = "../../../../../system-parachains/asset-hu integration-tests-helpers = { path = "../../../helpers" } kusama-polkadot-system-emulated-network = { path = "../../../networks/kusama-polkadot-system" } polkadot-system-emulated-network = { path = "../../../networks/polkadot-system" } -system-parachains-constants = { path = "../../../../../system-parachains/constants" } # Snowbridge snowbridge-beacon-primitives = { version = "0.1.0" } diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index aa74fa7c4a..44e5496598 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -13,7 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. use crate::*; -use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::BridgeHubEthereumBaseFee; +use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::{ + BridgeHubEthereumBaseFee, EthereumNetwork, +}; use bp_bridge_hub_polkadot::snowbridge::{ CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, }; @@ -42,7 +44,6 @@ use snowbridge_router_primitives::inbound::{ }; use sp_core::{H160, H256}; use sp_runtime::{DispatchError::Token, TokenError::FundsUnavailable}; -use system_parachains_constants::polkadot::snowbridge::EthereumNetwork; const INITIAL_FUND: u128 = 5_000_000_000 * POLKADOT_ED; const CHAIN_ID: u64 = 1; 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 b6b052c43b..8229748360 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -76,7 +76,7 @@ use parachains_common::{ use sp_runtime::RuntimeDebug; pub use system_parachains_constants::SLOT_DURATION; use system_parachains_constants::{ - kusama::{consensus::*, currency::*, fee::WeightToFee, snowbridge::EthereumNetwork}, + kusama::{consensus::*, currency::*, fee::WeightToFee}, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, }; use xcm::latest::prelude::{AssetId, BodyId}; @@ -398,7 +398,11 @@ impl pallet_assets::Config for Runtime { type CreateOrigin = ForeignCreators< ( FromSiblingParachain, xcm::v3::Location>, - FromNetwork, + FromNetwork< + xcm_config::UniversalLocation, + xcm_config::bridging::to_ethereum::EthereumNetwork, + xcm::v3::Location, + >, ), ForeignCreatorsSovereignAccountOf, AccountId, diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs index b101d1ae02..6addf4c657 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs @@ -24,7 +24,6 @@ use assets_common::{ matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset}, TrustBackedAssetsAsLocation, }; -use bp_bridge_hub_kusama::snowbridge::InboundQueuePalletInstance; use frame_support::{ parameter_types, traits::{ @@ -44,7 +43,7 @@ use parachains_common::{ use polkadot_parachain_primitives::primitives::Sibling; use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; -use system_parachains_constants::{kusama::snowbridge::EthereumNetwork, TREASURY_PALLET_ID}; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -801,6 +800,8 @@ pub mod bridging { pub mod to_ethereum { use super::*; + pub use bp_bridge_hub_kusama::snowbridge::EthereumNetwork; + use bp_bridge_hub_kusama::snowbridge::InboundQueuePalletInstance; parameter_types! { /// User fee for ERC20 token transfer back to Ethereum. 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 4571d1bef8..0d8e946e83 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs @@ -16,12 +16,11 @@ // limitations under the License. use asset_hub_kusama_runtime::xcm_config::bridging::{ - to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable}, + to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, }; use sp_core::H160; use sp_std::prelude::*; -use system_parachains_constants::kusama::snowbridge::EthereumNetwork; use xcm::prelude::*; use xcm_builder::{ExporterFor, NetworkExportTable}; 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 f59c55282d..39399b2100 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -113,7 +113,7 @@ use parachains_common::{ use sp_runtime::RuntimeDebug; pub use system_parachains_constants::SLOT_DURATION; use system_parachains_constants::{ - polkadot::{consensus::*, currency::*, fee::WeightToFee, snowbridge::EthereumNetwork}, + polkadot::{consensus::*, currency::*, fee::WeightToFee}, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, }; use xcm::latest::prelude::{AssetId, BodyId}; @@ -328,7 +328,11 @@ impl pallet_assets::Config for Runtime { type CreateOrigin = ForeignCreators< ( FromSiblingParachain, xcm::v3::Location>, - FromNetwork, + FromNetwork< + xcm_config::UniversalLocation, + xcm_config::bridging::to_ethereum::EthereumNetwork, + xcm::v3::Location, + >, ), ForeignCreatorsSovereignAccountOf, AccountId, diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs index 07ea679c87..b23f5d410c 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs @@ -24,7 +24,6 @@ use assets_common::{ matching::{FromNetwork, FromSiblingParachain, IsForeignConcreteAsset}, TrustBackedAssetsAsLocation, }; -use bp_bridge_hub_polkadot::snowbridge::InboundQueuePalletInstance; use frame_support::{ parameter_types, traits::{ @@ -45,7 +44,7 @@ use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_constants::system_parachain; use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; -use system_parachains_constants::{polkadot::snowbridge::EthereumNetwork, TREASURY_PALLET_ID}; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, @@ -795,6 +794,8 @@ pub mod bridging { pub mod to_ethereum { use super::*; + pub use bp_bridge_hub_polkadot::snowbridge::EthereumNetwork; + use bp_bridge_hub_polkadot::snowbridge::InboundQueuePalletInstance; parameter_types! { /// User fee for ERC20 token transfer back to Ethereum. 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 56bf6b2b66..77f7054726 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs @@ -16,12 +16,11 @@ // limitations under the License. use asset_hub_polkadot_runtime::xcm_config::bridging::{ - to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable}, + to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, }; use sp_core::H160; use sp_std::prelude::*; -use system_parachains_constants::polkadot::snowbridge::EthereumNetwork; use xcm::prelude::*; use xcm_builder::{ExporterFor, NetworkExportTable}; diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml index cceec60b14..fbef882772 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/primitives/Cargo.toml @@ -18,6 +18,7 @@ system-parachains-constants = { path = "../../../constants", default-features = bp-bridge-hub-cumulus = { default-features = false , version = "0.8.0" } bp-runtime = { default-features = false , version = "0.8.0" } bp-messages = { default-features = false , version = "0.8.0" } +snowbridge-core = { default-features = false , version = "0.1.0" } # Substrate Based Dependencies frame-support = { default-features = false, version = "29.0.0" } @@ -25,7 +26,8 @@ sp-api = { default-features = false, version = "27.0.0" } sp-runtime = { default-features = false, version = "32.0.0" } sp-std = { default-features = false , version = "14.0.0" } -snowbridge-core = { default-features = false , version = "0.1.0" } +# Polkadot +xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" } [features] default = [ "std" ] @@ -41,4 +43,5 @@ std = [ "sp-runtime/std", "sp-std/std", "system-parachains-constants/std", + "xcm/std", ] 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 3575dc860f..5f0ca1f9b6 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 @@ -164,6 +164,7 @@ pub mod snowbridge { use kusama_runtime_constants::currency::UNITS; use snowbridge_core::{PricingParameters, Rewards, U256}; use sp_runtime::FixedU128; + use xcm::latest::NetworkId; parameter_types! { /// Should match the `ForeignAssets::create` index on Asset Hub. @@ -189,6 +190,11 @@ pub mod snowbridge { remote: U256::one(), } }; + /// Network and location for the Ethereum chain. On Kusama, the Ethereum chain bridged + /// to is the Ethereum Main network, with chain ID 1. + /// + /// + pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 1 }; } } diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs index 1b883feed3..dc940f797c 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/bridge_to_ethereum_config.rs @@ -15,8 +15,8 @@ // along with Cumulus. If not, see . use crate::{xcm_config::UniversalLocation, Runtime}; +pub use bp_bridge_hub_kusama::snowbridge::EthereumNetwork; use snowbridge_router_primitives::outbound::EthereumBlobExporter; -use system_parachains_constants::kusama::snowbridge::EthereumNetwork; /// Exports message to the Ethereum Gateway contract. pub type SnowbridgeExporter = EthereumBlobExporter< diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs index aa4db73fbf..56588e8320 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs @@ -15,6 +15,7 @@ // along with Cumulus. If not, see . use super::{ + bridge_to_ethereum_config::EthereumNetwork, bridge_to_polkadot_config::{ DeliveryRewardInBalance, RequiredStakeForStakeAndSlash, ToBridgeHubPolkadotHaulBlobExporter, }, @@ -39,7 +40,7 @@ use polkadot_parachain_primitives::primitives::Sibling; use snowbridge_runtime_common::XcmExportFeeToSibling; use sp_runtime::traits::AccountIdConversion; use sp_std::marker::PhantomData; -use system_parachains_constants::{kusama::snowbridge::EthereumNetwork, TREASURY_PALLET_ID}; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml index c532610ab3..6787337771 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/primitives/Cargo.toml @@ -18,6 +18,7 @@ system-parachains-constants = { path = "../../../constants", default-features = bp-bridge-hub-cumulus = { default-features = false , version = "0.8.0" } bp-runtime = { default-features = false , version = "0.8.0" } bp-messages = { default-features = false , version = "0.8.0" } +snowbridge-core = { default-features = false , version = "0.1.0" } # Substrate Based Dependencies frame-support = { default-features = false, version = "29.0.0" } @@ -25,7 +26,8 @@ sp-api = { default-features = false, version = "27.0.0" } sp-runtime = { default-features = false, version = "32.0.0" } sp-std = { default-features = false , version = "14.0.0" } -snowbridge-core = { default-features = false , version = "0.1.0" } +# Polkadot +xcm = { package = "staging-xcm", default-features = false, version = "8.0.1" } [features] default = [ "std" ] @@ -40,4 +42,5 @@ std = [ "sp-runtime/std", "sp-std/std", "system-parachains-constants/std", + "xcm/std", ] 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 dac465843f..08d13349d4 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 @@ -155,6 +155,7 @@ pub mod snowbridge { use polkadot_runtime_constants::currency::UNITS; use snowbridge_core::{PricingParameters, Rewards, U256}; use sp_runtime::FixedU128; + use xcm::latest::NetworkId; parameter_types! { /// Should match the `ForeignAssets::create` index on Asset Hub. @@ -180,6 +181,11 @@ pub mod snowbridge { remote: U256::one(), } }; + /// Network and location for the Ethereum chain. On Polkadot, the Ethereum chain bridged + /// to is the Ethereum Main network, with chain ID 1. + /// + /// + pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 1 }; } } diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_ethereum_config.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_ethereum_config.rs index c8108f189f..5803366ef1 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_ethereum_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/bridge_to_ethereum_config.rs @@ -15,8 +15,8 @@ // along with Cumulus. If not, see . use crate::{xcm_config::UniversalLocation, Runtime}; +pub use bp_bridge_hub_polkadot::snowbridge::EthereumNetwork; use snowbridge_router_primitives::outbound::EthereumBlobExporter; -use system_parachains_constants::polkadot::snowbridge::EthereumNetwork; /// Exports message to the Ethereum Gateway contract. pub type SnowbridgeExporter = EthereumBlobExporter< diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs index 98c6e8efda..bfef8a7cda 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/xcm_config.rs @@ -15,6 +15,7 @@ // along with Cumulus. If not, see . use super::{ + bridge_to_ethereum_config::EthereumNetwork, bridge_to_kusama_config::{ DeliveryRewardInBalance, RequiredStakeForStakeAndSlash, ToBridgeHubKusamaHaulBlobExporter, }, @@ -40,7 +41,7 @@ use polkadot_runtime_constants::system_parachain; use snowbridge_runtime_common::XcmExportFeeToSibling; use sp_runtime::traits::AccountIdConversion; use sp_std::marker::PhantomData; -use system_parachains_constants::{polkadot::snowbridge::EthereumNetwork, TREASURY_PALLET_ID}; +use system_parachains_constants::TREASURY_PALLET_ID; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs index 0f29ba0f34..ed25d41e8c 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs @@ -30,12 +30,12 @@ use frame_support::{ traits::{OnFinalize, OnInitialize}, }; use frame_system::pallet_prelude::BlockNumberFor; -use polkadot_runtime_constants::currency::UNITS; use parachains_common::{AccountId, AuraId, Balance}; pub use parachains_runtimes_test_utils::test_cases::change_storage_constant_by_governance_works; use parachains_runtimes_test_utils::{ AccountIdOf, CollatorSessionKeys, ExtBuilder, XcmReceivedFrom, }; +use polkadot_runtime_constants::currency::UNITS; use snowbridge_core::{gwei, meth, ChannelId, ParaId, Rewards}; use snowbridge_pallet_ethereum_client::WeightInfo; use snowbridge_pallet_system::{ diff --git a/system-parachains/constants/Cargo.toml b/system-parachains/constants/Cargo.toml index 4f13f25e9d..89c581e95b 100644 --- a/system-parachains/constants/Cargo.toml +++ b/system-parachains/constants/Cargo.toml @@ -17,7 +17,6 @@ polkadot-core-primitives = { default-features = false, version = "8.0.0"} polkadot-primitives = { default-features = false , version = "8.0.1" } polkadot-runtime-constants = { path = "../../relay/polkadot/constants", default-features = false} sp-runtime = { default-features = false , version = "32.0.0" } -xcm = { package = "staging-xcm", default-features = false, version = "8.0.0" } [features] default = [ "std" ] @@ -29,5 +28,4 @@ std = [ "polkadot-primitives/std", "polkadot-runtime-constants/std", "sp-runtime/std", - "xcm/std", ] diff --git a/system-parachains/constants/src/kusama.rs b/system-parachains/constants/src/kusama.rs index 9aa17fceed..97ef0f189b 100644 --- a/system-parachains/constants/src/kusama.rs +++ b/system-parachains/constants/src/kusama.rs @@ -133,16 +133,3 @@ pub mod fee { ::weight_to_fee(weight) } } - -pub mod snowbridge { - use frame_support::parameter_types; - use xcm::opaque::lts::NetworkId; - - parameter_types! { - /// Network and location for the Ethereum chain. On Kusama, the Ethereum chain bridged - /// to is the Ethereum Main network, with chain ID 1. - /// - /// - pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 1 }; - } -} diff --git a/system-parachains/constants/src/polkadot.rs b/system-parachains/constants/src/polkadot.rs index ec8004446a..028784270c 100644 --- a/system-parachains/constants/src/polkadot.rs +++ b/system-parachains/constants/src/polkadot.rs @@ -151,16 +151,3 @@ pub mod fee { } } } - -pub mod snowbridge { - use frame_support::parameter_types; - use xcm::opaque::lts::NetworkId; - - parameter_types! { - /// Network and location for the Ethereum chain. On Polkadot, the Ethereum chain bridged - /// to is the Ethereum Main network, with chain ID 1. - /// - /// - pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 1 }; - } -} From d326e77d582f8e6f1b72f8c0b7c6c290909568f6 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 19 Mar 2024 16:09:10 +0100 Subject: [PATCH 2/4] Move `bridge_hub_inbound_queue_pallet_index_is_correct` to the runtimes --- .../bridge-hub-kusama/src/tests/snowbridge.rs | 13 +------------ .../bridge-hub-polkadot/src/tests/snowbridge.rs | 13 +------------ .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 8 ++++++++ .../bridge-hub-kusama/tests/snowbridge.rs | 6 ++---- .../bridge-hubs/bridge-hub-polkadot/src/lib.rs | 8 ++++++++ .../bridge-hub-polkadot/tests/snowbridge.rs | 6 ++---- 6 files changed, 22 insertions(+), 32 deletions(-) diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs index 3346c3f045..7cf5122831 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs @@ -16,9 +16,7 @@ use crate::*; use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::{ BridgeHubEthereumBaseFee, EthereumNetwork, }; -use bp_bridge_hub_kusama::snowbridge::{ - CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, -}; +use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, CreateAssetDeposit}; use bridge_hub_kusama_runtime::{ EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin, }; @@ -677,15 +675,6 @@ fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_p assert_eq!(bridge_hub_inbound_queue_asset_deposit, asset_deposit); } -/// Tests the EthereumInboundQueue pallet index matches the pallet constant. -#[test] -fn bridge_hub_inbound_queue_pallet_index_is_correct() { - let inbound_queue_inbound_queue_pallet_index = - ::EthereumInboundQueue::index(); - - assert_eq!(inbound_queue_inbound_queue_pallet_index as u8, InboundQueuePalletInstance::get()); -} - fn ethereum_sovereign_account() -> AccountId { let origin_location = (Parent, Parent, EthereumNetwork::get()).into(); GlobalConsensusEthereumConvertsFor::::convert_location(&origin_location).unwrap() diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index 00aaaf9029..cffde4a941 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -16,9 +16,7 @@ use crate::*; use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::{ BridgeHubEthereumBaseFee, EthereumNetwork, }; -use bp_bridge_hub_polkadot::snowbridge::{ - CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, -}; +use bp_bridge_hub_polkadot::snowbridge::{CreateAssetCall, CreateAssetDeposit}; use bridge_hub_polkadot_runtime::{ EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin, }; @@ -681,15 +679,6 @@ fn bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_p assert_eq!(bridge_hub_inbound_queue_asset_deposit, asset_deposit); } -/// Tests the EthereumInboundQueue pallet index matches the pallet constant. -#[test] -fn bridge_hub_inbound_queue_pallet_index_is_correct() { - let inbound_queue_inbound_queue_pallet_index = - ::EthereumInboundQueue::index(); - - assert_eq!(inbound_queue_inbound_queue_pallet_index as u8, InboundQueuePalletInstance::get()); -} - fn ethereum_sovereign_account() -> AccountId { let origin_location = (Parent, Parent, EthereumNetwork::get()).into(); GlobalConsensusEthereumConvertsFor::::convert_location(&origin_location).unwrap() 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 478abff03b..a7dc80393a 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -1369,6 +1369,14 @@ cumulus_pallet_parachain_system::register_validate_block! { mod tests { use super::*; + #[test] + fn bridge_hub_inbound_queue_pallet_index_is_correct() { + assert_eq!( + InboundQueuePalletInstance::get(), + ::index() as u8 + ); + } + #[test] fn test_transasction_byte_fee_is_one_tenth_of_relay() { let relay_tbf = kusama_runtime_constants::fee::TRANSACTION_BYTE_FEE; diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs index c34e873532..cf2de79777 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/tests/snowbridge.rs @@ -38,11 +38,9 @@ use parachains_runtimes_test_utils::{ }; use snowbridge_core::{gwei, meth, ChannelId, ParaId, Rewards}; use snowbridge_pallet_ethereum_client::WeightInfo; -use snowbridge_pallet_system::{ - BalanceOf, PricingParameters, PricingParametersOf, WeightInfo as EthereumSystemWeightInfo, -}; +use snowbridge_pallet_system::{PricingParametersOf, WeightInfo as EthereumSystemWeightInfo}; use snowbridge_runtime_test_common::initial_fund; -use sp_core::{H160, U256}; +use sp_core::H160; use sp_keyring::AccountKeyring::Alice; use sp_runtime::{ generic::{Era, SignedPayload}, 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 aa0fc3c777..f8c36c91f7 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -1370,6 +1370,14 @@ cumulus_pallet_parachain_system::register_validate_block! { mod tests { use super::*; + #[test] + fn bridge_hub_inbound_queue_pallet_index_is_correct() { + assert_eq!( + InboundQueuePalletInstance::get(), + ::index() as u8 + ); + } + #[test] fn test_transasction_byte_fee_is_one_tenth_of_relay() { let relay_tbf = polkadot_runtime_constants::fee::TRANSACTION_BYTE_FEE; diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs index 3738d4affc..703ef69a69 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/tests/snowbridge.rs @@ -38,11 +38,9 @@ use parachains_runtimes_test_utils::{ use polkadot_runtime_constants::currency::UNITS; use snowbridge_core::{gwei, meth, ChannelId, ParaId, Rewards}; use snowbridge_pallet_ethereum_client::WeightInfo; -use snowbridge_pallet_system::{ - BalanceOf, PricingParameters, PricingParametersOf, WeightInfo as EthereumSystemWeightInfo, -}; +use snowbridge_pallet_system::{PricingParametersOf, WeightInfo as EthereumSystemWeightInfo}; use snowbridge_runtime_test_common::initial_fund; -use sp_core::{H160, U256}; +use sp_core::H160; use sp_keyring::AccountKeyring::Alice; use sp_runtime::{ generic::{Era, SignedPayload}, From 115c3ffaab2ac60ef4236e915bd1a2bb5dd78092 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 19 Mar 2024 16:20:20 +0100 Subject: [PATCH 3/4] Move `bridge_hub_inbound_queue_deposit_config_is_equal_to_asset_hub_foreign_asset_pallet_deposit` to the AH runtimes --- .../bridge-hub-kusama/src/tests/snowbridge.rs | 13 +------------ .../src/tests/snowbridge.rs | 13 +------------ .../asset-hub-kusama/tests/snowbridge.rs | 19 ++++++++++++++++--- .../asset-hub-polkadot/tests/snowbridge.rs | 19 ++++++++++++++++--- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs index 7cf5122831..6a3c64fc5a 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-kusama/src/tests/snowbridge.rs @@ -16,7 +16,7 @@ use crate::*; use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::{ BridgeHubEthereumBaseFee, EthereumNetwork, }; -use bp_bridge_hub_kusama::snowbridge::{CreateAssetCall, CreateAssetDeposit}; +use bp_bridge_hub_kusama::snowbridge::CreateAssetCall; use bridge_hub_kusama_runtime::{ EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin, }; @@ -664,17 +664,6 @@ fn asset_hub_foreign_assets_pallet_is_configured_correctly_in_bridge_hub() { ); } -/// 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() { - let asset_deposit = asset_hub_kusama_runtime::ForeignAssetsAssetDeposit::get(); - - let bridge_hub_inbound_queue_asset_deposit = CreateAssetDeposit::get(); - - assert_eq!(bridge_hub_inbound_queue_asset_deposit, asset_deposit); -} - fn ethereum_sovereign_account() -> AccountId { let origin_location = (Parent, Parent, EthereumNetwork::get()).into(); GlobalConsensusEthereumConvertsFor::::convert_location(&origin_location).unwrap() diff --git a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs index cffde4a941..bb48b47972 100644 --- a/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs +++ b/integration-tests/emulated/tests/bridges/bridge-hub-polkadot/src/tests/snowbridge.rs @@ -16,7 +16,7 @@ use crate::*; use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::{ BridgeHubEthereumBaseFee, EthereumNetwork, }; -use bp_bridge_hub_polkadot::snowbridge::{CreateAssetCall, CreateAssetDeposit}; +use bp_bridge_hub_polkadot::snowbridge::CreateAssetCall; use bridge_hub_polkadot_runtime::{ EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin, }; @@ -668,17 +668,6 @@ fn asset_hub_foreign_assets_pallet_is_configured_correctly_in_bridge_hub() { ); } -/// 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() { - let asset_deposit = asset_hub_polkadot_runtime::ForeignAssetsAssetDeposit::get(); - - let bridge_hub_inbound_queue_asset_deposit = CreateAssetDeposit::get(); - - assert_eq!(bridge_hub_inbound_queue_asset_deposit, asset_deposit); -} - fn ethereum_sovereign_account() -> AccountId { let origin_location = (Parent, Parent, EthereumNetwork::get()).into(); GlobalConsensusEthereumConvertsFor::::convert_location(&origin_location).unwrap() 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 0d8e946e83..4d37f99f74 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/tests/snowbridge.rs @@ -15,15 +15,28 @@ // 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, +use asset_hub_kusama_runtime::{ + xcm_config::bridging::{ + to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, + SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, + }, + ForeignAssetsAssetDeposit, }; 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/tests/snowbridge.rs b/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs index 77f7054726..a4927cac42 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/tests/snowbridge.rs @@ -15,15 +15,28 @@ // 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, +use asset_hub_polkadot_runtime::{ + xcm_config::bridging::{ + to_ethereum::{BridgeHubEthereumBaseFee, BridgeTable, EthereumNetwork}, + SiblingBridgeHub, XcmBridgeHubRouterFeeAssetId, + }, + ForeignAssetsAssetDeposit, }; 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(|| { From 853d17dc5392b4e6749d1cbb815b15263993090c Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Tue, 19 Mar 2024 16:47:18 +0100 Subject: [PATCH 4/4] 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,