Skip to content

Commit

Permalink
add xcmp call and move xcmp dmp queue to seperate config file (#1973)
Browse files Browse the repository at this point in the history
* add xcmp call and move xcmp dmp to seperation config

* fix CI
  • Loading branch information
zqhxuyuan authored Mar 20, 2022
1 parent b50d527 commit db31365
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 68 deletions.
21 changes: 1 addition & 20 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ pub use pallet_timestamp::Call as TimestampCall;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

use crate::xcm_config::XcmOriginToCallOrigin;
pub use authority::AuthorityConfigImpl;
pub use constants::{fee::*, time::*};
pub use primitives::{
Expand All @@ -102,8 +101,6 @@ pub use runtime_common::{
TipPerWeightStep, ACA, AUSD, DOT, LCDOT, LDOT, RENBTC,
};
pub use xcm::latest::prelude::*;
use xcm_config::XcmConfig;
pub use xcm_executor::{Assets, Config, XcmExecutor};

mod authority;
mod benchmarking;
Expand Down Expand Up @@ -1444,22 +1441,6 @@ impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = PolkadotXcm;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
}

parameter_types! {
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account();
Expand Down Expand Up @@ -1589,7 +1570,7 @@ construct_runtime!(
SessionManager: module_session_manager::{Pallet, Call, Storage, Event<T>, Config<T>} = 45,

// XCM
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Storage, Event<T>} = 50,
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
PolkadotXcm: pallet_xcm::{Pallet, Storage, Call, Event<T>, Origin, Config} = 51,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 52,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
Expand Down
21 changes: 19 additions & 2 deletions runtime/acala/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::{
constants::fee::*, AcalaTreasuryAccount, AccountId, AssetIdMapping, AssetIdMaps, Balance, Call, Convert,
Currencies, CurrencyId, Event, ExistentialDeposits, FixedRateOfForeignAsset, GetNativeCurrencyId,
NativeTokenExistentialDeposit, Origin, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeBlockWeights,
TransactionFeePoolTrader, UnknownTokens, XcmExecutor, XcmpQueue, ACA, AUSD,
TransactionFeePoolTrader, UnknownTokens, XcmpQueue, ACA, AUSD,
};
use codec::{Decode, Encode};
pub use cumulus_primitives_core::ParaId;
Expand All @@ -33,7 +33,7 @@ use orml_traits::{parameter_type_with_key, MultiCurrency};
use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use runtime_common::AcalaDropAssets;
use runtime_common::{AcalaDropAssets, EnsureRootOrHalfGeneralCouncil};
use xcm::latest::prelude::*;
pub use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
Expand All @@ -42,6 +42,7 @@ pub use xcm_builder::{
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeRevenue, TakeWeightCredit,
};
use xcm_executor::XcmExecutor;

parameter_types! {
pub DotLocation: MultiLocation = MultiLocation::parent();
Expand Down Expand Up @@ -206,6 +207,22 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = PolkadotXcm;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
}

pub type LocalAssetTransactor = MultiCurrencyAdapter<
Currencies,
UnknownTokens,
Expand Down
9 changes: 6 additions & 3 deletions runtime/integration-tests/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ mod mandala_imports {
ParachainInfo, ParachainSystem, Proxy, ProxyType, Ratio, Runtime, Scheduler, Session, SessionKeys,
SessionManager, SevenDays, StableAsset, StableAssetPalletId, System, Timestamp, TipPerWeightStep, TokenSymbol,
Tokens, TransactionPayment, TransactionPaymentPalletId, TreasuryAccount, TreasuryPalletId, UncheckedExtrinsic,
Utility, Vesting, XcmExecutor, XcmInterface, EVM, NFT,
Utility, Vesting, XcmInterface, EVM, NFT,
};
pub use runtime_common::{cent, dollar, millicent, ACA, AUSD, DOT, KSM, LDOT, LKSM};
pub use sp_runtime::traits::AccountIdConversion;
pub use xcm_executor::XcmExecutor;

pub const NATIVE_CURRENCY: CurrencyId = ACA;
pub const LIQUID_CURRENCY: CurrencyId = LDOT;
Expand Down Expand Up @@ -90,11 +91,12 @@ mod karura_imports {
OneDay, Origin, OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, ProxyType,
Ratio, RelayChainBlockNumberProvider, Runtime, Scheduler, Session, SessionManager, SevenDays, System,
Timestamp, TipPerWeightStep, TokenSymbol, Tokens, TransactionPayment, TransactionPaymentPalletId,
TreasuryPalletId, Utility, Vesting, XTokens, XcmExecutor, XcmInterface, EVM, NFT,
TreasuryPalletId, Utility, Vesting, XTokens, XcmInterface, EVM, NFT,
};
pub use primitives::TradingPair;
pub use runtime_common::{calculate_asset_ratio, cent, dollar, millicent, KAR, KSM, KUSD, LKSM};
pub use sp_runtime::traits::AccountIdConversion;
pub use xcm_executor::XcmExecutor;

parameter_types! {
pub EnabledTradingPairs: Vec<TradingPair> = vec![
Expand Down Expand Up @@ -135,12 +137,13 @@ mod acala_imports {
OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, ProxyType, Ratio,
RelayChainBlockNumberProvider, Runtime, Scheduler, Session, SessionManager, SevenDays, System, Timestamp,
TipPerWeightStep, TokenSymbol, Tokens, TransactionPayment, TransactionPaymentPalletId, TreasuryPalletId,
Utility, Vesting, XTokens, XcmExecutor, XcmInterface, EVM, LCDOT, NFT,
Utility, Vesting, XTokens, XcmInterface, EVM, LCDOT, NFT,
};
pub use frame_support::parameter_types;
pub use primitives::TradingPair;
pub use runtime_common::{cent, dollar, millicent, ACA, AUSD, DOT, LDOT};
pub use sp_runtime::traits::AccountIdConversion;
pub use xcm_executor::XcmExecutor;

parameter_types! {
pub EnabledTradingPairs: Vec<TradingPair> = vec![
Expand Down
21 changes: 1 addition & 20 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,7 @@ pub use runtime_common::{
TipPerWeightStep, BNC, KAR, KBTC, KINT, KSM, KUSD, LKSM, PHA, RENBTC, VSKSM,
};
pub use xcm::latest::prelude::*;
use xcm_config::XcmConfig;
pub use xcm_executor::{Assets, Config, XcmExecutor};

use crate::xcm_config::XcmOriginToCallOrigin;
/// Import the stable_asset pallet.
pub use nutsfinance_stable_asset;

Expand Down Expand Up @@ -1458,22 +1455,6 @@ impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = PolkadotXcm;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
}

parameter_types! {
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account();
Expand Down Expand Up @@ -1670,7 +1651,7 @@ construct_runtime!(
SessionManager: module_session_manager::{Pallet, Call, Storage, Event<T>, Config<T>} = 45,

// XCM
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Storage, Event<T>} = 50,
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,
PolkadotXcm: pallet_xcm::{Pallet, Storage, Call, Event<T>, Origin, Config} = 51,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 52,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,
Expand Down
21 changes: 19 additions & 2 deletions runtime/karura/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::{
constants::{fee::*, parachains},
AccountId, AssetIdMapping, AssetIdMaps, Balance, Call, Convert, Currencies, CurrencyId, Event, ExistentialDeposits,
GetNativeCurrencyId, KaruraTreasuryAccount, NativeTokenExistentialDeposit, Origin, ParachainInfo, ParachainSystem,
PolkadotXcm, Runtime, RuntimeBlockWeights, UnknownTokens, XcmExecutor, XcmInterface, XcmpQueue, KAR, KUSD, LKSM,
PolkadotXcm, Runtime, RuntimeBlockWeights, UnknownTokens, XcmInterface, XcmpQueue, KAR, KUSD, LKSM,
};
use codec::{Decode, Encode};
pub use cumulus_primitives_core::ParaId;
Expand All @@ -34,7 +34,7 @@ use orml_traits::{parameter_type_with_key, MultiCurrency};
use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use runtime_common::AcalaDropAssets;
use runtime_common::{AcalaDropAssets, EnsureRootOrHalfGeneralCouncil};
use xcm::latest::prelude::*;
pub use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
Expand All @@ -43,6 +43,7 @@ pub use xcm_builder::{
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeRevenue, TakeWeightCredit,
};
use xcm_executor::XcmExecutor;

#[cfg(not(feature = "integration-tests"))]
use super::{FixedRateOfForeignAsset, TransactionFeePoolTrader};
Expand Down Expand Up @@ -268,6 +269,22 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = PolkadotXcm;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
}

parameter_types! {
pub SelfLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::get().into())));
}
Expand Down
19 changes: 0 additions & 19 deletions runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ pub use runtime_common::{
TipPerWeightStep, ACA, AUSD, DOT, LDOT, RENBTC,
};
pub use xcm::latest::prelude::*;
use xcm_config::XcmConfig;
pub use xcm_executor::{traits::WeightTrader, Assets, Config, XcmExecutor};

use crate::xcm_config::XcmOriginToCallOrigin;
/// Import the stable_asset pallet.
pub use nutsfinance_stable_asset;

Expand Down Expand Up @@ -1600,22 +1597,6 @@ impl cumulus_pallet_parachain_system::Config for Runtime {

impl parachain_info::Config for Runtime {}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
}

impl orml_unknown_tokens::Config for Runtime {
type Event = Event;
}
Expand Down
21 changes: 19 additions & 2 deletions runtime/mandala/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::{
constants::fee::*, AccountId, AssetIdMapping, AssetIdMaps, Balance, Call, Convert, Currencies, CurrencyId, Event,
ExistentialDeposits, FixedRateOfForeignAsset, GetNativeCurrencyId, NativeTokenExistentialDeposit, Origin,
ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeBlockWeights, TransactionFeePoolTrader,
TreasuryAccount, UnknownTokens, XcmExecutor, XcmpQueue, ACA,
TreasuryAccount, UnknownTokens, XcmpQueue, ACA,
};
use codec::{Decode, Encode};
pub use cumulus_primitives_core::ParaId;
Expand All @@ -33,7 +33,7 @@ use orml_traits::{parameter_type_with_key, MultiCurrency};
use orml_xcm_support::{DepositToAlternative, IsNativeConcrete, MultiCurrencyAdapter, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use polkadot_parachain::primitives::Sibling;
use runtime_common::AcalaDropAssets;
use runtime_common::{AcalaDropAssets, EnsureRootOrHalfGeneralCouncil};
use xcm::latest::prelude::*;
pub use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom,
Expand All @@ -42,6 +42,7 @@ pub use xcm_builder::{
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeRevenue, TakeWeightCredit,
};
use xcm_executor::XcmExecutor;

parameter_types! {
pub const DotLocation: MultiLocation = MultiLocation::parent();
Expand Down Expand Up @@ -199,6 +200,22 @@ impl cumulus_pallet_xcm::Config for Runtime {
type XcmExecutor = XcmExecutor<XcmConfig>;
}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOrigin = EnsureRootOrHalfGeneralCouncil;
type ControllerOriginConverter = XcmOriginToCallOrigin;
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRootOrHalfGeneralCouncil;
}

pub type LocalAssetTransactor = MultiCurrencyAdapter<
Currencies,
UnknownTokens,
Expand Down

0 comments on commit db31365

Please sign in to comment.