Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3cdde97
Part.1
aurexav Dec 17, 2024
ad06f78
Companion of paritytech/polkadot-sdk#3052
aurexav Dec 17, 2024
ca15b06
Companion of paritytech/polkadot-sdk#3221
aurexav Dec 17, 2024
b6e7cd4
Companion of paritytech/polkadot-sdk#3002
aurexav Dec 17, 2024
0702a44
Companion of paritytech/polkadot-sdk#1781
aurexav Dec 17, 2024
bc4d286
Companion of paritytech/polkadot-sdk#3505
aurexav Dec 17, 2024
3ef19e6
Companion of paritytech/polkadot-sdk#3696
aurexav Dec 17, 2024
66184fc
Companion of paritytech/polkadot-sdk#3607
aurexav Dec 17, 2024
df28cf1
Companion of paritytech/polkadot-sdk#3844
aurexav Dec 17, 2024
66f3256
Companion of paritytech/polkadot-sdk#3854
aurexav Dec 17, 2024
ab6fdaa
Companion of paritytech/polkadot-sdk#3858
aurexav Dec 17, 2024
84d1f43
Companion of paritytech/polkadot-sdk#2714
aurexav Dec 18, 2024
153dcff
Fix nostd compile
aurexav Dec 18, 2024
735f466
Companion of paritytech/polkadot-sdk#3660
aurexav Dec 18, 2024
b17ee23
Companion of paritytech/polkadot-sdk#4238
aurexav Dec 18, 2024
5ab0f08
Companion of paritytech/polkadot-sdk#4177
aurexav Dec 18, 2024
855735b
Companion of paritytech/polkadot-sdk#4156
aurexav Dec 18, 2024
be7fbda
Companion of paritytech/polkadot-sdk#4346
aurexav Dec 18, 2024
658fdc5
Companion of paritytech/polkadot-sdk#4355
aurexav Dec 18, 2024
3f2b3a6
Companion of paritytech/polkadot-sdk#3952
aurexav Dec 25, 2024
b0b9249
Companion of paritytech/polkadot-sdk#4410
aurexav Dec 25, 2024
3b94aad
Companion of paritytech/polkadot-sdk#4634
aurexav Dec 25, 2024
b4ac1a3
Companion of paritytech/polkadot-sdk#4666
aurexav Dec 25, 2024
33b3fee
Companion of paritytech/polkadot-sdk#3820
aurexav Dec 25, 2024
22ed2e6
Companion of paritytech/polkadot-sdk#4831
aurexav Dec 25, 2024
e6e1e38
Companion of paritytech/polkadot-sdk#4730
aurexav Dec 25, 2024
6cac042
Companion of paritytech/polkadot-sdk#4857
aurexav Dec 25, 2024
cf85cbc
Companion of paritytech/polkadot-sdk#4805
aurexav Dec 25, 2024
5b3dcf3
Companion of paritytech/polkadot-sdk#3350
aurexav Dec 25, 2024
9bccc9b
Add missing updates
aurexav Dec 25, 2024
fe387bf
Fix XCM related
jiguantong Dec 25, 2024
54606af
Compile all runtime
aurexav Dec 25, 2024
91a0ec4
Fixes
aurexav Dec 27, 2024
64fa8f4
Fixes
aurexav Dec 27, 2024
447b568
Companion of paritytech/polkadot-sdk#2944
aurexav Dec 27, 2024
50e9d5c
Fix tests
aurexav Dec 27, 2024
7726226
Format
aurexav Dec 27, 2024
8e088c6
Fix unit test cases
boundless-forest Dec 27, 2024
57f64f2
Format
aurexav Dec 29, 2024
cbb0388
Format
aurexav Dec 29, 2024
04d2b1b
Add missing features
aurexav Dec 29, 2024
47d8cb5
Fixes
aurexav Dec 30, 2024
a36af4a
Update Cargo.toml to include EVM patches and fix tracing test assertions
boundless-forest Dec 30, 2024
a3443f0
Remove unnecessary console.log from EVM tracing test
boundless-forest Dec 30, 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
Prev Previous commit
Next Next commit
Fix XCM related
  • Loading branch information
