diff --git a/bridges/snowbridge/pallets/inbound-queue-v2/src/api.rs b/bridges/snowbridge/pallets/inbound-queue-v2/src/api.rs index e8c969f389c2..a285a7c5af42 100644 --- a/bridges/snowbridge/pallets/inbound-queue-v2/src/api.rs +++ b/bridges/snowbridge/pallets/inbound-queue-v2/src/api.rs @@ -4,12 +4,13 @@ use crate::{Config, Error}; use snowbridge_core::inbound::Proof; -use snowbridge_router_primitives::inbound::{dry_run::DryRunMessage, v2::Message}; +use snowbridge_router_primitives::inbound::v2::{ConvertMessage, Message}; use xcm::latest::Xcm; -pub fn dry_run(message: Message, _proof: Proof) -> Result<(Xcm<()>, u128), Error> + +pub fn dry_run(message: Message, _proof: Proof) -> Result, Error> where T: Config, { - let _dry_run_result = T::XCMDryRunner::dry_run_xcm(message); - Ok((Xcm::<()>::new(), 0)) + let xcm = T::MessageConverter::convert(message).map_err(|e| Error::::ConvertMessage(e))?; + Ok(xcm) } diff --git a/bridges/snowbridge/pallets/inbound-queue-v2/src/lib.rs b/bridges/snowbridge/pallets/inbound-queue-v2/src/lib.rs index 392cb4d0dcf6..144f78603986 100644 --- a/bridges/snowbridge/pallets/inbound-queue-v2/src/lib.rs +++ b/bridges/snowbridge/pallets/inbound-queue-v2/src/lib.rs @@ -49,10 +49,7 @@ use snowbridge_core::{ inbound::{Message, VerificationError, Verifier}, BasicOperatingMode, }; -use snowbridge_router_primitives::inbound::{ - dry_run::DryRunMessage, - v2::{ConvertMessage, Message as MessageV2}, -}; +use snowbridge_router_primitives::inbound::v2::{ConvertMessage, Message as MessageV2}; pub use weights::WeightInfo; #[cfg(feature = "runtime-benchmarks")] @@ -88,7 +85,6 @@ pub mod pallet { /// XCM message sender type XcmSender: SendXcm; - type XCMDryRunner: DryRunMessage; /// Address of the Gateway contract #[pallet::constant] type GatewayAddress: Get; diff --git a/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs b/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs index f35337da3a61..307dd31479b5 100644 --- a/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs +++ b/bridges/snowbridge/pallets/inbound-queue-v2/src/mock.rs @@ -135,14 +135,6 @@ impl SendXcm for MockXcmSender { } } -pub struct MockXcmDryRunner; - -impl DryRunMessage for MockXcmDryRunner { - fn dry_run_xcm(_message: Message) -> Result, DryRunError> { - Ok(Xcm::<()>::new()) - } -} - pub const DOT: u128 = 10_000_000_000; pub struct MockTokenIdConvert; @@ -166,7 +158,6 @@ impl inbound_queue::Config for Test { type RuntimeEvent = RuntimeEvent; type Verifier = MockVerifier; type XcmSender = MockXcmSender; - type XCMDryRunner = MockXcmDryRunner; type WeightInfo = (); type GatewayAddress = GatewayAddress; type AssetHubParaId = ConstU32<1000>; diff --git a/bridges/snowbridge/primitives/router/src/inbound/dry_run.rs b/bridges/snowbridge/primitives/router/src/inbound/dry_run.rs deleted file mode 100644 index a4db78666816..000000000000 --- a/bridges/snowbridge/primitives/router/src/inbound/dry_run.rs +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// SPDX-FileCopyrightText: 2023 Snowfork -extern crate alloc; - -use crate::inbound::v2::{ConvertMessage, Message}; -use codec::{Decode, Encode}; -use scale_info::TypeInfo; -use sp_runtime::{ - traits::PhantomData, -}; -use xcm::{ - latest::Xcm, -}; - -#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] -pub enum DryRunError { - /// Message cannot be decoded. - InvalidPayload, - /// An API call is unsupported. - Unimplemented, - /// Converting a versioned data structure from one version to another failed. - VersionedConversionFailed, -} - -pub trait DryRunMessage { - fn dry_run_xcm(message: Message) -> Result, DryRunError>; -} - -pub struct MessageToXCM -where - - MessageConverter: ConvertMessage, -{ - _phantom: PhantomData, -} - -impl DryRunMessage - for MessageToXCM -where - MessageConverter: ConvertMessage, -{ - fn dry_run_xcm(message: Message) -> Result, DryRunError> { - let message_xcm = - MessageConverter::convert(message).map_err(|_| DryRunError::InvalidPayload)?; - - Ok(message_xcm) - } -} diff --git a/bridges/snowbridge/primitives/router/src/inbound/mod.rs b/bridges/snowbridge/primitives/router/src/inbound/mod.rs index 1c8e68abf1be..37890e878603 100644 --- a/bridges/snowbridge/primitives/router/src/inbound/mod.rs +++ b/bridges/snowbridge/primitives/router/src/inbound/mod.rs @@ -2,7 +2,6 @@ // SPDX-FileCopyrightText: 2023 Snowfork // SPDX-FileCopyrightText: 2021-2022 Parity Technologies (UK) Ltd. -pub mod dry_run; pub mod v1; pub mod v2; use codec::Encode; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs index b0a606552460..efb1364ead4d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/bridge_to_ethereum_config.rs @@ -26,7 +26,6 @@ use parachains_common::{AccountId, Balance}; use snowbridge_beacon_primitives::{Fork, ForkVersions}; use snowbridge_core::{gwei, meth, AllowSiblingsOnly, PricingParameters, Rewards}; use snowbridge_router_primitives::{ - inbound::v1::MessageToXcm, outbound::{v1::EthereumBlobExporter, v2::EthereumBlobExporter as EthereumBlobExporterV2}, }; use sp_core::H160; @@ -95,7 +94,7 @@ impl snowbridge_pallet_inbound_queue::Config for Runtime { type GatewayAddress = EthereumGatewayAddress; #[cfg(feature = "runtime-benchmarks")] type Helper = Runtime; - type MessageConverter = MessageToXcm< + type MessageConverter = snowbridge_router_primitives::inbound::v1::MessageToXcm< CreateAssetCall, CreateAssetDeposit, ConstU8, @@ -124,6 +123,8 @@ impl snowbridge_pallet_inbound_queue_v2::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] type Helper = Runtime; type WeightInfo = crate::weights::snowbridge_pallet_inbound_queue_v2::WeightInfo; + type AssetHubParaId = ConstU32<1000>; + type MessageConverter = snowbridge_router_primitives::inbound::v2::MessageToXcm>; } impl snowbridge_pallet_outbound_queue::Config for Runtime {