diff --git a/Cargo.lock b/Cargo.lock index b7e0b3585ff7..c9440fd9c3a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11346,6 +11346,7 @@ dependencies = [ "rococo-runtime-constants", "scale-info", "smallvec", + "snowbridge-router-primitives", "sp-consensus-aura", "sp-core", "sp-io", diff --git a/cumulus/parachains/common/Cargo.toml b/cumulus/parachains/common/Cargo.toml index dcaea40d2da0..ef108870cb67 100644 --- a/cumulus/parachains/common/Cargo.toml +++ b/cumulus/parachains/common/Cargo.toml @@ -47,6 +47,9 @@ cumulus-primitives-core = { path = "../../primitives/core", default-features = f cumulus-primitives-utility = { path = "../../primitives/utility", default-features = false } parachain-info = { package = "staging-parachain-info", path = "../pallets/parachain-info", default-features = false } +# Snowbridge +snowbridge-router-primitives = { path = "../../../../parachain/primitives/router", default-features = false } + [dev-dependencies] pallet-authorship = { path = "../../../substrate/frame/authorship", default-features = false } sp-io = { path = "../../../substrate/primitives/io", default-features = false } @@ -75,6 +78,7 @@ std = [ "polkadot-primitives/std", "rococo-runtime-constants/std", "scale-info/std", + "snowbridge-router-primitives/std", "sp-consensus-aura/std", "sp-core/std", "sp-io/std", @@ -96,6 +100,7 @@ runtime-benchmarks = [ "pallet-collator-selection/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", + "snowbridge-router-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", ] diff --git a/cumulus/parachains/common/src/rococo.rs b/cumulus/parachains/common/src/rococo.rs index 72e16927f38c..5cdb1bb35600 100644 --- a/cumulus/parachains/common/src/rococo.rs +++ b/cumulus/parachains/common/src/rococo.rs @@ -119,7 +119,9 @@ pub mod consensus { } pub mod snowbridge { - use frame_support::parameter_types; + use crate::rococo::currency::{EXISTENTIAL_DEPOSIT, UNITS}; + use frame_support::{parameter_types, weights::Weight}; + use snowbridge_router_primitives::inbound::CreateAssetCallInfo; use xcm::opaque::lts::NetworkId; /// The pallet index of the Ethereum inbound queue pallet in the bridge hub runtime. @@ -128,5 +130,11 @@ pub mod snowbridge { parameter_types! { /// Network and location for the Ethereum chain. pub EthereumNetwork: NetworkId = NetworkId::Ethereum { chain_id: 11155111 }; + pub const CreateAssetCall: CreateAssetCallInfo = CreateAssetCallInfo { + call_index: [53,0], + asset_deposit: (UNITS / 10) + EXISTENTIAL_DEPOSIT, + min_balance: 1, + transact_weight_at_most: Weight::from_parts(400_000_000, 8_000) + }; } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs index a93746b36032..4260ec660f95 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/tests/snowbridge.rs @@ -1,37 +1,34 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2023 Snowfork -pub use asset_hub_rococo_runtime::{Runtime, RuntimeCall}; +use asset_hub_rococo_runtime::Runtime; +pub use asset_hub_rococo_runtime::RuntimeCall; use codec::Encode; use frame_support::instances::Instance2; +use parachains_common::rococo::snowbridge::CreateAssetCall; +use snowbridge_router_primitives::inbound::CreateAssetCallInfo; use sp_runtime::MultiAddress; use xcm::latest::prelude::*; #[test] fn test_foreign_create_asset_call_compatibility() { - // assert_eq!( - // RuntimeCall::ForeignAssets(pallet_assets::Call::create { - // id: MultiLocation::default(), - // admin: MultiAddress::Id([0; 32].into()), - // min_balance: 1, - // }) - // .encode(), - // snowbridge_router_primitives::inbound::Call::ForeignAssets( - // snowbridge_router_primitives::inbound::ForeignAssetsCall::create { - // id: MultiLocation::default(), - // admin: MultiAddress::Id([0; 32].into()), - // min_balance: 1, - // } - // ) - // .encode() - // ); + let call = &RuntimeCall::ForeignAssets(pallet_assets::Call::create { + id: MultiLocation::default(), + admin: MultiAddress::Id([0; 32].into()), + min_balance: 1, + }) + .encode(); + let call_index = &call[..2]; + let snowbridge_call: CreateAssetCallInfo = CreateAssetCall::get(); + assert_eq!(call_index, snowbridge_call.call_index); } #[test] fn check_foreign_create_asset_call_with_sane_weight() { use pallet_assets::WeightInfo; let actual = >::WeightInfo::create(); - let max_weight = snowbridge_router_primitives::inbound::FOREIGN_CREATE_ASSET_WEIGHT_AT_MOST; + let snowbridge_call: CreateAssetCallInfo = CreateAssetCall::get(); + let max_weight = snowbridge_call.transact_weight_at_most; assert!( actual.all_lte(max_weight), "max_weight: {:?} should be adjusted to actual {:?}", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index a64d8b26ec61..2204377e240e 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -500,8 +500,6 @@ parameter_types! { } parameter_types! { - pub const CreateAssetCall: [u8;2] = [53, 0]; - pub const CreateAssetDeposit: u128 = (UNITS / 10) + EXISTENTIAL_DEPOSIT; pub const InboundQueuePalletInstance: u8 = parachains_common::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX; pub Parameters: PricingParameters = PricingParameters { exchange_rate: FixedU128::from_rational(1, 400), @@ -561,8 +559,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type Helper = Runtime; type MessageConverter = MessageToXcm< - CreateAssetCall, - CreateAssetDeposit, + parachains_common::rococo::snowbridge::CreateAssetCall, InboundQueuePalletInstance, AccountId, Balance,