jiguantong committed Dec 25, 2024
commit fe387bfb146001094f2b2040a9cf8978a8f72675
271 changes: 146 additions & 125 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ moonbeam-rpc-primitives-debug = { git = "https://github.com/darwinia-n
moonbeam-rpc-trace = { git = "https://github.com/darwinia-network/moonbeam", branch = "stable2407" }
pallet-asset-manager = { git = "https://github.com/darwinia-network/moonbeam", branch = "stable2407", default-features = false }
pallet-evm-precompile-conviction-voting = { git = "https://github.com/darwinia-network/moonbeam", branch = "stable2407", default-features = false }
pallet-xcm-weight-trader = { git = "https://github.com/darwinia-network/moonbeam", branch = "stable2407", default-features = false }
xcm-primitives = { git = "https://github.com/darwinia-network/moonbeam", branch = "stable2407", default-features = false }

# open-web3-stack
Expand Down
11 changes: 3 additions & 8 deletions runtime/koi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ pallet-evm-precompile-simple = { workspace = true }
moonbeam-rpc-primitives-debug = { workspace = true }
pallet-asset-manager = { workspace = true }
pallet-evm-precompile-conviction-voting = { workspace = true }
pallet-xcm-weight-trader = { workspace = true }
precompile-utils = { workspace = true }
xcm-primitives = { workspace = true }
# moonbeam optional
moonbeam-evm-tracer = { workspace = true, optional = true }

# open-web3-stack
orml-xcm-support = { workspace = true }
orml-xtokens = { workspace = true }

# polkadot-sdk
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -159,14 +159,14 @@ std = [
"moonbeam-rpc-primitives-debug/std",
"pallet-asset-manager/std",
"pallet-evm-precompile-conviction-voting/std",
"pallet-xcm-weight-trader/std",
"precompile-utils/std",
"xcm-primitives/std",
# moonbeam optional
"moonbeam-evm-tracer?/std",

# open-web3-stack
"orml-xcm-support/std",
"orml-xtokens/std",

# polkadot-sdk
"cumulus-pallet-aura-ext/std",
Expand Down Expand Up @@ -245,11 +245,9 @@ runtime-benchmarks = [

# moonbeam
"pallet-asset-manager/runtime-benchmarks",
"pallet-xcm-weight-trader/runtime-benchmarks",
"xcm-primitives/runtime-benchmarks",

# open-web3-stack
"orml-xtokens/runtime-benchmarks",

# polkadot-sdk
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
Expand Down Expand Up @@ -294,9 +292,6 @@ try-runtime = [
# moonbeam
"pallet-asset-manager/try-runtime",

# open-web3-stack
"orml-xtokens/try-runtime",

# frontier
"fp-self-contained/try-runtime",
"pallet-ethereum/try-runtime",
Expand Down
30 changes: 6 additions & 24 deletions runtime/koi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ mod runtime {
#[runtime::pallet_index(26)]
pub type XcmpQueue = cumulus_pallet_xcmp_queue;
#[runtime::pallet_index(27)]
pub type XcmPallet = pallet_xcm;
pub type PolkadotXcm = pallet_xcm;
#[runtime::pallet_index(28)]
pub type CumulusXcm = cumulus_pallet_xcm;
// #[runtime::pallet_index(29)]
Expand All @@ -191,10 +191,11 @@ mod runtime {
pub type MessageQueue = pallet_message_queue;
#[runtime::pallet_index(31)]
pub type AssetManager = pallet_asset_manager;
#[runtime::pallet_index(32)]
pub type XTokens = orml_xtokens;
// Previously 32: XTokens
#[runtime::pallet_index(33)]
pub type AssetLimit = darwinia_asset_limit;
#[runtime::pallet_index(38)]
pub type XcmWeightTrader = pallet_xcm_weight_trader;

// EVM stuff.
#[runtime::pallet_index(34)]
Expand Down Expand Up @@ -403,30 +404,11 @@ sp_api::impl_runtime_apis! {

impl xcm_runtime_apis::fees::XcmPaymentApi<Block> for Runtime {
fn query_acceptable_payment_assets(xcm_version: xcm::Version) -> Result<Vec<xcm::VersionedAssetId>, xcm_runtime_apis::fees::Error> {
let acceptable_assets = vec![xcm::latest::AssetId(RelayLocation::get())];

PolkadotXcm::query_acceptable_payment_assets(xcm_version, acceptable_assets)
XcmWeightTrader::query_acceptable_payment_assets(xcm_version)
}

fn query_weight_to_asset_fee(weight: frame_support::weights::Weight, asset: xcm::VersionedAssetId) -> Result<u128, xcm_runtime_apis::fees::Error> {
// polkadot-sdk
use frame_support::weights::WeightToFee as _;

match asset.try_as::<xcm::latest::AssetId>() {
Ok(asset_id) if asset_id.0 == RelayLocation::get() => {
Ok(WeightToFee::weight_to_fee(&weight))
},
Ok(asset_id) => {
log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - unhandled asset_id: {asset_id:?}!");

Err(xcm_runtime_apis::fees::Error::AssetNotFound)
},
Err(_) => {
log::trace!(target: "xcm::xcm_runtime_apis", "query_weight_to_asset_fee - failed to convert asset: {asset:?}!");

Err(xcm_runtime_apis::fees::Error::VersionedConversionFailed)
}
}
XcmWeightTrader::query_weight_to_asset_fee(weight, asset)
}

fn query_xcm_weight(message: xcm::VersionedXcm<()>) -> Result<frame_support::weights::Weight, xcm_runtime_apis::fees::Error> {
Expand Down
5 changes: 2 additions & 3 deletions runtime/koi/src/pallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ mod message_queue;
mod asset_manager;
pub use asset_manager::*;

mod orml_xtokens;
pub use orml_xtokens::*;

mod asset_limit;

mod xcm_weight_trader;

// EVM stuff.
mod ethereum;

Expand Down
81 changes: 0 additions & 81 deletions runtime/koi/src/pallets/orml_xtokens.rs

This file was deleted.

67 changes: 38 additions & 29 deletions runtime/koi/src/pallets/polkadot_xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,6 @@ pub type Barrier = xcm_builder::TrailingSetTopicAsId<(
xcm_builder::AllowKnownQueryResponses<PolkadotXcm>,
)>;

/// This is the struct that will handle the revenue from xcm fees
/// We do not burn anything because we want to mimic exactly what
/// the sovereign account has
pub type XcmFeesToAccount = xcm_primitives::XcmFeesToAccount<
Assets,
(
xcm_builder::ConvertedConcreteId<
AssetId,
Balance,
xcm_primitives::AsAssetType<AssetId, AssetType, AssetManager>,
xcm_executor::traits::JustTry,
>,
),
AccountId,
XcmFeesAccount,
>;
pub type XcmWeigher = xcm_builder::FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
/// No local origins on this chain are allowed to dispatch XCM sends/executions.
pub type LocalOriginToLocation =
Expand All @@ -166,6 +150,38 @@ pub type XcmRouter = xcm_builder::WithUniqueTopic<(
XcmpQueue,
)>;

frame_support::parameter_types! {
/// Location of Asset Hub
pub AssetHubLocation: Location = Location::new(1, [Parachain(1000)]);
pub RelayLocationFilter: AssetFilter = Wild(AllOf {
fun: WildFungible,
id: xcm::prelude::AssetId(RelayLocation::get()),
});
pub RelayChainNativeAssetFromAssetHub: (AssetFilter, Location) = (
RelayLocationFilter::get(),
AssetHubLocation::get()
);
// We need this to be able to catch when someone is trying to execute a non-
// cross-chain transfer in xtokens through the absolute path way
pub SelfLocationAbsolute: Location = Location {
parents:1,
interior: [
Parachain(ParachainInfo::parachain_id().into())
].into()
};
}

type Reserves = (
// Assets bridged from different consensus systems held in reserve on Asset Hub.
xcm_primitives::IsBridgedConcreteAssetFrom<AssetHubLocation>,
// Relaychain (DOT) from Asset Hub
xcm_builder::Case<RelayChainNativeAssetFromAssetHub>,
// Assets which the reserve is the same as the origin.
xcm_primitives::MultiNativeAsset<
xcm_primitives::AbsoluteAndRelativeReserve<SelfLocationAbsolute>,
>,
);

pub struct XcmExecutorConfig;
impl xcm_executor::Config for XcmExecutorConfig {
type Aliasers = frame_support::traits::Nothing;
Expand All @@ -181,9 +197,7 @@ impl xcm_executor::Config for XcmExecutorConfig {
type HrmpChannelAcceptedHandler = ();
type HrmpChannelClosingHandler = ();
type HrmpNewChannelOpenRequestHandler = ();
type IsReserve = orml_xcm_support::MultiNativeAsset<
xcm_primitives::AbsoluteAndRelativeReserve<SelfLocationAbsolute>,
>;
type IsReserve = Reserves;
type IsTeleporter = ();
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type MessageExporter = ();
Expand All @@ -193,16 +207,11 @@ impl xcm_executor::Config for XcmExecutorConfig {
type RuntimeCall = RuntimeCall;
type SafeCallFilter = frame_support::traits::Everything;
type SubscriptionService = PolkadotXcm;
type Trader = (
xcm_builder::UsingComponents<
<Runtime as pallet_transaction_payment::Config>::WeightToFee,
SelfReserve,
AccountId,
Balances,
DealWithFees<Runtime>,
>,
xcm_primitives::FirstAssetTrader<AssetType, AssetManager, XcmFeesToAccount>,
);
// As trader we use the XcmWeightTrader pallet.
// For each foreign asset, the fee is computed based on its relative price (also
// stored in the XcmWeightTrader pallet) against the native asset.
// For the native asset fee is computed using WeightToFee implementation.
type Trader = pallet_xcm_weight_trader::Trader<Runtime>;
type TransactionalProcessor = xcm_builder::FrameTransactionalProcessor;
type UniversalAliases = frame_support::traits::Nothing;
// Teleporting is disabled.
Expand Down
39 changes: 39 additions & 0 deletions runtime/koi/src/pallets/xcm_weight_trader.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This file is part of Darwinia.
//
// Copyright (C) Darwinia Network
// SPDX-License-Identifier: GPL-3.0
//
// Darwinia is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Darwinia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

// darwinia
use crate::*;

impl pallet_xcm_weight_trader::Config for Runtime {
type AccountIdToLocation = xcm_primitives::AccountIdToLocation<AccountId>;
type AddSupportedAssetOrigin = Root;
type AssetLocationFilter = frame_support::traits::Everything;
type AssetTransactor = AssetTransactors;
type Balance = Balance;
type EditSupportedAssetOrigin = Root;
type NativeLocation = SelfReserve;
#[cfg(feature = "runtime-benchmarks")]
type NotFilteredLocation = RelayLocation;
type PauseSupportedAssetOrigin = Root;
type RemoveSupportedAssetOrigin = Root;
type ResumeSupportedAssetOrigin = Root;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_xcm_weight_trader::WeightInfo<Runtime>;
type WeightToFee = <Runtime as pallet_transaction_payment::Config>::WeightToFee;
type XcmFeesAccount = XcmFeesAccount;
}
1 change: 1 addition & 0 deletions runtime/koi/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ pub mod pallet_treasury;
pub mod pallet_tx_pause;
pub mod pallet_utility;
pub mod pallet_whitelist;
pub mod pallet_xcm_weight_trader;
17 changes: 17 additions & 0 deletions runtime/koi/src/weights/pallet_asset_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,21 @@ impl<T: frame_system::Config> pallet_asset_manager::WeightInfo for WeightInfo<T>
.saturating_add(T::DbWeight::get().writes(6))
.saturating_add(Weight::from_parts(0, 14))
}
/// Storage: `AssetManager::AssetIdType` (r:1 w:1)
/// Proof: `AssetManager::AssetIdType` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AssetManager::AssetTypeId` (r:0 w:1)
/// Proof: `AssetManager::AssetTypeId` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `x` is `[5, 100]`.
fn remove_existing_asset_type() -> Weight {
// Proof Size summary in bytes:
// Measured: `447 + x * (4 ±0)`
// Estimated: `3909 + x * (5 ±0)`
// Minimum execution time: 14_047_000 picoseconds.
Weight::from_parts(15_828_607, 3909)
// Standard Error: 1_451
.saturating_add(Weight::from_parts(74_700, 0))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(Weight::from_parts(0, 5))
}
}
Loading
Loading