Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cumulus/pallets/xcmp-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,12 @@ impl<T: Config> InspectMessageQueues for Pallet<T> {
fn clear_messages() {
// Best effort.
let _ = OutboundXcmpMessages::<T>::clear(u32::MAX, None);
OutboundXcmpStatus::<T>::mutate(|details_vec| {
for details in details_vec {
details.first_index = 0;
details.last_index = 0;
}
});
}

fn get_messages() -> Vec<(VersionedLocation, Vec<VersionedXcm<()>>)> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ macro_rules! test_can_estimate_and_pay_exact_fees {
(Parent, 100_000_000_000u128),
);
let origin = OriginCaller::system(RawOrigin::Signed(sender.clone()));
let result = Runtime::dry_run_call(origin, call).unwrap();
let result = Runtime::dry_run_call(origin, call, xcm::prelude::XCM_VERSION).unwrap();
let local_xcm = result.local_xcm.unwrap().clone();
let local_xcm_weight = Runtime::query_xcm_weight(local_xcm).unwrap();
local_execution_fees = Runtime::query_weight_to_asset_fee(
Expand Down Expand Up @@ -635,7 +635,7 @@ macro_rules! test_dry_run_transfer_across_pk_bridge {
use frame_support::{dispatch::RawOrigin, traits::fungible};
use sp_runtime::AccountId32;
use xcm::prelude::*;
use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV1;
use xcm_runtime_apis::dry_run::runtime_decl_for_dry_run_api::DryRunApiV2;

let who = AccountId32::new([1u8; 32]);
let transfer_amount = 10_000_000_000_000u128;
Expand Down Expand Up @@ -665,7 +665,7 @@ macro_rules! test_dry_run_transfer_across_pk_bridge {
fee_asset_item: 0,
weight_limit: Unlimited,
});
let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call).unwrap();
let result = Runtime::dry_run_call(OriginCaller::system(RawOrigin::Signed(who)), call, XCM_VERSION).unwrap();
// We assert the dry run succeeds and sends only one message to the local bridge hub.
assert!(result.execution_result.is_ok());
assert_eq!(result.forwarded_xcms.len(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::imports::*;
use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees;
use frame_support::dispatch::RawOrigin;
use xcm_runtime_apis::{
dry_run::runtime_decl_for_dry_run_api::DryRunApiV1,
dry_run::runtime_decl_for_dry_run_api::DryRunApiV2,
fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1,
};

Expand Down Expand Up @@ -146,7 +146,7 @@ fn multi_hop_works() {

let call = transfer_assets_para_to_para_through_ah_call(test.clone());
let origin = OriginCaller::system(RawOrigin::Signed(sender.clone()));
let result = Runtime::dry_run_call(origin, call).unwrap();
let result = Runtime::dry_run_call(origin, call, xcm::prelude::XCM_VERSION).unwrap();
// We filter the result to get only the messages we are interested in.
let (destination_to_query, messages_to_query) = &result
.forwarded_xcms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::imports::*;
use emulated_integration_tests_common::test_can_estimate_and_pay_exact_fees;
use frame_support::dispatch::RawOrigin;
use xcm_runtime_apis::{
dry_run::runtime_decl_for_dry_run_api::DryRunApiV1,
dry_run::runtime_decl_for_dry_run_api::DryRunApiV2,
fees::runtime_decl_for_xcm_payment_api::XcmPaymentApiV1,
};

Expand Down Expand Up @@ -148,7 +148,7 @@ fn multi_hop_works() {

let call = transfer_assets_para_to_para_through_ah_call(test.clone());
let origin = OriginCaller::system(RawOrigin::Signed(sender.clone()));
let result = Runtime::dry_run_call(origin, call).unwrap();
let result = Runtime::dry_run_call(origin, call, xcm::prelude::XCM_VERSION).unwrap();
// We filter the result to get only the messages we are interested in.
let (destination_to_query, messages_to_query) = &result
.forwarded_xcms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ use xcm::latest::prelude::{
};
use xcm::{
latest::prelude::{AssetId, BodyId},
VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
};
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
Expand Down Expand Up @@ -1470,8 +1471,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use xcm::{
latest::prelude::AssetId,
prelude::{VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm},
Version as XcmVersion,
};

#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -1587,8 +1588,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ use snowbridge_core::{
outbound::{Command, Fee},
AgentId, PricingParameters,
};
use xcm::{latest::prelude::*, prelude::*};
use xcm::{latest::prelude::*, prelude::*, Version as XcmVersion};
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
Expand Down Expand Up @@ -872,8 +872,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ use snowbridge_core::{
AgentId, PricingParameters,
};
use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
use xcm::VersionedLocation;
use xcm::{Version as XcmVersion, VersionedLocation};

use westend_runtime_constants::system_parachain::{ASSET_HUB_ID, BRIDGE_HUB_ID};

Expand Down Expand Up @@ -804,8 +804,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use polkadot_runtime_common::{
impls::VersionedLocatableAsset, BlockHashCount, SlowAdjustingFeeUpdate,
};
use xcm::prelude::*;
use xcm::{prelude::*, Version as XcmVersion};
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
Expand Down Expand Up @@ -987,8 +987,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use parachains_common::{
};
pub use parachains_common::{AuraId, Balance};
use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
use xcm::prelude::*;
use xcm::{prelude::*, Version as XcmVersion};
use xcm_config::CollatorSelectionUpdateOrigin;
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
Expand Down Expand Up @@ -630,8 +630,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use xcm::prelude::*;
use xcm::{prelude::*, Version as XcmVersion};
use xcm_config::{
FellowshipLocation, GovernanceLocation, RocRelayLocation, XcmOriginToTransactDispatchOrigin,
};
Expand Down Expand Up @@ -839,8 +839,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use xcm::prelude::*;
use xcm::{prelude::*, Version as XcmVersion};
use xcm_config::{
FellowshipLocation, GovernanceLocation, TokenRelayLocation, XcmOriginToTransactDispatchOrigin,
};
Expand Down Expand Up @@ -831,8 +831,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
6 changes: 3 additions & 3 deletions cumulus/parachains/runtimes/people/people-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use xcm::prelude::*;
use xcm::{prelude::*, Version as XcmVersion};
use xcm_config::{
FellowshipLocation, GovernanceLocation, PriceForSiblingParachainDelivery, XcmConfig,
XcmOriginToTransactDispatchOrigin,
Expand Down Expand Up @@ -807,8 +807,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
6 changes: 3 additions & 3 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use xcm::prelude::*;
use xcm::{prelude::*, Version as XcmVersion};
use xcm_config::{
FellowshipLocation, GovernanceLocation, PriceForSiblingParachainDelivery, XcmConfig,
XcmOriginToTransactDispatchOrigin,
Expand Down Expand Up @@ -805,8 +805,8 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
Expand Down
63 changes: 7 additions & 56 deletions cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use assets_common::{
local_and_foreign_assets::{LocalFromLeft, TargetFromLeft},
AssetIdForTrustBackedAssetsConvert,
};
use codec::Encode;
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ClaimQueueOffset, CoreSelector, ParaId};
use frame_support::{
Expand Down Expand Up @@ -75,7 +74,7 @@ pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Dispatchable},
traits::{AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
Expand All @@ -93,7 +92,8 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use xcm::{
latest::prelude::{AssetId as AssetLocationId, BodyId},
VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
Version as XcmVersion, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
};
use xcm_runtime_apis::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
Expand Down Expand Up @@ -1023,61 +1023,12 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
use xcm_builder::InspectMessageQueues;
use xcm_executor::RecordXcm;
use xcm::prelude::*;
pallet_xcm::Pallet::<Runtime>::set_record_xcm(true);
frame_system::Pallet::<Runtime>::reset_events(); // To make sure we only record events from current call.
let result = call.dispatch(origin.into());
pallet_xcm::Pallet::<Runtime>::set_record_xcm(false);
let local_xcm = pallet_xcm::Pallet::<Runtime>::recorded_xcm();
let forwarded_xcms = xcm_config::XcmRouter::get_messages();
let events: Vec<RuntimeEvent> = System::read_events_no_consensus().map(|record| record.event.clone()).collect();
Ok(CallDryRunEffects {
local_xcm: local_xcm.map(VersionedXcm::<()>::from),
forwarded_xcms,
emitted_events: events,
execution_result: result,
})
fn dry_run_call(origin: OriginCaller, call: RuntimeCall, result_xcms_version: XcmVersion) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call, result_xcms_version)
}

fn dry_run_xcm(origin_location: VersionedLocation, program: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
use xcm_builder::InspectMessageQueues;
use xcm::prelude::*;

let origin_location: Location = origin_location.try_into().map_err(|error| {
log::error!(
target: "xcm::DryRunApi::dry_run_xcm",
"Location version conversion failed with error: {:?}",
error,
);
XcmDryRunApiError::VersionedConversionFailed
})?;
let program: Xcm<RuntimeCall> = program.try_into().map_err(|error| {
log::error!(
target: "xcm::DryRunApi::dry_run_xcm",
"Xcm version conversion failed with error {:?}",
error,
);
XcmDryRunApiError::VersionedConversionFailed
})?;
let mut hash = program.using_encoded(sp_core::hashing::blake2_256);
frame_system::Pallet::<Runtime>::reset_events(); // To make sure we only record events from current call.
let result = xcm_executor::XcmExecutor::<xcm_config::XcmConfig>::prepare_and_execute(
origin_location,
program,
&mut hash,
Weight::MAX, // Max limit.
Weight::zero(),
);
let forwarded_xcms = xcm_config::XcmRouter::get_messages();
let events: Vec<RuntimeEvent> = System::read_events_no_consensus().map(|record| record.event.clone()).collect();
Ok(XcmDryRunEffects {
forwarded_xcms,
emitted_events: events,
execution_result: result,
})
fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
}
}

Expand Down
Loading