Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polkadot-sdk v1.13.0 uplift #1358

Merged
merged 29 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6068a3f
deps uplift
ipapandinas Sep 5, 2024
4fc0e05
RuntimeGenesisConfig generic type removed from GenericChainSpec
ipapandinas Sep 5, 2024
d190155
XcmRecorder type added xcm_executor config
ipapandinas Sep 5, 2024
b6506cc
MaxActiveOutboundChannels & MaxPageSize types added, xcmp queue palle…
ipapandinas Sep 5, 2024
6d63a79
XcmPaymentApi refactored, DryRunApi implemented
ipapandinas Sep 5, 2024
fc812f5
preservation Protect added to burn_from in pallet balances
ipapandinas Sep 5, 2024
277e37a
pallet balances weights updated
ipapandinas Sep 5, 2024
02f1c99
xcm api integration test extended
ipapandinas Sep 7, 2024
a411c7e
xcm api integration test extended
ipapandinas Sep 7, 2024
97551a6
xcm api implemented in fake_runtime_apis
ipapandinas Sep 7, 2024
4c1e26b
runtime used to generate genesis state for benchmarking
ipapandinas Sep 7, 2024
6738535
vendor libs updated
ipapandinas Sep 9, 2024
caae82b
cargo fmt
ipapandinas Sep 9, 2024
c3fe841
Small typo fixed and 'Preserve' used in burn_from
ipapandinas Sep 10, 2024
2c46cb3
fix zepter CI
ipapandinas Sep 10, 2024
b5a7618
revert xcm api implementation in fake_runtime_apis
ipapandinas Sep 10, 2024
a0f665b
Update scripts/run_benchmarks.sh
ipapandinas Sep 10, 2024
661ab10
Revert "vendor libs updated"
ipapandinas Sep 11, 2024
753df36
XcmRecorder relies on PolkadotXcm for production runtimes
ipapandinas Sep 11, 2024
1c2c599
fix to ensure asset XCM version conversion
ipapandinas Sep 11, 2024
cab7465
Revert "Update scripts/run_benchmarks.sh"
ipapandinas Sep 11, 2024
0187025
Revert "runtime used to generate genesis state for benchmarking"
ipapandinas Sep 11, 2024
0546708
weight_to_fee implemeted in pallet-xc-asset-config
ipapandinas Sep 11, 2024
ab3ec8c
fix typo
ipapandinas Sep 12, 2024
936d410
XcmRecorder integration test
ipapandinas Sep 12, 2024
fd33f7c
fix zepter CI
ipapandinas Sep 12, 2024
e593d3b
XcmRecorder integration test from Runtime XcmConfig
ipapandinas Sep 12, 2024
7141da7
DryRunApi integration tests improved
ipapandinas Sep 13, 2024
2a1dc19
todo comment added
ipapandinas Sep 16, 2024
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
2,745 changes: 1,394 additions & 1,351 deletions Cargo.lock

Large diffs are not rendered by default.

312 changes: 154 additions & 158 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use local_runtime::wasm_binary_unwrap;
use sc_service::ChainType;

/// Specialized `ChainSpec` for local network.
pub type ChainSpec = sc_service::GenericChainSpec<local_runtime::RuntimeGenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec;

