diff --git a/Cargo.lock b/Cargo.lock index 17b28a3a00..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]] @@ -1271,6 +1273,7 @@ dependencies = [ "sp-api", "sp-runtime", "sp-std", + "staging-xcm", "system-parachains-constants", ] @@ -1288,6 +1291,7 @@ dependencies = [ "sp-api", "sp-runtime", "sp-std", + "staging-xcm", "system-parachains-constants", ] @@ -1536,7 +1540,6 @@ dependencies = [ "sp-runtime", "staging-xcm", "staging-xcm-executor", - "system-parachains-constants", ] [[package]] @@ -1687,7 +1690,6 @@ dependencies = [ "sp-runtime", "staging-xcm", "staging-xcm-executor", - "system-parachains-constants", ] [[package]] @@ -14625,7 +14627,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 56f1c851a2..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 @@ -13,10 +13,10 @@ // 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 bp_bridge_hub_kusama::snowbridge::{ - CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, +use asset_hub_kusama_runtime::xcm_config::bridging::to_ethereum::{ + BridgeHubEthereumBaseFee, EthereumNetwork, }; +use bp_bridge_hub_kusama::snowbridge::CreateAssetCall; use bridge_hub_kusama_runtime::{ EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin, }; @@ -46,7 +46,7 @@ use snowbridge_router_primitives::inbound::{ }; use sp_core::{H160, H256}; use sp_runtime::{DispatchError::Token, FixedU128, TokenError::FundsUnavailable}; -use system_parachains_constants::kusama::{currency::UNITS, snowbridge::EthereumNetwork}; +use system_parachains_constants::kusama::currency::UNITS; const INITIAL_FUND: u128 = 5_000_000_000 * KUSAMA_ED; const CHAIN_ID: u64 = 1; @@ -664,26 +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); -} - -/// 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/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 af5c515d90..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 @@ -13,10 +13,10 @@ // 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 bp_bridge_hub_polkadot::snowbridge::{ - CreateAssetCall, CreateAssetDeposit, InboundQueuePalletInstance, +use asset_hub_polkadot_runtime::xcm_config::bridging::to_ethereum::{ + BridgeHubEthereumBaseFee, EthereumNetwork, }; +use bp_bridge_hub_polkadot::snowbridge::CreateAssetCall; use bridge_hub_polkadot_runtime::{ EthereumBeaconClient, EthereumGatewayAddress, EthereumInboundQueue, Runtime, RuntimeOrigin, }; @@ -46,7 +46,7 @@ use snowbridge_router_primitives::inbound::{ }; use sp_core::{H160, H256}; use sp_runtime::{DispatchError::Token, FixedU128, TokenError::FundsUnavailable}; -use system_parachains_constants::polkadot::{currency::UNITS, snowbridge::EthereumNetwork}; +use system_parachains_constants::polkadot::currency::UNITS; const INITIAL_FUND: u128 = 5_000_000_000 * POLKADOT_ED; const CHAIN_ID: u64 = 1; @@ -668,26 +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); -} - -/// 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/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 b6b052c43b..8070b827bf 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, @@ -1760,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/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/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 f59c55282d..9b4ef06108 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, @@ -1717,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/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..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,15 +161,13 @@ 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; 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, @@ -189,6 +187,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/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index 478abff03b..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, @@ -1369,6 +1367,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/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-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/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..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,15 +152,13 @@ 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; 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, @@ -180,6 +178,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/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index aa0fc3c777..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, @@ -1370,6 +1368,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/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 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}, 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 }; - } -}