From d68c3d6944fb88d5c9f11056856694ecc14f201b Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 14 Feb 2024 09:32:38 +0800 Subject: [PATCH 01/44] Fix for unit test --- bridges/snowbridge/pallets/inbound-queue/src/mock.rs | 1 - bridges/snowbridge/pallets/system/src/mock.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs index d75c3c6a1863..110f611c6766 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs @@ -88,7 +88,6 @@ impl pallet_balances::Config for Test { type MaxFreezes = (); type RuntimeHoldReason = (); type RuntimeFreezeReason = (); - type MaxHolds = (); } parameter_types! { diff --git a/bridges/snowbridge/pallets/system/src/mock.rs b/bridges/snowbridge/pallets/system/src/mock.rs index bc2295781327..edc3f141b073 100644 --- a/bridges/snowbridge/pallets/system/src/mock.rs +++ b/bridges/snowbridge/pallets/system/src/mock.rs @@ -136,7 +136,6 @@ impl pallet_balances::Config for Test { type MaxFreezes = (); type RuntimeHoldReason = (); type RuntimeFreezeReason = (); - type MaxHolds = (); } impl pallet_xcm_origin::Config for Test { From 307ecd6301e6135b05e9d9cef4c60df543795fdd Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 14 Feb 2024 09:37:46 +0800 Subject: [PATCH 02/44] Update for transact --- .../primitives/router/src/inbound/mod.rs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index c20554c6d184..369924881eac 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -56,6 +56,21 @@ pub enum Command { /// XCM execution fee on AssetHub fee: u128, }, + /// call arbitrary transact on dest chain + Transact { + /// The address of the sender + sender: H160, + /// OriginKind + origin_kind: OriginKind, + /// XCM execution fee on dest chain + fee: u128, + /// The ref_time part of weight_at_most + weight_ref_time: u64, + /// The proof_size part of weight_at_most + weight_proof_size: u64, + /// The payload of the transact + payload: Vec, + }, } /// Destination for bridged tokens @@ -146,6 +161,19 @@ impl Ok(Self::convert_send_token(chain_id, token, destination, amount, fee)), + V1(MessageV1 { + chain_id, + command: + Transact { sender, origin_kind, fee, weight_ref_time, weight_proof_size, payload }, + }) => Ok(Self::convert_transact( + chain_id, + sender, + origin_kind, + fee, + weight_ref_time, + weight_proof_size, + payload, + )), } } } @@ -289,6 +317,39 @@ where [GlobalConsensus(network), AccountKey20 { network: None, key: token.into() }], ) } + + fn convert_transact( + chain_id: u64, + sender: H160, + origin_kind: OriginKind, + fee: u128, + weight_ref_time: u64, + weight_proof_size: u64, + payload: Vec, + ) -> (Xcm<()>, Balance) { + let xcm_fee: Asset = (Location::parent(), fee).into(); + + let xcm: Xcm<()> = vec![ + // Teleport required fees. + ReceiveTeleportedAsset(xcm_fee.clone().into()), + // Pay for execution. + BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, + // Change origin to the bridge. + UniversalOrigin(GlobalConsensus(Ethereum { chain_id })), + // DescendOrigin to the sender. + DescendOrigin(AccountKey20 { network: None, key: sender.into() }.into()), + // Transact on dest chain. + Transact { + origin_kind, + require_weight_at_most: Weight::from_parts(weight_ref_time, weight_proof_size), + call: payload.into(), + }, + ExpectTransactStatus(MaybeErrorCode::Success), + ] + .into(); + + (xcm, fee.into()) + } } pub struct GlobalConsensusEthereumConvertsFor(PhantomData); From 7c493bddf1e44a03ee28bc449726e2904e6c6585 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 13 Feb 2024 21:32:45 +0800 Subject: [PATCH 03/44] Penpal config for transact --- Cargo.lock | 3 + .../bridges/bridge-hub-rococo/Cargo.toml | 1 + .../bridge-hub-rococo/src/tests/snowbridge.rs | 50 +++++++++++++++- .../runtimes/testing/penpal/Cargo.toml | 2 + .../runtimes/testing/penpal/src/xcm_config.rs | 58 +++++++++++++++++-- 5 files changed, 108 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13ddeae06263..bcab77b76035 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1943,6 +1943,8 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", "frame-support", + "frame-system", + "hex", "hex-literal", "pallet-asset-conversion", "pallet-assets", @@ -11608,6 +11610,7 @@ dependencies = [ "sp-core", "sp-genesis-builder", "sp-inherents", + "sp-io", "sp-offchain", "sp-runtime", "sp-session", diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml index 89f0d2a9ca6d..b2d34ce5c355 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml @@ -18,6 +18,7 @@ hex-literal = "0.4.1" # Substrate sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false } frame-support = { path = "../../../../../../../substrate/frame/support", default-features = false } +frame-system = { path = "../../../../../../../substrate/frame/system", default-features = false } pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false } pallet-asset-conversion = { path = "../../../../../../../substrate/frame/asset-conversion", default-features = false } pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 5e1a2af660b0..d69cccd60172 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -27,7 +27,9 @@ use snowbridge_pallet_inbound_queue_fixtures::{ InboundQueueFixture, }; use snowbridge_pallet_system; -use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor; +use snowbridge_router_primitives::inbound::{ + Command, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, +}; use sp_core::H256; use sp_runtime::{ArithmeticError::Underflow, DispatchError::Arithmetic}; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; @@ -38,6 +40,7 @@ const TREASURY_ACCOUNT: [u8; 32] = hex!("6d6f646c70792f74727372790000000000000000000000000000000000000000"); const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"); const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e"); +const XCM_FEE: u128 = 40_000_000_000; #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum ControlCall { @@ -320,6 +323,51 @@ fn send_token_from_ethereum_to_penpal() { }); } +#[test] +fn transact_from_ethereum_to_penpal() { + // Fund AssetHub sovereign account so that it can pay execution fees. + BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender: hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(), + fee: XCM_FEE, + weight_ref_time: 40_000_000, + weight_proof_size: 8_000, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + }, + }); + // Convert the message to XCM + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check that system event remarked on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::System(frame_system::Event::Remarked { .. }) => {}, + ] + ); + }); +} + /// Tests the registering of a token as an asset on AssetHub, and then subsequently sending /// a token from Ethereum to AssetHub. #[test] diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index dab687c52778..c591c56ccfcf 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -46,6 +46,7 @@ sp-api = { path = "../../../../../substrate/primitives/api", default-features = sp-block-builder = { path = "../../../../../substrate/primitives/block-builder", default-features = false } sp-consensus-aura = { path = "../../../../../substrate/primitives/consensus/aura", default-features = false } sp-core = { path = "../../../../../substrate/primitives/core", default-features = false } +sp-io = { path = "../../../../../substrate/primitives/io", default-features = false } sp-genesis-builder = { path = "../../../../../substrate/primitives/genesis-builder", default-features = false } sp-inherents = { path = "../../../../../substrate/primitives/inherents", default-features = false } sp-offchain = { path = "../../../../../substrate/primitives/offchain", default-features = false } @@ -132,6 +133,7 @@ std = [ "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", + "sp-io/std", "substrate-wasm-builder", "testnet-parachains-constants/std", "xcm-builder/std", diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 3fad47576fd6..b862fded755c 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -27,6 +27,7 @@ use super::{ ForeignAssets, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, }; +use codec::Encode; use core::marker::PhantomData; use frame_support::{ parameter_types, @@ -40,10 +41,12 @@ use frame_system::EnsureRoot; use pallet_asset_tx_payment::HandleCredit; use pallet_assets::Instance1; use pallet_xcm::XcmPassthrough; +use parachains_common::{rococo::snowbridge::EthereumNetwork, xcm_config::ConcreteAssetFromSystem}; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; +use sp_io::hashing::blake2_256; use sp_runtime::traits::Zero; -use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; +use sp_std::collections::btree_set::BTreeSet; use xcm::latest::prelude::*; #[allow(deprecated)] use xcm_builder::{ @@ -56,7 +59,10 @@ use xcm_builder::{ SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, }; -use xcm_executor::{traits::JustTry, XcmExecutor}; +use xcm_executor::{ + traits::{ConvertLocation, JustTry}, + XcmExecutor, +}; parameter_types! { pub const RelayLocation: Location = Location::parent(); @@ -75,6 +81,7 @@ pub type LocationToAccountId = ( SiblingParachainConvertsVia, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, + GlobalConsensusEthereumAddressConvertsFor, ); /// Means for transacting assets on this chain. @@ -318,8 +325,49 @@ pub type Reserves = ( NativeAssetFrom, AssetPrefixFrom, ); -pub type TrustedTeleporters = - (AssetFromChain,); + +pub type TrustedTeleporters = ( + ConcreteAssetFromSystem, + AssetFromChain, +); + +parameter_types! { + pub SiblingBridgeHubLocation: Location = Location::new( + 1, + [ + Parachain(1013), + ] + ); + pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( + sp_std::vec![ + (SiblingBridgeHubLocation::get(),GlobalConsensus(EthereumNetwork::get())), + ] + ); +} + +pub struct GlobalConsensusEthereumAddressConvertsFor(PhantomData); +impl ConvertLocation for GlobalConsensusEthereumAddressConvertsFor +where + AccountId: From<[u8; 32]> + Clone, +{ + fn convert_location(location: &Location) -> Option { + match location.unpack() { + (_, [first_loc, AccountKey20 { network: None, key: sender }]) + if *first_loc == + Junction::from( + parachains_common::rococo::snowbridge::EthereumNetwork::get(), + ) => + Some(blake2_256(&(b"AccountKey20", sender).encode()).into()), + _ => None, + } + } +} + +impl Contains<(Location, Junction)> for UniversalAliases { + fn contains(alias: &(Location, Junction)) -> bool { + UniversalAliases::get().contains(alias) + } +} pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { @@ -346,7 +394,7 @@ impl xcm_executor::Config for XcmConfig { type AssetExchanger = (); type FeeManager = (); type MessageExporter = (); - type UniversalAliases = Nothing; + type UniversalAliases = UniversalAliases; type CallDispatcher = RuntimeCall; type SafeCallFilter = Everything; type Aliasers = Nothing; From e55cfd161540bad9131c6d7a387156a88b6f253d Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 14 Feb 2024 13:35:17 +0800 Subject: [PATCH 04/44] Fix import --- Cargo.lock | 1 - .../parachains/runtimes/testing/penpal/src/xcm_config.rs | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bcab77b76035..f0e70d300d57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1944,7 +1944,6 @@ dependencies = [ "emulated-integration-tests-common", "frame-support", "frame-system", - "hex", "hex-literal", "pallet-asset-conversion", "pallet-assets", diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index b862fded755c..6ab6fcf3ee83 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -41,12 +41,13 @@ use frame_system::EnsureRoot; use pallet_asset_tx_payment::HandleCredit; use pallet_assets::Instance1; use pallet_xcm::XcmPassthrough; -use parachains_common::{rococo::snowbridge::EthereumNetwork, xcm_config::ConcreteAssetFromSystem}; +use parachains_common::xcm_config::ConcreteAssetFromSystem; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; use sp_io::hashing::blake2_256; use sp_runtime::traits::Zero; use sp_std::collections::btree_set::BTreeSet; +use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; use xcm::latest::prelude::*; #[allow(deprecated)] use xcm_builder::{ @@ -353,10 +354,7 @@ where fn convert_location(location: &Location) -> Option { match location.unpack() { (_, [first_loc, AccountKey20 { network: None, key: sender }]) - if *first_loc == - Junction::from( - parachains_common::rococo::snowbridge::EthereumNetwork::get(), - ) => + if *first_loc == Junction::from(EthereumNetwork::get()) => Some(blake2_256(&(b"AccountKey20", sender).encode()).into()), _ => None, } From 45c3372b40936ede126e2a3ae22a67592f7f1d00 Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 14 Feb 2024 13:52:49 +0800 Subject: [PATCH 05/44] Fix taplo --- cumulus/parachains/runtimes/testing/penpal/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index c591c56ccfcf..3d39d378d982 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -46,7 +46,7 @@ sp-api = { path = "../../../../../substrate/primitives/api", default-features = sp-block-builder = { path = "../../../../../substrate/primitives/block-builder", default-features = false } sp-consensus-aura = { path = "../../../../../substrate/primitives/consensus/aura", default-features = false } sp-core = { path = "../../../../../substrate/primitives/core", default-features = false } -sp-io = { path = "../../../../../substrate/primitives/io", default-features = false } +sp-io = { path = "../../../../../substrate/primitives/io", default-features = false } sp-genesis-builder = { path = "../../../../../substrate/primitives/genesis-builder", default-features = false } sp-inherents = { path = "../../../../../substrate/primitives/inherents", default-features = false } sp-offchain = { path = "../../../../../substrate/primitives/offchain", default-features = false } @@ -126,6 +126,7 @@ std = [ "sp-core/std", "sp-genesis-builder/std", "sp-inherents/std", + "sp-io/std", "sp-offchain/std", "sp-runtime/std", "sp-session/std", @@ -133,7 +134,6 @@ std = [ "sp-storage/std", "sp-transaction-pool/std", "sp-version/std", - "sp-io/std", "substrate-wasm-builder", "testnet-parachains-constants/std", "xcm-builder/std", From 26df8073a0ee6bb600a8d98b687382c54617ecb1 Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 14 Feb 2024 15:21:50 +0800 Subject: [PATCH 06/44] Fix for breaking emulated tests --- .../runtimes/testing/penpal/src/xcm_config.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 6ab6fcf3ee83..f1f016f0cddc 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -41,7 +41,6 @@ use frame_system::EnsureRoot; use pallet_asset_tx_payment::HandleCredit; use pallet_assets::Instance1; use pallet_xcm::XcmPassthrough; -use parachains_common::xcm_config::ConcreteAssetFromSystem; use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; use sp_io::hashing::blake2_256; @@ -327,8 +326,24 @@ pub type Reserves = ( AssetPrefixFrom, ); +pub struct ConcreteAssetFromBridgeHub(PhantomData); +impl> ContainsPair + for ConcreteAssetFromBridgeHub +{ + fn contains(asset: &Asset, origin: &Location) -> bool { + log::trace!(target: "xcm::contains", "ConcreteAssetFromBridgeHub asset: {:?}, origin: {:?}", asset, origin); + let is_from_bh = match origin.unpack() { + // System parachain + (1, [Parachain(id)]) => *id == 1013, + // Others + _ => false, + }; + asset.id.0 == AssetLocation::get() && is_from_bh + } +} + pub type TrustedTeleporters = ( - ConcreteAssetFromSystem, + ConcreteAssetFromBridgeHub, AssetFromChain, ); From c4fe0315881b119491111f1cf9665d59fcf3a25f Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 14 Feb 2024 15:48:23 +0800 Subject: [PATCH 07/44] Remove unused --- bridges/snowbridge/pallets/system/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/bridges/snowbridge/pallets/system/src/lib.rs b/bridges/snowbridge/pallets/system/src/lib.rs index 13abee14b4af..b7f38fb753d3 100644 --- a/bridges/snowbridge/pallets/system/src/lib.rs +++ b/bridges/snowbridge/pallets/system/src/lib.rs @@ -79,8 +79,6 @@ use xcm_executor::traits::ConvertLocation; #[cfg(feature = "runtime-benchmarks")] use frame_support::traits::OriginTrait; -pub use pallet::*; - pub type BalanceOf = <::Token as Inspect<::AccountId>>::Balance; pub type AccountIdOf = ::AccountId; From 51b76fe5271e67337a15da4c0b097822f8580f12 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 15 Feb 2024 00:29:21 +0800 Subject: [PATCH 08/44] Tranfer fees to BH for transact --- .../pallets/inbound-queue/src/lib.rs | 49 ++++++++++++++----- .../pallets/inbound-queue/src/mock.rs | 1 + .../primitives/router/src/inbound/mod.rs | 2 +- .../bridge-hub-rococo/src/tests/snowbridge.rs | 6 +-- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 1 + 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index bdc21fcf0370..fa96556bc274 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -64,9 +64,8 @@ use snowbridge_core::{ sibling_sovereign_account, BasicOperatingMode, Channel, ChannelId, ParaId, PricingParameters, StaticLookup, }; -use snowbridge_router_primitives::{ - inbound, - inbound::{ConvertMessage, ConvertMessageError}, +use snowbridge_router_primitives::inbound::{ + Command, ConvertMessage, ConvertMessageError, MessageV1, VersionedMessage, }; use sp_runtime::{traits::Saturating, SaturatedConversion, TokenError}; @@ -139,6 +138,9 @@ pub mod pallet { /// To withdraw and deposit an asset. type AssetTransactor: TransactAsset; + + /// Returns the parachain ID we are running with. + type SelfParaId: Get; } #[pallet::hooks] @@ -268,8 +270,8 @@ pub mod pallet { T::Token::transfer(&sovereign_account, &who, delivery_cost, Preservation::Preserve)?; // Decode message into XCM - let (xcm, fee) = - match inbound::VersionedMessage::decode_all(&mut envelope.payload.as_ref()) { + let (xcm, fee, message) = + match VersionedMessage::decode_all(&mut envelope.payload.as_ref()) { Ok(message) => Self::do_convert(envelope.message_id, message)?, Err(_) => return Err(Error::::InvalidPayload.into()), }; @@ -281,8 +283,13 @@ pub mod pallet { fee ); - // Burning fees for teleport - Self::burn_fees(channel.para_id, fee)?; + let _ = match message { + // Transfer fees to BH for transact + VersionedMessage::V1(MessageV1 { command: Command::Transact { .. }, .. }) => + Self::transfer_fees(channel.para_id, fee), + // Burning fees for teleport + _ => Self::burn_fees(channel.para_id, fee), + }?; // Attempt to send XCM to a dest parachain let message_id = Self::send_xcm(xcm, channel.para_id)?; @@ -314,13 +321,13 @@ pub mod pallet { impl Pallet { pub fn do_convert( message_id: H256, - message: inbound::VersionedMessage, - ) -> Result<(Xcm<()>, BalanceOf), Error> { - let (mut xcm, fee) = - T::MessageConverter::convert(message).map_err(|e| Error::::ConvertMessage(e))?; + message: VersionedMessage, + ) -> Result<(Xcm<()>, BalanceOf, VersionedMessage), Error> { + let (mut xcm, fee) = T::MessageConverter::convert(message.clone()) + .map_err(|e| Error::::ConvertMessage(e))?; // Append the message id as an XCM topic xcm.inner_mut().extend(vec![SetTopic(message_id.into())]); - Ok((xcm, fee)) + Ok((xcm, fee, message)) } pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result> { @@ -360,6 +367,24 @@ pub mod pallet { })?; Ok(()) } + + pub fn transfer_fees(para_id: ParaId, fee: BalanceOf) -> DispatchResult { + let dummy_context = + XcmContext { origin: None, message_id: Default::default(), topic: None }; + let from = Location::new(1, [Parachain(para_id.into())]); + let to = Location::new(1, [Parachain(T::SelfParaId::get().into())]); + let fees = (Location::parent(), fee.saturated_into::()).into(); + T::AssetTransactor::transfer_asset(&fees, &from, &to, &dummy_context).map_err( + |error| { + log::error!( + target: LOG_TARGET, + "XCM asset transfer failed with error {:?}", error + ); + TokenError::FundsUnavailable + }, + )?; + Ok(()) + } } /// API for accessing the delivery cost of a message diff --git a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs index 110f611c6766..6bda109d6dd5 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs @@ -257,6 +257,7 @@ impl inbound_queue::Config for Test { type LengthToFee = IdentityFee; type MaxMessageSize = ConstU32<1024>; type AssetTransactor = SuccessfulTransactor; + type SelfParaId = OwnParaId; } pub fn last_events(n: usize) -> Vec { diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 369924881eac..6d4958bcadb8 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -331,7 +331,7 @@ where let xcm: Xcm<()> = vec![ // Teleport required fees. - ReceiveTeleportedAsset(xcm_fee.clone().into()), + WithdrawAsset(xcm_fee.clone().into()), // Pay for execution. BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, // Change origin to the bridge. diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index d69cccd60172..9d04960d0ce1 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -325,8 +325,8 @@ fn send_token_from_ethereum_to_penpal() { #[test] fn transact_from_ethereum_to_penpal() { - // Fund AssetHub sovereign account so that it can pay execution fees. - BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); + // Fund BridgeHub sovereign account on penpal so that it can pay execution fees. + PenpalA::fund_para_sovereign(BridgeHubRococo::para_id().into(), INITIAL_FUND); BridgeHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -344,7 +344,7 @@ fn transact_from_ethereum_to_penpal() { }, }); // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + let (xcm, _, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); 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 0d4c1defa37b..2ba6b9bd6b42 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 @@ -574,6 +574,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { type WeightInfo = weights::snowbridge_pallet_inbound_queue::WeightInfo; type PricingParameters = EthereumSystem; type AssetTransactor = ::AssetTransactor; + type SelfParaId = parachain_info::Pallet; } impl snowbridge_pallet_outbound_queue::Config for Runtime { From 3ed7260d6d3fe91921e931c785cb2e11bf201292 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 15 Feb 2024 08:51:57 +0800 Subject: [PATCH 09/44] Remove the teleport config --- .../pallets/inbound-queue/src/lib.rs | 1 + .../primitives/router/src/inbound/mod.rs | 2 +- .../runtimes/testing/penpal/src/xcm_config.rs | 22 ++----------------- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index fa96556bc274..806bc60a8938 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -368,6 +368,7 @@ pub mod pallet { Ok(()) } + /// Transfer fees to BH to pay the xcm execution on dest chain pub fn transfer_fees(para_id: ParaId, fee: BalanceOf) -> DispatchResult { let dummy_context = XcmContext { origin: None, message_id: Default::default(), topic: None }; diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 6d4958bcadb8..009271481954 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -330,7 +330,7 @@ where let xcm_fee: Asset = (Location::parent(), fee).into(); let xcm: Xcm<()> = vec![ - // Teleport required fees. + // Withdraw fees from BH to pay the xcm execution WithdrawAsset(xcm_fee.clone().into()), // Pay for execution. BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index f1f016f0cddc..95ef36bdebeb 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -326,26 +326,8 @@ pub type Reserves = ( AssetPrefixFrom, ); -pub struct ConcreteAssetFromBridgeHub(PhantomData); -impl> ContainsPair - for ConcreteAssetFromBridgeHub -{ - fn contains(asset: &Asset, origin: &Location) -> bool { - log::trace!(target: "xcm::contains", "ConcreteAssetFromBridgeHub asset: {:?}, origin: {:?}", asset, origin); - let is_from_bh = match origin.unpack() { - // System parachain - (1, [Parachain(id)]) => *id == 1013, - // Others - _ => false, - }; - asset.id.0 == AssetLocation::get() && is_from_bh - } -} - -pub type TrustedTeleporters = ( - ConcreteAssetFromBridgeHub, - AssetFromChain, -); +pub type TrustedTeleporters = + (AssetFromChain,); parameter_types! { pub SiblingBridgeHubLocation: Location = Location::new( From 772fa46743249851ad26b7c6601f85b23410eee4 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 15 Feb 2024 13:54:25 +0800 Subject: [PATCH 10/44] Enable create agent/channel by xcm --- .../bridge-hub-rococo/src/tests/snowbridge.rs | 102 +++++++++--------- .../bridge-hub-rococo/src/xcm_config.rs | 4 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 9d04960d0ce1..1e8a8cb5dc50 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -74,9 +74,8 @@ pub fn send_inbound_message(fixture: InboundQueueFixture) -> DispatchResult { /// Create an agent on Ethereum. An agent is a representation of an entity in the Polkadot /// ecosystem (like a parachain) on Ethereum. #[test] -#[ignore] fn create_agent() { - let origin_para: u32 = 1001; + let origin_para: u32 = 2000; // Fund the origin parachain sovereign account so that it can pay execution fees. BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND); @@ -84,7 +83,7 @@ fn create_agent() { let destination = Rococo::child_location_of(BridgeHubRococo::para_id()).into(); let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); - // Construct XCM to create an agent for para 1001 + // Construct XCM to create an agent for para 2000 let remote_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(Parachain(origin_para).into()), @@ -131,9 +130,8 @@ fn create_agent() { /// Create a channel for a consensus system. A channel is a bidirectional messaging channel /// between BridgeHub and Ethereum. #[test] -#[ignore] fn create_channel() { - let origin_para: u32 = 1001; + let origin_para: u32 = 2000; // Fund AssetHub sovereign account so that it can pay execution fees. BridgeHubRococo::fund_para_sovereign(origin_para.into(), INITIAL_FUND); @@ -142,7 +140,7 @@ fn create_channel() { Rococo::child_location_of(BridgeHubRococo::para_id()).into(); let create_agent_call = SnowbridgeControl::Control(ControlCall::CreateAgent {}); - // Construct XCM to create an agent for para 1001 + // Construct XCM to create an agent for para 2000 let create_agent_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(Parachain(origin_para).into()), @@ -155,7 +153,7 @@ fn create_channel() { let create_channel_call = SnowbridgeControl::Control(ControlCall::CreateChannel { mode: OperatingMode::Normal }); - // Construct XCM to create a channel for para 1001 + // Construct XCM to create a channel for para 2000 let create_channel_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(Parachain(origin_para).into()), @@ -323,51 +321,6 @@ fn send_token_from_ethereum_to_penpal() { }); } -#[test] -fn transact_from_ethereum_to_penpal() { - // Fund BridgeHub sovereign account on penpal so that it can pay execution fees. - PenpalA::fund_para_sovereign(BridgeHubRococo::para_id().into(), INITIAL_FUND); - - BridgeHubRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::Transact { - sender: hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(), - fee: XCM_FEE, - weight_ref_time: 40_000_000, - weight_proof_size: 8_000, - origin_kind: OriginKind::SovereignAccount, - payload: hex!("00071468656c6c6f").to_vec(), - }, - }); - // Convert the message to XCM - let (xcm, _, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); - - assert_expected_events!( - BridgeHubRococo, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - PenpalA::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check that system event remarked on PenPal - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::System(frame_system::Event::Remarked { .. }) => {}, - ] - ); - }); -} - /// Tests the registering of a token as an asset on AssetHub, and then subsequently sending /// a token from Ethereum to AssetHub. #[test] @@ -583,3 +536,48 @@ fn send_token_from_ethereum_to_asset_hub_fail_for_insufficient_fund() { assert_err!(send_inbound_message(make_register_token_message()), Arithmetic(Underflow)); }); } + +#[test] +fn transact_from_ethereum_to_penpal() { + // Fund BridgeHub sovereign account on penpal so that it can pay execution fees. + PenpalA::fund_para_sovereign(BridgeHubRococo::para_id().into(), INITIAL_FUND); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender: hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(), + fee: XCM_FEE, + weight_ref_time: 40_000_000, + weight_proof_size: 8_000, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + }, + }); + // Convert the message to XCM + let (xcm, _, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check that system event remarked on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::System(frame_system::Event::Remarked { .. }) => {}, + ] + ); + }); +} diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index b7d170707cfd..9819a01adc96 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -233,7 +233,9 @@ impl Contains for SafeCallFilter { snowbridge_pallet_system::Call::set_pricing_parameters { .. } | snowbridge_pallet_system::Call::force_update_channel { .. } | snowbridge_pallet_system::Call::force_transfer_native_from_agent { .. } | - snowbridge_pallet_system::Call::set_token_transfer_fees { .. }, + snowbridge_pallet_system::Call::set_token_transfer_fees { .. } | + snowbridge_pallet_system::Call::create_agent { .. } | + snowbridge_pallet_system::Call::create_channel { .. }, ) ) } From 540a7919a52fddac8c018f6e29d7988537c608a2 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 16 Feb 2024 12:42:36 +0800 Subject: [PATCH 11/44] Refund surplus --- bridges/snowbridge/primitives/router/src/inbound/mod.rs | 9 +++++++++ .../parachains/runtimes/testing/penpal/src/xcm_config.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 009271481954..326840bc0b24 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -345,6 +345,15 @@ where call: payload.into(), }, ExpectTransactStatus(MaybeErrorCode::Success), + RefundSurplus, + // Deposit surplus to sender. + DepositAsset { + assets: Wild(AllCounted(1u32)), + beneficiary: Location{ parents: 1, interior: Junctions::from([ + GlobalConsensus(Ethereum { chain_id }), + AccountKey20 { network: None, key: sender.into() }, + ]) } + }, ] .into(); diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 95ef36bdebeb..db7d17d1985b 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -350,8 +350,8 @@ where { fn convert_location(location: &Location) -> Option { match location.unpack() { - (_, [first_loc, AccountKey20 { network: None, key: sender }]) - if *first_loc == Junction::from(EthereumNetwork::get()) => + (parents, [first_loc, AccountKey20 { network: None, key: sender }]) + if parents == 1 && *first_loc == Junction::from(EthereumNetwork::get()) => Some(blake2_256(&(b"AccountKey20", sender).encode()).into()), _ => None, } From 051b3b6af9d5607118677acb32b8a0fe84129733 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 16 Feb 2024 17:19:59 +0800 Subject: [PATCH 12/44] Fix format --- bridges/snowbridge/primitives/router/src/inbound/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 326840bc0b24..6b78b4b84c51 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -349,10 +349,13 @@ where // Deposit surplus to sender. DepositAsset { assets: Wild(AllCounted(1u32)), - beneficiary: Location{ parents: 1, interior: Junctions::from([ + beneficiary: Location { + parents: 1, + interior: Junctions::from([ GlobalConsensus(Ethereum { chain_id }), AccountKey20 { network: None, key: sender.into() }, - ]) } + ]), + }, }, ] .into(); From e5231854f37cd9b5b1e1ec9cd543f0600daf06f8 Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 16 Feb 2024 17:54:46 +0800 Subject: [PATCH 13/44] Replace hardcode value --- Cargo.lock | 1 + cumulus/parachains/runtimes/testing/penpal/Cargo.toml | 2 ++ cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f0e70d300d57..1f2af50a315f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11567,6 +11567,7 @@ name = "penpal-runtime" version = "0.14.0" dependencies = [ "assets-common", + "bp-bridge-hub-rococo", "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index 3d39d378d982..a7e2f353e0b0 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -80,11 +80,13 @@ parachain-info = { package = "staging-parachain-info", path = "../../../pallets/ parachains-common = { path = "../../../common", default-features = false } testnet-parachains-constants = { path = "../../constants", default-features = false, features = ["rococo"] } assets-common = { path = "../../assets/common", default-features = false } +bp-bridge-hub-rococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false } [features] default = ["std"] std = [ "assets-common/std", + "bp-bridge-hub-rococo/std", "codec/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index db7d17d1985b..3954cefd32eb 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -333,7 +333,7 @@ parameter_types! { pub SiblingBridgeHubLocation: Location = Location::new( 1, [ - Parachain(1013), + Parachain(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), ] ); pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( From a8b84355336e9968c1ebe87054b8b465ffab3606 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 20 Feb 2024 00:44:03 +0800 Subject: [PATCH 14/44] Leave to user to prefund sovereign account on the destination chain to pay fees --- .../pallets/inbound-queue/src/lib.rs | 26 +++---------------- .../primitives/router/src/inbound/mod.rs | 10 +++---- .../bridge-hub-rococo/src/tests/snowbridge.rs | 14 ++++++---- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index 806bc60a8938..70d4f4de0a64 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -284,10 +284,9 @@ pub mod pallet { ); let _ = match message { - // Transfer fees to BH for transact - VersionedMessage::V1(MessageV1 { command: Command::Transact { .. }, .. }) => - Self::transfer_fees(channel.para_id, fee), - // Burning fees for teleport + // For transact do nothing here and leave it to dest chain to pay for fees by sender + VersionedMessage::V1(MessageV1 { command: Command::Transact { .. }, .. }) => Ok(()), + // For others burning fees for teleport _ => Self::burn_fees(channel.para_id, fee), }?; @@ -367,25 +366,6 @@ pub mod pallet { })?; Ok(()) } - - /// Transfer fees to BH to pay the xcm execution on dest chain - pub fn transfer_fees(para_id: ParaId, fee: BalanceOf) -> DispatchResult { - let dummy_context = - XcmContext { origin: None, message_id: Default::default(), topic: None }; - let from = Location::new(1, [Parachain(para_id.into())]); - let to = Location::new(1, [Parachain(T::SelfParaId::get().into())]); - let fees = (Location::parent(), fee.saturated_into::()).into(); - T::AssetTransactor::transfer_asset(&fees, &from, &to, &dummy_context).map_err( - |error| { - log::error!( - target: LOG_TARGET, - "XCM asset transfer failed with error {:?}", error - ); - TokenError::FundsUnavailable - }, - )?; - Ok(()) - } } /// API for accessing the delivery cost of a message diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 6b78b4b84c51..cb36d3cc9dde 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -330,14 +330,14 @@ where let xcm_fee: Asset = (Location::parent(), fee).into(); let xcm: Xcm<()> = vec![ - // Withdraw fees from BH to pay the xcm execution - WithdrawAsset(xcm_fee.clone().into()), - // Pay for execution. - BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, // Change origin to the bridge. UniversalOrigin(GlobalConsensus(Ethereum { chain_id })), // DescendOrigin to the sender. DescendOrigin(AccountKey20 { network: None, key: sender.into() }.into()), + // Withdraw fees from sender to pay the xcm execution + WithdrawAsset(xcm_fee.clone().into()), + // Pay for execution. + BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, // Transact on dest chain. Transact { origin_kind, @@ -346,7 +346,7 @@ where }, ExpectTransactStatus(MaybeErrorCode::Success), RefundSurplus, - // Deposit surplus to sender. + // Deposit surplus back to sender. DepositAsset { assets: Wild(AllCounted(1u32)), beneficiary: Location { diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 1e8a8cb5dc50..2b2be3feebd4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -16,7 +16,7 @@ use crate::*; use bridge_hub_rococo_runtime::{EthereumBeaconClient, EthereumInboundQueue, RuntimeOrigin}; use codec::{Decode, Encode}; use emulated_integration_tests_common::xcm_emulator::ConvertLocation; -use frame_support::pallet_prelude::TypeInfo; +use frame_support::{__private::hashing::blake2_256, pallet_prelude::TypeInfo}; use hex_literal::hex; use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender; use snowbridge_core::outbound::OperatingMode; @@ -30,7 +30,7 @@ use snowbridge_pallet_system; use snowbridge_router_primitives::inbound::{ Command, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, }; -use sp_core::H256; +use sp_core::{H160, H256}; use sp_runtime::{ArithmeticError::Underflow, DispatchError::Arithmetic}; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; @@ -539,8 +539,12 @@ fn send_token_from_ethereum_to_asset_hub_fail_for_insufficient_fund() { #[test] fn transact_from_ethereum_to_penpal() { - // Fund BridgeHub sovereign account on penpal so that it can pay execution fees. - PenpalA::fund_para_sovereign(BridgeHubRococo::para_id().into(), INITIAL_FUND); + // Fund sender on penpal so that it can pay execution fees. + let sender: H160 = hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(); + PenpalA::fund_accounts(vec![( + blake2_256(&(b"AccountKey20", sender).encode()).into(), + INITIAL_FUND, + )]); BridgeHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -549,7 +553,7 @@ fn transact_from_ethereum_to_penpal() { let message = VersionedMessage::V1(MessageV1 { chain_id: CHAIN_ID, command: Command::Transact { - sender: hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(), + sender, fee: XCM_FEE, weight_ref_time: 40_000_000, weight_proof_size: 8_000, From b10d19ecf2886fa1b54cb49ebd71a7230325bd4a Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 20 Feb 2024 00:53:10 +0800 Subject: [PATCH 15/44] Update import path --- Cargo.lock | 1 + .../emulated/tests/bridges/bridge-hub-rococo/Cargo.toml | 1 + .../tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 1f2af50a315f..68e9c97488e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1963,6 +1963,7 @@ dependencies = [ "snowbridge-pallet-system", "snowbridge-router-primitives", "sp-core", + "sp-io", "sp-runtime", "staging-xcm", "staging-xcm-executor", diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml index b2d34ce5c355..b1d51032dc3f 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml @@ -24,6 +24,7 @@ pallet-asset-conversion = { path = "../../../../../../../substrate/frame/asset-c pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false } pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue" } sp-runtime = { path = "../../../../../../../substrate/primitives/runtime", default-features = false } +sp-io = { path = "../../../../../../../substrate/primitives/io", default-features = false } # Polkadot xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 2b2be3feebd4..fc5c258ded71 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -16,7 +16,7 @@ use crate::*; use bridge_hub_rococo_runtime::{EthereumBeaconClient, EthereumInboundQueue, RuntimeOrigin}; use codec::{Decode, Encode}; use emulated_integration_tests_common::xcm_emulator::ConvertLocation; -use frame_support::{__private::hashing::blake2_256, pallet_prelude::TypeInfo}; +use frame_support::pallet_prelude::TypeInfo; use hex_literal::hex; use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender; use snowbridge_core::outbound::OperatingMode; @@ -31,6 +31,7 @@ use snowbridge_router_primitives::inbound::{ Command, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, }; use sp_core::{H160, H256}; +use sp_io::hashing::blake2_256; use sp_runtime::{ArithmeticError::Underflow, DispatchError::Arithmetic}; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; From e3639185b3f75db9f73856d82846e9f759d7dfcb Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 20 Feb 2024 12:58:19 +0800 Subject: [PATCH 16/44] Unit test for transact --- .../pallets/inbound-queue/src/lib.rs | 20 +++++------ .../pallets/inbound-queue/src/test.rs | 35 ++++++++++++++++++- .../bridge-hub-rococo/src/tests/snowbridge.rs | 2 +- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index 70d4f4de0a64..9ef032d24965 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -269,12 +269,12 @@ pub mod pallet { let delivery_cost = Self::calculate_delivery_cost(message.encode().len() as u32); T::Token::transfer(&sovereign_account, &who, delivery_cost, Preservation::Preserve)?; - // Decode message into XCM - let (xcm, fee, message) = - match VersionedMessage::decode_all(&mut envelope.payload.as_ref()) { - Ok(message) => Self::do_convert(envelope.message_id, message)?, - Err(_) => return Err(Error::::InvalidPayload.into()), - }; + // Decode payload into VersionMessage + let message = VersionedMessage::decode_all(&mut envelope.payload.as_ref()) + .map_err(|_| Error::::InvalidPayload)?; + + // Convert VersionMessage to XCM + let (xcm, fee) = Self::do_convert(envelope.message_id, message.clone())?; log::info!( target: LOG_TARGET, @@ -321,12 +321,12 @@ pub mod pallet { pub fn do_convert( message_id: H256, message: VersionedMessage, - ) -> Result<(Xcm<()>, BalanceOf, VersionedMessage), Error> { - let (mut xcm, fee) = T::MessageConverter::convert(message.clone()) - .map_err(|e| Error::::ConvertMessage(e))?; + ) -> Result<(Xcm<()>, BalanceOf), Error> { + let (mut xcm, fee) = + T::MessageConverter::convert(message).map_err(|e| Error::::ConvertMessage(e))?; // Append the message id as an XCM topic xcm.inner_mut().extend(vec![SetTopic(message_id.into())]); - Ok((xcm, fee, message)) + Ok((xcm, fee)) } pub fn send_xcm(xcm: Xcm<()>, dest: ParaId) -> Result> { diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 9a47e475b8c9..ef3e27c3beac 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -2,12 +2,13 @@ // SPDX-FileCopyrightText: 2023 Snowfork use super::*; -use frame_support::{assert_noop, assert_ok}; +use frame_support::{assert_noop, assert_ok, weights::Weight}; use hex_literal::hex; use snowbridge_core::{inbound::Proof, ChannelId}; use sp_keyring::AccountKeyring as Keyring; use sp_runtime::{DispatchError, TokenError}; use sp_std::convert::From; +use xcm::prelude::{OriginKind, Transact}; use crate::{Error, Event as InboundQueueEvent}; @@ -210,3 +211,35 @@ fn test_set_operating_mode_root_only() { ); }); } + +#[test] +fn test_convert_transact() { + new_tester().execute_with(|| { + let message_id: H256 = [1; 32].into(); + let sender: H160 = hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(); + let fee: u128 = 40_000_000_000; + let weight_at_most = Weight::from_parts(40_000_000, 8_000); + let origin_kind = OriginKind::SovereignAccount; + let payload = hex!("00071468656c6c6f").to_vec(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: 11155111, + command: Command::Transact { + sender, + fee, + weight_ref_time: weight_at_most.ref_time(), + weight_proof_size: weight_at_most.proof_size(), + origin_kind, + payload: payload.clone(), + }, + }); + // Convert the message to XCM + let (xcm, dest_fee) = InboundQueue::do_convert(message_id, message).unwrap(); + let instructions = xcm.into_inner(); + assert_eq!(instructions.len(), 9); + assert_eq!(dest_fee, fee.into()); + let transact = instructions.get(4).unwrap().clone(); + let expected = + Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; + assert_eq!(transact, expected); + }); +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index fc5c258ded71..4b1394df3488 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -563,7 +563,7 @@ fn transact_from_ethereum_to_penpal() { }, }); // Convert the message to XCM - let (xcm, _, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); From 13217f13973b8f9b64089e3185b2ca9702169da2 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 22 Feb 2024 11:52:01 +0800 Subject: [PATCH 17/44] DescendOrigin to inbound-queue first --- bridges/snowbridge/primitives/router/src/inbound/mod.rs | 2 ++ cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index cb36d3cc9dde..f1088655b019 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -330,6 +330,8 @@ where let xcm_fee: Asset = (Location::parent(), fee).into(); let xcm: Xcm<()> = vec![ + // Only our inbound-queue pallet is allowed to invoke `UniversalOrigin` + DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), // Change origin to the bridge. UniversalOrigin(GlobalConsensus(Ethereum { chain_id })), // DescendOrigin to the sender. diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 3954cefd32eb..a07b3db47f4e 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -330,15 +330,16 @@ pub type TrustedTeleporters = (AssetFromChain,); parameter_types! { - pub SiblingBridgeHubLocation: Location = Location::new( + pub SiblingBridgeHubWithEthereumInboundQueueInstance: Location = Location::new( 1, [ Parachain(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID), + PalletInstance(testnet_parachains_constants::rococo::snowbridge::INBOUND_QUEUE_PALLET_INDEX) ] ); pub UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( sp_std::vec![ - (SiblingBridgeHubLocation::get(),GlobalConsensus(EthereumNetwork::get())), + (SiblingBridgeHubWithEthereumInboundQueueInstance::get(),GlobalConsensus(EthereumNetwork::get())), ] ); } From 257e75da50a82098d32e0855040bdf2d21986abf Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 22 Feb 2024 14:30:30 +0800 Subject: [PATCH 18/44] Fix breaking test --- bridges/snowbridge/pallets/inbound-queue/src/test.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index ef3e27c3beac..0ad32467ebd5 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -235,9 +235,9 @@ fn test_convert_transact() { // Convert the message to XCM let (xcm, dest_fee) = InboundQueue::do_convert(message_id, message).unwrap(); let instructions = xcm.into_inner(); - assert_eq!(instructions.len(), 9); + assert_eq!(instructions.len(), 10); assert_eq!(dest_fee, fee.into()); - let transact = instructions.get(4).unwrap().clone(); + let transact = instructions.get(5).unwrap().clone(); let expected = Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; assert_eq!(transact, expected); From e03942a066b09ffd6c16d2a6a5375eba35f3c702 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 22 Feb 2024 21:17:03 +0800 Subject: [PATCH 19/44] First match RegisterToken or SendToken --- .../snowbridge/pallets/inbound-queue/src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index 9ef032d24965..895530a5aa4e 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -283,12 +283,16 @@ pub mod pallet { fee ); - let _ = match message { + match message { + // For RegisterToken|SendToken burning fees for teleport + VersionedMessage::V1(MessageV1 { + command: Command::RegisterToken { .. }, .. + }) | + VersionedMessage::V1(MessageV1 { command: Command::SendToken { .. }, .. }) => + Self::burn_fees(channel.para_id, fee)?, // For transact do nothing here and leave it to dest chain to pay for fees by sender - VersionedMessage::V1(MessageV1 { command: Command::Transact { .. }, .. }) => Ok(()), - // For others burning fees for teleport - _ => Self::burn_fees(channel.para_id, fee), - }?; + VersionedMessage::V1(MessageV1 { command: Command::Transact { .. }, .. }) => (), + }; // Attempt to send XCM to a dest parachain let message_id = Self::send_xcm(xcm, channel.para_id)?; From 698a9e94fbca12c86d8cc2a54d2cb73fab131271 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 22 Feb 2024 22:44:41 +0800 Subject: [PATCH 20/44] Remove deprecated --- bridges/snowbridge/pallets/inbound-queue/src/lib.rs | 3 --- bridges/snowbridge/pallets/inbound-queue/src/mock.rs | 1 - .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 1 - 3 files changed, 5 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index 895530a5aa4e..83bb1f2428d6 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -138,9 +138,6 @@ pub mod pallet { /// To withdraw and deposit an asset. type AssetTransactor: TransactAsset; - - /// Returns the parachain ID we are running with. - type SelfParaId: Get; } #[pallet::hooks] diff --git a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs index 6bda109d6dd5..110f611c6766 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs @@ -257,7 +257,6 @@ impl inbound_queue::Config for Test { type LengthToFee = IdentityFee; type MaxMessageSize = ConstU32<1024>; type AssetTransactor = SuccessfulTransactor; - type SelfParaId = OwnParaId; } pub fn last_events(n: usize) -> Vec { 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 4507a3210095..965d99f00895 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 @@ -574,7 +574,6 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { type WeightInfo = weights::snowbridge_pallet_inbound_queue::WeightInfo; type PricingParameters = EthereumSystem; type AssetTransactor = ::AssetTransactor; - type SelfParaId = parachain_info::Pallet; } impl snowbridge_pallet_outbound_queue::Config for Runtime { From 9968a37a69ba1b2e1439aacf9025d962b9849e8a Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 22 Feb 2024 23:00:00 +0800 Subject: [PATCH 21/44] Use SetAppendix and refund surplus when transact fail --- .../pallets/inbound-queue/src/test.rs | 4 +-- .../primitives/router/src/inbound/mod.rs | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 0ad32467ebd5..a618df200722 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -235,9 +235,9 @@ fn test_convert_transact() { // Convert the message to XCM let (xcm, dest_fee) = InboundQueue::do_convert(message_id, message).unwrap(); let instructions = xcm.into_inner(); - assert_eq!(instructions.len(), 10); + assert_eq!(instructions.len(), 8); assert_eq!(dest_fee, fee.into()); - let transact = instructions.get(5).unwrap().clone(); + let transact = instructions.get(6).unwrap().clone(); let expected = Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; assert_eq!(transact, expected); diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index f1088655b019..53de55fb3486 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -340,25 +340,26 @@ where WithdrawAsset(xcm_fee.clone().into()), // Pay for execution. BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, + SetAppendix(Xcm(vec![ + RefundSurplus, + // Deposit surplus back to sender. + DepositAsset { + assets: Wild(AllCounted(1u32)), + beneficiary: Location { + parents: 1, + interior: Junctions::from([ + GlobalConsensus(Ethereum { chain_id }), + AccountKey20 { network: None, key: sender.into() }, + ]), + }, + }, + ])), // Transact on dest chain. Transact { origin_kind, require_weight_at_most: Weight::from_parts(weight_ref_time, weight_proof_size), call: payload.into(), }, - ExpectTransactStatus(MaybeErrorCode::Success), - RefundSurplus, - // Deposit surplus back to sender. - DepositAsset { - assets: Wild(AllCounted(1u32)), - beneficiary: Location { - parents: 1, - interior: Junctions::from([ - GlobalConsensus(Ethereum { chain_id }), - AccountKey20 { network: None, key: sender.into() }, - ]), - }, - }, ] .into(); From 40ea01a612e68d8c7d830f28785af6a5d65a8677 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 22 Feb 2024 23:12:12 +0800 Subject: [PATCH 22/44] Ignore parents which is meaningless for GlobalConsensus locations --- bridges/snowbridge/primitives/router/src/inbound/mod.rs | 2 +- cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 53de55fb3486..bdb4828348a3 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -346,7 +346,7 @@ where DepositAsset { assets: Wild(AllCounted(1u32)), beneficiary: Location { - parents: 1, + parents: 0, interior: Junctions::from([ GlobalConsensus(Ethereum { chain_id }), AccountKey20 { network: None, key: sender.into() }, diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index a07b3db47f4e..af6710c89495 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -351,8 +351,8 @@ where { fn convert_location(location: &Location) -> Option { match location.unpack() { - (parents, [first_loc, AccountKey20 { network: None, key: sender }]) - if parents == 1 && *first_loc == Junction::from(EthereumNetwork::get()) => + (_, [first_loc, AccountKey20 { network: None, key: sender }]) + if *first_loc == Junction::from(EthereumNetwork::get()) => Some(blake2_256(&(b"AccountKey20", sender).encode()).into()), _ => None, } From 004afd25b949ade440753b04c6d68715b01ff4fc Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 23 Feb 2024 12:30:03 +0800 Subject: [PATCH 23/44] Reuse weight type --- .../pallets/inbound-queue/src/test.rs | 3 +-- .../primitives/router/src/inbound/mod.rs | 21 ++++++------------- .../bridge-hub-rococo/src/tests/snowbridge.rs | 3 +-- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index a618df200722..5b4c7e6ac308 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -226,8 +226,7 @@ fn test_convert_transact() { command: Command::Transact { sender, fee, - weight_ref_time: weight_at_most.ref_time(), - weight_proof_size: weight_at_most.proof_size(), + weight_at_most, origin_kind, payload: payload.clone(), }, diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index bdb4828348a3..76d19122191c 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -64,10 +64,8 @@ pub enum Command { origin_kind: OriginKind, /// XCM execution fee on dest chain fee: u128, - /// The ref_time part of weight_at_most - weight_ref_time: u64, - /// The proof_size part of weight_at_most - weight_proof_size: u64, + /// The weight required at most on dest chain + weight_at_most: Weight, /// The payload of the transact payload: Vec, }, @@ -163,15 +161,13 @@ impl Ok(Self::convert_transact( chain_id, sender, origin_kind, fee, - weight_ref_time, - weight_proof_size, + weight_at_most, payload, )), } @@ -323,8 +319,7 @@ where sender: H160, origin_kind: OriginKind, fee: u128, - weight_ref_time: u64, - weight_proof_size: u64, + weight_at_most: Weight, payload: Vec, ) -> (Xcm<()>, Balance) { let xcm_fee: Asset = (Location::parent(), fee).into(); @@ -355,11 +350,7 @@ where }, ])), // Transact on dest chain. - Transact { - origin_kind, - require_weight_at_most: Weight::from_parts(weight_ref_time, weight_proof_size), - call: payload.into(), - }, + Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, ] .into(); diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 4b1394df3488..1777f5e59caa 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -556,8 +556,7 @@ fn transact_from_ethereum_to_penpal() { command: Command::Transact { sender, fee: XCM_FEE, - weight_ref_time: 40_000_000, - weight_proof_size: 8_000, + weight_at_most: Weight::from_parts(40_000_000, 8_000), origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), }, From 85d2c03a31b59417711043fc989992d2cb5e4b8d Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 23 Feb 2024 16:54:10 +0800 Subject: [PATCH 24/44] Update sender consistent with smoke test --- Cargo.lock | 1 + .../emulated/tests/bridges/bridge-hub-rococo/Cargo.toml | 1 + .../bridges/bridge-hub-rococo/src/tests/snowbridge.rs | 9 ++++----- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6dcce4f9c04..f04c1ba14016 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1945,6 +1945,7 @@ dependencies = [ "emulated-integration-tests-common", "frame-support", "frame-system", + "hex", "hex-literal", "pallet-asset-conversion", "pallet-assets", diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml index b1d51032dc3f..3141e01b5846 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml @@ -14,6 +14,7 @@ workspace = true codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } hex-literal = "0.4.1" +hex = "0.4.3" # Substrate sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 1777f5e59caa..a511acc74504 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -541,11 +541,10 @@ fn send_token_from_ethereum_to_asset_hub_fail_for_insufficient_fund() { #[test] fn transact_from_ethereum_to_penpal() { // Fund sender on penpal so that it can pay execution fees. - let sender: H160 = hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(); - PenpalA::fund_accounts(vec![( - blake2_256(&(b"AccountKey20", sender).encode()).into(), - INITIAL_FUND, - )]); + let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); + let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); + println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); + PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); BridgeHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; From 626ec76393e795301b376a4ce581308fbf9f80d2 Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 26 Feb 2024 10:37:18 +0800 Subject: [PATCH 25/44] Update Cargo.toml --- bridges/snowbridge/Cargo.toml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bridges/snowbridge/Cargo.toml b/bridges/snowbridge/Cargo.toml index a9e9ed9abf95..ca70de1d0e07 100644 --- a/bridges/snowbridge/Cargo.toml +++ b/bridges/snowbridge/Cargo.toml @@ -52,3 +52,16 @@ derivable_impls = { level = "allow", priority = 2 } # false pos stable_sort_primitive = { level = "allow", priority = 2 } # prefer stable sort extra-unused-type-parameters = { level = "allow", priority = 2 } # stylistic default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic + +[workspace.dependencies] +polkavm-linker = "0.8.2" +polkavm-derive = "0.8.0" +log = { version = "0.4.20", default-features = false } +quote = { version = "1.0.33" } +serde = { version = "1.0.197", default-features = false } +serde-big-array = { version = "0.3.2" } +serde_derive = { version = "1.0.117" } +serde_json = { version = "1.0.114", default-features = false } +serde_yaml = { version = "0.9" } +syn = { version = "2.0.50" } +thiserror = { version = "1.0.48" } From 0686fcde7c827360a62d65b569c4f126a6ed7b0a Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 26 Feb 2024 11:00:33 +0800 Subject: [PATCH 26/44] Fix breaking test --- bridges/snowbridge/pallets/system/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bridges/snowbridge/pallets/system/src/lib.rs b/bridges/snowbridge/pallets/system/src/lib.rs index b7f38fb753d3..13abee14b4af 100644 --- a/bridges/snowbridge/pallets/system/src/lib.rs +++ b/bridges/snowbridge/pallets/system/src/lib.rs @@ -79,6 +79,8 @@ use xcm_executor::traits::ConvertLocation; #[cfg(feature = "runtime-benchmarks")] use frame_support::traits::OriginTrait; +pub use pallet::*; + pub type BalanceOf = <::Token as Inspect<::AccountId>>::Balance; pub type AccountIdOf = ::AccountId; From 7cc0d59597dc5a0b507335133230641cf87984a5 Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 26 Feb 2024 16:07:14 +0800 Subject: [PATCH 27/44] Improve tests --- .../pallets/inbound-queue/fixtures/src/lib.rs | 1 + .../fixtures/src/send_call_to_penpal.rs | 41 +++++ bridges/snowbridge/pallets/system/src/lib.rs | 2 +- .../templates/send_call_to_penpal.mustache | 45 +++++ .../templates/send_token_to_penpal.mustache | 45 +++++ .../bridge-hub-rococo/src/tests/snowbridge.rs | 158 +++++++++++++++++- 6 files changed, 285 insertions(+), 7 deletions(-) create mode 100644 bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs create mode 100644 bridges/snowbridge/templates/send_call_to_penpal.mustache create mode 100644 bridges/snowbridge/templates/send_token_to_penpal.mustache diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/lib.rs index 4f3445b29053..6950bcb781df 100644 --- a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/lib.rs @@ -8,6 +8,7 @@ use sp_core::RuntimeDebug; pub mod register_token; pub mod register_token_with_insufficient_fee; +pub mod send_call_to_penpal; pub mod send_token; pub mod send_token_to_penpal; diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs new file mode 100644 index 000000000000..1a47a2eda2e8 --- /dev/null +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork +// Generated, do not edit! +// See ethereum client README.md for instructions to generate + +use crate::InboundQueueFixture; +use hex_literal::hex; +use snowbridge_beacon_primitives::CompactExecutionHeader; +use snowbridge_core::inbound::{Log, Message, Proof}; +use sp_std::vec; + +pub fn make_send_call_to_penpal_message() -> InboundQueueFixture { + InboundQueueFixture { + execution_header: CompactExecutionHeader{ + parent_hash: hex!("e0fa68ceff08e6f024c84f408540372801b209ff8f11481a9dc6bc5db3ce92d3").into(), + block_number: 831, + state_root: hex!("ccc30635f32d558620d45ead60eabbe70dbf179b475fa9cec5a3791fd5be2b78").into(), + receipts_root: hex!("6bba8f0093461e22cd265bc0de44bf7a596db58ecbf44432e6de8b3490deb077").into(), + }, + message: Message { + event_log: Log { + address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), + topics: vec![ + hex!("7153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84f").into(), + hex!("a69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3").into(), + hex!("c9ad11f6e2d2b770f52e7cbe22ba779eb8e5e000e0db4e5032488898bd3529ec").into(), + ], + data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003e00a736aa00000000000290a987b944cb1dcce5564e5fdecd7a54d3de27fe0100902f5009000000000000000000000002688909017d2000071468656c6c6f0000").into(), + }, + proof: Proof { + block_hash: hex!("be15f3cdf217baad8cc5c40d7e2dc1f173ab3bdaa58e5819905bb0c73f46cf78").into(), + tx_index: 0, + data: (vec![ + hex!("6bba8f0093461e22cd265bc0de44bf7a596db58ecbf44432e6de8b3490deb077").to_vec(), + ], vec![ + hex!("f90234822080b9022e02f9022a0183016e01b9010000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000200000000000000000020000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000010000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002004000000000000000000000200000000000000f9011ff9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0a69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3a0c9ad11f6e2d2b770f52e7cbe22ba779eb8e5e000e0db4e5032488898bd3529ecb8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003e00a736aa00000000000290a987b944cb1dcce5564e5fdecd7a54d3de27fe0100902f5009000000000000000000000002688909017d2000071468656c6c6f0000").to_vec(), + ]), + }, + }, + } +} diff --git a/bridges/snowbridge/pallets/system/src/lib.rs b/bridges/snowbridge/pallets/system/src/lib.rs index 13abee14b4af..78915ff00853 100644 --- a/bridges/snowbridge/pallets/system/src/lib.rs +++ b/bridges/snowbridge/pallets/system/src/lib.rs @@ -101,7 +101,7 @@ where } /// Hash the location to produce an agent id -fn agent_id_of(location: &Location) -> Result { +pub fn agent_id_of(location: &Location) -> Result { T::AgentIdOf::convert_location(location).ok_or(Error::::LocationConversionFailed.into()) } diff --git a/bridges/snowbridge/templates/send_call_to_penpal.mustache b/bridges/snowbridge/templates/send_call_to_penpal.mustache new file mode 100644 index 000000000000..22e667cebbba --- /dev/null +++ b/bridges/snowbridge/templates/send_call_to_penpal.mustache @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork +// Generated, do not edit! +// See ethereum client README.md for instructions to generate + +use crate::InboundQueueFixture; +use hex_literal::hex; +use snowbridge_beacon_primitives::CompactExecutionHeader; +use snowbridge_core::inbound::{Log, Message, Proof}; +use sp_std::vec; + +pub fn make_send_call_to_penpal_message() -> InboundQueueFixture { + InboundQueueFixture { + execution_header: CompactExecutionHeader{ + parent_hash: hex!("{{InboundMessageTest.ExecutionHeader.ParentHash}}").into(), + block_number: {{InboundMessageTest.ExecutionHeader.BlockNumber}}, + state_root: hex!("{{InboundMessageTest.ExecutionHeader.StateRoot}}").into(), + receipts_root: hex!("{{InboundMessageTest.ExecutionHeader.ReceiptsRoot}}").into(), + }, + message: Message { + event_log: Log { + address: hex!("{{InboundMessageTest.Message.EventLog.Address}}").into(), + topics: vec![ + {{#InboundMessageTest.Message.EventLog.Topics}} + hex!("{{.}}").into(), + {{/InboundMessageTest.Message.EventLog.Topics}} + ], + data: hex!("{{InboundMessageTest.Message.EventLog.Data}}").into(), + }, + proof: Proof { + block_hash: hex!("{{InboundMessageTest.Message.Proof.BlockHash}}").into(), + tx_index: {{InboundMessageTest.Message.Proof.TxIndex}}, + data: (vec![ + {{#InboundMessageTest.Message.Proof.Data.Keys}} + hex!("{{.}}").to_vec(), + {{/InboundMessageTest.Message.Proof.Data.Keys}} + ], vec![ + {{#InboundMessageTest.Message.Proof.Data.Values}} + hex!("{{.}}").to_vec(), + {{/InboundMessageTest.Message.Proof.Data.Values}} + ]), + }, + }, + } +} diff --git a/bridges/snowbridge/templates/send_token_to_penpal.mustache b/bridges/snowbridge/templates/send_token_to_penpal.mustache new file mode 100644 index 000000000000..ae3de3d6ea55 --- /dev/null +++ b/bridges/snowbridge/templates/send_token_to_penpal.mustache @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: Apache-2.0 +// SPDX-FileCopyrightText: 2023 Snowfork +// Generated, do not edit! +// See ethereum client README.md for instructions to generate + +use crate::InboundQueueFixture; +use hex_literal::hex; +use snowbridge_beacon_primitives::CompactExecutionHeader; +use snowbridge_core::inbound::{Log, Message, Proof}; +use sp_std::vec; + +pub fn make_send_token_to_penpal_message() -> InboundQueueFixture { + InboundQueueFixture { + execution_header: CompactExecutionHeader{ + parent_hash: hex!("{{InboundMessageTest.ExecutionHeader.ParentHash}}").into(), + block_number: {{InboundMessageTest.ExecutionHeader.BlockNumber}}, + state_root: hex!("{{InboundMessageTest.ExecutionHeader.StateRoot}}").into(), + receipts_root: hex!("{{InboundMessageTest.ExecutionHeader.ReceiptsRoot}}").into(), + }, + message: Message { + event_log: Log { + address: hex!("{{InboundMessageTest.Message.EventLog.Address}}").into(), + topics: vec![ + {{#InboundMessageTest.Message.EventLog.Topics}} + hex!("{{.}}").into(), + {{/InboundMessageTest.Message.EventLog.Topics}} + ], + data: hex!("{{InboundMessageTest.Message.EventLog.Data}}").into(), + }, + proof: Proof { + block_hash: hex!("{{InboundMessageTest.Message.Proof.BlockHash}}").into(), + tx_index: {{InboundMessageTest.Message.Proof.TxIndex}}, + data: (vec![ + {{#InboundMessageTest.Message.Proof.Data.Keys}} + hex!("{{.}}").to_vec(), + {{/InboundMessageTest.Message.Proof.Data.Keys}} + ], vec![ + {{#InboundMessageTest.Message.Proof.Data.Values}} + hex!("{{.}}").to_vec(), + {{/InboundMessageTest.Message.Proof.Data.Values}} + ]), + }, + }, + } +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index a511acc74504..1ef753b16512 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -19,12 +19,12 @@ use emulated_integration_tests_common::xcm_emulator::ConvertLocation; use frame_support::pallet_prelude::TypeInfo; use hex_literal::hex; use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender; -use snowbridge_core::outbound::OperatingMode; +use snowbridge_core::{outbound::OperatingMode, Channel, ChannelId}; use snowbridge_pallet_inbound_queue_fixtures::{ register_token::make_register_token_message, register_token_with_insufficient_fee::make_register_token_with_infufficient_fee_message, - send_token::make_send_token_message, send_token_to_penpal::make_send_token_to_penpal_message, - InboundQueueFixture, + send_call_to_penpal::make_send_call_to_penpal_message, send_token::make_send_token_message, + send_token_to_penpal::make_send_token_to_penpal_message, InboundQueueFixture, }; use snowbridge_pallet_system; use snowbridge_router_primitives::inbound::{ @@ -42,6 +42,10 @@ const TREASURY_ACCOUNT: [u8; 32] = const WETH: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"); const ETHEREUM_DESTINATION_ADDRESS: [u8; 20] = hex!("44a57ee2f2FCcb85FDa2B0B18EBD0D8D2333700e"); const XCM_FEE: u128 = 40_000_000_000; +const XCM_WEIGHT: Weight = Weight::from_parts(40_000_000, 8_000); +const INSUFFICIENT_XCM_FEE: u128 = 1_000; +const INSUFFICIENT_XCM_WEIGHT: Weight = Weight::from_parts(1_000, 1_000); +const INSUFFICIENT_FUND: u128 = 1_000; #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum ControlCall { @@ -545,6 +549,101 @@ fn transact_from_ethereum_to_penpal() { let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); + BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Runtime = ::Runtime; + + let agent_id = snowbridge_pallet_system::agent_id_of::(&Location::new( + 1, + [Parachain(PenpalA::para_id().into())], + )) + .unwrap(); + snowbridge_pallet_system::Agents::::insert(agent_id, ()); + let channel_id: ChannelId = PenpalA::para_id().into(); + snowbridge_pallet_system::Channels::::insert( + channel_id, + Channel { agent_id, para_id: PenpalA::para_id() }, + ); + + // Construct Send call to penpal message and sent to inbound queue + send_inbound_message(make_send_call_to_penpal_message()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check that system event remarked on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::System(frame_system::Event::Remarked { .. }) => {}, + ] + ); + }); +} + +#[test] +fn transact_from_ethereum_to_penpal_insufficient_fee() { + // Fund sender on penpal so that it can pay execution fees. + let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); + let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); + println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); + PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender, + fee: INSUFFICIENT_XCM_FEE, + weight_at_most: XCM_WEIGHT, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + }, + }); + // Convert the message to XCM + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check xcm execution fails on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success:false,.. }) => {}, + ] + ); + }); +} + +#[test] +fn transact_from_ethereum_to_penpal_sender_insufficient_fund() { + // Fund sender on penpal so that it can pay execution fees. + let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); + let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); + println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); + PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INSUFFICIENT_FUND)]); BridgeHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -555,7 +654,7 @@ fn transact_from_ethereum_to_penpal() { command: Command::Transact { sender, fee: XCM_FEE, - weight_at_most: Weight::from_parts(40_000_000, 8_000), + weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), }, @@ -575,11 +674,58 @@ fn transact_from_ethereum_to_penpal() { PenpalA::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; - // Check that system event remarked on PenPal + // Check xcm execution fails on PenPal assert_expected_events!( PenpalA, vec![ - RuntimeEvent::System(frame_system::Event::Remarked { .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success:false,.. }) => {}, + ] + ); + }); +} + +#[test] +fn transact_from_ethereum_to_penpal_insufficient_weight() { + // Fund sender on penpal so that it can pay execution fees. + let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); + let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); + println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); + PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender, + fee: XCM_FEE, + weight_at_most: INSUFFICIENT_XCM_WEIGHT, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + }, + }); + // Convert the message to XCM + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check xcm execution fails on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success:false,.. }) => {}, ] ); }); From 7b916e5ff30fa614c7a3f7168974c5f2bab9aab4 Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 6 Mar 2024 22:11:31 +0800 Subject: [PATCH 28/44] Add TransactFeeMode --- .../pallets/inbound-queue/src/test.rs | 2 + .../primitives/router/src/inbound/mod.rs | 45 +++++++-- .../bridge-hub-rococo/src/tests/snowbridge.rs | 91 +++++++++++++++++-- .../runtimes/testing/penpal/src/xcm_config.rs | 5 +- 4 files changed, 127 insertions(+), 16 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 02278f2826db..aafe937a468a 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -5,6 +5,7 @@ use super::*; use frame_support::{assert_noop, assert_ok, weights::Weight}; use hex_literal::hex; use snowbridge_core::{inbound::Proof, ChannelId}; +use snowbridge_router_primitives::inbound::TransactFeeMode; use sp_keyring::AccountKeyring as Keyring; use sp_runtime::DispatchError; use sp_std::convert::From; @@ -270,6 +271,7 @@ fn test_convert_transact() { weight_at_most, origin_kind, payload: payload.clone(), + fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 76d19122191c..b5d47a1039c8 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -62,6 +62,8 @@ pub enum Command { sender: H160, /// OriginKind origin_kind: OriginKind, + /// FeeMode + fee_mode: TransactFeeMode, /// XCM execution fee on dest chain fee: u128, /// The weight required at most on dest chain @@ -71,6 +73,15 @@ pub enum Command { }, } +/// TransactFeeMode +#[derive(Clone, Encode, Decode, RuntimeDebug)] +pub enum TransactFeeMode { + /// Transact Fee paid full on Ethereum side upfront + OnEthereum, + /// Transact Fee paid on destination chain by prefunded sender + OnSubstrate, +} + /// Destination for bridged tokens #[derive(Clone, Encode, Decode, RuntimeDebug)] pub enum Destination { @@ -161,11 +172,12 @@ impl Ok(Self::convert_transact( chain_id, sender, origin_kind, + fee_mode, fee, weight_at_most, payload, @@ -318,23 +330,39 @@ where chain_id: u64, sender: H160, origin_kind: OriginKind, + fee_mode: TransactFeeMode, fee: u128, weight_at_most: Weight, payload: Vec, ) -> (Xcm<()>, Balance) { let xcm_fee: Asset = (Location::parent(), fee).into(); - let xcm: Xcm<()> = vec![ + let mut message = vec![ // Only our inbound-queue pallet is allowed to invoke `UniversalOrigin` DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), // Change origin to the bridge. UniversalOrigin(GlobalConsensus(Ethereum { chain_id })), // DescendOrigin to the sender. DescendOrigin(AccountKey20 { network: None, key: sender.into() }.into()), - // Withdraw fees from sender to pay the xcm execution - WithdrawAsset(xcm_fee.clone().into()), - // Pay for execution. - BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, + ]; + message = match fee_mode { + TransactFeeMode::OnSubstrate => { + message.extend(vec![ + // Withdraw fees from sender to pay the xcm execution + WithdrawAsset(xcm_fee.clone().into()), + // Pay for execution. + BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, + ]); + message + }, + TransactFeeMode::OnEthereum => { + let mut unpaid = + vec![UnpaidExecution { weight_limit: Unlimited, check_origin: None }]; + unpaid.extend(message); + unpaid + }, + }; + message.extend(vec![ SetAppendix(Xcm(vec![ RefundSurplus, // Deposit surplus back to sender. @@ -351,10 +379,9 @@ where ])), // Transact on dest chain. Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, - ] - .into(); + ]); - (xcm, fee.into()) + (message.into(), fee.into()) } } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 10fb3450f778..6de36e548369 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -23,12 +23,12 @@ use snowbridge_core::{outbound::OperatingMode, Channel, ChannelId}; use snowbridge_pallet_inbound_queue_fixtures::{ register_token::make_register_token_message, register_token_with_insufficient_fee::make_register_token_with_infufficient_fee_message, - send_call_to_penpal::make_send_call_to_penpal_message, send_token::make_send_token_message, - send_token_to_penpal::make_send_token_to_penpal_message, InboundQueueFixture, + send_token::make_send_token_message, send_token_to_penpal::make_send_token_to_penpal_message, + InboundQueueFixture, }; use snowbridge_pallet_system; use snowbridge_router_primitives::inbound::{ - Command, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, + Command, GlobalConsensusEthereumConvertsFor, MessageV1, TransactFeeMode, VersionedMessage, }; use sp_core::{H160, H256}; use sp_io::hashing::blake2_256; @@ -543,7 +543,7 @@ fn send_token_from_ethereum_to_asset_hub_fail_for_insufficient_fund() { } #[test] -fn transact_from_ethereum_to_penpal() { +fn transact_from_ethereum_to_penpal_fee_paid_on_substrate() { // Fund sender on penpal so that it can pay execution fees. let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); @@ -567,8 +567,22 @@ fn transact_from_ethereum_to_penpal() { Channel { agent_id, para_id: PenpalA::para_id() }, ); - // Construct Send call to penpal message and sent to inbound queue - send_inbound_message(make_send_call_to_penpal_message()).unwrap(); + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender, + fee: XCM_FEE, + weight_at_most: XCM_WEIGHT, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + fee_mode: TransactFeeMode::OnSubstrate, + }, + }); + // Convert the message to XCM + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); assert_expected_events!( BridgeHubRococo, @@ -610,6 +624,7 @@ fn transact_from_ethereum_to_penpal_insufficient_fee() { weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), + fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM @@ -657,6 +672,7 @@ fn transact_from_ethereum_to_penpal_sender_insufficient_fund() { weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), + fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM @@ -704,6 +720,7 @@ fn transact_from_ethereum_to_penpal_insufficient_weight() { weight_at_most: INSUFFICIENT_XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), + fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM @@ -730,3 +747,65 @@ fn transact_from_ethereum_to_penpal_insufficient_weight() { ); }); } + +#[test] +fn transact_from_ethereum_to_penpal_fee_paid_on_ethereum() { + // Fund sender on penpal so that it can pay execution fees. + let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); + let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); + println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); + PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); + BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Runtime = ::Runtime; + + let agent_id = snowbridge_pallet_system::agent_id_of::(&Location::new( + 1, + [Parachain(PenpalA::para_id().into())], + )) + .unwrap(); + snowbridge_pallet_system::Agents::::insert(agent_id, ()); + let channel_id: ChannelId = PenpalA::para_id().into(); + snowbridge_pallet_system::Channels::::insert( + channel_id, + Channel { agent_id, para_id: PenpalA::para_id() }, + ); + + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender, + fee: XCM_FEE, + weight_at_most: XCM_WEIGHT, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + fee_mode: TransactFeeMode::OnEthereum, + }, + }); + // Convert the message to XCM + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check that system event remarked on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::System(frame_system::Event::Remarked { .. }) => {}, + ] + ); + }); +} diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 1066c24551a5..1b90c5ab16b0 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -33,7 +33,7 @@ use frame_support::{ parameter_types, traits::{ fungibles::{self, Balanced, Credit}, - ConstU32, Contains, ContainsPair, Everything, Get, Nothing, + ConstU32, Contains, ContainsPair, Equals, Everything, Get, Nothing, }, weights::Weight, }; @@ -203,6 +203,8 @@ pub type Barrier = TrailingSetTopicAsId<( TakeWeightCredit, // Expected responses are OK. AllowKnownQueryResponses, + // Allow from BridgeHub + AllowExplicitUnpaidExecutionFrom>, // Allow XCMs with some computed origins to pass through. WithComputedOrigin< ( @@ -340,6 +342,7 @@ parameter_types! { (SiblingBridgeHubWithEthereumInboundQueueInstance::get(),GlobalConsensus(EthereumNetwork::get())), ] ); + pub SiblingBridgeHub: Location = Location::new(1, [Parachain(bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID)]); } pub struct GlobalConsensusEthereumAddressConvertsFor(PhantomData); From 15759a480c9f5715971422c91b0b253202c61ee5 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 7 Mar 2024 01:57:01 +0800 Subject: [PATCH 29/44] Improve convert logic --- .../primitives/router/src/inbound/mod.rs | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index b5d47a1039c8..45c233cb941e 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -352,35 +352,46 @@ where WithdrawAsset(xcm_fee.clone().into()), // Pay for execution. BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, + SetAppendix(Xcm(vec![ + RefundSurplus, + // Deposit surplus back to sender. + DepositAsset { + assets: Wild(AllCounted(1u32)), + beneficiary: Location { + parents: 0, + interior: Junctions::from([ + GlobalConsensus(Ethereum { chain_id }), + AccountKey20 { network: None, key: sender.into() }, + ]), + }, + }, + ])), + // Transact on dest chain. + Transact { + origin_kind, + require_weight_at_most: weight_at_most, + call: payload.into(), + }, ]); message }, TransactFeeMode::OnEthereum => { - let mut unpaid = - vec![UnpaidExecution { weight_limit: Unlimited, check_origin: None }]; + let mut unpaid = vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + // Actually BurnAsset does nothing on dest chain, included here only for + // the dest chain to implement a custom Barrier which inspect the fee as + // expected(i.e. can cover the transact cost to avoid spamming) + BurnAsset(xcm_fee.clone().into()), + Transact { + origin_kind, + require_weight_at_most: weight_at_most, + call: payload.into(), + }, + ]; unpaid.extend(message); unpaid }, }; - message.extend(vec![ - SetAppendix(Xcm(vec![ - RefundSurplus, - // Deposit surplus back to sender. - DepositAsset { - assets: Wild(AllCounted(1u32)), - beneficiary: Location { - parents: 0, - interior: Junctions::from([ - GlobalConsensus(Ethereum { chain_id }), - AccountKey20 { network: None, key: sender.into() }, - ]), - }, - }, - ])), - // Transact on dest chain. - Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, - ]); - (message.into(), fee.into()) } } From 04a339e67c2ce76856002c4c25ed5db62d8210c7 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 7 Mar 2024 09:45:27 +0800 Subject: [PATCH 30/44] Fix UniversalLocation --- cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 1b90c5ab16b0..3402b0b5d290 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -65,9 +65,10 @@ use xcm_executor::{ parameter_types! { pub const RelayLocation: Location = Location::parent(); - pub const RelayNetwork: Option = None; + pub const RelayNetwork: NetworkId = Rococo; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - pub UniversalLocation: InteriorLocation = [Parachain(ParachainInfo::parachain_id().into())].into(); + pub UniversalLocation: InteriorLocation = + [GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into(); } /// Type for specifying how a `Location` can be converted into an `AccountId`. This is used From c18f77115499f2806999ecf17c80261a7c178d42 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 7 Mar 2024 11:15:18 +0800 Subject: [PATCH 31/44] AllowUnpaidExecutionFromSnowBridgeWithFeeChecked --- .../bridge-hub-rococo/src/tests/snowbridge.rs | 57 +++++++++++++++++++ .../runtimes/testing/penpal/src/xcm_config.rs | 57 +++++++++++++++---- 2 files changed, 103 insertions(+), 11 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 6de36e548369..20b5a497edee 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -809,3 +809,60 @@ fn transact_from_ethereum_to_penpal_fee_paid_on_ethereum() { ); }); } + +#[test] +fn transact_from_ethereum_to_penpal_fee_paid_on_ethereum_fail_for_insufficient_fee() { + BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type Runtime = ::Runtime; + + let agent_id = snowbridge_pallet_system::agent_id_of::(&Location::new( + 1, + [Parachain(PenpalA::para_id().into())], + )) + .unwrap(); + snowbridge_pallet_system::Agents::::insert(agent_id, ()); + let channel_id: ChannelId = PenpalA::para_id().into(); + snowbridge_pallet_system::Channels::::insert( + channel_id, + Channel { agent_id, para_id: PenpalA::para_id() }, + ); + + let message_id: H256 = [1; 32].into(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::Transact { + sender: hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(), + fee: INSUFFICIENT_XCM_FEE, + weight_at_most: XCM_WEIGHT, + origin_kind: OriginKind::SovereignAccount, + payload: hex!("00071468656c6c6f").to_vec(), + fee_mode: TransactFeeMode::OnEthereum, + }, + }); + // Convert the message to XCM + let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + // Send the XCM + let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + // Check xcm execution fails on PenPal + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed{ .. }) => {}, + ] + ); + }); +} diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 3402b0b5d290..2355b6b6031a 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -30,10 +30,10 @@ use super::{ use codec::Encode; use core::marker::PhantomData; use frame_support::{ - parameter_types, + ensure, parameter_types, traits::{ fungibles::{self, Balanced, Credit}, - ConstU32, Contains, ContainsPair, Equals, Everything, Get, Nothing, + ConstU32, Contains, ContainsPair, Equals, Everything, Get, Nothing, ProcessMessageError, }, weights::Weight, }; @@ -45,21 +45,21 @@ use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; use sp_io::hashing::blake2_256; use sp_runtime::traits::Zero; -use sp_std::collections::btree_set::BTreeSet; +use sp_std::{collections::btree_set::BTreeSet, ops::ControlFlow}; use testnet_parachains_constants::rococo::snowbridge::EthereumNetwork; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, - ConvertedConcreteId, EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, - FungibleAdapter, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, NoChecking, - ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, - SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, StartsWith, TakeWeightCredit, TrailingSetTopicAsId, - UsingComponents, WithComputedOrigin, WithUniqueTopic, + ConvertedConcreteId, CreateMatcher, EnsureXcmOrigin, FixedWeightBounds, + FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, IsConcrete, LocalMint, + MatchXcm, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, StartsWith, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, }; use xcm_executor::{ - traits::{ConvertLocation, JustTry}, + traits::{ConvertLocation, JustTry, Properties, ShouldExecute, WeightTrader}, XcmExecutor, }; @@ -200,12 +200,47 @@ impl Contains for CommonGoodAssetsParachain { } } +pub struct AllowUnpaidExecutionFromSnowBridgeWithFeeChecked(PhantomData); +impl> ShouldExecute for AllowUnpaidExecutionFromSnowBridgeWithFeeChecked { + fn should_execute( + origin: &Location, + instructions: &mut [Instruction], + max_weight: Weight, + _properties: &mut Properties, + ) -> Result<(), ProcessMessageError> { + log::trace!( + target: "xcm::barriers", + "AllowUnpaidExecutionFromSnowBridgeWithFeeChecked origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", + origin, instructions, max_weight, _properties, + ); + ensure!(T::contains(origin), ProcessMessageError::Unsupported); + let mut fee_assets = xcm::prelude::Assets::default(); + instructions.matcher().match_next_inst_while( + |_| true, + |inst| match inst { + BurnAsset(assets) => { + fee_assets = assets.clone(); + Ok(ControlFlow::Break(())) + }, + + _ => Ok(ControlFlow::Continue(())), + }, + )?; + let mut trader = ::Trader::new(); + let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None }; + trader + .buy_weight(max_weight, fee_assets.into(), &ctx) + .map_err(|_| ProcessMessageError::Unsupported)?; + Ok(()) + } +} + pub type Barrier = TrailingSetTopicAsId<( TakeWeightCredit, // Expected responses are OK. AllowKnownQueryResponses, // Allow from BridgeHub - AllowExplicitUnpaidExecutionFrom>, + AllowUnpaidExecutionFromSnowBridgeWithFeeChecked>, // Allow XCMs with some computed origins to pass through. WithComputedOrigin< ( From 362e41404055877a683026e232a325bb7a8acc51 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 19 Mar 2024 17:39:54 +0800 Subject: [PATCH 32/44] Remove feeMode and fully charge all cost on Ethereum --- .../pallets/inbound-queue/src/test.rs | 6 +- .../primitives/router/src/inbound/mod.rs | 70 ++---------- .../bridge-hub-rococo/src/tests/snowbridge.rs | 103 +----------------- 3 files changed, 11 insertions(+), 168 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index aafe937a468a..7fd88e1d740e 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -5,7 +5,6 @@ use super::*; use frame_support::{assert_noop, assert_ok, weights::Weight}; use hex_literal::hex; use snowbridge_core::{inbound::Proof, ChannelId}; -use snowbridge_router_primitives::inbound::TransactFeeMode; use sp_keyring::AccountKeyring as Keyring; use sp_runtime::DispatchError; use sp_std::convert::From; @@ -271,15 +270,14 @@ fn test_convert_transact() { weight_at_most, origin_kind, payload: payload.clone(), - fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM let (xcm, dest_fee) = InboundQueue::do_convert(message_id, message).unwrap(); let instructions = xcm.into_inner(); - assert_eq!(instructions.len(), 8); + assert_eq!(instructions.len(), 7); assert_eq!(dest_fee, fee.into()); - let transact = instructions.get(6).unwrap().clone(); + let transact = instructions.get(2).unwrap().clone(); let expected = Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; assert_eq!(transact, expected); diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 45c233cb941e..39662a46e285 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -62,8 +62,6 @@ pub enum Command { sender: H160, /// OriginKind origin_kind: OriginKind, - /// FeeMode - fee_mode: TransactFeeMode, /// XCM execution fee on dest chain fee: u128, /// The weight required at most on dest chain @@ -73,15 +71,6 @@ pub enum Command { }, } -/// TransactFeeMode -#[derive(Clone, Encode, Decode, RuntimeDebug)] -pub enum TransactFeeMode { - /// Transact Fee paid full on Ethereum side upfront - OnEthereum, - /// Transact Fee paid on destination chain by prefunded sender - OnSubstrate, -} - /// Destination for bridged tokens #[derive(Clone, Encode, Decode, RuntimeDebug)] pub enum Destination { @@ -172,12 +161,11 @@ impl Ok(Self::convert_transact( chain_id, sender, origin_kind, - fee_mode, fee, weight_at_most, payload, @@ -330,14 +318,19 @@ where chain_id: u64, sender: H160, origin_kind: OriginKind, - fee_mode: TransactFeeMode, fee: u128, weight_at_most: Weight, payload: Vec, ) -> (Xcm<()>, Balance) { let xcm_fee: Asset = (Location::parent(), fee).into(); - let mut message = vec![ + let message = vec![ + UnpaidExecution { weight_limit: Unlimited, check_origin: None }, + // Actually BurnAsset does nothing on dest chain, included here only for + // the dest chain to implement a custom Barrier which inspect the fee as + // expected(i.e. can cover the transact cost to avoid spamming) + BurnAsset(xcm_fee.clone().into()), + Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, // Only our inbound-queue pallet is allowed to invoke `UniversalOrigin` DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), // Change origin to the bridge. @@ -345,53 +338,6 @@ where // DescendOrigin to the sender. DescendOrigin(AccountKey20 { network: None, key: sender.into() }.into()), ]; - message = match fee_mode { - TransactFeeMode::OnSubstrate => { - message.extend(vec![ - // Withdraw fees from sender to pay the xcm execution - WithdrawAsset(xcm_fee.clone().into()), - // Pay for execution. - BuyExecution { fees: xcm_fee.clone(), weight_limit: Unlimited }, - SetAppendix(Xcm(vec![ - RefundSurplus, - // Deposit surplus back to sender. - DepositAsset { - assets: Wild(AllCounted(1u32)), - beneficiary: Location { - parents: 0, - interior: Junctions::from([ - GlobalConsensus(Ethereum { chain_id }), - AccountKey20 { network: None, key: sender.into() }, - ]), - }, - }, - ])), - // Transact on dest chain. - Transact { - origin_kind, - require_weight_at_most: weight_at_most, - call: payload.into(), - }, - ]); - message - }, - TransactFeeMode::OnEthereum => { - let mut unpaid = vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - // Actually BurnAsset does nothing on dest chain, included here only for - // the dest chain to implement a custom Barrier which inspect the fee as - // expected(i.e. can cover the transact cost to avoid spamming) - BurnAsset(xcm_fee.clone().into()), - Transact { - origin_kind, - require_weight_at_most: weight_at_most, - call: payload.into(), - }, - ]; - unpaid.extend(message); - unpaid - }, - }; (message.into(), fee.into()) } } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index d6d04d01b74e..09a28d8eee78 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -28,7 +28,7 @@ use snowbridge_pallet_inbound_queue_fixtures::{ }; use snowbridge_pallet_system; use snowbridge_router_primitives::inbound::{ - Command, GlobalConsensusEthereumConvertsFor, MessageV1, TransactFeeMode, VersionedMessage, + Command, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, }; use sp_core::{H160, H256}; use sp_io::hashing::blake2_256; @@ -45,7 +45,6 @@ const XCM_FEE: u128 = 40_000_000_000; const XCM_WEIGHT: Weight = Weight::from_parts(40_000_000, 8_000); const INSUFFICIENT_XCM_FEE: u128 = 1_000; const INSUFFICIENT_XCM_WEIGHT: Weight = Weight::from_parts(1_000, 1_000); -const INSUFFICIENT_FUND: u128 = 1_000; #[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] pub enum ControlCall { @@ -574,7 +573,6 @@ fn transact_from_ethereum_to_penpal_fee_paid_on_substrate() { weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), - fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM @@ -602,102 +600,6 @@ fn transact_from_ethereum_to_penpal_fee_paid_on_substrate() { }); } -#[test] -fn transact_from_ethereum_to_penpal_insufficient_fee() { - // Fund sender on penpal so that it can pay execution fees. - let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); - let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); - println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); - PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); - - BridgeHubRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::Transact { - sender, - fee: INSUFFICIENT_XCM_FEE, - weight_at_most: XCM_WEIGHT, - origin_kind: OriginKind::SovereignAccount, - payload: hex!("00071468656c6c6f").to_vec(), - fee_mode: TransactFeeMode::OnSubstrate, - }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); - - assert_expected_events!( - BridgeHubRococo, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - PenpalA::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check xcm execution fails on PenPal - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success:false,.. }) => {}, - ] - ); - }); -} - -#[test] -fn transact_from_ethereum_to_penpal_sender_insufficient_fund() { - // Fund sender on penpal so that it can pay execution fees. - let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); - let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); - println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); - PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INSUFFICIENT_FUND)]); - - BridgeHubRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - let message_id: H256 = [1; 32].into(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::Transact { - sender, - fee: XCM_FEE, - weight_at_most: XCM_WEIGHT, - origin_kind: OriginKind::SovereignAccount, - payload: hex!("00071468656c6c6f").to_vec(), - fee_mode: TransactFeeMode::OnSubstrate, - }, - }); - // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); - // Send the XCM - let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); - - assert_expected_events!( - BridgeHubRococo, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - PenpalA::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - // Check xcm execution fails on PenPal - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed { success:false,.. }) => {}, - ] - ); - }); -} - #[test] fn transact_from_ethereum_to_penpal_insufficient_weight() { // Fund sender on penpal so that it can pay execution fees. @@ -718,7 +620,6 @@ fn transact_from_ethereum_to_penpal_insufficient_weight() { weight_at_most: INSUFFICIENT_XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), - fee_mode: TransactFeeMode::OnSubstrate, }, }); // Convert the message to XCM @@ -780,7 +681,6 @@ fn transact_from_ethereum_to_penpal_fee_paid_on_ethereum() { weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), - fee_mode: TransactFeeMode::OnEthereum, }, }); // Convert the message to XCM @@ -837,7 +737,6 @@ fn transact_from_ethereum_to_penpal_fee_paid_on_ethereum_fail_for_insufficient_f weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, payload: hex!("00071468656c6c6f").to_vec(), - fee_mode: TransactFeeMode::OnEthereum, }, }); // Convert the message to XCM From 9d0af91c2134a13dca49f9522e31d6a5ba7c5fb8 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 11 Apr 2024 09:38:57 +0800 Subject: [PATCH 33/44] Fix build error --- Cargo.lock | 1 - bridges/snowbridge/Cargo.lock | 511 ++++++++---------- .../fixtures/src/send_call_to_penpal.rs | 41 +- .../runtimes/testing/penpal/Cargo.toml | 2 - 4 files changed, 261 insertions(+), 294 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d4494cc8b79..207dd6cf2e86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11668,7 +11668,6 @@ name = "penpal-runtime" version = "0.14.0" dependencies = [ "assets-common", - "bp-bridge-hub-rococo", "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", diff --git a/bridges/snowbridge/Cargo.lock b/bridges/snowbridge/Cargo.lock index f090b5a0395d..09239d833218 100644 --- a/bridges/snowbridge/Cargo.lock +++ b/bridges/snowbridge/Cargo.lock @@ -43,7 +43,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -106,7 +106,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" dependencies = [ "alloy-rlp-derive", - "arrayvec 0.7.4", + "arrayvec", "bytes", ] @@ -118,7 +118,7 @@ checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -133,7 +133,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", "syn-solidity", "tiny-keccak", ] @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad32ce52e4161730f7098c077cd2ed6229b5804ccf99e5366be1ab72a98b4e1" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" [[package]] name = "approx" @@ -189,6 +189,20 @@ dependencies = [ "num-traits", ] +[[package]] +name = "aquamarine" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1da02abba9f9063d786eab1509833ebb2fac0f966862ca59439c76b9c566760" +dependencies = [ + "include_dir", + "itertools", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "aquamarine" version = "0.5.0" @@ -200,7 +214,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -568,12 +582,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "arrayvec" version = "0.7.4" @@ -639,7 +647,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -661,7 +669,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -698,7 +706,7 @@ dependencies = [ "ark-std 0.4.0", "dleq_vrf", "fflonk", - "merlin 3.0.0", + "merlin", "rand_chacha 0.3.1", "rand_core 0.6.4", "ring", @@ -735,19 +743,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bip39" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f" -dependencies = [ - "bitcoin_hashes", - "rand", - "rand_core 0.6.4", - "serde", - "unicode-normalization", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -763,11 +758,21 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + [[package]] name = "bitcoin_hashes" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "hex-conservative", +] [[package]] name = "bitflags" @@ -810,29 +815,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", - "arrayvec 0.7.4", + "arrayvec", "constant_time_eq", ] -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -841,16 +834,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", + "generic-array", ] [[package]] @@ -1119,12 +1103,6 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "bytemuck" version = "1.14.3" @@ -1233,7 +1211,7 @@ dependencies = [ "ark-std 0.4.0", "fflonk", "getrandom_or_panic", - "merlin 3.0.0", + "merlin", "rand_chacha 0.3.1", ] @@ -1402,7 +1380,7 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", "subtle", "zeroize", @@ -1414,7 +1392,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.7", + "generic-array", "rand_core 0.6.4", "typenum", ] @@ -1425,17 +1403,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.7", - "subtle", -] - -[[package]] -name = "crypto-mac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25fab6889090c8133f3deb8f73ba3c65a7f456f66436fc012a1b1e272b1e103e" -dependencies = [ - "generic-array 0.14.7", + "generic-array", "subtle", ] @@ -1474,6 +1442,7 @@ dependencies = [ "pallet-message-queue", "parity-scale-codec", "polkadot-parachain-primitives", + "polkadot-runtime-common", "polkadot-runtime-parachains", "scale-info", "sp-core", @@ -1496,7 +1465,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -1598,7 +1567,6 @@ dependencies = [ "frame-support", "log", "pallet-asset-conversion", - "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-runtime-common", "polkadot-runtime-parachains", @@ -1623,19 +1591,6 @@ dependencies = [ "sp-trie", ] -[[package]] -name = "curve25519-dalek" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" -dependencies = [ - "byteorder", - "digest 0.8.1", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -1674,7 +1629,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -1701,7 +1656,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -1718,7 +1673,7 @@ checksum = "5d914fcc6452d133236ee067a9538be25ba6a644a450e1a6c617da84bf029854" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -1766,22 +1721,13 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -1808,7 +1754,7 @@ dependencies = [ "ark-serialize 0.4.2", "ark-std 0.4.0", "ark-transcript", - "arrayvec 0.7.4", + "arrayvec", "zeroize", ] @@ -1833,7 +1779,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.50", + "syn 2.0.58", "termcolor", "toml", "walkdir", @@ -1882,6 +1828,7 @@ dependencies = [ "digest 0.10.7", "elliptic-curve", "rfc6979", + "serdect", "signature", "spki", ] @@ -1940,11 +1887,12 @@ dependencies = [ "crypto-bigint", "digest 0.10.7", "ff", - "generic-array 0.14.7", + "generic-array", "group", "pkcs8", "rand_core 0.6.4", "sec1", + "serdect", "subtle", "zeroize", ] @@ -1972,7 +1920,7 @@ checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -1983,7 +1931,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -2072,15 +2020,9 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -2105,7 +2047,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "139834ddba373bbdd213dffe02c8d110508dcf1726c2be27e8d1f7d7e1856418" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "auto_impl", "bytes", ] @@ -2130,7 +2072,7 @@ dependencies = [ "ark-poly", "ark-serialize 0.4.2", "ark-std 0.4.0", - "merlin 3.0.0", + "merlin", ] [[package]] @@ -2225,7 +2167,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -2248,6 +2190,7 @@ dependencies = [ name = "frame-executive" version = "28.0.0" dependencies = [ + "aquamarine 0.3.3", "frame-support", "frame-system", "frame-try-runtime", @@ -2277,7 +2220,7 @@ dependencies = [ name = "frame-support" version = "28.0.0" dependencies = [ - "aquamarine", + "aquamarine 0.5.0", "array-bytes 6.2.2", "bitflags 1.3.2", "docify", @@ -2328,7 +2271,7 @@ dependencies = [ "proc-macro2", "quote", "sp-crypto-hashing", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -2339,7 +2282,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -2348,7 +2291,7 @@ version = "11.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -2475,7 +2418,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -2514,15 +2457,6 @@ dependencies = [ "slab", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -2653,6 +2587,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-conservative" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2" + [[package]] name = "hex-literal" version = "0.4.1" @@ -2665,17 +2605,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac 0.11.0", + "crypto-mac", "digest 0.9.0", ] @@ -2695,7 +2625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.7", + "generic-array", "hmac 0.8.1", ] @@ -2870,6 +2800,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "once_cell", + "serdect", "sha2 0.10.8", ] @@ -2990,9 +2921,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru" @@ -3021,7 +2952,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -3035,7 +2966,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -3046,7 +2977,7 @@ checksum = "9ea73aa640dc01d62a590d48c0c3521ed739d53b27f919b25c3551e233481654" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -3057,7 +2988,7 @@ checksum = "ef9d79ae96aaba821963320eb2b6e34d17df1e5a83d8a1985c29cc5be59577b3" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -3112,18 +3043,6 @@ dependencies = [ "hash-db", ] -[[package]] -name = "merlin" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.5.1", - "zeroize", -] - [[package]] name = "merlin" version = "3.0.0" @@ -3204,7 +3123,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "itoa", ] @@ -3275,12 +3194,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -3808,6 +3721,7 @@ dependencies = [ "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", + "xcm-fee-payment-runtime-api", ] [[package]] @@ -3906,6 +3820,19 @@ dependencies = [ "substrate-wasm-builder", ] +[[package]] +name = "parity-bip39" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e69bf016dc406eff7d53a7d3f7cf1c2e72c82b9088aac1118591e36dd2cd3e9" +dependencies = [ + "bitcoin_hashes", + "rand", + "rand_core 0.6.4", + "serde", + "unicode-normalization", +] + [[package]] name = "parity-bytes" version = "0.1.2" @@ -3918,7 +3845,7 @@ version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ - "arrayvec 0.7.4", + "arrayvec", "bitvec", "byte-slice-cast", "bytes", @@ -3997,6 +3924,17 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "password-hash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "paste" version = "1.0.14" @@ -4005,11 +3943,12 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" -version = "0.8.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" dependencies = [ - "crypto-mac 0.11.0", + "digest 0.10.7", + "password-hash", ] [[package]] @@ -4143,7 +4082,6 @@ dependencies = [ "pallet-transaction-payment", "pallet-treasury", "pallet-vesting", - "pallet-xcm-benchmarks", "parity-scale-codec", "polkadot-primitives", "polkadot-runtime-parachains", @@ -4233,13 +4171,28 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92c99f7eee94e7be43ba37eef65ad0ee8cbaf89b7c00001c3f6d2be985cb1817" +[[package]] +name = "polkavm-common" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9428a5cfcc85c5d7b9fc4b6a18c4b802d0173d768182a51cc7751640f08b92" + [[package]] name = "polkavm-derive" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79fa916f7962348bd1bb1a65a83401675e6fc86c51a0fdbcf92a3108e58e6125" dependencies = [ - "polkavm-derive-impl-macro", + "polkavm-derive-impl-macro 0.8.0", +] + +[[package]] +name = "polkavm-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" +dependencies = [ + "polkavm-derive-impl-macro 0.9.0", ] [[package]] @@ -4248,10 +4201,22 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c10b2654a8a10a83c260bfb93e97b262cf0017494ab94a65d389e0eda6de6c9c" dependencies = [ - "polkavm-common", + "polkavm-common 0.8.0", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "polkavm-derive-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fdfc49717fb9a196e74a5d28e0bc764eb394a2c803eb11133a31ac996c60c" +dependencies = [ + "polkavm-common 0.9.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -4260,21 +4225,31 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e85319a0d5129dc9f021c62607e0804f5fb777a05cdda44d750ac0732def66" dependencies = [ - "polkavm-derive-impl", - "syn 2.0.50", + "polkavm-derive-impl 0.8.0", + "syn 2.0.58", +] + +[[package]] +name = "polkavm-derive-impl-macro" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" +dependencies = [ + "polkavm-derive-impl 0.9.0", + "syn 2.0.58", ] [[package]] name = "polkavm-linker" -version = "0.8.2" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdec1451cb18261d5d01de82acc15305e417fb59588cdcb3127d3dcc9672b925" +checksum = "9c7be503e60cf56c0eb785f90aaba4b583b36bff00e93997d93fef97f9553c39" dependencies = [ "gimli 0.28.1", "hashbrown 0.14.3", "log", "object 0.32.2", - "polkavm-common", + "polkavm-common 0.9.0", "regalloc2", "rustc-demangle", ] @@ -4359,7 +4334,7 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -4528,7 +4503,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -4611,7 +4586,7 @@ dependencies = [ "blake2", "common", "fflonk", - "merlin 3.0.0", + "merlin", ] [[package]] @@ -4761,9 +4736,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.10.0" +version = "2.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" dependencies = [ "bitvec", "cfg-if", @@ -4775,9 +4750,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.10.0" +version = "2.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", @@ -4796,22 +4771,6 @@ dependencies = [ "hashbrown 0.13.2", ] -[[package]] -name = "schnorrkel" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "curve25519-dalek 2.1.3", - "merlin 2.0.1", - "rand_core 0.5.1", - "sha2 0.8.2", - "subtle", - "zeroize", -] - [[package]] name = "schnorrkel" version = "0.11.4" @@ -4820,10 +4779,10 @@ checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" dependencies = [ "aead", "arrayref", - "arrayvec 0.7.4", + "arrayvec", "curve25519-dalek 4.1.2", "getrandom_or_panic", - "merlin 3.0.0", + "merlin", "rand_core 0.6.4", "serde_bytes", "sha2 0.10.8", @@ -4857,8 +4816,9 @@ checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", "der", - "generic-array 0.14.7", + "generic-array", "pkcs8", + "serdect", "subtle", "zeroize", ] @@ -4967,7 +4927,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -4991,15 +4951,13 @@ dependencies = [ ] [[package]] -name = "sha2" -version = "0.8.2" +name = "serdect" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", + "base16ct", + "serde", ] [[package]] @@ -5012,7 +4970,7 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug", ] [[package]] @@ -5118,7 +5076,7 @@ dependencies = [ [[package]] name = "snowbridge-beacon-primitives" -version = "0.9.0" +version = "0.2.0" dependencies = [ "byte-slice-cast", "frame-support", @@ -5142,7 +5100,7 @@ dependencies = [ [[package]] name = "snowbridge-core" -version = "0.9.0" +version = "0.2.0" dependencies = [ "ethabi-decode", "frame-support", @@ -5165,7 +5123,7 @@ dependencies = [ [[package]] name = "snowbridge-ethereum" -version = "0.9.0" +version = "0.3.0" dependencies = [ "ethabi-decode", "ethbloom", @@ -5204,7 +5162,7 @@ dependencies = [ [[package]] name = "snowbridge-outbound-queue-merkle-tree" -version = "0.9.0" +version = "0.3.0" dependencies = [ "array-bytes 4.2.0", "env_logger", @@ -5219,7 +5177,7 @@ dependencies = [ [[package]] name = "snowbridge-outbound-queue-runtime-api" -version = "0.9.0" +version = "0.2.0" dependencies = [ "frame-support", "parity-scale-codec", @@ -5233,7 +5191,7 @@ dependencies = [ [[package]] name = "snowbridge-pallet-ethereum-client" -version = "0.9.0" +version = "0.2.0" dependencies = [ "bp-runtime", "byte-slice-cast", @@ -5279,7 +5237,7 @@ dependencies = [ [[package]] name = "snowbridge-pallet-inbound-queue" -version = "0.9.0" +version = "0.2.0" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -5312,7 +5270,7 @@ dependencies = [ [[package]] name = "snowbridge-pallet-inbound-queue-fixtures" -version = "0.9.0" +version = "0.10.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5326,7 +5284,7 @@ dependencies = [ [[package]] name = "snowbridge-pallet-outbound-queue" -version = "0.9.0" +version = "0.2.0" dependencies = [ "bridge-hub-common", "ethabi-decode", @@ -5351,7 +5309,7 @@ dependencies = [ [[package]] name = "snowbridge-pallet-system" -version = "0.9.0" +version = "0.2.0" dependencies = [ "ethabi-decode", "frame-benchmarking", @@ -5402,7 +5360,7 @@ dependencies = [ [[package]] name = "snowbridge-runtime-common" -version = "0.9.0" +version = "0.2.0" dependencies = [ "frame-support", "frame-system", @@ -5418,7 +5376,7 @@ dependencies = [ [[package]] name = "snowbridge-runtime-test-common" -version = "0.9.0" +version = "0.2.0" dependencies = [ "assets-common", "bridge-hub-test-utils", @@ -5495,7 +5453,7 @@ dependencies = [ [[package]] name = "snowbridge-system-runtime-api" -version = "0.9.0" +version = "0.2.0" dependencies = [ "parity-scale-codec", "snowbridge-core", @@ -5536,7 +5494,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -5555,6 +5513,7 @@ dependencies = [ name = "sp-arithmetic" version = "23.0.0" dependencies = [ + "docify", "integer-sqrt", "num-traits", "parity-scale-codec", @@ -5591,7 +5550,6 @@ dependencies = [ "sp-api", "sp-application-crypto", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5601,7 +5559,6 @@ dependencies = [ "sp-api", "sp-inherents", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5616,7 +5573,6 @@ dependencies = [ "sp-consensus-slots", "sp-inherents", "sp-runtime", - "sp-std 14.0.0", "sp-timestamp", ] @@ -5634,7 +5590,6 @@ dependencies = [ "sp-core", "sp-inherents", "sp-runtime", - "sp-std 14.0.0", "sp-timestamp", ] @@ -5652,7 +5607,6 @@ dependencies = [ "sp-core", "sp-keystore", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5662,7 +5616,6 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std 14.0.0", "sp-timestamp", ] @@ -5672,7 +5625,6 @@ version = "28.0.0" dependencies = [ "array-bytes 6.2.2", "bandersnatch_vrfs", - "bip39", "bitflags 1.3.2", "blake2", "bounded-collections", @@ -5684,16 +5636,18 @@ dependencies = [ "hash256-std-hasher", "impl-serde", "itertools", + "k256", "libsecp256k1", "log", - "merlin 3.0.0", + "merlin", + "parity-bip39", "parity-scale-codec", "parking_lot", "paste", "primitive-types", "rand", "scale-info", - "schnorrkel 0.11.4", + "schnorrkel", "secp256k1", "secrecy", "serde", @@ -5750,7 +5704,7 @@ version = "0.0.0" dependencies = [ "quote", "sp-crypto-hashing", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -5759,7 +5713,7 @@ version = "14.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -5769,7 +5723,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk#de6d02591b57d03f70ed8db dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -5778,7 +5732,6 @@ version = "0.25.0" dependencies = [ "environmental", "parity-scale-codec", - "sp-std 14.0.0", "sp-storage 19.0.0", ] @@ -5800,7 +5753,6 @@ dependencies = [ "serde_json", "sp-api", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5812,7 +5764,6 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std 14.0.0", "thiserror", ] @@ -5825,6 +5776,7 @@ dependencies = [ "libsecp256k1", "log", "parity-scale-codec", + "polkavm-derive 0.9.1", "rustversion", "secp256k1", "sp-core", @@ -5874,7 +5826,6 @@ dependencies = [ "frame-metadata", "parity-scale-codec", "scale-info", - "sp-std 14.0.0", ] [[package]] @@ -5887,7 +5838,6 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -5938,7 +5888,7 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive", + "polkavm-derive 0.9.1", "primitive-types", "sp-externalities 0.25.0", "sp-runtime-interface-proc-macro 17.0.0", @@ -5957,7 +5907,7 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive", + "polkavm-derive 0.8.0", "primitive-types", "sp-externalities 0.25.0 (git+https://github.com/paritytech/polkadot-sdk)", "sp-runtime-interface-proc-macro 17.0.0 (git+https://github.com/paritytech/polkadot-sdk)", @@ -5977,7 +5927,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -5990,7 +5940,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -6004,7 +5954,6 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-staking", - "sp-std 14.0.0", ] [[package]] @@ -6017,7 +5966,6 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std 14.0.0", ] [[package]] @@ -6033,7 +5981,6 @@ dependencies = [ "sp-core", "sp-externalities 0.25.0", "sp-panic-handler", - "sp-std 14.0.0", "sp-trie", "thiserror", "tracing", @@ -6058,7 +6005,6 @@ dependencies = [ "ref-cast", "serde", "sp-debug-derive 14.0.0", - "sp-std 14.0.0", ] [[package]] @@ -6082,7 +6028,6 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "sp-std 14.0.0", "thiserror", ] @@ -6091,7 +6036,6 @@ name = "sp-tracing" version = "16.0.0" dependencies = [ "parity-scale-codec", - "sp-std 14.0.0", "tracing", "tracing-core", "tracing-subscriber", @@ -6133,7 +6077,6 @@ dependencies = [ "schnellru", "sp-core", "sp-externalities 0.25.0", - "sp-std 14.0.0", "thiserror", "tracing", "trie-db", @@ -6163,7 +6106,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -6174,7 +6117,6 @@ dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec", - "sp-std 14.0.0", "wasmtime", ] @@ -6202,7 +6144,6 @@ dependencies = [ "smallvec", "sp-arithmetic", "sp-debug-derive 14.0.0", - "sp-std 14.0.0", ] [[package]] @@ -6360,14 +6301,12 @@ dependencies = [ [[package]] name = "substrate-bip39" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" +version = "0.4.7" dependencies = [ - "hmac 0.11.0", + "hmac 0.12.1", "pbkdf2", - "schnorrkel 0.9.1", - "sha2 0.9.9", + "schnorrkel", + "sha2 0.10.8", "zeroize", ] @@ -6408,9 +6347,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.50" +version = "2.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f1bdc9872430ce9b75da68329d1c1746faf50ffac5f19e02b71e37ff881ffb" +checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" dependencies = [ "proc-macro2", "quote", @@ -6426,7 +6365,7 @@ dependencies = [ "paste", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -6491,7 +6430,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -6614,7 +6553,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -6866,7 +6805,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", "wasm-bindgen-shared", ] @@ -6900,7 +6839,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6933,7 +6872,7 @@ checksum = "a5211b7550606857312bba1d978a8ec75692eae187becc5e680444fffc5e6f89" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -7403,6 +7342,20 @@ dependencies = [ "tap", ] +[[package]] +name = "xcm-fee-payment-runtime-api" +version = "0.1.0" +dependencies = [ + "frame-support", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std 14.0.0", + "sp-weights", + "staging-xcm", +] + [[package]] name = "xcm-procedural" version = "7.0.0" @@ -7410,7 +7363,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -7430,7 +7383,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] @@ -7450,7 +7403,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.50", + "syn 2.0.58", ] [[package]] diff --git a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs index 1a47a2eda2e8..0e1c6229dbcc 100644 --- a/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs +++ b/bridges/snowbridge/pallets/inbound-queue/fixtures/src/send_call_to_penpal.rs @@ -3,20 +3,13 @@ // Generated, do not edit! // See ethereum client README.md for instructions to generate -use crate::InboundQueueFixture; use hex_literal::hex; -use snowbridge_beacon_primitives::CompactExecutionHeader; -use snowbridge_core::inbound::{Log, Message, Proof}; +use snowbridge_beacon_primitives::{types::deneb, ExecutionProof, VersionedExecutionPayloadHeader}; +use snowbridge_core::inbound::{InboundQueueFixture, Log, Message, Proof}; use sp_std::vec; pub fn make_send_call_to_penpal_message() -> InboundQueueFixture { InboundQueueFixture { - execution_header: CompactExecutionHeader{ - parent_hash: hex!("e0fa68ceff08e6f024c84f408540372801b209ff8f11481a9dc6bc5db3ce92d3").into(), - block_number: 831, - state_root: hex!("ccc30635f32d558620d45ead60eabbe70dbf179b475fa9cec5a3791fd5be2b78").into(), - receipts_root: hex!("6bba8f0093461e22cd265bc0de44bf7a596db58ecbf44432e6de8b3490deb077").into(), - }, message: Message { event_log: Log { address: hex!("eda338e4dc46038493b885327842fd3e301cab39").into(), @@ -28,14 +21,38 @@ pub fn make_send_call_to_penpal_message() -> InboundQueueFixture { data: hex!("00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003e00a736aa00000000000290a987b944cb1dcce5564e5fdecd7a54d3de27fe0100902f5009000000000000000000000002688909017d2000071468656c6c6f0000").into(), }, proof: Proof { - block_hash: hex!("be15f3cdf217baad8cc5c40d7e2dc1f173ab3bdaa58e5819905bb0c73f46cf78").into(), - tx_index: 0, - data: (vec![ + receipt_proof: (vec![ hex!("6bba8f0093461e22cd265bc0de44bf7a596db58ecbf44432e6de8b3490deb077").to_vec(), ], vec![ hex!("f90234822080b9022e02f9022a0183016e01b9010000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000200000000000000000020000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000010000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002004000000000000000000000200000000000000f9011ff9011c94eda338e4dc46038493b885327842fd3e301cab39f863a07153f9357c8ea496bba60bf82e67143e27b64462b49041f8e689e1b05728f84fa0a69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7ad8fb06c6fa3a0c9ad11f6e2d2b770f52e7cbe22ba779eb8e5e000e0db4e5032488898bd3529ecb8a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000003e00a736aa00000000000290a987b944cb1dcce5564e5fdecd7a54d3de27fe0100902f5009000000000000000000000002688909017d2000071468656c6c6f0000").to_vec(), ]), + execution_proof: ExecutionProof { + header: Default::default(), + ancestry_proof: None, + execution_header: VersionedExecutionPayloadHeader::Deneb(deneb::ExecutionPayloadHeader{ + parent_hash: Default::default(), + fee_recipient: Default::default(), + state_root: Default::default(), + receipts_root: Default::default(), + logs_bloom: vec![], + prev_randao: Default::default(), + block_number: 0, + gas_limit: 0, + gas_used: 0, + timestamp: 0, + extra_data: vec![], + base_fee_per_gas: Default::default(), + block_hash: Default::default(), + transactions_root: Default::default(), + withdrawals_root: Default::default(), + blob_gas_used: 0, + excess_blob_gas: 0, + }), + execution_branch: vec![], + }, }, }, + finalized_header: Default::default(), + block_roots_root: Default::default(), } } diff --git a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml index e0df69d97e51..4cdbf4776c8b 100644 --- a/cumulus/parachains/runtimes/testing/penpal/Cargo.toml +++ b/cumulus/parachains/runtimes/testing/penpal/Cargo.toml @@ -79,13 +79,11 @@ pallet-collator-selection = { path = "../../../../pallets/collator-selection", d parachain-info = { package = "staging-parachain-info", path = "../../../pallets/parachain-info", default-features = false } parachains-common = { path = "../../../common", default-features = false } assets-common = { path = "../../assets/common", default-features = false } -bp-bridge-hub-rococo = { path = "../../../../../bridges/primitives/chain-bridge-hub-rococo", default-features = false } [features] default = ["std"] std = [ "assets-common/std", - "bp-bridge-hub-rococo/std", "codec/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-parachain-system/std", From 68abf04e4c07ea0711334df794a575917e25dd7a Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 11 Apr 2024 10:10:18 +0800 Subject: [PATCH 34/44] Make network specific types as storage which can be changed --- .../runtimes/testing/penpal/src/xcm_config.rs | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index d7ef0f803620..bc53ce482346 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -67,10 +67,24 @@ parameter_types! { pub const RelayLocation: Location = Location::parent(); // Local native currency which is stored in `pallet_balances`` pub const PenpalNativeCurrency: Location = Location::here(); - pub const RelayNetwork: NetworkId = Rococo; + pub storage RelayNetwork: NetworkId = Rococo; pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorLocation = [GlobalConsensus(RelayNetwork::get()),Parachain(ParachainInfo::parachain_id().into())].into(); pub TreasuryAccount: AccountId = TREASURY_PALLET_ID.into_account_truncating(); + pub storage EthereumNetwork: NetworkId = Ethereum { chain_id: 11155111 }; + pub storage SiblingBridgeHubWithEthereumInboundQueueInstance: Location = Location::new( + 1, + [ + Parachain(1013), + PalletInstance(80) + ] + ); + pub storage UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( + sp_std::vec![ + (SiblingBridgeHubWithEthereumInboundQueueInstance::get(),GlobalConsensus(EthereumNetwork::get())), + ] + ); + pub storage SiblingBridgeHub: Location = Location::new(1, [Parachain(1013)]); } /// Type for specifying how a `Location` can be converted into an `AccountId`. This is used @@ -352,23 +366,6 @@ pub type TrustedReserves = ( pub type TrustedTeleporters = (AssetFromChain,); -parameter_types! { - pub storage EthereumNetwork: NetworkId = Ethereum { chain_id: 11155111 }; - pub storage SiblingBridgeHubWithEthereumInboundQueueInstance: Location = Location::new( - 1, - [ - Parachain(1013), - PalletInstance(80) - ] - ); - pub storage UniversalAliases: BTreeSet<(Location, Junction)> = BTreeSet::from_iter( - sp_std::vec![ - (SiblingBridgeHubWithEthereumInboundQueueInstance::get(),GlobalConsensus(EthereumNetwork::get())), - ] - ); - pub storage SiblingBridgeHub: Location = Location::new(1, [Parachain(1013)]); -} - pub struct GlobalConsensusEthereumAddressConvertsFor(PhantomData); impl ConvertLocation for GlobalConsensusEthereumAddressConvertsFor where From 76b01b24663f7982cf5eeb10ab18b0b2acffec2a Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 11 Apr 2024 11:23:47 +0800 Subject: [PATCH 35/44] Remove the fund steps unnecessary --- .../bridge-hub-rococo/src/tests/snowbridge.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 735c59e4d038..68560db75247 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -565,11 +565,6 @@ fn register_weth_token_in_asset_hub_fail_for_insufficient_fee() { #[test] fn transact_from_ethereum_to_penpal_success() { - // Fund sender on penpal so that it can pay execution fees. - let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); - let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); - println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); - PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); BridgeHubRococo::execute_with(|| { @@ -592,7 +587,7 @@ fn transact_from_ethereum_to_penpal_success() { let message = VersionedMessage::V1(MessageV1 { chain_id: CHAIN_ID, command: Command::Transact { - sender, + sender: hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(), fee: XCM_FEE, weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, @@ -626,12 +621,6 @@ fn transact_from_ethereum_to_penpal_success() { #[test] fn transact_from_ethereum_to_penpal_insufficient_weight() { - // Fund sender on penpal so that it can pay execution fees. - let sender: H160 = hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(); - let sovereign_of_sender = blake2_256(&(b"AccountKey20", sender).encode()); - println!("sovereign account of the sender: {:#?}", hex::encode(sovereign_of_sender.clone())); - PenpalA::fund_accounts(vec![(sovereign_of_sender.into(), INITIAL_FUND)]); - BridgeHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; @@ -639,7 +628,7 @@ fn transact_from_ethereum_to_penpal_insufficient_weight() { let message = VersionedMessage::V1(MessageV1 { chain_id: CHAIN_ID, command: Command::Transact { - sender, + sender: hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(), fee: XCM_FEE, weight_at_most: INSUFFICIENT_XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, From 87ed09747e3e627c8a1eef255d94177ae2bc339b Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 11 Apr 2024 18:06:19 +0800 Subject: [PATCH 36/44] Move Transact after Origin operations --- bridges/snowbridge/primitives/router/src/inbound/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index fc996938c361..d9f3abfbc7a3 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -351,13 +351,13 @@ where // the dest chain to implement a custom Barrier which inspect the fee as // expected(i.e. can cover the transact cost to avoid spamming) BurnAsset(xcm_fee.clone().into()), - Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, // Only our inbound-queue pallet is allowed to invoke `UniversalOrigin` DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), // Change origin to the bridge. UniversalOrigin(GlobalConsensus(Ethereum { chain_id })), // DescendOrigin to the sender. DescendOrigin(AccountKey20 { network: None, key: sender.into() }.into()), + Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, // Forward message id SetTopic(message_id.into()), ]; From 0ea24a4bc260b3c9ac5d35e81b4966ba1ec0c767 Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 11 Apr 2024 20:50:42 +0800 Subject: [PATCH 37/44] Fix breaking test --- bridges/snowbridge/pallets/inbound-queue/src/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 9a3fdb33abbb..90f9b11788ba 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -269,7 +269,7 @@ fn test_convert_transact() { let instructions = xcm.into_inner(); assert_eq!(instructions.len(), 7); assert_eq!(dest_fee, fee.into()); - let transact = instructions.get(2).unwrap().clone(); + let transact = instructions.get(5).unwrap().clone(); let expected = Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; assert_eq!(transact, expected); From cd7a64a1ca5b8e1ea6339125c0c966065ada8e70 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 16 Apr 2024 09:30:03 +0800 Subject: [PATCH 38/44] Fix compile error --- bridges/snowbridge/pallets/inbound-queue/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index 347535e50954..db38afbdc72e 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -48,7 +48,7 @@ use frame_support::{ }; use frame_system::ensure_signed; use scale_info::TypeInfo; -use sp_core::H160; +use sp_core::{H160, H256}; use sp_runtime::traits::Zero; use sp_std::{convert::TryFrom, vec}; use xcm::prelude::{ @@ -70,8 +70,6 @@ pub use weights::WeightInfo; #[cfg(feature = "runtime-benchmarks")] use snowbridge_beacon_primitives::BeaconHeader; -#[cfg(feature = "runtime-benchmarks")] -use sp_core::H256; type BalanceOf = <::Token as Inspect<::AccountId>>::Balance; From 966abdf04551727c5ab032d820925ec1a76aa8cf Mon Sep 17 00:00:00 2001 From: ron Date: Wed, 17 Apr 2024 22:13:40 +0800 Subject: [PATCH 39/44] Use native token of destination chain to pay fee from a pre-funded sovereign account --- .../primitives/router/src/inbound/mod.rs | 12 +++--- .../bridge-hub-rococo/src/tests/snowbridge.rs | 11 +++++- .../runtimes/testing/penpal/src/xcm_config.rs | 38 +------------------ 3 files changed, 15 insertions(+), 46 deletions(-) diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index d9f3abfbc7a3..9938a8bce05a 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -343,20 +343,18 @@ where weight_at_most: Weight, payload: Vec, ) -> (Xcm<()>, Balance) { - let xcm_fee: Asset = (Location::parent(), fee).into(); + // Fee in native token of destination chain + let xcm_fee: Asset = (Location::here(), fee).into(); let message = vec![ - UnpaidExecution { weight_limit: Unlimited, check_origin: None }, - // Actually BurnAsset does nothing on dest chain, included here only for - // the dest chain to implement a custom Barrier which inspect the fee as - // expected(i.e. can cover the transact cost to avoid spamming) - BurnAsset(xcm_fee.clone().into()), - // Only our inbound-queue pallet is allowed to invoke `UniversalOrigin` DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), // Change origin to the bridge. UniversalOrigin(GlobalConsensus(Ethereum { chain_id })), // DescendOrigin to the sender. DescendOrigin(AccountKey20 { network: None, key: sender.into() }.into()), + WithdrawAsset(xcm_fee.clone().into()), + // Pay for execution. + BuyExecution { fees: xcm_fee, weight_limit: Unlimited }, Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, // Forward message id SetTopic(message_id.into()), diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index bba7fc9eda1a..e56c55d32b66 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -568,6 +568,13 @@ fn register_weth_token_in_asset_hub_fail_for_insufficient_fee() { fn transact_from_ethereum_to_penpal_success() { BridgeHubRococo::fund_para_sovereign(PenpalA::para_id().into(), INITIAL_FUND); + // Fund sender on penpal so that it can pay execution fees. + let sender: H160 = hex!("ee9170abfbf9421ad6dd07f6bdec9d89f2b581e0").into(); + PenpalA::fund_accounts(vec![( + blake2_256(&(b"AccountKey20", sender).encode()).into(), + INITIAL_FUND, + )]); + BridgeHubRococo::execute_with(|| { type RuntimeEvent = ::RuntimeEvent; type Runtime = ::Runtime; @@ -588,7 +595,7 @@ fn transact_from_ethereum_to_penpal_success() { let message = VersionedMessage::V1(MessageV1 { chain_id: CHAIN_ID, command: Command::Transact { - sender: hex!("90A987B944Cb1dCcE5564e5FDeCD7a54D3de27Fe").into(), + sender, fee: XCM_FEE, weight_at_most: XCM_WEIGHT, origin_kind: OriginKind::SovereignAccount, @@ -711,7 +718,7 @@ fn transact_from_ethereum_to_penpal_insufficient_fee() { assert_expected_events!( PenpalA, vec![ - RuntimeEvent::MessageQueue(pallet_message_queue::Event::ProcessingFailed{ .. }) => {}, + RuntimeEvent::MessageQueue(pallet_message_queue::Event::Processed{ success:false,.. }) => {}, ] ); }); diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 0eb5c75c8171..2a1318c23707 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -224,47 +224,10 @@ impl Contains for CommonGoodAssetsParachain { } } -pub struct AllowUnpaidExecutionFromSnowBridgeWithFeeChecked(PhantomData); -impl> ShouldExecute for AllowUnpaidExecutionFromSnowBridgeWithFeeChecked { - fn should_execute( - origin: &Location, - instructions: &mut [Instruction], - max_weight: Weight, - _properties: &mut Properties, - ) -> Result<(), ProcessMessageError> { - log::trace!( - target: "xcm::barriers", - "AllowUnpaidExecutionFromSnowBridgeWithFeeChecked origin: {:?}, instructions: {:?}, max_weight: {:?}, properties: {:?}", - origin, instructions, max_weight, _properties, - ); - ensure!(T::contains(origin), ProcessMessageError::Unsupported); - let mut fee_assets = xcm::prelude::Assets::default(); - instructions.matcher().match_next_inst_while( - |_| true, - |inst| match inst { - BurnAsset(assets) => { - fee_assets = assets.clone(); - Ok(ControlFlow::Break(())) - }, - - _ => Ok(ControlFlow::Continue(())), - }, - )?; - let mut trader = ::Trader::new(); - let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None }; - trader - .buy_weight(max_weight, fee_assets.into(), &ctx) - .map_err(|_| ProcessMessageError::Unsupported)?; - Ok(()) - } -} - pub type Barrier = TrailingSetTopicAsId<( TakeWeightCredit, // Expected responses are OK. AllowKnownQueryResponses, - // Allow from BridgeHub - AllowUnpaidExecutionFromSnowBridgeWithFeeChecked>, // Allow XCMs with some computed origins to pass through. WithComputedOrigin< ( @@ -402,6 +365,7 @@ impl xcm_executor::Config for XcmConfig { type Weigher = FixedWeightBounds; type Trader = ( UsingComponents>, + UsingComponents>, // This trader allows to pay with `is_sufficient=true` "Foreign" assets from dedicated // `pallet_assets` instance - `ForeignAssets`. cumulus_primitives_utility::TakeFirstAssetTrader< From 1cab94c80aefdf3497d69828a22ac15bd27dbb95 Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 22 Apr 2024 11:33:40 +0800 Subject: [PATCH 40/44] Use native token or DOT based on whether its a system parachain or not --- bridges/snowbridge/Cargo.lock | 1093 ++++------------- .../pallets/inbound-queue/src/lib.rs | 6 +- .../pallets/inbound-queue/src/test.rs | 2 +- .../primitives/router/src/inbound/mod.rs | 12 +- .../bridge-hub-rococo/src/tests/snowbridge.rs | 11 +- .../runtimes/testing/penpal/src/xcm_config.rs | 23 +- 6 files changed, 239 insertions(+), 908 deletions(-) diff --git a/bridges/snowbridge/Cargo.lock b/bridges/snowbridge/Cargo.lock index 09239d833218..4ac38230f775 100644 --- a/bridges/snowbridge/Cargo.lock +++ b/bridges/snowbridge/Cargo.lock @@ -105,22 +105,10 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" dependencies = [ - "alloy-rlp-derive", "arrayvec", "bytes", ] -[[package]] -name = "alloy-rlp-derive" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.58", -] - [[package]] name = "alloy-sol-macro" version = "0.4.2" @@ -174,6 +162,54 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.82" @@ -189,20 +225,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "aquamarine" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1da02abba9f9063d786eab1509833ebb2fac0f966862ca59439c76b9c566760" -dependencies = [ - "include_dir", - "itertools", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "aquamarine" version = "0.5.0" @@ -588,79 +610,17 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" -[[package]] -name = "asset-test-utils" -version = "7.0.0" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "pallet-assets", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-timestamp", - "pallet-xcm", - "pallet-xcm-bridge-hub-router", - "parachains-common", - "parachains-runtimes-test-utils", - "parity-scale-codec", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "staging-parachain-info", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "substrate-wasm-builder", -] - -[[package]] -name = "assets-common" -version = "0.7.0" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "impl-trait-for-tuples", - "log", - "pallet-asset-conversion", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std 14.0.0", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "substrate-wasm-builder", -] - [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", "syn 2.0.58", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "auto_impl" version = "1.1.2" @@ -849,130 +809,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bp-header-chain" -version = "0.7.0" -dependencies = [ - "bp-runtime", - "finality-grandpa", - "frame-support", - "parity-scale-codec", - "scale-info", - "serde", - "sp-consensus-grandpa", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "bp-messages" -version = "0.7.0" -dependencies = [ - "bp-header-chain", - "bp-runtime", - "frame-support", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-std 14.0.0", -] - -[[package]] -name = "bp-parachains" -version = "0.7.0" -dependencies = [ - "bp-header-chain", - "bp-polkadot-core", - "bp-runtime", - "frame-support", - "impl-trait-for-tuples", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "bp-polkadot-core" -version = "0.7.0" -dependencies = [ - "bp-messages", - "bp-runtime", - "frame-support", - "frame-system", - "parity-scale-codec", - "parity-util-mem", - "scale-info", - "serde", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "bp-relayers" -version = "0.7.0" -dependencies = [ - "bp-messages", - "bp-runtime", - "frame-support", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "bp-runtime" -version = "0.7.0" -dependencies = [ - "frame-support", - "frame-system", - "hash-db", - "impl-trait-for-tuples", - "log", - "num-traits", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std 14.0.0", - "sp-trie", - "trie-db", -] - -[[package]] -name = "bp-test-utils" -version = "0.7.0" -dependencies = [ - "bp-header-chain", - "bp-parachains", - "bp-polkadot-core", - "bp-runtime", - "ed25519-dalek", - "finality-grandpa", - "parity-scale-codec", - "sp-application-crypto", - "sp-consensus-grandpa", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", - "sp-trie", -] - -[[package]] -name = "bp-xcm-bridge-hub" -version = "0.2.0" -dependencies = [ - "sp-std 14.0.0", -] - [[package]] name = "bp-xcm-bridge-hub-router" version = "0.6.0" @@ -985,7 +821,7 @@ dependencies = [ [[package]] name = "bridge-hub-common" -version = "0.0.0" +version = "0.1.0" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -999,80 +835,6 @@ dependencies = [ "staging-xcm", ] -[[package]] -name = "bridge-hub-test-utils" -version = "0.7.0" -dependencies = [ - "asset-test-utils", - "bp-header-chain", - "bp-messages", - "bp-polkadot-core", - "bp-relayers", - "bp-runtime", - "bp-test-utils", - "bridge-runtime-common", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "log", - "pallet-balances", - "pallet-bridge-grandpa", - "pallet-bridge-messages", - "pallet-bridge-parachains", - "pallet-bridge-relayers", - "pallet-timestamp", - "pallet-utility", - "parachains-common", - "parachains-runtimes-test-utils", - "parity-scale-codec", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-std 14.0.0", - "sp-tracing 16.0.0", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", -] - -[[package]] -name = "bridge-runtime-common" -version = "0.7.0" -dependencies = [ - "bp-header-chain", - "bp-messages", - "bp-parachains", - "bp-polkadot-core", - "bp-relayers", - "bp-runtime", - "bp-xcm-bridge-hub", - "bp-xcm-bridge-hub-router", - "frame-support", - "frame-system", - "hash-db", - "log", - "pallet-bridge-grandpa", - "pallet-bridge-messages", - "pallet-bridge-parachains", - "pallet-bridge-relayers", - "pallet-transaction-payment", - "pallet-utility", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "sp-trie", - "staging-xcm", - "staging-xcm-builder", - "static_assertions", -] - [[package]] name = "bs58" version = "0.5.0" @@ -1199,6 +961,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "common" version = "0.1.0" @@ -1407,23 +1175,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "cumulus-pallet-aura-ext" -version = "0.7.0" -dependencies = [ - "cumulus-pallet-parachain-system", - "frame-support", - "frame-system", - "pallet-aura", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-aura", - "sp-runtime", - "sp-std 14.0.0", -] - [[package]] name = "cumulus-pallet-parachain-system" version = "0.7.0" @@ -1468,34 +1219,6 @@ dependencies = [ "syn 2.0.58", ] -[[package]] -name = "cumulus-pallet-session-benchmarking" -version = "9.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-session", - "parity-scale-codec", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "cumulus-pallet-xcm" -version = "0.7.0" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "staging-xcm", -] - [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.7.0" @@ -1547,35 +1270,16 @@ dependencies = [ "sp-core", "sp-inherents", "sp-std 14.0.0", - "sp-trie", -] - -[[package]] -name = "cumulus-primitives-proof-size-hostfunction" -version = "0.2.0" -dependencies = [ - "sp-externalities 0.25.0", - "sp-runtime-interface 24.0.0", - "sp-trie", -] - -[[package]] -name = "cumulus-primitives-utility" -version = "0.7.0" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "pallet-asset-conversion", - "parity-scale-codec", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", + "sp-trie", +] + +[[package]] +name = "cumulus-primitives-proof-size-hostfunction" +version = "0.2.0" +dependencies = [ + "sp-externalities 0.25.0", + "sp-runtime-interface 24.0.0", + "sp-trie", ] [[package]] @@ -1708,6 +1412,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-syn-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1760,21 +1475,21 @@ dependencies = [ [[package]] name = "docify" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc4fd38aaa9fb98ac70794c82a00360d1e165a87fbf96a8a91f9dfc602aaee2" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" dependencies = [ "docify_macros", ] [[package]] name = "docify_macros" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63fa215f3a0d40fb2a221b3aa90d8e1fbb8379785a990cb60d62ac71ebdc6460" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" dependencies = [ "common-path", - "derive-syn-parse", + "derive-syn-parse 0.2.0", "once_cell", "proc-macro2", "quote", @@ -1934,17 +1649,27 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "env_filter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_logger" -version = "0.9.3" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" dependencies = [ - "atty", + "anstream", + "anstyle", + "env_filter", "humantime", "log", - "regex", - "termcolor", ] [[package]] @@ -2093,22 +1818,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "finality-grandpa" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" -dependencies = [ - "either", - "futures", - "futures-timer", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot", - "scale-info", -] - [[package]] name = "fixed-hash" version = "0.8.0" @@ -2186,24 +1895,6 @@ dependencies = [ "sp-std 14.0.0", ] -[[package]] -name = "frame-executive" -version = "28.0.0" -dependencies = [ - "aquamarine 0.3.3", - "frame-support", - "frame-system", - "frame-try-runtime", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "sp-tracing 16.0.0", -] - [[package]] name = "frame-metadata" version = "16.0.0" @@ -2220,7 +1911,7 @@ dependencies = [ name = "frame-support" version = "28.0.0" dependencies = [ - "aquamarine 0.5.0", + "aquamarine", "array-bytes 6.2.2", "bitflags 1.3.2", "docify", @@ -2262,7 +1953,7 @@ version = "23.0.0" dependencies = [ "Inflector", "cfg-expr", - "derive-syn-parse", + "derive-syn-parse 0.2.0", "expander", "frame-support-procedural-tools", "itertools", @@ -2313,39 +2004,6 @@ dependencies = [ "sp-weights", ] -[[package]] -name = "frame-system-benchmarking" -version = "28.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "frame-system-rpc-runtime-api" -version = "26.0.0" -dependencies = [ - "parity-scale-codec", - "sp-api", -] - -[[package]] -name = "frame-try-runtime" -version = "0.34.0" -dependencies = [ - "frame-support", - "parity-scale-codec", - "sp-api", - "sp-runtime", - "sp-std 14.0.0", -] - [[package]] name = "fs-err" version = "2.11.0" @@ -2433,12 +2091,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" -[[package]] -name = "futures-timer" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" - [[package]] name = "futures-util" version = "0.3.30" @@ -2566,15 +2218,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.8" @@ -2761,7 +2404,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.8", + "hermit-abi", "libc", "windows-sys 0.48.0", ] @@ -2925,15 +2568,6 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" -[[package]] -name = "lru" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" -dependencies = [ - "hashbrown 0.12.3", -] - [[package]] name = "mach" version = "0.3.2" @@ -2962,7 +2596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "468155613a44cfd825f1fb0ffa532b018253920d404e6fca1e8d43155198a46d" dependencies = [ "const-random", - "derive-syn-parse", + "derive-syn-parse 0.1.5", "macro_magic_core_macros", "proc-macro2", "quote", @@ -3000,6 +2634,15 @@ dependencies = [ "regex-automata 0.1.10", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matrixmultiply" version = "0.3.8" @@ -3097,6 +2740,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num-bigint" version = "0.4.4" @@ -3163,7 +2816,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.8", + "hermit-abi", "libc", ] @@ -3201,21 +2854,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] -name = "pallet-asset-conversion" -version = "10.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", -] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pallet-asset-rate" @@ -3231,54 +2873,6 @@ dependencies = [ "sp-std 14.0.0", ] -[[package]] -name = "pallet-asset-tx-payment" -version = "28.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "pallet-assets" -version = "29.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "pallet-aura" -version = "27.0.0" -dependencies = [ - "frame-support", - "frame-system", - "log", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-aura", - "sp-runtime", - "sp-std 14.0.0", -] - [[package]] name = "pallet-authority-discovery" version = "28.0.0" @@ -3345,82 +2939,6 @@ dependencies = [ "sp-std 14.0.0", ] -[[package]] -name = "pallet-bridge-grandpa" -version = "0.7.0" -dependencies = [ - "bp-header-chain", - "bp-runtime", - "bp-test-utils", - "finality-grandpa", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-consensus-grandpa", - "sp-runtime", - "sp-std 14.0.0", - "sp-trie", -] - -[[package]] -name = "pallet-bridge-messages" -version = "0.7.0" -dependencies = [ - "bp-messages", - "bp-runtime", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "num-traits", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "pallet-bridge-parachains" -version = "0.7.0" -dependencies = [ - "bp-header-chain", - "bp-parachains", - "bp-polkadot-core", - "bp-runtime", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-bridge-grandpa", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std 14.0.0", - "sp-trie", -] - -[[package]] -name = "pallet-bridge-relayers" -version = "0.7.0" -dependencies = [ - "bp-messages", - "bp-relayers", - "bp-runtime", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-bridge-messages", - "parity-scale-codec", - "scale-info", - "sp-arithmetic", - "sp-runtime", - "sp-std 14.0.0", -] - [[package]] name = "pallet-broker" version = "0.6.0" @@ -3431,6 +2949,7 @@ dependencies = [ "frame-system", "parity-scale-codec", "scale-info", + "sp-api", "sp-arithmetic", "sp-core", "sp-runtime", @@ -3474,7 +2993,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std 14.0.0", - "strum", + "strum 0.26.2", ] [[package]] @@ -3510,52 +3029,37 @@ dependencies = [ [[package]] name = "pallet-identity" -version = "28.0.0" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", -] - -[[package]] -name = "pallet-message-queue" -version = "31.0.0" +version = "28.0.0" dependencies = [ - "environmental", + "enumflags2", "frame-benchmarking", "frame-support", "frame-system", "log", "parity-scale-codec", "scale-info", - "sp-arithmetic", - "sp-core", "sp-io", "sp-runtime", "sp-std 14.0.0", - "sp-weights", ] [[package]] -name = "pallet-multisig" -version = "28.0.0" +name = "pallet-message-queue" +version = "31.0.0" dependencies = [ + "environmental", "frame-benchmarking", "frame-support", "frame-system", "log", "parity-scale-codec", "scale-info", + "sp-arithmetic", + "sp-core", "sp-io", "sp-runtime", "sp-std 14.0.0", + "sp-weights", ] [[package]] @@ -3643,17 +3147,6 @@ dependencies = [ "sp-std 14.0.0", ] -[[package]] -name = "pallet-transaction-payment-rpc-runtime-api" -version = "28.0.0" -dependencies = [ - "pallet-transaction-payment", - "parity-scale-codec", - "sp-api", - "sp-runtime", - "sp-weights", -] - [[package]] name = "pallet-treasury" version = "27.0.0" @@ -3724,72 +3217,6 @@ dependencies = [ "xcm-fee-payment-runtime-api", ] -[[package]] -name = "pallet-xcm-benchmarks" -version = "7.0.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", -] - -[[package]] -name = "pallet-xcm-bridge-hub-router" -version = "0.5.0" -dependencies = [ - "bp-xcm-bridge-hub-router", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std 14.0.0", - "staging-xcm", - "staging-xcm-builder", -] - -[[package]] -name = "parachains-common" -version = "7.0.0" -dependencies = [ - "cumulus-primitives-core", - "cumulus-primitives-utility", - "frame-support", - "frame-system", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-message-queue", - "pallet-xcm", - "parity-scale-codec", - "polkadot-primitives", - "scale-info", - "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0", - "staging-parachain-info", - "staging-xcm", - "staging-xcm-executor", - "substrate-wasm-builder", -] - [[package]] name = "parachains-runtimes-test-utils" version = "7.0.0" @@ -3866,35 +3293,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "parity-util-mem" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d32c34f4f5ca7f9196001c0aba5a1f9a5a12382c8944b8b0f90233282d1e8f8" -dependencies = [ - "cfg-if", - "ethereum-types", - "hashbrown 0.12.3", - "impl-trait-for-tuples", - "lru", - "parity-util-mem-derive", - "parking_lot", - "primitive-types", - "smallvec", - "winapi", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2", - "syn 1.0.109", - "synstructure", -] - [[package]] name = "parity-wasm" version = "0.45.0" @@ -5080,7 +4478,6 @@ version = "0.2.0" dependencies = [ "byte-slice-cast", "frame-support", - "frame-system", "hex", "hex-literal", "parity-scale-codec", @@ -5095,7 +4492,6 @@ dependencies = [ "sp-std 14.0.0", "ssz_rs", "ssz_rs_derive", - "static_assertions", ] [[package]] @@ -5133,12 +4529,10 @@ dependencies = [ "parity-scale-codec", "rand", "rlp", - "rustc-hex", "scale-info", "serde", "serde-big-array", "serde_json", - "sp-core", "sp-io", "sp-runtime", "sp-std 14.0.0", @@ -5184,17 +4578,13 @@ dependencies = [ "snowbridge-core", "snowbridge-outbound-queue-merkle-tree", "sp-api", - "sp-core", "sp-std 14.0.0", - "staging-xcm", ] [[package]] name = "snowbridge-pallet-ethereum-client" version = "0.2.0" dependencies = [ - "bp-runtime", - "byte-slice-cast", "frame-benchmarking", "frame-support", "frame-system", @@ -5203,7 +4593,6 @@ dependencies = [ "pallet-timestamp", "parity-scale-codec", "rand", - "rlp", "scale-info", "serde", "serde_json", @@ -5216,8 +4605,6 @@ dependencies = [ "sp-keyring", "sp-runtime", "sp-std 14.0.0", - "ssz_rs", - "ssz_rs_derive", "static_assertions", ] @@ -5225,9 +4612,6 @@ dependencies = [ name = "snowbridge-pallet-ethereum-client-fixtures" version = "0.9.0" dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", "hex-literal", "snowbridge-beacon-primitives", "snowbridge-core", @@ -5240,21 +4624,18 @@ name = "snowbridge-pallet-inbound-queue" version = "0.2.0" dependencies = [ "alloy-primitives", - "alloy-rlp", "alloy-sol-types", "frame-benchmarking", "frame-support", "frame-system", "hex-literal", "log", - "num-traits", "pallet-balances", "parity-scale-codec", "scale-info", "serde", "snowbridge-beacon-primitives", "snowbridge-core", - "snowbridge-ethereum", "snowbridge-pallet-ethereum-client", "snowbridge-pallet-inbound-queue-fixtures", "snowbridge-router-primitives", @@ -5264,7 +4645,6 @@ dependencies = [ "sp-runtime", "sp-std 14.0.0", "staging-xcm", - "staging-xcm-builder", "staging-xcm-executor", ] @@ -5272,9 +4652,6 @@ dependencies = [ name = "snowbridge-pallet-inbound-queue-fixtures" version = "0.10.0" dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", "hex-literal", "snowbridge-beacon-primitives", "snowbridge-core", @@ -5291,7 +4668,6 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "hex-literal", "pallet-message-queue", "parity-scale-codec", "scale-info", @@ -5304,14 +4680,12 @@ dependencies = [ "sp-keyring", "sp-runtime", "sp-std 14.0.0", - "staging-xcm", ] [[package]] name = "snowbridge-pallet-system" version = "0.2.0" dependencies = [ - "ethabi-decode", "frame-benchmarking", "frame-support", "frame-system", @@ -5331,7 +4705,6 @@ dependencies = [ "sp-runtime", "sp-std 14.0.0", "staging-xcm", - "staging-xcm-builder", "staging-xcm-executor", ] @@ -5339,22 +4712,18 @@ dependencies = [ name = "snowbridge-router-primitives" version = "0.9.0" dependencies = [ - "ethabi-decode", "frame-support", - "frame-system", "hex-literal", "log", "parity-scale-codec", "rustc-hex", "scale-info", - "serde", "snowbridge-core", "sp-core", "sp-io", "sp-runtime", "sp-std 14.0.0", "staging-xcm", - "staging-xcm-builder", "staging-xcm-executor", ] @@ -5363,7 +4732,6 @@ name = "snowbridge-runtime-common" version = "0.2.0" dependencies = [ "frame-support", - "frame-system", "log", "parity-scale-codec", "snowbridge-core", @@ -5378,77 +4746,30 @@ dependencies = [ name = "snowbridge-runtime-test-common" version = "0.2.0" dependencies = [ - "assets-common", - "bridge-hub-test-utils", - "bridge-runtime-common", - "cumulus-pallet-aura-ext", "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal", - "log", - "pallet-aura", - "pallet-authorship", "pallet-balances", "pallet-collator-selection", "pallet-message-queue", - "pallet-multisig", "pallet-session", "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", "pallet-utility", "pallet-xcm", - "pallet-xcm-benchmarks", - "parachains-common", "parachains-runtimes-test-utils", "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain-primitives", - "polkadot-runtime-common", - "scale-info", - "serde", - "smallvec", - "snowbridge-beacon-primitives", "snowbridge-core", - "snowbridge-outbound-queue-runtime-api", "snowbridge-pallet-ethereum-client", "snowbridge-pallet-ethereum-client-fixtures", - "snowbridge-pallet-inbound-queue", "snowbridge-pallet-outbound-queue", "snowbridge-pallet-system", - "snowbridge-router-primitives", - "snowbridge-system-runtime-api", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", "sp-core", - "sp-genesis-builder", - "sp-inherents", "sp-io", "sp-keyring", - "sp-offchain", "sp-runtime", - "sp-session", - "sp-std 14.0.0", - "sp-storage 19.0.0", - "sp-transaction-pool", - "sp-version", "staging-parachain-info", "staging-xcm", - "staging-xcm-builder", "staging-xcm-executor", - "static_assertions", ] [[package]] @@ -5458,7 +4779,6 @@ dependencies = [ "parity-scale-codec", "snowbridge-core", "sp-api", - "sp-core", "sp-std 14.0.0", "staging-xcm", ] @@ -5552,15 +4872,6 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "sp-block-builder" -version = "26.0.0" -dependencies = [ - "sp-api", - "sp-inherents", - "sp-runtime", -] - [[package]] name = "sp-consensus-aura" version = "0.32.0" @@ -5593,22 +4904,6 @@ dependencies = [ "sp-timestamp", ] -[[package]] -name = "sp-consensus-grandpa" -version = "13.0.0" -dependencies = [ - "finality-grandpa", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "sp-runtime", -] - [[package]] name = "sp-consensus-slots" version = "0.32.0" @@ -5688,7 +4983,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing" -version = "0.0.0" +version = "0.1.0" dependencies = [ "blake2b_simd", "byteorder", @@ -5700,7 +4995,7 @@ dependencies = [ [[package]] name = "sp-crypto-hashing-proc-macro" -version = "0.0.0" +version = "0.1.0" dependencies = [ "quote", "sp-crypto-hashing", @@ -5748,8 +5043,10 @@ dependencies = [ [[package]] name = "sp-genesis-builder" -version = "0.7.0" +version = "0.8.0" dependencies = [ + "parity-scale-codec", + "scale-info", "serde_json", "sp-api", "sp-runtime", @@ -5798,7 +5095,7 @@ version = "31.0.0" dependencies = [ "sp-core", "sp-runtime", - "strum", + "strum 0.26.2", ] [[package]] @@ -5840,15 +5137,6 @@ dependencies = [ "sp-runtime", ] -[[package]] -name = "sp-offchain" -version = "26.0.0" -dependencies = [ - "sp-api", - "sp-core", - "sp-runtime", -] - [[package]] name = "sp-panic-handler" version = "13.0.0" @@ -6038,7 +5326,7 @@ dependencies = [ "parity-scale-codec", "tracing", "tracing-core", - "tracing-subscriber", + "tracing-subscriber 0.3.18", ] [[package]] @@ -6050,15 +5338,7 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk)", "tracing", "tracing-core", - "tracing-subscriber", -] - -[[package]] -name = "sp-transaction-pool" -version = "26.0.0" -dependencies = [ - "sp-api", - "sp-runtime", + "tracing-subscriber 0.2.25", ] [[package]] @@ -6113,11 +5393,9 @@ dependencies = [ name = "sp-wasm-interface" version = "20.0.0" dependencies = [ - "anyhow", "impl-trait-for-tuples", "log", "parity-scale-codec", - "wasmtime", ] [[package]] @@ -6282,8 +5560,14 @@ name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" dependencies = [ - "strum_macros", + "strum_macros 0.26.2", ] [[package]] @@ -6299,6 +5583,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.58", +] + [[package]] name = "substrate-bip39" version = "0.4.7" @@ -6321,7 +5618,7 @@ dependencies = [ "parity-wasm", "polkavm-linker", "sp-maybe-compressed-blob", - "strum", + "strum 0.26.2", "tempfile", "toml", "walkdir", @@ -6368,18 +5665,6 @@ dependencies = [ "syn 2.0.58", ] -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - [[package]] name = "tap" version = "1.0.1" @@ -6577,6 +5862,17 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-serde" version = "0.1.3" @@ -6596,7 +5892,7 @@ dependencies = [ "ansi_term", "chrono", "lazy_static", - "matchers", + "matchers 0.0.1", "regex", "serde", "serde_json", @@ -6605,18 +5901,35 @@ dependencies = [ "thread_local", "tracing", "tracing-core", - "tracing-log", + "tracing-log 0.1.4", "tracing-serde", ] +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers 0.1.0", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log 0.2.0", +] + [[package]] name = "trie-db" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff28e0f815c2fea41ebddf148e008b077d2faddb026c9555b29696114d602642" +checksum = "65ed83be775d85ebb0e272914fff6462c39b3ddd6dc67b5c1c41271aad280c69" dependencies = [ "hash-db", - "hashbrown 0.13.2", "log", "rustc-hex", "smallvec", @@ -6723,6 +6036,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "valuable" version = "0.1.0" @@ -6883,8 +6202,8 @@ checksum = "fc942673e7684671f0c5708fc18993569d184265fd5223bb51fc8e5b9b6cfd52" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index db38afbdc72e..da1bf69fa5e9 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -280,7 +280,8 @@ pub mod pallet { .map_err(|_| Error::::InvalidPayload)?; // Convert VersionMessage to XCM - let (xcm, fee) = Self::do_convert(envelope.message_id, message.clone())?; + let (xcm, fee) = + Self::do_convert(channel.para_id, envelope.message_id, message.clone())?; log::info!( target: LOG_TARGET, @@ -329,10 +330,11 @@ pub mod pallet { impl Pallet { pub fn do_convert( + para_id: ParaId, message_id: H256, message: VersionedMessage, ) -> Result<(Xcm<()>, BalanceOf), Error> { - let (xcm, fee) = T::MessageConverter::convert(message_id, message) + let (xcm, fee) = T::MessageConverter::convert(para_id, message_id, message) .map_err(|e| Error::::ConvertMessage(e))?; Ok((xcm, fee)) } diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 90f9b11788ba..c5045a44afb4 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -265,7 +265,7 @@ fn test_convert_transact() { }, }); // Convert the message to XCM - let (xcm, dest_fee) = InboundQueue::do_convert(message_id, message).unwrap(); + let (xcm, dest_fee) = InboundQueue::do_convert(1000.into(), message_id, message).unwrap(); let instructions = xcm.into_inner(); assert_eq!(instructions.len(), 7); assert_eq!(dest_fee, fee.into()); diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 9938a8bce05a..5b6182704856 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -9,6 +9,7 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::{traits::tokens::Balance as BalanceT, weights::Weight, PalletError}; use scale_info::TypeInfo; +use snowbridge_core::{IsSystem, ParaId}; use sp_core::{Get, RuntimeDebug, H160, H256}; use sp_io::hashing::blake2_256; use sp_runtime::MultiAddress; @@ -129,6 +130,7 @@ pub trait ConvertMessage { type AccountId; /// Converts a versioned message into an XCM message and an optional topicID fn convert( + para_id: ParaId, message_id: H256, message: VersionedMessage, ) -> Result<(Xcm<()>, Self::Balance), ConvertMessageError>; @@ -155,6 +157,7 @@ impl Result<(Xcm<()>, Self::Balance), ConvertMessageError> { @@ -169,6 +172,7 @@ impl Ok(Self::convert_transact( + para_id, message_id, chain_id, sender, @@ -335,6 +339,7 @@ where } fn convert_transact( + para_id: ParaId, message_id: H256, chain_id: u64, sender: H160, @@ -344,7 +349,12 @@ where payload: Vec, ) -> (Xcm<()>, Balance) { // Fee in native token of destination chain - let xcm_fee: Asset = (Location::here(), fee).into(); + let mut xcm_fee: Asset = (Location::here(), fee).into(); + + // For system parachain use relay token as fee + if ParaId::from(para_id).is_system() { + xcm_fee = (Location::parent(), fee).into(); + } let message = vec![ DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index e56c55d32b66..7c64ab00d222 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -541,7 +541,7 @@ fn register_weth_token_in_asset_hub_fail_for_insufficient_fee() { fee: INSUFFICIENT_XCM_FEE, }, }); - let (xcm, _) = Converter::convert(message_id, message).unwrap(); + let (xcm, _) = Converter::convert(AssetHubRococo::para_id(), message_id, message).unwrap(); let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap(); assert_expected_events!( @@ -603,7 +603,8 @@ fn transact_from_ethereum_to_penpal_success() { }, }); // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + let (xcm, _) = + EthereumInboundQueue::do_convert(PenpalA::para_id(), message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); @@ -644,7 +645,8 @@ fn transact_from_ethereum_to_penpal_insufficient_weight() { }, }); // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + let (xcm, _) = + EthereumInboundQueue::do_convert(PenpalA::para_id(), message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); @@ -700,7 +702,8 @@ fn transact_from_ethereum_to_penpal_insufficient_fee() { }, }); // Convert the message to XCM - let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); + let (xcm, _) = + EthereumInboundQueue::do_convert(PenpalA::para_id(), message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); diff --git a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs index 2a1318c23707..364dffd80dd6 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/xcm_config.rs @@ -32,11 +32,8 @@ use crate::{BaseDeliveryFee, FeeAssetId, TransactionByteFee}; use codec::Encode; use core::marker::PhantomData; use frame_support::{ - ensure, parameter_types, - traits::{ - ConstU32, Contains, ContainsPair, Equals, Everything, EverythingBut, Get, Nothing, - ProcessMessageError, - }, + parameter_types, + traits::{ConstU32, Contains, ContainsPair, Everything, EverythingBut, Get, Nothing}, weights::Weight, }; use frame_system::EnsureRoot; @@ -46,20 +43,20 @@ use polkadot_parachain_primitives::primitives::Sibling; use polkadot_runtime_common::{impls::ToAuthor, xcm_sender::ExponentialPrice}; use sp_core::blake2_256; use sp_runtime::traits::{AccountIdConversion, ConvertInto}; -use sp_std::{collections::btree_set::BTreeSet, ops::ControlFlow}; +use sp_std::collections::btree_set::BTreeSet; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, CreateMatcher, - EnsureXcmOrigin, FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, - FungiblesAdapter, IsConcrete, LocalMint, MatchXcm, NativeAsset, NoChecking, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, StartsWith, - TakeWeightCredit, TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, + AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, EnsureXcmOrigin, + FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, FungiblesAdapter, IsConcrete, + LocalMint, NativeAsset, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, StartsWith, TakeWeightCredit, + TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents, XcmFeeToAccount, }; use xcm_executor::{ - traits::{ConvertLocation, JustTry, Properties, ShouldExecute, WeightTrader}, + traits::{ConvertLocation, JustTry}, XcmExecutor, }; From 5a229728b1dc360c2d9939d6ca1b6ed67cfa229a Mon Sep 17 00:00:00 2001 From: ron Date: Fri, 26 Apr 2024 23:18:43 +0800 Subject: [PATCH 41/44] Make fee asset as configuration parameter of the Channel --- .../pallets/inbound-queue/src/lib.rs | 7 +- .../pallets/inbound-queue/src/mock.rs | 6 +- .../pallets/inbound-queue/src/test.rs | 12 ++- .../pallets/system/src/benchmarking.rs | 37 ++++++-- bridges/snowbridge/pallets/system/src/lib.rs | 41 +++++++-- .../snowbridge/pallets/system/src/tests.rs | 89 ++++++++++++++++--- bridges/snowbridge/primitives/core/src/lib.rs | 3 + .../primitives/router/src/inbound/mod.rs | 29 +++--- .../bridge-hub-rococo/src/tests/snowbridge.rs | 30 ++++--- 9 files changed, 195 insertions(+), 59 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index da1bf69fa5e9..c113ccce7ec4 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -84,6 +84,7 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + use xcm::VersionedLocation; #[pallet::pallet] pub struct Pallet(_); @@ -281,7 +282,7 @@ pub mod pallet { // Convert VersionMessage to XCM let (xcm, fee) = - Self::do_convert(channel.para_id, envelope.message_id, message.clone())?; + Self::do_convert(channel.fee_asset_id, envelope.message_id, message.clone())?; log::info!( target: LOG_TARGET, @@ -330,11 +331,11 @@ pub mod pallet { impl Pallet { pub fn do_convert( - para_id: ParaId, + fee_asset_id: VersionedLocation, message_id: H256, message: VersionedMessage, ) -> Result<(Xcm<()>, BalanceOf), Error> { - let (xcm, fee) = T::MessageConverter::convert(para_id, message_id, message) + let (xcm, fee) = T::MessageConverter::convert(fee_asset_id, message_id, message) .map_err(|e| Error::::ConvertMessage(e))?; Ok((xcm, fee)) } diff --git a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs index c96c868bc26e..3f0794180e75 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/mock.rs @@ -195,7 +195,11 @@ impl StaticLookup for MockChannelLookup { { return None } - Some(Channel { agent_id: H256::zero(), para_id: ASSET_HUB_PARAID.into() }) + Some(Channel { + agent_id: H256::zero(), + para_id: ASSET_HUB_PARAID.into(), + fee_asset_id: VersionedLocation::from(Location::here()), + }) } } diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index c5045a44afb4..9f3b9574d217 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -8,7 +8,10 @@ use snowbridge_core::{inbound::Proof, ChannelId}; use sp_keyring::AccountKeyring as Keyring; use sp_runtime::DispatchError; use sp_std::convert::From; -use xcm::prelude::{OriginKind, Transact}; +use xcm::{ + prelude::{OriginKind, Transact}, + VersionedLocation, +}; use crate::{Error, Event as InboundQueueEvent}; @@ -265,7 +268,12 @@ fn test_convert_transact() { }, }); // Convert the message to XCM - let (xcm, dest_fee) = InboundQueue::do_convert(1000.into(), message_id, message).unwrap(); + let (xcm, dest_fee) = InboundQueue::do_convert( + VersionedLocation::from(Location::parent()), + message_id, + message, + ) + .unwrap(); let instructions = xcm.into_inner(); assert_eq!(instructions.len(), 7); assert_eq!(dest_fee, fee.into()); diff --git a/bridges/snowbridge/pallets/system/src/benchmarking.rs b/bridges/snowbridge/pallets/system/src/benchmarking.rs index ef908ad6a3f9..58956cb22668 100644 --- a/bridges/snowbridge/pallets/system/src/benchmarking.rs +++ b/bridges/snowbridge/pallets/system/src/benchmarking.rs @@ -83,7 +83,11 @@ mod benchmarks { SnowbridgeControl::::create_agent(origin.clone())?; #[extrinsic_call] - _(origin as T::RuntimeOrigin, OperatingMode::Normal); + _( + origin as T::RuntimeOrigin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()), + ); Ok(()) } @@ -95,10 +99,18 @@ mod benchmarks { let origin = T::Helper::make_xcm_origin(origin_location); fund_sovereign_account::(origin_para_id.into())?; SnowbridgeControl::::create_agent(origin.clone())?; - SnowbridgeControl::::create_channel(origin.clone(), OperatingMode::Normal)?; + SnowbridgeControl::::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()), + )?; #[extrinsic_call] - _(origin as T::RuntimeOrigin, OperatingMode::RejectingOutboundMessages); + _( + origin as T::RuntimeOrigin, + OperatingMode::RejectingOutboundMessages, + VersionedLocation::from(Location::here()), + ); Ok(()) } @@ -112,10 +124,19 @@ mod benchmarks { fund_sovereign_account::(origin_para_id.into())?; SnowbridgeControl::::create_agent(origin.clone())?; - SnowbridgeControl::::create_channel(origin.clone(), OperatingMode::Normal)?; + SnowbridgeControl::::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()), + )?; #[extrinsic_call] - _(RawOrigin::Root, channel_id, OperatingMode::RejectingOutboundMessages); + _( + RawOrigin::Root, + channel_id, + OperatingMode::RejectingOutboundMessages, + VersionedLocation::from(Location::here()), + ); Ok(()) } @@ -127,7 +148,11 @@ mod benchmarks { let origin = T::Helper::make_xcm_origin(origin_location); fund_sovereign_account::(origin_para_id.into())?; SnowbridgeControl::::create_agent(origin.clone())?; - SnowbridgeControl::::create_channel(origin.clone(), OperatingMode::Normal)?; + SnowbridgeControl::::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()), + )?; #[extrinsic_call] _(origin as T::RuntimeOrigin, H160::default(), 1); diff --git a/bridges/snowbridge/pallets/system/src/lib.rs b/bridges/snowbridge/pallets/system/src/lib.rs index 715bb764cd34..e8ee05e2e592 100644 --- a/bridges/snowbridge/pallets/system/src/lib.rs +++ b/bridges/snowbridge/pallets/system/src/lib.rs @@ -385,7 +385,11 @@ pub mod pallet { /// - `mode`: Initial operating mode of the channel #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::create_channel())] - pub fn create_channel(origin: OriginFor, mode: OperatingMode) -> DispatchResult { + pub fn create_channel( + origin: OriginFor, + mode: OperatingMode, + fee_asset_id: VersionedLocation, + ) -> DispatchResult { let origin_location: Location = T::SiblingOrigin::ensure_origin(origin)?; // Ensure that origin location is a sibling parachain @@ -396,7 +400,7 @@ pub mod pallet { ensure!(Agents::::contains_key(agent_id), Error::::NoAgent); ensure!(!Channels::::contains_key(channel_id), Error::::ChannelAlreadyCreated); - let channel = Channel { agent_id, para_id }; + let channel = Channel { agent_id, para_id, fee_asset_id }; Channels::::insert(channel_id, channel); let command = Command::CreateChannel { channel_id, agent_id, mode }; @@ -417,7 +421,11 @@ pub mod pallet { /// - `mode`: Initial operating mode of the channel #[pallet::call_index(5)] #[pallet::weight(T::WeightInfo::update_channel())] - pub fn update_channel(origin: OriginFor, mode: OperatingMode) -> DispatchResult { + pub fn update_channel( + origin: OriginFor, + mode: OperatingMode, + fee_asset_id: VersionedLocation, + ) -> DispatchResult { let origin_location: Location = T::SiblingOrigin::ensure_origin(origin)?; // Ensure that origin location is a sibling parachain @@ -427,6 +435,10 @@ pub mod pallet { ensure!(Channels::::contains_key(channel_id), Error::::NoChannel); + Channels::::mutate_extant(channel_id, |channel| { + channel.fee_asset_id = fee_asset_id; + }); + let command = Command::UpdateChannel { channel_id, mode }; let pays_fee = PaysFee::::Partial(sibling_sovereign_account::(para_id)); @@ -451,11 +463,16 @@ pub mod pallet { origin: OriginFor, channel_id: ChannelId, mode: OperatingMode, + fee_asset_id: VersionedLocation, ) -> DispatchResult { ensure_root(origin)?; ensure!(Channels::::contains_key(channel_id), Error::::NoChannel); + Channels::::mutate_extant(channel_id, |channel| { + channel.fee_asset_id = fee_asset_id; + }); + let command = Command::UpdateChannel { channel_id, mode }; Self::send(PRIMARY_GOVERNANCE_CHANNEL, command, PaysFee::::No)?; @@ -634,7 +651,11 @@ pub mod pallet { Agents::::insert(asset_hub_agent_id, ()); Channels::::insert( asset_hub_channel_id, - Channel { agent_id: asset_hub_agent_id, para_id: asset_hub_para_id }, + Channel { + agent_id: asset_hub_agent_id, + para_id: asset_hub_para_id, + fee_asset_id: VersionedLocation::from(Location::parent()), + }, ); // Governance channels @@ -645,13 +666,21 @@ pub mod pallet { // Primary governance channel Channels::::insert( PRIMARY_GOVERNANCE_CHANNEL, - Channel { agent_id: bridge_hub_agent_id, para_id }, + Channel { + agent_id: bridge_hub_agent_id, + para_id, + fee_asset_id: VersionedLocation::from(Location::parent()), + }, ); // Secondary governance channel Channels::::insert( SECONDARY_GOVERNANCE_CHANNEL, - Channel { agent_id: bridge_hub_agent_id, para_id }, + Channel { + agent_id: bridge_hub_agent_id, + para_id, + fee_asset_id: VersionedLocation::from(Location::parent()), + }, ); Ok(()) diff --git a/bridges/snowbridge/pallets/system/src/tests.rs b/bridges/snowbridge/pallets/system/src/tests.rs index 09f24195a30a..5ddd0f3ebfd6 100644 --- a/bridges/snowbridge/pallets/system/src/tests.rs +++ b/bridges/snowbridge/pallets/system/src/tests.rs @@ -248,7 +248,11 @@ fn create_channel() { let _ = Balances::mint_into(&sovereign_account, 10000); assert_ok!(EthereumSystem::create_agent(origin.clone())); - assert_ok!(EthereumSystem::create_channel(origin, OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); }); } @@ -264,10 +268,18 @@ fn create_channel_fail_already_exists() { let _ = Balances::mint_into(&sovereign_account, 10000); assert_ok!(EthereumSystem::create_agent(origin.clone())); - assert_ok!(EthereumSystem::create_channel(origin.clone(), OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); assert_noop!( - EthereumSystem::create_channel(origin, OperatingMode::Normal), + EthereumSystem::create_channel( + origin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + ), Error::::ChannelAlreadyCreated ); }); @@ -281,6 +293,7 @@ fn create_channel_bad_origin() { EthereumSystem::create_channel( make_xcm_origin(Location::new(1, [])), OperatingMode::Normal, + VersionedLocation::from(Location::here()), ), BadOrigin, ); @@ -293,6 +306,7 @@ fn create_channel_bad_origin() { [Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }], )), OperatingMode::Normal, + VersionedLocation::from(Location::here()), ), BadOrigin, ); @@ -305,6 +319,7 @@ fn create_channel_bad_origin() { [Junction::AccountId32 { network: None, id: [67u8; 32] }], )), OperatingMode::Normal, + VersionedLocation::from(Location::here()), ), BadOrigin, ); @@ -314,6 +329,7 @@ fn create_channel_bad_origin() { EthereumSystem::create_channel( RuntimeOrigin::signed([14; 32].into()), OperatingMode::Normal, + VersionedLocation::from(Location::here()), ), BadOrigin ); @@ -334,10 +350,18 @@ fn update_channel() { // First create the channel let _ = Balances::mint_into(&sovereign_account, 10000); assert_ok!(EthereumSystem::create_agent(origin.clone())); - assert_ok!(EthereumSystem::create_channel(origin.clone(), OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); // Now try to update it - assert_ok!(EthereumSystem::update_channel(origin, OperatingMode::Normal)); + assert_ok!(EthereumSystem::update_channel( + origin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); System::assert_last_event(RuntimeEvent::EthereumSystem(crate::Event::UpdateChannel { channel_id: ParaId::from(2000).into(), @@ -353,7 +377,11 @@ fn update_channel_bad_origin() { // relay chain location not allowed assert_noop!( - EthereumSystem::update_channel(make_xcm_origin(Location::new(1, [])), mode,), + EthereumSystem::update_channel( + make_xcm_origin(Location::new(1, [])), + mode, + VersionedLocation::from(Location::here()) + ), BadOrigin, ); @@ -365,6 +393,7 @@ fn update_channel_bad_origin() { [Parachain(2000), Junction::AccountId32 { network: None, id: [67u8; 32] }], )), mode, + VersionedLocation::from(Location::here()), ), BadOrigin, ); @@ -377,18 +406,30 @@ fn update_channel_bad_origin() { [Junction::AccountId32 { network: None, id: [67u8; 32] }], )), mode, + VersionedLocation::from(Location::here()), ), BadOrigin, ); // Signed origin not allowed assert_noop!( - EthereumSystem::update_channel(RuntimeOrigin::signed([14; 32].into()), mode), + EthereumSystem::update_channel( + RuntimeOrigin::signed([14; 32].into()), + mode, + VersionedLocation::from(Location::here()) + ), BadOrigin ); // None origin not allowed - assert_noop!(EthereumSystem::update_channel(RuntimeOrigin::none(), mode), BadOrigin); + assert_noop!( + EthereumSystem::update_channel( + RuntimeOrigin::none(), + mode, + VersionedLocation::from(Location::here()) + ), + BadOrigin + ); }); } @@ -400,7 +441,11 @@ fn update_channel_fails_not_exist() { // Now try to update it assert_noop!( - EthereumSystem::update_channel(origin, OperatingMode::Normal), + EthereumSystem::update_channel( + origin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + ), Error::::NoChannel ); }); @@ -419,7 +464,11 @@ fn force_update_channel() { // First create the channel let _ = Balances::mint_into(&sovereign_account, 10000); assert_ok!(EthereumSystem::create_agent(origin.clone())); - assert_ok!(EthereumSystem::create_channel(origin.clone(), OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); // Now try to force update it let force_origin = RuntimeOrigin::root(); @@ -427,6 +476,7 @@ fn force_update_channel() { force_origin, channel_id, OperatingMode::Normal, + VersionedLocation::from(Location::here()), )); System::assert_last_event(RuntimeEvent::EthereumSystem(crate::Event::UpdateChannel { @@ -447,6 +497,7 @@ fn force_update_channel_bad_origin() { RuntimeOrigin::signed([14; 32].into()), ParaId::from(1000).into(), mode, + VersionedLocation::from(Location::here()), ), BadOrigin, ); @@ -463,7 +514,11 @@ fn transfer_native_from_agent() { // First create the agent and channel assert_ok!(EthereumSystem::create_agent(origin.clone())); - assert_ok!(EthereumSystem::create_channel(origin, OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); let origin = make_xcm_origin(origin_location.clone()); assert_ok!(EthereumSystem::transfer_native_from_agent(origin, recipient, amount),); @@ -549,7 +604,11 @@ fn charge_fee_for_create_agent() { assert_ok!(EthereumSystem::create_agent(origin.clone())); let fee_charged = initial_sovereign_balance - Balances::balance(&sovereign_account); - assert_ok!(EthereumSystem::create_channel(origin, OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin, + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); // assert sovereign_balance decreased by (fee.base_fee + fee.delivery_fee) let message = Message { @@ -584,7 +643,11 @@ fn charge_fee_for_transfer_native_from_agent() { // create_agent & create_channel first assert_ok!(EthereumSystem::create_agent(origin.clone())); - assert_ok!(EthereumSystem::create_channel(origin.clone(), OperatingMode::Normal)); + assert_ok!(EthereumSystem::create_channel( + origin.clone(), + OperatingMode::Normal, + VersionedLocation::from(Location::here()) + )); // assert sovereign_balance decreased by only the base_fee let sovereign_balance_before = Balances::balance(&sovereign_account); diff --git a/bridges/snowbridge/primitives/core/src/lib.rs b/bridges/snowbridge/primitives/core/src/lib.rs index ed1af4225d24..1ad256cd5869 100644 --- a/bridges/snowbridge/primitives/core/src/lib.rs +++ b/bridges/snowbridge/primitives/core/src/lib.rs @@ -36,6 +36,7 @@ pub type AgentId = H256; pub use operating_mode::BasicOperatingMode; pub use pricing::{PricingParameters, Rewards}; +use xcm::VersionedLocation; pub fn sibling_sovereign_account(para_id: ParaId) -> T::AccountId where @@ -132,6 +133,8 @@ pub struct Channel { pub agent_id: AgentId, /// ID of the parachain who will receive or send messages using this channel pub para_id: ParaId, + /// ID of the fee asset + pub fee_asset_id: VersionedLocation, } pub trait StaticLookup { diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 5b6182704856..b4228fc52d83 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -9,7 +9,6 @@ use codec::{Decode, Encode}; use core::marker::PhantomData; use frame_support::{traits::tokens::Balance as BalanceT, weights::Weight, PalletError}; use scale_info::TypeInfo; -use snowbridge_core::{IsSystem, ParaId}; use sp_core::{Get, RuntimeDebug, H160, H256}; use sp_io::hashing::blake2_256; use sp_runtime::MultiAddress; @@ -122,6 +121,8 @@ pub struct MessageToXcm< pub enum ConvertMessageError { /// The message version is not supported for conversion. UnsupportedVersion, + /// The fee asset is not supported for conversion. + UnsupportedFeeAsset, } /// convert the inbound message to xcm which will be forwarded to the destination chain @@ -130,7 +131,7 @@ pub trait ConvertMessage { type AccountId; /// Converts a versioned message into an XCM message and an optional topicID fn convert( - para_id: ParaId, + fee_asset_id: VersionedLocation, message_id: H256, message: VersionedMessage, ) -> Result<(Xcm<()>, Self::Balance), ConvertMessageError>; @@ -157,7 +158,7 @@ impl Result<(Xcm<()>, Self::Balance), ConvertMessageError> { @@ -171,8 +172,8 @@ impl Ok(Self::convert_transact( - para_id, + }) => Self::convert_transact( + fee_asset_id, message_id, chain_id, sender, @@ -180,7 +181,7 @@ impl, - ) -> (Xcm<()>, Balance) { - // Fee in native token of destination chain - let mut xcm_fee: Asset = (Location::here(), fee).into(); - - // For system parachain use relay token as fee - if ParaId::from(para_id).is_system() { - xcm_fee = (Location::parent(), fee).into(); - } + ) -> Result<(Xcm<()>, Balance), ConvertMessageError> { + let fee_asset_id: Location = + fee_asset_id.try_into().map_err(|_| ConvertMessageError::UnsupportedFeeAsset)?; + let xcm_fee: Asset = (fee_asset_id, fee).into(); let message = vec![ DescendOrigin(PalletInstance(InboundQueuePalletInstance::get()).into()), @@ -369,7 +366,7 @@ where // Forward message id SetTopic(message_id.into()), ]; - (message.into(), fee.into()) + Ok((message.into(), fee.into())) } } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 7c64ab00d222..fa3e05029f7e 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -50,7 +50,7 @@ pub enum ControlCall { #[codec(index = 3)] CreateAgent, #[codec(index = 4)] - CreateChannel { mode: OperatingMode }, + CreateChannel { mode: OperatingMode, fee_asset_id: VersionedLocation }, } #[allow(clippy::large_enum_variant)] @@ -152,8 +152,10 @@ fn create_channel() { }, ])); - let create_channel_call = - SnowbridgeControl::Control(ControlCall::CreateChannel { mode: OperatingMode::Normal }); + let create_channel_call = SnowbridgeControl::Control(ControlCall::CreateChannel { + mode: OperatingMode::Normal, + fee_asset_id: VersionedLocation::from(Location::here()), + }); // Construct XCM to create a channel for para 1001 let create_channel_xcm = VersionedXcm::from(Xcm::<()>(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, @@ -541,7 +543,9 @@ fn register_weth_token_in_asset_hub_fail_for_insufficient_fee() { fee: INSUFFICIENT_XCM_FEE, }, }); - let (xcm, _) = Converter::convert(AssetHubRococo::para_id(), message_id, message).unwrap(); + + let fee_asset_id = VersionedLocation::from(Location::parent()); + let (xcm, _) = Converter::convert(fee_asset_id, message_id, message).unwrap(); let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap(); assert_expected_events!( @@ -586,9 +590,11 @@ fn transact_from_ethereum_to_penpal_success() { .unwrap(); snowbridge_pallet_system::Agents::::insert(agent_id, ()); let channel_id: ChannelId = PenpalA::para_id().into(); + + let fee_asset_id = VersionedLocation::from(Location::here()); snowbridge_pallet_system::Channels::::insert( channel_id, - Channel { agent_id, para_id: PenpalA::para_id() }, + Channel { agent_id, para_id: PenpalA::para_id(), fee_asset_id: fee_asset_id.clone() }, ); let message_id: H256 = [1; 32].into(); @@ -603,8 +609,7 @@ fn transact_from_ethereum_to_penpal_success() { }, }); // Convert the message to XCM - let (xcm, _) = - EthereumInboundQueue::do_convert(PenpalA::para_id(), message_id, message).unwrap(); + let (xcm, _) = EthereumInboundQueue::do_convert(fee_asset_id, message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); @@ -644,9 +649,9 @@ fn transact_from_ethereum_to_penpal_insufficient_weight() { payload: hex!("00071468656c6c6f").to_vec(), }, }); + let fee_asset_id = VersionedLocation::from(Location::here()); // Convert the message to XCM - let (xcm, _) = - EthereumInboundQueue::do_convert(PenpalA::para_id(), message_id, message).unwrap(); + let (xcm, _) = EthereumInboundQueue::do_convert(fee_asset_id, message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); @@ -685,9 +690,11 @@ fn transact_from_ethereum_to_penpal_insufficient_fee() { .unwrap(); snowbridge_pallet_system::Agents::::insert(agent_id, ()); let channel_id: ChannelId = PenpalA::para_id().into(); + + let fee_asset_id = VersionedLocation::from(Location::here()); snowbridge_pallet_system::Channels::::insert( channel_id, - Channel { agent_id, para_id: PenpalA::para_id() }, + Channel { agent_id, para_id: PenpalA::para_id(), fee_asset_id: fee_asset_id.clone() }, ); let message_id: H256 = [1; 32].into(); @@ -702,8 +709,7 @@ fn transact_from_ethereum_to_penpal_insufficient_fee() { }, }); // Convert the message to XCM - let (xcm, _) = - EthereumInboundQueue::do_convert(PenpalA::para_id(), message_id, message).unwrap(); + let (xcm, _) = EthereumInboundQueue::do_convert(fee_asset_id, message_id, message).unwrap(); // Send the XCM let _ = EthereumInboundQueue::send_xcm(xcm, PenpalA::para_id().into()).unwrap(); From 9829de7a0e12816c96c820b91abe195af8486269 Mon Sep 17 00:00:00 2001 From: ron Date: Sun, 28 Apr 2024 11:05:35 +0800 Subject: [PATCH 42/44] Zero fee for transact --- .../snowbridge/pallets/inbound-queue/src/lib.rs | 14 ++++---------- .../snowbridge/pallets/inbound-queue/src/test.rs | 2 +- .../primitives/router/src/inbound/mod.rs | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index c113ccce7ec4..b5fc2fe15450 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -291,16 +291,10 @@ pub mod pallet { fee ); - match message { - // For RegisterToken|SendToken burning fees for teleport - VersionedMessage::V1(MessageV1 { - command: Command::RegisterToken { .. }, .. - }) | - VersionedMessage::V1(MessageV1 { command: Command::SendToken { .. }, .. }) => - Self::burn_fees(channel.para_id, fee)?, - // For transact do nothing here and leave it to dest chain to pay for fees by sender - VersionedMessage::V1(MessageV1 { command: Command::Transact { .. }, .. }) => (), - }; + if fee > BalanceOf::::zero() { + // Burning fees for teleport + Self::burn_fees(channel.para_id, fee)?; + } // Attempt to send XCM to a dest parachain let message_id = Self::send_xcm(xcm, channel.para_id)?; diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 9f3b9574d217..04e99b67bbcb 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -276,7 +276,7 @@ fn test_convert_transact() { .unwrap(); let instructions = xcm.into_inner(); assert_eq!(instructions.len(), 7); - assert_eq!(dest_fee, fee.into()); + assert_eq!(dest_fee, 0); let transact = instructions.get(5).unwrap().clone(); let expected = Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index b4228fc52d83..99fe85cd5ec8 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -366,7 +366,7 @@ where // Forward message id SetTopic(message_id.into()), ]; - Ok((message.into(), fee.into())) + Ok((message.into(), Balance::zero())) } } From 2f30d4651a269deab22149c97bfceec44bf1614b Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 29 Apr 2024 14:32:22 +0800 Subject: [PATCH 43/44] Remove unused --- bridges/snowbridge/pallets/inbound-queue/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs index b5fc2fe15450..4de4f5cee829 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/lib.rs @@ -233,7 +233,6 @@ pub mod pallet { let who = ensure_signed(origin)?; ensure!(!Self::operating_mode().is_halted(), Error::::Halted); - #[cfg(not(any(feature = "std", test)))] // submit message to verifier for verification,ignore for integration tests T::Verifier::verify(&message.event_log, &message.proof) .map_err(|e| Error::::Verification(e))?; From ee6bdc5acd4dc8ad508d4e8ac115c4fafaad633c Mon Sep 17 00:00:00 2001 From: ron Date: Sat, 4 May 2024 00:06:20 +0800 Subject: [PATCH 44/44] Deposit any left over fees back into the pre-funded account --- .../snowbridge/pallets/inbound-queue/src/test.rs | 3 +-- .../primitives/router/src/inbound/mod.rs | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bridges/snowbridge/pallets/inbound-queue/src/test.rs b/bridges/snowbridge/pallets/inbound-queue/src/test.rs index 04e99b67bbcb..398bd413c900 100644 --- a/bridges/snowbridge/pallets/inbound-queue/src/test.rs +++ b/bridges/snowbridge/pallets/inbound-queue/src/test.rs @@ -275,9 +275,8 @@ fn test_convert_transact() { ) .unwrap(); let instructions = xcm.into_inner(); - assert_eq!(instructions.len(), 7); assert_eq!(dest_fee, 0); - let transact = instructions.get(5).unwrap().clone(); + let transact = instructions.get(6).unwrap().clone(); let expected = Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }; assert_eq!(transact, expected); diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 99fe85cd5ec8..468ba94a8c01 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -362,9 +362,21 @@ where WithdrawAsset(xcm_fee.clone().into()), // Pay for execution. BuyExecution { fees: xcm_fee, weight_limit: Unlimited }, + SetAppendix(Xcm(vec![ + RefundSurplus, + DepositAsset { + assets: Wild(AllCounted(1)), + beneficiary: Location::new( + 0, + [ + GlobalConsensus(Ethereum { chain_id }), + AccountKey20 { network: None, key: sender.into() }, + ], + ), + }, + SetTopic(message_id.into()), + ])), Transact { origin_kind, require_weight_at_most: weight_at_most, call: payload.into() }, - // Forward message id - SetTopic(message_id.into()), ]; Ok((message.into(), Balance::zero())) }