/// Development config.
pub fn development_config() -> ChainSpec {
Expand Down
3 changes: 1 addition & 2 deletions bin/collator/src/parachain/chain_spec/astar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use astar_runtime::wasm_binary_unwrap;
use sc_service::ChainType;

/// Specialized `ChainSpec` for Astar Network.
pub type AstarChainSpec =
sc_service::GenericChainSpec<astar_runtime::RuntimeGenesisConfig, Extensions>;
pub type AstarChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Get Astar chain specification.
pub fn get_chain_spec() -> AstarChainSpec {
Expand Down
4 changes: 2 additions & 2 deletions bin/collator/src/parachain/chain_spec/shibuya.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use super::Extensions;
use astar_primitives::parachain::SHIBUYA_ID;
use sc_service::ChainType;
use shibuya_runtime::{wasm_binary_unwrap, RuntimeGenesisConfig};
use shibuya_runtime::wasm_binary_unwrap;

/// Specialized `ChainSpec` for Shibuya testnet.
pub type ShibuyaChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig, Extensions>;
pub type ShibuyaChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Gen Shibuya chain specification.
pub fn get_chain_spec() -> ShibuyaChainSpec {
Expand Down
3 changes: 1 addition & 2 deletions bin/collator/src/parachain/chain_spec/shiden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use sc_service::ChainType;
use shiden_runtime::wasm_binary_unwrap;

/// Specialized `ChainSpec` for Shiden Network.
pub type ShidenChainSpec =
sc_service::GenericChainSpec<shiden_runtime::RuntimeGenesisConfig, Extensions>;
pub type ShidenChainSpec = sc_service::GenericChainSpec<Extensions>;

/// Gen Shiden chain specification.
pub fn get_chain_spec() -> ShidenChainSpec {
Expand Down
1 change: 1 addition & 0 deletions pallets/astar-xcm-benchmarks/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ impl xcm_executor::Config for XcmConfig {
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type XcmRecorder = ();
}

impl pallet_xcm_benchmarks::Config for Test {
Expand Down
10 changes: 8 additions & 2 deletions pallets/unified-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ pub mod pallet {
/// - `signature`: A signature generated by the address to prove ownership
///
/// WARNING:
/// - This extrisic only handles transfer of native balance, if your EVM
/// - This extrinsic only handles transfer of native balance, if your EVM
/// address contains any other native assets like XC20, DAppStaking unclaimed rewards,
/// etc you need to transfer them before hand, otherwise FUNDS WILL BE LOST FOREVER.
/// - Once connected user cannot change their mapping EVER.
Expand Down Expand Up @@ -277,7 +277,13 @@ impl<T: Config> Pallet<T> {
let balance = T::Currency::reducible_balance(who, Preserve, Polite);
let fee = T::AccountMappingStorageFee::get();
ensure!(balance >= fee, Error::<T>::FundsUnavailable);
T::Currency::burn_from(who, T::AccountMappingStorageFee::get(), Exact, Polite)
T::Currency::burn_from(
who,
T::AccountMappingStorageFee::get(),
Preserve,
Exact,
Polite,
)
ipapandinas marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
13 changes: 12 additions & 1 deletion pallets/xc-asset-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
//! `ExecutionPaymentRate` interface for fetching `units per second` if asset is supported payment asset
//! - `get_units_per_second`
//!
//! - `weight_to_fee` method is used to convert weight to fee based on units per second and weight.

#![cfg_attr(not(feature = "std"), no_std)]

Expand All @@ -72,7 +73,9 @@ pub use weights::WeightInfo;
pub mod pallet {

use crate::weights::WeightInfo;
use frame_support::{pallet_prelude::*, traits::EnsureOrigin};
use frame_support::{
pallet_prelude::*, traits::EnsureOrigin, weights::constants::WEIGHT_REF_TIME_PER_SECOND,
};
use frame_system::pallet_prelude::*;
use parity_scale_codec::HasCompact;
use sp_std::boxed::Box;
Expand Down Expand Up @@ -116,6 +119,14 @@ pub mod pallet {
}
}

impl<T: Config> Pallet<T> {
/// Convert weight to fee based on units per second and weight.
pub fn weight_to_fee(weight: Weight, units_per_second: u128) -> u128 {
units_per_second.saturating_mul(weight.ref_time() as u128)
/ (WEIGHT_REF_TIME_PER_SECOND as u128)
}
}

#[pallet::config]
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
Expand Down
1 change: 1 addition & 0 deletions precompiles/xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ impl xcm_executor::Config for XcmConfig {
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type XcmRecorder = ();
}

parameter_types! {
Expand Down
3 changes: 2 additions & 1 deletion runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pallet-xcm-benchmarks = { workspace = true, optional = true }

# cumulus dependencies
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true, features = ["parameterized-consensus-hook"] }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-primitives-aura = { workspace = true }
Expand Down Expand Up @@ -285,6 +285,7 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
Expand Down
67 changes: 37 additions & 30 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ use xcm::{
v4::{AssetId as XcmAssetId, Location as XcmLocation},
IntoVersion, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
};
use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError;
use xcm_fee_payment_runtime_api::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
};

use astar_primitives::{
dapp_staking::{
Expand Down Expand Up @@ -1907,49 +1910,43 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::XcmPaymentApi<Block> for Runtime {
impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
if !matches!(xcm_version, xcm::v3::VERSION | xcm::v4::VERSION) {
return Err(XcmPaymentApiError::UnhandledXcmVersion);
}

// Native asset is always supported
let native_asset_location: XcmLocation = XcmLocation::try_from(xcm_config::AstarLocation::get())
.map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;

Ok([VersionedAssetId::V4(native_asset_location.into())]
.into_iter()
// Acquire foreign assets which have 'units per second' configured
.chain(
pallet_xc_asset_config::AssetLocationUnitsPerSecond::<Runtime>::iter_keys().filter_map(|asset_location| {

match XcmLocation::try_from(asset_location) {
Ok(asset) => Some(VersionedAssetId::V4(asset.into())),
Err(_) => None,
}
})
).filter_map(|asset| asset.into_version(xcm_version).ok()).collect())
let mut acceptable_assets = vec![XcmAssetId::from(xcm_config::AstarLocation::get())];

// Add foreign assets that have 'units per second' configured
acceptable_assets.extend(
pallet_xc_asset_config::AssetLocationUnitsPerSecond::<Runtime>::iter_keys().filter_map(
|asset_location| match XcmLocation::try_from(asset_location) {
Ok(location) => Some(XcmAssetId::from(location)),
Err(_) => None,
},
),
);

PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
let native_asset_location = XcmLocation::try_from(xcm_config::AstarLocation::get())
.map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
let native_asset = VersionedAssetId::V4(native_asset_location.into());

let asset = asset
.into_version(xcm::v4::VERSION)
.map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
let asset = asset.into_version(xcm::v4::VERSION).map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
let asset_id: XcmAssetId = asset.try_into().map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;

if native_asset == asset {
Ok(XcmWeightToFee::weight_to_fee(&weight))
} else {
let asset_id: XcmAssetId = asset.try_into().map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
// for native token
if asset_id.0 == xcm_config::AstarLocation::get() {
Ok(WeightToFee::weight_to_fee(&weight))
}
// for foreign assets that have 'units per second' configures
ipapandinas marked this conversation as resolved.
Show resolved Hide resolved
else {
let versioned_location = VersionedLocation::V4(asset_id.0);

match pallet_xc_asset_config::AssetLocationUnitsPerSecond::<Runtime>::get(versioned_location) {
Some(units_per_sec) => {
Ok(units_per_sec.saturating_mul(weight.ref_time() as u128)
/ (WEIGHT_REF_TIME_PER_SECOND as u128))
Ok(pallet_xc_asset_config::Pallet::<Runtime>::weight_to_fee(weight, units_per_sec))
}
None => Err(XcmPaymentApiError::AssetNotFound),
}
Expand All @@ -1965,6 +1962,16 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
ipapandinas marked this conversation as resolved.
Show resolved Hide resolved
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_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)
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {

fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
Expand Down
3 changes: 3 additions & 0 deletions runtime/astar/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ impl xcm_executor::Config for XcmConfig {
type HrmpNewChannelOpenRequestHandler = ();
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type XcmRecorder = PolkadotXcm;
ipapandinas marked this conversation as resolved.
Show resolved Hide resolved
}

/// Local origins on this chain are allowed to dispatch XCM sends/executions.
Expand Down Expand Up @@ -335,6 +336,8 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type VersionWrapper = PolkadotXcm;
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
type MaxInboundSuspended = ConstU32<1_000>;
type MaxActiveOutboundChannels = ConstU32<128>;
type MaxPageSize = ConstU32<{ 128 * 1024 }>;
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
Expand Down
18 changes: 14 additions & 4 deletions runtime/local/src/weights/pallet_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,22 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for SubstrateWeight<T>
// Minimum execution time: 5_975_000 picoseconds.
Weight::from_parts(6_179_000, 0)
}

fn burn() -> Weight {

/// Storage: `UnifiedAccounts::NativeToEvm` (r:1 w:0)
/// Proof: `UnifiedAccounts::NativeToEvm` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`)
fn burn_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3533`
// Minimum execution time: 35_000_000 picoseconds.
Weight::from_parts(36_000_000, 3533)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
fn burn_keep_alive() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 30_151_000 picoseconds.
Weight::from_parts(30_968_000, 0)
// Minimum execution time: 22_000_000 picoseconds.
Weight::from_parts(22_000_000, 0)
}
}
3 changes: 2 additions & 1 deletion runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ vesting-mbm = { workspace = true }

# cumulus dependencies
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true, features = ["parameterized-consensus-hook"] }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-primitives-aura = { workspace = true }
Expand Down Expand Up @@ -320,6 +320,7 @@ runtime-benchmarks = [
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-fee-payment-runtime-api/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"orml-oracle/runtime-benchmarks",
Expand Down
68 changes: 37 additions & 31 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ use xcm::{
v4::{AssetId as XcmAssetId, Location as XcmLocation},
IntoVersion, VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm,
};
use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError;
use xcm_fee_payment_runtime_api::{
dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects},
fees::Error as XcmPaymentApiError,
};

use astar_primitives::{
dapp_staking::{
Expand Down Expand Up @@ -2238,50 +2241,43 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::XcmPaymentApi<Block> for Runtime {
impl xcm_fee_payment_runtime_api::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<VersionedAssetId>, XcmPaymentApiError> {
if !matches!(xcm_version, xcm::v3::VERSION | xcm::v4::VERSION) {
return Err(XcmPaymentApiError::UnhandledXcmVersion);
}

// Native asset is always supported
let native_asset_location: XcmLocation = XcmLocation::try_from(xcm_config::ShibuyaLocation::get())
.map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;

Ok([VersionedAssetId::V4(native_asset_location.into())]
.into_iter()
// Acquire foreign assets which have 'units per second' configured
.chain(
pallet_xc_asset_config::AssetLocationUnitsPerSecond::<Runtime>::iter_keys().filter_map(|asset_location| {

match XcmLocation::try_from(asset_location) {
Ok(asset) => Some(VersionedAssetId::V4(asset.into())),
Err(_) => None,
}
})
).filter_map(|asset| asset.into_version(xcm_version).ok()).collect())
let mut acceptable_assets = vec![XcmAssetId::from(xcm_config::ShibuyaLocation::get())];

// Add foreign assets that have 'units per second' configured
acceptable_assets.extend(
pallet_xc_asset_config::AssetLocationUnitsPerSecond::<Runtime>::iter_keys().filter_map(
|asset_location| match XcmLocation::try_from(asset_location) {
Ok(location) => Some(XcmAssetId::from(location)),
Err(_) => None,
},
),
);

PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
}

// TODO: improve this function, reduce code duplication, especially on a such a functional level
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you tried to resolve this with a good step forward but it's not what I had in mind 🙂

Right now the WeightToForeignAssetFee is in no way bound to the pallet that actually handles the conversion, which is XcmAssetConfig.

If you want to take this approach, I'd suggest to define this function directly in that pallet. That way it would be more tied together. Because even though you've introduced the new type with the function, it's not used inside aforementioned pallet, hence we still have unnecessary code (and functional) duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved the weight_to_fee logic directly into the XcAssetConfig pallet. In the future, we could consider creating a WeightToFee trait (similar to ExecutionPaymentRate) to eliminate code duplication in astar-primitives. This might be outside the scope of this uplift, but it's something to keep in mind.

fn query_weight_to_asset_fee(weight: Weight, asset: VersionedAssetId) -> Result<u128, XcmPaymentApiError> {
let native_asset_location = XcmLocation::try_from(xcm_config::ShibuyaLocation::get())
.map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
let native_asset = VersionedAssetId::V4(native_asset_location.into());

let asset = asset
.into_version(xcm::v4::VERSION)
.map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
let asset = asset.into_version(xcm::v4::VERSION).map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
let asset_id: XcmAssetId = asset.try_into().map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;

if native_asset == asset {
Ok(XcmWeightToFee::weight_to_fee(&weight))
} else {
let asset_id: XcmAssetId = asset.try_into().map_err(|_| XcmPaymentApiError::VersionedConversionFailed)?;
// for native token
if asset_id.0 == xcm_config::ShibuyaLocation::get() {
Ok(WeightToFee::weight_to_fee(&weight))
}
// for foreign assets that have 'units per second' configures
else {
let versioned_location = VersionedLocation::V4(asset_id.0);

match pallet_xc_asset_config::AssetLocationUnitsPerSecond::<Runtime>::get(versioned_location) {
Some(units_per_sec) => {
Ok(units_per_sec.saturating_mul(weight.ref_time() as u128)
/ (WEIGHT_REF_TIME_PER_SECOND as u128))
Ok(pallet_xc_asset_config::Pallet::<Runtime>::weight_to_fee(weight, units_per_sec))
}
None => Err(XcmPaymentApiError::AssetNotFound),
}
Expand All @@ -2297,6 +2293,16 @@ impl_runtime_apis! {
}
}

impl xcm_fee_payment_runtime_api::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_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)
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {

fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
Expand Down
Loading
Loading