diff --git a/Cargo.lock b/Cargo.lock
index 418d2d15e..a36315b3b 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -63,6 +63,7 @@ dependencies = [
"log",
"module-aggregated-dex",
"module-asset-registry",
+ "module-assethub",
"module-auction-manager",
"module-cdp-engine",
"module-cdp-treasury",
@@ -87,7 +88,6 @@ dependencies = [
"module-nft",
"module-nominees-election",
"module-prices",
- "module-relaychain",
"module-session-manager",
"module-support",
"module-transaction-pause",
@@ -2804,6 +2804,7 @@ dependencies = [
"log",
"module-aggregated-dex",
"module-asset-registry",
+ "module-assethub",
"module-auction-manager",
"module-cdp-engine",
"module-cdp-treasury",
@@ -2828,7 +2829,6 @@ dependencies = [
"module-nft",
"module-nominees-election",
"module-prices",
- "module-relaychain",
"module-session-manager",
"module-support",
"module-transaction-pause",
@@ -3216,6 +3216,7 @@ dependencies = [
"log",
"module-aggregated-dex",
"module-asset-registry",
+ "module-assethub",
"module-auction-manager",
"module-cdp-engine",
"module-cdp-treasury",
@@ -3241,7 +3242,6 @@ dependencies = [
"module-nft",
"module-nominees-election",
"module-prices",
- "module-relaychain",
"module-session-manager",
"module-support",
"module-transaction-pause",
@@ -3488,6 +3488,23 @@ dependencies = [
"staging-xcm",
]
+[[package]]
+name = "module-assethub"
+version = "2.30.0"
+dependencies = [
+ "acala-primitives",
+ "cumulus-primitives-core",
+ "frame-support",
+ "frame-system",
+ "module-support",
+ "parity-scale-codec",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+ "staging-xcm",
+]
+
[[package]]
name = "module-auction-manager"
version = "2.30.0"
@@ -4073,23 +4090,6 @@ dependencies = [
"sp-std",
]
-[[package]]
-name = "module-relaychain"
-version = "2.30.0"
-dependencies = [
- "acala-primitives",
- "cumulus-primitives-core",
- "frame-support",
- "frame-system",
- "module-support",
- "parity-scale-codec",
- "sp-core",
- "sp-io",
- "sp-runtime",
- "sp-std",
- "staging-xcm",
-]
-
[[package]]
name = "module-session-manager"
version = "2.30.0"
@@ -4187,11 +4187,9 @@ dependencies = [
"frame-system",
"insta",
"log",
+ "module-assethub",
"module-currencies",
- "module-relaychain",
"module-support",
- "orml-tokens",
- "orml-traits",
"pallet-balances",
"pallet-xcm",
"parity-scale-codec",
@@ -6496,6 +6494,7 @@ dependencies = [
"mandala-runtime",
"module-aggregated-dex",
"module-asset-registry",
+ "module-assethub",
"module-auction-manager",
"module-cdp-engine",
"module-cdp-treasury",
@@ -6513,7 +6512,6 @@ dependencies = [
"module-loans",
"module-nft",
"module-prices",
- "module-relaychain",
"module-session-manager",
"module-support",
"module-transaction-payment",
@@ -6554,6 +6552,7 @@ dependencies = [
"pallet-utility",
"pallet-xcm",
"parity-scale-codec",
+ "polkadot-parachain-primitives",
"runtime-common",
"serde_json",
"smallvec",
diff --git a/Cargo.toml b/Cargo.toml
index fc661507f..e74d343c7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -201,7 +201,7 @@ module-nft = { path = "modules/nft", default-features = false }
module-xnft = { path = "modules/xnft", default-features = false }
module-nominees-election = { path = "modules/nominees-election", default-features = false }
module-prices = { path = "modules/prices", default-features = false }
-module-relaychain = { path = "modules/relaychain", default-features = false }
+module-assethub = { path = "modules/assethub", default-features = false }
module-session-manager = { path = "modules/session-manager", default-features = false }
module-support = { path = "modules/support", default-features = false }
module-transaction-pause = { path = "modules/transaction-pause", default-features = false }
diff --git a/modules/relaychain/Cargo.toml b/modules/assethub/Cargo.toml
similarity index 96%
rename from modules/relaychain/Cargo.toml
rename to modules/assethub/Cargo.toml
index a7188611d..7ee9f483d 100644
--- a/modules/relaychain/Cargo.toml
+++ b/modules/assethub/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "module-relaychain"
+name = "module-assethub"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
diff --git a/modules/assethub/src/lib.rs b/modules/assethub/src/lib.rs
new file mode 100644
index 000000000..b2f5d470d
--- /dev/null
+++ b/modules/assethub/src/lib.rs
@@ -0,0 +1,271 @@
+// This file is part of Acala.
+
+// Copyright (C) 2020-2025 Acala Foundation.
+// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
+
+// This program 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.
+
+// This program 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 this program. If not, see .
+
+//! # Module AssetHub
+//!
+//! This module is in charge of handling assethub related utilities and business logic.
+
+#![cfg_attr(not(feature = "std"), no_std)]
+#![allow(clippy::unused_unit)]
+#![allow(clippy::large_enum_variant)]
+
+use parity_scale_codec::{Decode, Encode, FullCodec};
+use sp_runtime::{traits::StaticLookup, RuntimeDebug};
+
+use frame_support::traits::Get;
+use module_support::assethub::*;
+use primitives::{AccountId, Balance};
+use sp_std::{boxed::Box, marker::PhantomData, prelude::*};
+
+pub use cumulus_primitives_core::ParaId;
+use xcm::v4::{prelude::*, Weight as XcmWeight};
+
+/// The encoded index corresponds to AssetHub's Runtime module configuration.
+/// https://github.com/polkadot-fellows/runtimes/blob/2fb47566718a974c261b68fffaae500be5581820/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs#L1065
+#[derive(Encode, Decode, RuntimeDebug)]
+pub enum KusamaAssetHubCall {
+ #[codec(index = 10)]
+ Balances(BalancesCall),
+ #[codec(index = 89)] // TODO: update
+ Staking(StakingCall),
+ #[codec(index = 40)]
+ Utility(Box>),
+ #[codec(index = 42)]
+ Proxy(Box>),
+ #[codec(index = 31)]
+ XcmPallet(XcmCall),
+}
+
+impl AssetHubCall for KusamaAssetHubCall {
+ fn balances(call: BalancesCall) -> Self {
+ KusamaAssetHubCall::Balances(call)
+ }
+
+ fn staking(call: StakingCall) -> Self {
+ KusamaAssetHubCall::Staking(call)
+ }
+
+ fn utility(call: UtilityCall) -> Self {
+ KusamaAssetHubCall::Utility(Box::new(call))
+ }
+
+ fn proxy(call: ProxyCall) -> Self {
+ KusamaAssetHubCall::Proxy(Box::new(call))
+ }
+
+ fn xcm_pallet(call: XcmCall) -> Self {
+ KusamaAssetHubCall::XcmPallet(call)
+ }
+}
+
+/// The encoded index corresponds to AssetHub's Runtime module configuration.
+/// https://github.com/polkadot-fellows/runtimes/blob/2fb47566718a974c261b68fffaae500be5581820/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs#L983
+#[derive(Encode, Decode, RuntimeDebug)]
+pub enum PolkadotAssetHubCall {
+ #[codec(index = 10)]
+ Balances(BalancesCall),
+ #[codec(index = 89)] // TODO: check https://github.com/polkadot-fellows/runtimes/pull/812
+ Staking(StakingCall),
+ #[codec(index = 40)]
+ Utility(Box>),
+ #[codec(index = 42)]
+ Proxy(Box>),
+ #[codec(index = 31)]
+ XcmPallet(XcmCall),
+}
+
+impl AssetHubCall for PolkadotAssetHubCall {
+ fn balances(call: BalancesCall) -> Self {
+ PolkadotAssetHubCall::Balances(call)
+ }
+
+ fn staking(call: StakingCall) -> Self {
+ PolkadotAssetHubCall::Staking(call)
+ }
+
+ fn utility(call: UtilityCall) -> Self {
+ PolkadotAssetHubCall::Utility(Box::new(call))
+ }
+
+ fn proxy(call: ProxyCall) -> Self {
+ PolkadotAssetHubCall::Proxy(Box::new(call))
+ }
+
+ fn xcm_pallet(call: XcmCall) -> Self {
+ PolkadotAssetHubCall::XcmPallet(call)
+ }
+}
+
+pub struct AssetHubCallBuilder(PhantomData<(ParachainId, AHC)>);
+
+impl CallBuilder for AssetHubCallBuilder
+where
+ ParachainId: Get,
+ AHC: AssetHubCall + FullCodec,
+{
+ type AssetHubAccountId = AccountId;
+ type Balance = Balance;
+ type AssetHubCall = AHC;
+
+ fn utility_as_derivative_call(call: AHC, index: u16) -> AHC {
+ AHC::utility(UtilityCall::AsDerivative(index, call))
+ }
+
+ fn staking_bond_extra(amount: Self::Balance) -> AHC {
+ AHC::staking(StakingCall::BondExtra(amount))
+ }
+
+ fn staking_unbond(amount: Self::Balance) -> AHC {
+ AHC::staking(StakingCall::Unbond(amount))
+ }
+
+ fn staking_withdraw_unbonded(num_slashing_spans: u32) -> AHC {
+ AHC::staking(StakingCall::WithdrawUnbonded(num_slashing_spans))
+ }
+
+ fn staking_nominate(targets: Vec) -> AHC {
+ AHC::staking(StakingCall::Nominate(
+ targets.iter().map(|a| AssetHubLookup::unlookup(a.clone())).collect(),
+ ))
+ }
+
+ fn balances_transfer_keep_alive(to: Self::AssetHubAccountId, amount: Self::Balance) -> AHC {
+ AHC::balances(BalancesCall::TransferKeepAlive(AssetHubLookup::unlookup(to), amount))
+ }
+
+ fn xcm_pallet_reserve_transfer_assets(
+ dest: Location,
+ beneficiary: Location,
+ assets: Assets,
+ fee_assets_item: u32,
+ ) -> AHC {
+ AHC::xcm_pallet(XcmCall::LimitedReserveTransferAssets(
+ dest.into_versioned(),
+ beneficiary.into_versioned(),
+ assets.into(),
+ fee_assets_item,
+ WeightLimit::Unlimited,
+ ))
+ }
+
+ fn proxy_call(real: Self::AssetHubAccountId, call: AHC) -> AHC {
+ AHC::proxy(ProxyCall::Proxy(AssetHubLookup::unlookup(real), None, call))
+ }
+
+ fn finalize_transfer_asset_xcm_message(
+ to: Self::AssetHubAccountId,
+ amount: Self::Balance,
+ reserve: Location,
+ weight: XcmWeight,
+ ) -> Xcm<()> {
+ let asset = Asset {
+ id: AssetId(Location::parent()),
+ fun: Fungibility::Fungible(amount),
+ };
+ Xcm(vec![
+ WithdrawAsset(asset.clone().into()),
+ SetFeesMode { jit_withdraw: true },
+ InitiateReserveWithdraw {
+ assets: All.into(),
+ reserve,
+ xcm: Xcm(vec![
+ BuyExecution {
+ fees: asset,
+ weight_limit: Limited(weight),
+ },
+ DepositAsset {
+ assets: AllCounted(1).into(),
+ beneficiary: Location {
+ parents: 0,
+ interior: AccountId32 {
+ network: None,
+ id: to.into(),
+ }
+ .into(),
+ },
+ },
+ ]),
+ },
+ ])
+ }
+
+ fn finalize_call_into_xcm_message(call: AHC, extra_fee: Self::Balance, weight: XcmWeight) -> Xcm<()> {
+ let asset = Asset {
+ id: AssetId(Location::parent()),
+ fun: Fungibility::Fungible(extra_fee),
+ };
+ Xcm(vec![
+ WithdrawAsset(asset.clone().into()),
+ BuyExecution {
+ fees: asset,
+ weight_limit: Unlimited,
+ },
+ Transact {
+ origin_kind: OriginKind::SovereignAccount,
+ require_weight_at_most: weight,
+ call: call.encode().into(),
+ },
+ RefundSurplus,
+ DepositAsset {
+ assets: AllCounted(1).into(),
+ beneficiary: Location {
+ parents: 0,
+ interior: Parachain(ParachainId::get().into()).into(),
+ },
+ },
+ ])
+ }
+
+ fn finalize_multiple_calls_into_xcm_message(calls: Vec<(AHC, XcmWeight)>, extra_fee: Self::Balance) -> Xcm<()> {
+ let asset = Asset {
+ id: AssetId(Location::parent()),
+ fun: Fungibility::Fungible(extra_fee),
+ };
+
+ let transacts = calls
+ .iter()
+ .map(|(call, weight)| Transact {
+ origin_kind: OriginKind::SovereignAccount,
+ require_weight_at_most: *weight,
+ call: call.encode().into(),
+ })
+ .collect();
+
+ Xcm([
+ vec![
+ WithdrawAsset(asset.clone().into()),
+ BuyExecution {
+ fees: asset,
+ weight_limit: Unlimited,
+ },
+ ],
+ transacts,
+ vec![
+ RefundSurplus,
+ DepositAsset {
+ assets: AllCounted(1).into(),
+ beneficiary: Location {
+ parents: 0,
+ interior: Parachain(ParachainId::get().into()).into(),
+ },
+ },
+ ],
+ ]
+ .concat())
+ }
+}
diff --git a/modules/homa-validator-list/src/lib.rs b/modules/homa-validator-list/src/lib.rs
index 08f772328..4ff259a30 100644
--- a/modules/homa-validator-list/src/lib.rs
+++ b/modules/homa-validator-list/src/lib.rs
@@ -111,14 +111,14 @@ impl Guarantee {
}
}
-/// Information on a relay chain validator's slash
+/// Information on a assethub validator's slash
#[derive(Encode, Decode, Clone, RuntimeDebug, Eq, PartialEq, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-pub struct SlashInfo {
- /// Address of a validator on the relay chain
- pub validator: RelayChainAccountId,
- /// The amount of tokens a validator has in backing on the relay chain
- pub relaychain_token_amount: Balance,
+pub struct SlashInfo {
+ /// Address of a validator on the assethub
+ pub validator: ValidatorId,
+ /// The amount of tokens a validator has in backing on the assethub
+ pub token_amount: Balance,
}
/// Validator insurance and frozen status
@@ -138,16 +138,10 @@ pub mod module {
/// The overarching event type.
type RuntimeEvent: From> + IsType<::RuntimeEvent>;
- /// The AccountId of a relay chain account.
- type RelayChainAccountId: Parameter
- + Member
- + MaybeSerializeDeserialize
- + Debug
- + MaybeDisplay
- + Ord
- + MaxEncodedLen;
+ /// The AccountId of a assethub account.
+ type ValidatorId: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + Ord + MaxEncodedLen;
- /// The liquid representation of the staking token on the relay chain.
+ /// The liquid representation of the staking token on the assethub.
type LiquidTokenCurrency: BasicLockableCurrency;
/// The minimum amount of tokens that can be bonded to a validator.
@@ -185,47 +179,47 @@ pub mod module {
#[pallet::generate_deposit(pub(crate) fn deposit_event)]
pub enum Event {
FreezeValidator {
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
},
ThawValidator {
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
},
BondGuarantee {
who: T::AccountId,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
bond: Balance,
},
UnbondGuarantee {
who: T::AccountId,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
bond: Balance,
},
WithdrawnGuarantee {
who: T::AccountId,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
bond: Balance,
},
SlashGuarantee {
who: T::AccountId,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
bond: Balance,
},
RebondGuarantee {
who: T::AccountId,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
bond: Balance,
},
}
- /// The slash guarantee deposits for relaychain validators.
+ /// The slash guarantee deposits for assethub validators.
///
- /// Guarantees: double_map RelayChainAccountId, AccountId => Option
+ /// Guarantees: double_map ValidatorId, AccountId => Option
#[pallet::storage]
#[pallet::getter(fn guarantees)]
pub type Guarantees = StorageDoubleMap<
_,
Blake2_128Concat,
- T::RelayChainAccountId,
+ T::ValidatorId,
Twox64Concat,
T::AccountId,
Guarantee,
@@ -241,11 +235,11 @@ pub mod module {
/// Total deposit for validators.
///
- /// ValidatorBackings: map RelayChainAccountId => Option
+ /// ValidatorBackings: map ValidatorId => Option
#[pallet::storage]
#[pallet::getter(fn validator_backings)]
pub type ValidatorBackings =
- StorageMap<_, Blake2_128Concat, T::RelayChainAccountId, ValidatorBacking, OptionQuery>;
+ StorageMap<_, Blake2_128Concat, T::ValidatorId, ValidatorBacking, OptionQuery>;
#[pallet::pallet]
pub struct Pallet(_);
@@ -264,7 +258,7 @@ pub mod module {
#[pallet::weight(T::WeightInfo::bond())]
pub fn bond(
origin: OriginFor,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
#[pallet::compact] amount: Balance,
) -> DispatchResult {
let guarantor = ensure_signed(origin)?;
@@ -303,7 +297,7 @@ pub mod module {
#[pallet::weight(T::WeightInfo::unbond())]
pub fn unbond(
origin: OriginFor,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
#[pallet::compact] amount: Balance,
) -> DispatchResult {
let guarantor = ensure_signed(origin)?;
@@ -339,7 +333,7 @@ pub mod module {
#[pallet::weight(T::WeightInfo::rebond())]
pub fn rebond(
origin: OriginFor,
- validator: T::RelayChainAccountId,
+ validator: T::ValidatorId,
#[pallet::compact] amount: Balance,
) -> DispatchResult {
let guarantor = ensure_signed(origin)?;
@@ -368,7 +362,7 @@ pub mod module {
/// - `validator`: The AccountId of a validator on the relay chain to withdraw from
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::withdraw_unbonded())]
- pub fn withdraw_unbonded(origin: OriginFor, validator: T::RelayChainAccountId) -> DispatchResult {
+ pub fn withdraw_unbonded(origin: OriginFor, validator: T::ValidatorId) -> DispatchResult {
let guarantor = ensure_signed(origin)?;
ensure!(
!Self::validator_backings(&validator).unwrap_or_default().is_frozen,
@@ -399,7 +393,7 @@ pub mod module {
/// - `validators`: The AccountIds of the validators on the relay chain to freeze
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::freeze(validators.len() as u32))]
- pub fn freeze(origin: OriginFor, validators: Vec) -> DispatchResult {
+ pub fn freeze(origin: OriginFor, validators: Vec) -> DispatchResult {
T::GovernanceOrigin::ensure_origin(origin)?;
validators.iter().for_each(|validator| {
ValidatorBackings::::mutate_exists(validator, |maybe_validator| {
@@ -422,7 +416,7 @@ pub mod module {
/// - `validators`: The AccountIds of the validators on the relay chain to unfreeze
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::thaw(validators.len() as u32))]
- pub fn thaw(origin: OriginFor, validators: Vec) -> DispatchResult {
+ pub fn thaw(origin: OriginFor, validators: Vec) -> DispatchResult {
T::GovernanceOrigin::ensure_origin(origin)?;
validators.iter().for_each(|validator| {
ValidatorBackings::::mutate_exists(validator, |maybe_validator| {
@@ -445,7 +439,7 @@ pub mod module {
/// - `slashes`: The SlashInfos of the validators to be slashed
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::slash(slashes.len() as u32))]
- pub fn slash(origin: OriginFor, slashes: Vec>) -> DispatchResult {
+ pub fn slash(origin: OriginFor, slashes: Vec>) -> DispatchResult {
T::GovernanceOrigin::ensure_origin(origin)?;
let liquid_staking_exchange_rate = T::LiquidStakingExchangeRateProvider::get_exchange_rate();
let staking_liquid_exchange_rate = liquid_staking_exchange_rate.reciprocal().unwrap_or_default();
@@ -453,12 +447,12 @@ pub mod module {
for SlashInfo {
validator,
- relaychain_token_amount,
+ token_amount,
} in slashes
{
let ValidatorBacking { total_insurance, .. } = Self::validator_backings(&validator).unwrap_or_default();
let insurance_loss = staking_liquid_exchange_rate
- .saturating_mul_int(relaychain_token_amount)
+ .saturating_mul_int(token_amount)
.min(total_insurance);
for (guarantor, _) in Guarantees::::iter_prefix(&validator) {
@@ -490,7 +484,7 @@ pub mod module {
impl Pallet {
fn update_guarantee(
guarantor: &T::AccountId,
- validator: &T::RelayChainAccountId,
+ validator: &T::ValidatorId,
f: impl FnOnce(&mut Guarantee) -> DispatchResult,
) -> DispatchResult {
Guarantees::::try_mutate_exists(validator, guarantor, |maybe_guarantee| -> DispatchResult {
@@ -549,8 +543,8 @@ impl Pallet {
}
}
-impl Contains for Pallet {
- fn contains(account: &T::RelayChainAccountId) -> bool {
+impl Contains for Pallet {
+ fn contains(account: &T::ValidatorId) -> bool {
ValidatorBackings::::get(account)
.is_some_and(|vb| vb.total_insurance >= T::ValidatorInsuranceThreshold::get() && !vb.is_frozen)
}
diff --git a/modules/homa-validator-list/src/mock.rs b/modules/homa-validator-list/src/mock.rs
index 839811613..bf84f2999 100644
--- a/modules/homa-validator-list/src/mock.rs
+++ b/modules/homa-validator-list/src/mock.rs
@@ -121,7 +121,7 @@ parameter_types! {
impl Config for Runtime {
type RuntimeEvent = RuntimeEvent;
- type RelayChainAccountId = AccountId;
+ type ValidatorId = AccountId;
type LiquidTokenCurrency = LDOTCurrency;
type MinBondAmount = ConstU128<100>;
type BondingDuration = BondingDuration;
diff --git a/modules/homa-validator-list/src/tests.rs b/modules/homa-validator-list/src/tests.rs
index ac745093a..ef60181c9 100644
--- a/modules/homa-validator-list/src/tests.rs
+++ b/modules/homa-validator-list/src/tests.rs
@@ -701,11 +701,11 @@ fn slash_work() {
vec![
SlashInfo {
validator: VALIDATOR_1,
- relaychain_token_amount: 90
+ token_amount: 90
},
SlashInfo {
validator: VALIDATOR_2,
- relaychain_token_amount: 50
+ token_amount: 50
},
]
),
@@ -717,11 +717,11 @@ fn slash_work() {
vec![
SlashInfo {
validator: VALIDATOR_1,
- relaychain_token_amount: 90
+ token_amount: 90
},
SlashInfo {
validator: VALIDATOR_2,
- relaychain_token_amount: 50
+ token_amount: 50
},
]
));
diff --git a/modules/homa/src/lib.rs b/modules/homa/src/lib.rs
index ed20d29ce..3e70ecde9 100644
--- a/modules/homa/src/lib.rs
+++ b/modules/homa/src/lib.rs
@@ -49,18 +49,16 @@ pub mod weights;
pub mod module {
use super::*;
- pub type RelayChainAccountIdOf = <::XcmInterface as HomaSubAccountXcm<
- ::AccountId,
- Balance,
- >>::RelayChainAccountId;
+ pub type NomineeIdOf =
+ <::XcmInterface as HomaSubAccountXcm<::AccountId, Balance>>::NomineeId;
/// The subaccount's staking ledger which kept by Homa protocol
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, Default)]
pub struct StakingLedger {
- /// Corresponding to the active of the subaccount's staking ledger on relaychain
+ /// Corresponding to the active of the subaccount's staking ledger on assethub
#[codec(compact)]
pub bonded: Balance,
- /// Corresponding to the unlocking of the subaccount's staking ledger on relaychain
+ /// Corresponding to the unlocking of the subaccount's staking ledger on assethub
pub unlocking: Vec,
}
@@ -153,7 +151,7 @@ pub mod module {
/// Block number provider for the relaychain.
type RelayChainBlockNumber: BlockNumberProvider>;
- /// The XcmInterface to manage the staking of sub-account on relaychain.
+ /// The XcmInterface to manage the staking of sub-account on assethub.
type XcmInterface: HomaSubAccountXcm;
/// The limit for process redeem requests when bump era.
@@ -163,7 +161,7 @@ pub mod module {
/// Weight information for the extrinsics in this module.
type WeightInfo: WeightInfo;
- type NominationsProvider: NomineesProvider>;
+ type NominationsProvider: NomineesProvider>;
}
#[pallet::error]
@@ -216,7 +214,7 @@ pub mod module {
fee_in_liquid: Balance,
redeemed_staking_amount: Balance,
},
- /// Redeem request is redeemed by unbond on relaychain.
+ /// Redeem request is redeemed by unbond on assethub.
RedeemedByUnbond {
redeemer: T::AccountId,
era_index_when_unbond: EraIndex,
@@ -244,7 +242,7 @@ pub mod module {
},
/// The soft bonded cap of per sub account has been updated.
SoftBondedCapPerSubAccountUpdated { cap_amount: Balance },
- /// The estimated reward rate per era of relaychain staking has been updated.
+ /// The estimated reward rate per era of assethub staking has been updated.
EstimatedRewardRatePerEraUpdated { reward_rate: Rate },
/// The commission rate has been updated.
CommissionRateUpdated { commission_rate: Rate },
@@ -256,16 +254,16 @@ pub mod module {
BumpEraFrequencyUpdated { frequency: BlockNumberFor },
/// The interval eras to nominate.
NominateIntervalEraUpdated { eras: EraIndex },
- /// Withdraw unbonded from RelayChain
+ /// Withdraw unbonded from assethub
HomaWithdrawUnbonded { sub_account_index: u16, amount: Balance },
- /// Unbond staking currency of sub account on RelayChain
+ /// Unbond staking currency of sub account on assethub
HomaUnbond { sub_account_index: u16, amount: Balance },
- /// Transfer staking currency to sub account and bond on RelayChain
+ /// Transfer staking currency to sub account and bond on assethub
HomaBondExtra { sub_account_index: u16, amount: Balance },
- /// Nominate validators on RelayChain
+ /// Nominate validators on assethub
HomaNominate {
sub_account_index: u16,
- nominations: Vec>,
+ nominations: Vec>,
},
}
@@ -290,7 +288,7 @@ pub mod module {
#[pallet::getter(fn get_total_bonded)]
pub type TotalStakingBonded = StorageValue<_, Balance, ValueQuery>;
- /// The total staking currency to bond on relaychain when new era,
+ /// The total staking currency to bond on assethub when new era,
/// and that is available to be match fast redeem request.
/// ToBondPool value: StakingCurrencyAmount
#[pallet::storage]
@@ -298,7 +296,7 @@ pub mod module {
pub type ToBondPool = StorageValue<_, Balance, ValueQuery>;
/// The total amount of void liquid currency. It's will not be issued,
- /// used to avoid newly issued LDOT to obtain the incoming staking income from relaychain.
+ /// used to avoid newly issued LDOT to obtain the incoming staking income from assethub.
/// And it is guaranteed that the current exchange rate between liquid currency and staking
/// currency will not change. It will be reset to 0 at the beginning of the `rebalance` when new
/// era starts.
@@ -336,7 +334,7 @@ pub mod module {
#[pallet::storage]
pub type EstimatedRewardRatePerEra = StorageValue<_, FractionalRate, ValueQuery>;
- /// The maximum amount of bonded staking currency for a single sub on relaychain to obtain the
+ /// The maximum amount of bonded staking currency for a single sub on assethub to obtain the
/// best staking rewards.
///
/// SoftBondedCapPerSubAccount: value: Balance
@@ -418,8 +416,8 @@ pub mod module {
/// The redeem request will be executed in two ways:
/// 1. Redeem by fast match: Homa use staking currency in ToBondPool to match redeem request
/// in the current era, setting a higher fee_rate can increase the possibility of being fast
- /// matched. 2. Redeem by unbond on relaychain: if redeem request has not been fast matched
- /// in current era, Homa will unbond staking currency on relaychain when the next era
+ /// matched. 2. Redeem by unbond on assethub: if redeem request has not been fast matched
+ /// in current era, Homa will unbond staking currency on assethub when the next era
/// bumped. So redeemer at least wait for the unbonding period + extra 1 era to get the
/// redemption.
///
@@ -502,9 +500,9 @@ pub mod module {
///
/// Parameters:
/// - `soft_bonded_cap_per_sub_account`: soft cap of staking amount for a single nominator
- /// on relaychain to obtain the best staking rewards.
+ /// on assethub to obtain the best staking rewards.
/// - `estimated_reward_rate_per_era`: the estimated staking yield of each era on the
- /// current relay chain.
+ /// current relaychain.
/// - `commission_rate`: the rate to draw from estimated staking rewards as commission to
/// HomaTreasury
/// - `fast_match_fee_rate`: the fixed fee rate when redeem request is been fast matched.
@@ -575,7 +573,7 @@ pub mod module {
if let Some(change) = last_era_bumped_block {
// config last_era_bumped_block should not cause bump era to occur immediately, because
// the last_era_bumped_block after the bump era will not be same with the actual relaychain
- // era bumped block again, especially if it leads to multiple bump era.
+ // era bumped block again, especially if it leads to multiple bump era.
// and it should be config after config no-zero bump_era_frequency.
let bump_era_frequency = Self::bump_era_frequency();
let current_relay_chain_block = T::RelayChainBlockNumber::current_block_number();
@@ -599,7 +597,7 @@ pub mod module {
}
/// Reset the bonded and unbonding to local subaccounts ledger according to the ledger on
- /// relaychain. Requires `GovernanceOrigin`
+ /// assethub. Requires `GovernanceOrigin`
///
/// Parameters:
/// - `updates`: update list of subaccount.
@@ -665,10 +663,10 @@ pub mod module {
#[pallet::call_index(8)]
#[pallet::weight(< T as Config >::WeightInfo::on_initialize_with_bump_era(T::ProcessRedeemRequestsLimit::get()))]
- pub fn force_bump_current_era(origin: OriginFor, bump_amount: EraIndex) -> DispatchResultWithPostInfo {
+ pub fn force_bump_current_era(origin: OriginFor, bump_era: EraIndex) -> DispatchResultWithPostInfo {
T::GovernanceOrigin::ensure_origin(origin)?;
- let res = Self::bump_current_era(bump_amount);
+ let res = Self::bump_current_era(bump_era);
Ok(Some(T::WeightInfo::on_initialize_with_bump_era(res.unwrap_or_default())).into())
}
@@ -994,7 +992,7 @@ pub mod module {
Ok(())
}
- /// Get back unbonded of all subaccounts on relaychain by XCM.
+ /// Get back unbonded of all subaccounts on assethub by XCM.
/// The staking currency withdrew becomes available to be redeemed.
#[transactional]
pub fn process_scheduled_unbond(new_era: EraIndex) -> DispatchResult {
@@ -1029,12 +1027,12 @@ pub mod module {
}
/// Distribute PoolToBond to ActiveSubAccountsIndexList, then cross-transfer the
- /// distribution amount to the subaccounts on relaychain and bond it by XCM.
+ /// distribution amount to the subaccounts on assethub and bond it by XCM.
#[transactional]
pub fn process_to_bond_pool() -> DispatchResult {
let to_bond_pool = Self::to_bond_pool();
- // if to_bond is gte than MintThreshold, try to bond_extra on relaychain
+ // if to_bond is gte than MintThreshold, try to bond_extra on assethub
if to_bond_pool >= T::MintThreshold::get() {
let xcm_transfer_fee = T::XcmInterface::get_xcm_transfer_fee();
let bonded_list: Vec<(u16, Balance)> = T::ActiveSubAccountsIndexList::get()
@@ -1080,7 +1078,7 @@ pub mod module {
Ok(())
}
- /// Process redeem requests and subaccounts do unbond on relaychain by XCM message.
+ /// Process redeem requests and subaccounts do unbond on assethub by XCM message.
#[transactional]
pub fn process_redeem_requests(new_era: EraIndex) -> Result {
let era_index_to_expire = new_era + T::BondingDuration::get();
@@ -1149,7 +1147,7 @@ pub mod module {
Ok(handled_requests)
}
- /// Process nominate validators for subaccounts on relaychain.
+ /// Process nominate validators for subaccounts on assethub.
pub fn process_nominate(new_era: EraIndex) -> DispatchResult {
// check whether need to nominate
let nominate_interval_era = NominateIntervalEra::::get();
@@ -1180,12 +1178,12 @@ pub mod module {
}
/// Bump current era.
- /// The rebalance will send XCM messages to relaychain. Once the XCM message is sent,
+ /// The rebalance will send XCM messages to assethub. Once the XCM message is sent,
/// the execution result cannot be obtained and cannot be rolled back. So the process
/// of rebalance is not atomic.
- pub fn bump_current_era(amount: EraIndex) -> Result {
+ pub fn bump_current_era(bump_era: EraIndex) -> Result {
let previous_era = Self::relay_chain_current_era();
- let new_era = previous_era.saturating_add(amount);
+ let new_era = previous_era.saturating_add(bump_era);
RelayChainCurrentEra::::put(new_era);
LastEraBumpedBlock::::put(T::RelayChainBlockNumber::current_block_number());
Self::deposit_event(Event::::CurrentEraBumped { new_era_index: new_era });
diff --git a/modules/homa/src/mock.rs b/modules/homa/src/mock.rs
index 4f0fb54fb..2a52ddfbd 100644
--- a/modules/homa/src/mock.rs
+++ b/modules/homa/src/mock.rs
@@ -56,7 +56,7 @@ pub const VALIDATOR_D: AccountId = AccountId32::new([203u8; 32]);
/// mock XCM transfer.
pub struct MockHomaSubAccountXcm;
impl HomaSubAccountXcm for MockHomaSubAccountXcm {
- type RelayChainAccountId = AccountId;
+ type NomineeId = AccountId;
fn transfer_staking_to_sub_account(sender: &AccountId, _: u16, amount: Balance) -> DispatchResult {
Currencies::withdraw(
@@ -79,7 +79,7 @@ impl HomaSubAccountXcm for MockHomaSubAccountXcm {
Ok(())
}
- fn nominate_on_sub_account(_: u16, _: Vec) -> DispatchResult {
+ fn nominate_on_sub_account(_: u16, _: Vec) -> DispatchResult {
Ok(())
}
diff --git a/modules/relaychain/src/lib.rs b/modules/relaychain/src/lib.rs
deleted file mode 100644
index a390b8fe2..000000000
--- a/modules/relaychain/src/lib.rs
+++ /dev/null
@@ -1,234 +0,0 @@
-// This file is part of Acala.
-
-// Copyright (C) 2020-2025 Acala Foundation.
-// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
-
-// This program 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.
-
-// This program 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 this program. If not, see .
-
-//! # Module RelayChain
-//!
-//! This module is in charge of handling relaychain related utilities and business logic.
-
-#![cfg_attr(not(feature = "std"), no_std)]
-#![allow(clippy::unused_unit)]
-#![allow(clippy::large_enum_variant)]
-
-use parity_scale_codec::{Decode, Encode, FullCodec};
-use sp_runtime::{traits::StaticLookup, RuntimeDebug};
-
-use frame_support::traits::Get;
-use module_support::relaychain::*;
-use primitives::{AccountId, Balance};
-use sp_std::{boxed::Box, marker::PhantomData, prelude::*};
-
-pub use cumulus_primitives_core::ParaId;
-use xcm::v4::{prelude::*, Weight as XcmWeight};
-
-/// The encoded index corresponds to Kusama's Runtime module configuration.
-/// https://github.com/paritytech/polkadot/blob/444e96ae34bcec8362f0f947a07bd912b32ca48f/runtime/kusama/src/lib.rs#L1379
-#[derive(Encode, Decode, RuntimeDebug)]
-pub enum KusamaRelayChainCall {
- #[codec(index = 4)]
- Balances(BalancesCall),
- #[codec(index = 6)]
- Staking(StakingCall),
- #[codec(index = 24)]
- Utility(Box>),
- #[codec(index = 30)]
- Proxy(Box>),
- #[codec(index = 99)]
- XcmPallet(XcmCall),
-}
-
-impl RelayChainCall for KusamaRelayChainCall {
- fn balances(call: BalancesCall) -> Self {
- KusamaRelayChainCall::Balances(call)
- }
-
- fn staking(call: StakingCall) -> Self {
- KusamaRelayChainCall::Staking(call)
- }
-
- fn utility(call: UtilityCall) -> Self {
- KusamaRelayChainCall::Utility(Box::new(call))
- }
-
- fn proxy(call: ProxyCall) -> Self {
- KusamaRelayChainCall::Proxy(Box::new(call))
- }
-
- fn xcm_pallet(call: XcmCall) -> Self {
- KusamaRelayChainCall::XcmPallet(call)
- }
-}
-
-/// The encoded index corresponds to Polkadot's Runtime module configuration.
-/// https://github.com/paritytech/polkadot/blob/84a3962e76151ac5ed3afa4ef1e0af829531ab42/runtime/polkadot/src/lib.rs#L1040
-#[derive(Encode, Decode, RuntimeDebug)]
-pub enum PolkadotRelayChainCall {
- #[codec(index = 5)]
- Balances(BalancesCall),
- #[codec(index = 7)]
- Staking(StakingCall),
- #[codec(index = 26)]
- Utility(Box>),
- #[codec(index = 29)]
- Proxy(Box>),
- #[codec(index = 99)]
- XcmPallet(XcmCall),
-}
-
-impl RelayChainCall for PolkadotRelayChainCall {
- fn balances(call: BalancesCall) -> Self {
- PolkadotRelayChainCall::Balances(call)
- }
-
- fn staking(call: StakingCall) -> Self {
- PolkadotRelayChainCall::Staking(call)
- }
-
- fn utility(call: UtilityCall) -> Self {
- PolkadotRelayChainCall::Utility(Box::new(call))
- }
-
- fn proxy(call: ProxyCall) -> Self {
- PolkadotRelayChainCall::Proxy(Box::new(call))
- }
-
- fn xcm_pallet(call: XcmCall) -> Self {
- PolkadotRelayChainCall::XcmPallet(call)
- }
-}
-
-pub struct RelayChainCallBuilder(PhantomData<(ParachainId, RCC)>);
-
-impl CallBuilder for RelayChainCallBuilder
-where
- ParachainId: Get,
- RCC: RelayChainCall + FullCodec,
-{
- type RelayChainAccountId = AccountId;
- type Balance = Balance;
- type RelayChainCall = RCC;
-
- fn utility_as_derivative_call(call: RCC, index: u16) -> RCC {
- RCC::utility(UtilityCall::AsDerivative(index, call))
- }
-
- fn staking_bond_extra(amount: Self::Balance) -> RCC {
- RCC::staking(StakingCall::BondExtra(amount))
- }
-
- fn staking_unbond(amount: Self::Balance) -> RCC {
- RCC::staking(StakingCall::Unbond(amount))
- }
-
- fn staking_withdraw_unbonded(num_slashing_spans: u32) -> RCC {
- RCC::staking(StakingCall::WithdrawUnbonded(num_slashing_spans))
- }
-
- fn staking_nominate(targets: Vec) -> RCC {
- RCC::staking(StakingCall::Nominate(
- targets.iter().map(|a| RelayChainLookup::unlookup(a.clone())).collect(),
- ))
- }
-
- fn balances_transfer_keep_alive(to: Self::RelayChainAccountId, amount: Self::Balance) -> RCC {
- RCC::balances(BalancesCall::TransferKeepAlive(RelayChainLookup::unlookup(to), amount))
- }
-
- fn xcm_pallet_reserve_transfer_assets(
- dest: Location,
- beneficiary: Location,
- assets: Assets,
- fee_assets_item: u32,
- ) -> RCC {
- RCC::xcm_pallet(XcmCall::LimitedReserveTransferAssets(
- dest.into_versioned(),
- beneficiary.into_versioned(),
- assets.into(),
- fee_assets_item,
- WeightLimit::Unlimited,
- ))
- }
-
- fn proxy_call(real: Self::RelayChainAccountId, call: RCC) -> RCC {
- RCC::proxy(ProxyCall::Proxy(RelayChainLookup::unlookup(real), None, call))
- }
-
- fn finalize_call_into_xcm_message(call: RCC, extra_fee: Self::Balance, weight: XcmWeight) -> Xcm<()> {
- let asset = Asset {
- id: AssetId(Location::here()),
- fun: Fungibility::Fungible(extra_fee),
- };
- Xcm(vec![
- WithdrawAsset(asset.clone().into()),
- BuyExecution {
- fees: asset,
- weight_limit: Unlimited,
- },
- Transact {
- origin_kind: OriginKind::SovereignAccount,
- require_weight_at_most: weight,
- call: call.encode().into(),
- },
- RefundSurplus,
- DepositAsset {
- assets: AllCounted(1).into(), // there is only 1 asset on relaychain
- beneficiary: Location {
- parents: 0,
- interior: Parachain(ParachainId::get().into()).into(),
- },
- },
- ])
- }
-
- fn finalize_multiple_calls_into_xcm_message(calls: Vec<(RCC, XcmWeight)>, extra_fee: Self::Balance) -> Xcm<()> {
- let asset = Asset {
- id: AssetId(Location::here()),
- fun: Fungibility::Fungible(extra_fee),
- };
-
- let transacts = calls
- .iter()
- .map(|(call, weight)| Transact {
- origin_kind: OriginKind::SovereignAccount,
- require_weight_at_most: *weight,
- call: call.encode().into(),
- })
- .collect();
-
- Xcm([
- vec![
- WithdrawAsset(asset.clone().into()),
- BuyExecution {
- fees: asset,
- weight_limit: Unlimited,
- },
- ],
- transacts,
- vec![
- RefundSurplus,
- DepositAsset {
- assets: AllCounted(1).into(), // there is only 1 asset on relaychain
- beneficiary: Location {
- parents: 0,
- interior: Parachain(ParachainId::get().into()).into(),
- },
- },
- ],
- ]
- .concat())
- }
-}
diff --git a/modules/support/src/relaychain.rs b/modules/support/src/assethub.rs
similarity index 70%
rename from modules/support/src/relaychain.rs
rename to modules/support/src/assethub.rs
index d86ab1853..17952d989 100644
--- a/modules/support/src/relaychain.rs
+++ b/modules/support/src/assethub.rs
@@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-// * Since XCM V3, relaychain configs 'SafeCallFilter' to filter the call in Transact:
+// * Since XCM V3, xcm executor configs 'SafeCallFilter' to filter the call in Transact:
// * https://github.com/paritytech/polkadot/blob/master/runtime/polkadot/src/xcm_config.rs
use parity_scale_codec::{Decode, Encode, FullCodec};
@@ -31,13 +31,13 @@ use xcm::{prelude::*, v3::Weight as XcmWeight};
#[derive(Encode, Decode, RuntimeDebug)]
pub enum BalancesCall {
#[codec(index = 3)]
- TransferKeepAlive(::Source, #[codec(compact)] Balance),
+ TransferKeepAlive(::Source, #[codec(compact)] Balance),
}
#[derive(Encode, Decode, RuntimeDebug)]
-pub enum UtilityCall {
+pub enum UtilityCall {
#[codec(index = 1)]
- AsDerivative(u16, RCC),
+ AsDerivative(u16, AHC),
}
#[derive(Encode, Decode, RuntimeDebug)]
@@ -49,7 +49,7 @@ pub enum StakingCall {
#[codec(index = 3)]
WithdrawUnbonded(u32),
#[codec(index = 5)]
- Nominate(Vec<::Source>),
+ Nominate(Vec<::Source>),
}
/// `pallet-xcm` calls.
@@ -62,18 +62,18 @@ pub enum XcmCall {
}
// Same to `Polkadot` and `Kusama` runtime `Lookup` config.
-pub type RelayChainLookup = AccountIdLookup;
+pub type AssetHubLookup = AccountIdLookup;
/// `pallet-proxy` calls.
#[derive(Encode, Decode, RuntimeDebug)]
-pub enum ProxyCall {
+pub enum ProxyCall {
/// `proxy(real, force_proxy_type, call)` call. Force proxy type is not supported and
/// is always set to `None`.
#[codec(index = 0)]
- Proxy(::Source, Option<()>, RCC),
+ Proxy(::Source, Option<()>, AHC),
}
-pub trait RelayChainCall: Sized {
+pub trait AssetHubCall: Sized {
fn balances(call: BalancesCall) -> Self;
fn staking(call: StakingCall) -> Self;
fn utility(call: UtilityCall) -> Self;
@@ -82,41 +82,41 @@ pub trait RelayChainCall: Sized {
}
pub trait CallBuilder {
- type RelayChainAccountId: FullCodec;
+ type AssetHubAccountId: FullCodec;
type Balance: FullCodec;
- type RelayChainCall: FullCodec + RelayChainCall;
+ type AssetHubCall: FullCodec + AssetHubCall;
/// Execute a call, replacing the `Origin` with a sub-account.
/// params:
/// - call: The call to be executed.
/// - index: The index of sub-account to be used as the new origin.
- fn utility_as_derivative_call(call: Self::RelayChainCall, index: u16) -> Self::RelayChainCall;
+ fn utility_as_derivative_call(call: Self::AssetHubCall, index: u16) -> Self::AssetHubCall;
- /// Bond extra on relay-chain.
+ /// Bond extra on assethub.
/// params:
/// - amount: The amount of staking currency to bond.
- fn staking_bond_extra(amount: Self::Balance) -> Self::RelayChainCall;
+ fn staking_bond_extra(amount: Self::Balance) -> Self::AssetHubCall;
- /// Unbond on relay-chain.
+ /// Unbond on assethub.
/// params:
/// - amount: The amount of staking currency to unbond.
- fn staking_unbond(amount: Self::Balance) -> Self::RelayChainCall;
+ fn staking_unbond(amount: Self::Balance) -> Self::AssetHubCall;
- /// Withdraw unbonded staking on the relay-chain.
+ /// Withdraw unbonded staking on the assethub.
/// params:
/// - num_slashing_spans: The number of slashing spans to withdraw from.
- fn staking_withdraw_unbonded(num_slashing_spans: u32) -> Self::RelayChainCall;
+ fn staking_withdraw_unbonded(num_slashing_spans: u32) -> Self::AssetHubCall;
- /// Nominate the relay-chain.
+ /// Nominate the assethub.
/// params:
/// - targets: The target validator list.
- fn staking_nominate(targets: Vec) -> Self::RelayChainCall;
+ fn staking_nominate(targets: Vec) -> Self::AssetHubCall;
/// Transfer Staking currency to another account, disallowing "death".
/// params:
/// - to: The destination for the transfer
/// - amount: The amount of staking currency to be transferred.
- fn balances_transfer_keep_alive(to: Self::RelayChainAccountId, amount: Self::Balance) -> Self::RelayChainCall;
+ fn balances_transfer_keep_alive(to: Self::AssetHubAccountId, amount: Self::Balance) -> Self::AssetHubCall;
/// Reserve transfer assets.
/// params:
@@ -129,31 +129,41 @@ pub trait CallBuilder {
beneficiary: Location,
assets: Assets,
fee_assets_item: u32,
- ) -> Self::RelayChainCall;
+ ) -> Self::AssetHubCall;
/// Proxy a call with a `real` account without a forced proxy type.
/// params:
/// - real: The real account.
/// - call: The call to be executed.
- fn proxy_call(real: Self::RelayChainAccountId, call: Self::RelayChainCall) -> Self::RelayChainCall;
+ fn proxy_call(real: Self::AssetHubAccountId, call: Self::AssetHubCall) -> Self::AssetHubCall;
+
+ /// Wrap the final transfer asset into the Xcm format.
+ /// params:
+ /// - to: The destination account.
+ /// - amount: The amount of staking currency to be transferred.
+ /// - reserve: The reserve location.
+ /// - weight: the weight limit used for XCM.
+ fn finalize_transfer_asset_xcm_message(
+ to: Self::AssetHubAccountId,
+ amount: Self::Balance,
+ reserve: Location,
+ weight: XcmWeight,
+ ) -> Xcm<()>;
/// Wrap the final call into the Xcm format.
/// params:
/// - call: The call to be executed
/// - extra_fee: Extra fee (in staking currency) used for buy the `weight`.
/// - weight: the weight limit used for XCM.
- fn finalize_call_into_xcm_message(
- call: Self::RelayChainCall,
- extra_fee: Self::Balance,
- weight: XcmWeight,
- ) -> Xcm<()>;
+ fn finalize_call_into_xcm_message(call: Self::AssetHubCall, extra_fee: Self::Balance, weight: XcmWeight)
+ -> Xcm<()>;
/// Wrap the final multiple calls into the Xcm format.
/// params:
/// - calls: the multiple calls and its weight limit to be executed
/// - extra_fee: Extra fee (in staking currency) used for buy the `weight`.
fn finalize_multiple_calls_into_xcm_message(
- calls: Vec<(Self::RelayChainCall, XcmWeight)>,
+ calls: Vec<(Self::AssetHubCall, XcmWeight)>,
extra_fee: Self::Balance,
) -> Xcm<()>;
}
diff --git a/modules/support/src/homa.rs b/modules/support/src/homa.rs
index 172434fdb..5a7f06d13 100644
--- a/modules/support/src/homa.rs
+++ b/modules/support/src/homa.rs
@@ -22,18 +22,18 @@ use sp_std::{fmt::Debug, vec::Vec};
use xcm::v4::prelude::*;
pub trait HomaSubAccountXcm {
- type RelayChainAccountId: Debug + Clone + Ord;
- /// Cross-chain transfer staking currency to sub account on relaychain.
+ type NomineeId: Debug + Clone + Ord;
+ /// Cross-chain transfer staking currency to sub account on assethub.
fn transfer_staking_to_sub_account(sender: &AccountId, sub_account_index: u16, amount: Balance) -> DispatchResult;
- /// Send XCM message to the relaychain for sub account to withdraw_unbonded staking currency and
+ /// Send XCM message to the assethub for sub account to withdraw_unbonded staking currency and
/// send it back.
fn withdraw_unbonded_from_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult;
- /// Send XCM message to the relaychain for sub account to bond extra.
+ /// Send XCM message to the assethub for sub account to bond extra.
fn bond_extra_on_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult;
- /// Send XCM message to the relaychain for sub account to unbond.
+ /// Send XCM message to the assethub for sub account to unbond.
fn unbond_on_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult;
- /// Send XCM message to the relaychain for sub account to nominate.
- fn nominate_on_sub_account(sub_account_index: u16, targets: Vec) -> DispatchResult;
+ /// Send XCM message to the assethub for sub account to nominate.
+ fn nominate_on_sub_account(sub_account_index: u16, targets: Vec) -> DispatchResult;
/// The fee of cross-chain transfer is deducted from the recipient.
fn get_xcm_transfer_fee() -> Balance;
/// The fee of parachain
diff --git a/modules/support/src/lib.rs b/modules/support/src/lib.rs
index 4abaf1deb..bcf87571f 100644
--- a/modules/support/src/lib.rs
+++ b/modules/support/src/lib.rs
@@ -29,6 +29,7 @@ use sp_runtime::{
use sp_std::{prelude::*, result::Result, vec};
use xcm::prelude::*;
+pub mod assethub;
pub mod bounded;
pub mod dex;
pub mod earning;
@@ -37,7 +38,6 @@ pub mod homa;
pub mod honzon;
pub mod incentives;
pub mod mocks;
-pub mod relaychain;
pub mod stable_asset;
pub use crate::bounded::*;
diff --git a/modules/xcm-interface/Cargo.toml b/modules/xcm-interface/Cargo.toml
index 1cfac111b..9944a5d84 100644
--- a/modules/xcm-interface/Cargo.toml
+++ b/modules/xcm-interface/Cargo.toml
@@ -16,8 +16,8 @@ sp-core = { workspace = true }
sp-std = { workspace = true }
pallet-xcm = { workspace = true }
xcm = { workspace = true }
+xcm-executor = { workspace = true }
primitives = { workspace = true }
-orml-traits = { workspace = true }
module-support = { workspace = true }
[dev-dependencies]
@@ -27,9 +27,8 @@ pallet-balances = { workspace = true, features = ["std"] }
sp-io = { workspace = true, features = ["std"] }
xcm-builder = { workspace = true, features = ["std"] }
xcm-executor = { workspace = true, features = ["std"] }
-orml-tokens = { workspace = true, features = ["std"] }
module-currencies = { workspace = true, features = ["std"] }
-module-relaychain = { workspace = true, features = ["std"] }
+module-assethub = { workspace = true, features = ["std"] }
[features]
default = ["std"]
@@ -39,7 +38,6 @@ std = [
"frame-support/std",
"frame-system/std",
"module-support/std",
- "orml-traits/std",
"pallet-xcm/std",
"primitives/std",
"scale-info/std",
@@ -47,6 +45,7 @@ std = [
"sp-runtime/std",
"sp-std/std",
"xcm/std",
+ "xcm-executor/std"
]
runtime-benchmarks = [
"frame-benchmarking",
diff --git a/modules/xcm-interface/src/lib.rs b/modules/xcm-interface/src/lib.rs
index ae6cbb3f0..39761c5c7 100644
--- a/modules/xcm-interface/src/lib.rs
+++ b/modules/xcm-interface/src/lib.rs
@@ -18,7 +18,7 @@
//! Xcm Interface module.
//!
-//! This module interfaces Acala native modules with the Relaychain / parachains via the use of XCM.
+//! This module interfaces Acala native modules with the AssetHub / parachains via the use of XCM.
//! Functions in this module will create XCM messages that performs the requested functions and
//! send the messages out to the intended destination.
//!
@@ -29,26 +29,29 @@
use frame_support::{pallet_prelude::*, traits::Get};
use frame_system::pallet_prelude::*;
-use module_support::{relaychain::CallBuilder, HomaSubAccountXcm};
-use orml_traits::XcmTransfer;
-use primitives::{Balance, CurrencyId, EraIndex};
+use module_support::{assethub::CallBuilder, HomaSubAccountXcm};
+use primitives::{Balance, EraIndex};
use scale_info::TypeInfo;
+use sp_core::hashing;
use sp_runtime::traits::Convert;
use sp_std::{convert::From, prelude::*, vec, vec::Vec};
use xcm::{prelude::*, v3::Weight as XcmWeight};
+use xcm_executor::traits::WeightBounds;
mod mocks;
pub use module::*;
+const LOG_TARGET: &str = "xcm-interface";
+
#[frame_support::pallet]
pub mod module {
use super::*;
#[derive(Encode, Decode, Eq, PartialEq, Clone, RuntimeDebug, TypeInfo)]
pub enum XcmInterfaceOperation {
- // XTokens
- XtokensTransfer,
+ // PalletXcm transfer
+ XcmTransfer,
// Homa
HomaWithdrawUnbonded,
HomaBondExtra,
@@ -67,31 +70,24 @@ pub mod module {
/// Origin represented Governance
type UpdateOrigin: EnsureOrigin<::RuntimeOrigin>;
- /// The currency id of the Staking asset
- #[pallet::constant]
- type StakingCurrencyId: Get;
-
- /// The account of parachain on the relaychain.
+ /// The account of parachain on the assethub.
#[pallet::constant]
type ParachainAccount: Get;
- /// Unbonding slashing spans for unbonding on the relaychain.
+ /// Unbonding slashing spans for unbonding on the assethub.
#[pallet::constant]
- type RelayChainUnbondingSlashingSpans: Get;
+ type AssetHubUnbondingSlashingSpans: Get;
- /// The convert for convert sovereign subacocunt index to the Location where the
+ /// The convert for convert sovereign subacocunt index to the account where the
/// staking currencies are sent to.
- type SovereignSubAccountLocationConvert: Convert;
+ type SovereignSubAccountIdConvert: Convert;
- /// The Call builder for communicating with RelayChain via XCM messaging.
- type RelayChainCallBuilder: CallBuilder;
+ /// The Call builder for communicating with AssetHub via XCM messaging.
+ type AssetHubCallBuilder: CallBuilder;
- /// The interface to Cross-chain transfer.
- type XcmTransfer: XcmTransfer;
-
- /// Self parachain location.
+ /// AssetHub location.
#[pallet::constant]
- type SelfLocation: Get;
+ type AssetHubLocation: Get;
/// Convert AccountId to Location to build XCM message.
type AccountIdToLocation: Convert;
@@ -119,7 +115,7 @@ pub mod module {
}
/// The dest weight limit and fee for execution XCM msg sended by XcmInterface. Must be
- /// sufficient, otherwise the execution of XCM msg on relaychain will fail.
+ /// sufficient, otherwise the execution of XCM msg on assethub will fail.
///
/// XcmDestWeightAndFee: map: XcmInterfaceOperation => (Weight, Balance)
#[pallet::storage]
@@ -172,45 +168,69 @@ pub mod module {
}
impl HomaSubAccountXcm for Pallet {
- type RelayChainAccountId = T::AccountId;
+ type NomineeId = T::AccountId;
- /// Cross-chain transfer staking currency to sub account on relaychain.
+ /// Cross-chain transfer staking currency to sub account on assethub.
fn transfer_staking_to_sub_account(
sender: &T::AccountId,
sub_account_index: u16,
amount: Balance,
) -> DispatchResult {
- T::XcmTransfer::transfer(
- sender.clone(),
- T::StakingCurrencyId::get(),
- amount,
- T::SovereignSubAccountLocationConvert::convert(sub_account_index),
- WeightLimit::Limited(Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::XtokensTransfer).0),
- )
- .map(|_| ())
+ let (xcm_dest_weight, _xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::XcmTransfer);
+ let to = T::SovereignSubAccountIdConvert::convert(sub_account_index);
+ let reserve = T::AssetHubLocation::get();
+
+ let mut xcm_message =
+ T::AssetHubCallBuilder::finalize_transfer_asset_xcm_message(to, amount, reserve, xcm_dest_weight)
+ .into();
+
+ let origin_location = T::AccountIdToLocation::convert(sender.clone());
+ let mut hash = xcm_message.using_encoded(hashing::blake2_256);
+ let weight = T::Weigher::weight(&mut xcm_message).map_err(|e| {
+ log::error!(
+ target: LOG_TARGET,
+ "failed to weigh XCM message: {:?}", e
+ );
+ Error::::XcmFailed
+ })?;
+
+ log::debug!(
+ target: LOG_TARGET,
+ "origin_location {:?} send XCM to transfer staking currency {:?} to subaccount {:?}, message: {:?}",
+ origin_location, amount, sub_account_index, xcm_message
+ );
+ T::XcmExecutor::prepare_and_execute(origin_location, xcm_message, &mut hash, weight, weight)
+ .ensure_complete()
+ .map_err(|e| {
+ log::error!(
+ target: LOG_TARGET,
+ "XcmExecutor failed to execute XCM message: {:?}", e
+ );
+ Error::::XcmFailed
+ })?;
+
+ Ok(())
}
- /// Send XCM message to the relaychain for sub account to withdraw_unbonded staking currency
+ /// Send XCM message to the assethub for sub account to withdraw_unbonded staking currency
/// and send it back.
fn withdraw_unbonded_from_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult {
let (xcm_dest_weight, xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::HomaWithdrawUnbonded);
// TODO: config xcm_dest_weight and fee for withdraw_unbonded and transfer separately.
// Temporarily use double fee.
- let xcm_message = T::RelayChainCallBuilder::finalize_multiple_calls_into_xcm_message(
+ let xcm_message = T::AssetHubCallBuilder::finalize_multiple_calls_into_xcm_message(
vec![
(
- T::RelayChainCallBuilder::utility_as_derivative_call(
- T::RelayChainCallBuilder::staking_withdraw_unbonded(
- T::RelayChainUnbondingSlashingSpans::get(),
- ),
+ T::AssetHubCallBuilder::utility_as_derivative_call(
+ T::AssetHubCallBuilder::staking_withdraw_unbonded(T::AssetHubUnbondingSlashingSpans::get()),
sub_account_index,
),
xcm_dest_weight,
),
(
- T::RelayChainCallBuilder::utility_as_derivative_call(
- T::RelayChainCallBuilder::balances_transfer_keep_alive(T::ParachainAccount::get(), amount),
+ T::AssetHubCallBuilder::utility_as_derivative_call(
+ T::AssetHubCallBuilder::balances_transfer_keep_alive(T::ParachainAccount::get(), amount),
sub_account_index,
),
xcm_dest_weight,
@@ -219,9 +239,9 @@ pub mod module {
xcm_fee.saturating_mul(2),
);
- let result = pallet_xcm::Pallet::::send_xcm(Here, Parent, xcm_message);
+ let result = pallet_xcm::Pallet::::send_xcm(Here, T::AssetHubLocation::get(), xcm_message);
log::debug!(
- target: "xcm-interface",
+ target: LOG_TARGET,
"subaccount {:?} send XCM to withdraw unbonded {:?}, result: {:?}",
sub_account_index, amount, result
);
@@ -230,20 +250,20 @@ pub mod module {
Ok(())
}
- /// Send XCM message to the relaychain for sub account to bond extra.
+ /// Send XCM message to the assethub for sub account to bond extra.
fn bond_extra_on_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult {
let (xcm_dest_weight, xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::HomaBondExtra);
- let xcm_message = T::RelayChainCallBuilder::finalize_call_into_xcm_message(
- T::RelayChainCallBuilder::utility_as_derivative_call(
- T::RelayChainCallBuilder::staking_bond_extra(amount),
+ let xcm_message = T::AssetHubCallBuilder::finalize_call_into_xcm_message(
+ T::AssetHubCallBuilder::utility_as_derivative_call(
+ T::AssetHubCallBuilder::staking_bond_extra(amount),
sub_account_index,
),
xcm_fee,
xcm_dest_weight,
);
- let result = pallet_xcm::Pallet::::send_xcm(Here, Parent, xcm_message);
+ let result = pallet_xcm::Pallet::::send_xcm(Here, T::AssetHubLocation::get(), xcm_message);
log::debug!(
- target: "xcm-interface",
+ target: LOG_TARGET,
"subaccount {:?} send XCM to bond {:?}, result: {:?}",
sub_account_index, amount, result,
);
@@ -252,20 +272,20 @@ pub mod module {
Ok(())
}
- /// Send XCM message to the relaychain for sub account to unbond.
+ /// Send XCM message to the assethub for sub account to unbond.
fn unbond_on_sub_account(sub_account_index: u16, amount: Balance) -> DispatchResult {
let (xcm_dest_weight, xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::HomaUnbond);
- let xcm_message = T::RelayChainCallBuilder::finalize_call_into_xcm_message(
- T::RelayChainCallBuilder::utility_as_derivative_call(
- T::RelayChainCallBuilder::staking_unbond(amount),
+ let xcm_message = T::AssetHubCallBuilder::finalize_call_into_xcm_message(
+ T::AssetHubCallBuilder::utility_as_derivative_call(
+ T::AssetHubCallBuilder::staking_unbond(amount),
sub_account_index,
),
xcm_fee,
xcm_dest_weight,
);
- let result = pallet_xcm::Pallet::::send_xcm(Here, Parent, xcm_message);
+ let result = pallet_xcm::Pallet::::send_xcm(Here, T::AssetHubLocation::get(), xcm_message);
log::debug!(
- target: "xcm-interface",
+ target: LOG_TARGET,
"subaccount {:?} send XCM to unbond {:?}, result: {:?}",
sub_account_index, amount, result
);
@@ -274,20 +294,20 @@ pub mod module {
Ok(())
}
- /// Send XCM message to the relaychain for sub account to nominate.
- fn nominate_on_sub_account(sub_account_index: u16, targets: Vec) -> DispatchResult {
+ /// Send XCM message to the assethub for sub account to nominate.
+ fn nominate_on_sub_account(sub_account_index: u16, targets: Vec) -> DispatchResult {
let (xcm_dest_weight, xcm_fee) = Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::HomaNominate);
- let xcm_message = T::RelayChainCallBuilder::finalize_call_into_xcm_message(
- T::RelayChainCallBuilder::utility_as_derivative_call(
- T::RelayChainCallBuilder::staking_nominate(targets.clone()),
+ let xcm_message = T::AssetHubCallBuilder::finalize_call_into_xcm_message(
+ T::AssetHubCallBuilder::utility_as_derivative_call(
+ T::AssetHubCallBuilder::staking_nominate(targets.clone()),
sub_account_index,
),
xcm_fee,
xcm_dest_weight,
);
- let result = pallet_xcm::Pallet::::send_xcm(Here, Parent, xcm_message);
+ let result = pallet_xcm::Pallet::::send_xcm(Here, T::AssetHubLocation::get(), xcm_message);
log::debug!(
- target: "xcm-interface",
+ target: LOG_TARGET,
"subaccount {:?} send XCM to nominate {:?}, result: {:?}",
sub_account_index, targets, result
);
@@ -298,7 +318,7 @@ pub mod module {
/// The fee of cross-chain transfer is deducted from the recipient.
fn get_xcm_transfer_fee() -> Balance {
- Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::XtokensTransfer).1
+ Self::xcm_dest_weight_and_fee(XcmInterfaceOperation::XcmTransfer).1
}
/// The fee of parachain transfer.
diff --git a/modules/xcm-interface/src/mocks/kusama.rs b/modules/xcm-interface/src/mocks/kusama.rs
index 58bd936bf..6f41d3354 100644
--- a/modules/xcm-interface/src/mocks/kusama.rs
+++ b/modules/xcm-interface/src/mocks/kusama.rs
@@ -18,4 +18,4 @@
use super::*;
-impl_mock!(module_relaychain::KusamaRelayChainCall);
+impl_mock!(module_assethub::KusamaAssetHubCall);
diff --git a/modules/xcm-interface/src/mocks/mod.rs b/modules/xcm-interface/src/mocks/mod.rs
index 806fa25cf..448e59ace 100644
--- a/modules/xcm-interface/src/mocks/mod.rs
+++ b/modules/xcm-interface/src/mocks/mod.rs
@@ -25,8 +25,6 @@ use frame_support::{
traits::{ConstU128, ConstU32, Everything, Nothing},
};
use frame_system::{EnsureRoot, EnsureSignedBy};
-use orml_traits::xcm_transfer::Transferred;
-use primitives::{CurrencyId, TokenSymbol};
use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, SignedToAccountId32};
use xcm_executor::traits::XcmAssetTransfers;
@@ -37,8 +35,6 @@ pub mod polkadot;
pub type AccountId = AccountId32;
pub const ALICE: AccountId = AccountId32::new([1u8; 32]);
-pub const BOB: AccountId = AccountId32::new([2u8; 32]);
-pub const DOT: CurrencyId = CurrencyId::Token(TokenSymbol::DOT);
parameter_types! {
pub const UnitWeightCost: XcmWeight = XcmWeight::from_parts(10, 10);
@@ -58,81 +54,16 @@ ord_parameter_types! {
}
parameter_types! {
- pub const GetStakingCurrencyId: CurrencyId = DOT;
pub const ParachainAccount: AccountId = AccountId32::new([0u8; 32]);
- pub const ParachainId: module_relaychain::ParaId = module_relaychain::ParaId::new(2000);
- pub SelfLocation: Location = Location::new(1, Parachain(ParachainId::get().into()));
+ pub const ParachainId: module_assethub::ParaId = module_assethub::ParaId::new(2000);
+ pub const AssetHubId: module_assethub::ParaId = module_assethub::ParaId::new(1000);
+ pub AssetHubLocation: Location = Location::new(1, Parachain(AssetHubId::get().into()));
}
-pub struct SubAccountIndexLocationConvertor;
-impl Convert for SubAccountIndexLocationConvertor {
- fn convert(_sub_account_index: u16) -> Location {
- (Parent, Parachain(2000)).into()
- }
-}
-
-pub struct MockXcmTransfer;
-impl XcmTransfer for MockXcmTransfer {
- fn transfer(
- _who: AccountId,
- _currency_id: CurrencyId,
- _amount: Balance,
- _dest: Location,
- _dest_weight_limit: WeightLimit,
- ) -> Result, DispatchError> {
- unimplemented!()
- }
-
- /// Transfer `Asset`
- fn transfer_multiasset(
- _who: AccountId,
- _asset: Asset,
- _dest: Location,
- _dest_weight_limit: WeightLimit,
- ) -> Result, DispatchError> {
- unimplemented!()
- }
-
- fn transfer_with_fee(
- _who: AccountId,
- _currency_id: CurrencyId,
- _amount: Balance,
- _fee: Balance,
- _dest: Location,
- _dest_weight_limit: WeightLimit,
- ) -> Result, DispatchError> {
- unimplemented!()
- }
-
- /// Transfer `AssetWithFee`
- fn transfer_multiasset_with_fee(
- _who: AccountId,
- _asset: Asset,
- _fee: Asset,
- _dest: Location,
- _dest_weight_limit: WeightLimit,
- ) -> Result, DispatchError> {
- unimplemented!()
- }
-
- fn transfer_multicurrencies(
- _who: AccountId,
- _currencies: Vec<(CurrencyId, Balance)>,
- _fee_item: u32,
- _dest: Location,
- _dest_weight_limit: WeightLimit,
- ) -> Result, DispatchError> {
- unimplemented!()
- }
-
- fn transfer_multiassets(
- _who: AccountId,
- _assets: Assets,
- _fee: Asset,
- _dest: Location,
- _dest_weight_limit: WeightLimit,
- ) -> Result, DispatchError> {
- unimplemented!()
+pub struct SubAccountIndexAccountIdConvertor;
+impl Convert for SubAccountIndexAccountIdConvertor {
+ fn convert(_sub_account_index: u16) -> AccountId {
+ AccountId::new([1u8; 32])
}
}
@@ -212,7 +143,7 @@ impl XcmAssetTransfers for MockExec {
#[macro_export]
macro_rules! impl_mock {
- ($relaychain:ty) => {
+ ($assethub:ty) => {
pub type LocalOriginToLocation = SignedToAccountId32;
pub type Block = frame_system::mocking::MockBlock;
@@ -269,13 +200,11 @@ macro_rules! impl_mock {
impl Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type UpdateOrigin = EnsureSignedBy;
- type StakingCurrencyId = GetStakingCurrencyId;
type ParachainAccount = ParachainAccount;
- type RelayChainUnbondingSlashingSpans = ConstU32<28>;
- type SovereignSubAccountLocationConvert = SubAccountIndexLocationConvertor;
- type RelayChainCallBuilder = module_relaychain::RelayChainCallBuilder;
- type XcmTransfer = MockXcmTransfer;
- type SelfLocation = SelfLocation;
+ type AssetHubUnbondingSlashingSpans = ConstU32<28>;
+ type SovereignSubAccountIdConvert = SubAccountIndexAccountIdConvertor;
+ type AssetHubCallBuilder = module_assethub::AssetHubCallBuilder;
+ type AssetHubLocation = AssetHubLocation;
type AccountIdToLocation = AccountIdToLocation;
}
diff --git a/modules/xcm-interface/src/mocks/polkadot.rs b/modules/xcm-interface/src/mocks/polkadot.rs
index a18b1db21..b1743a053 100644
--- a/modules/xcm-interface/src/mocks/polkadot.rs
+++ b/modules/xcm-interface/src/mocks/polkadot.rs
@@ -18,4 +18,4 @@
use super::*;
-impl_mock!(module_relaychain::PolkadotRelayChainCall);
+impl_mock!(module_assethub::PolkadotAssetHubCall);
diff --git a/runtime/acala/Cargo.toml b/runtime/acala/Cargo.toml
index 45fdb08a9..8a9e2b66a 100644
--- a/runtime/acala/Cargo.toml
+++ b/runtime/acala/Cargo.toml
@@ -120,7 +120,7 @@ module-liquid-crowdloan = { workspace = true }
module-loans = { workspace = true }
module-nft = { workspace = true }
module-prices = { workspace = true }
-module-relaychain = { workspace = true }
+module-assethub = { workspace = true }
module-session-manager = { workspace = true }
module-support = { workspace = true }
module-transaction-pause = { workspace = true }
@@ -259,7 +259,7 @@ std = [
"module-loans/std",
"module-nft/std",
"module-prices/std",
- "module-relaychain/std",
+ "module-assethub/std",
"module-session-manager/std",
"module-support/std",
"module-transaction-pause/std",
diff --git a/runtime/acala/src/lib.rs b/runtime/acala/src/lib.rs
index 0979e12af..967731b8d 100644
--- a/runtime/acala/src/lib.rs
+++ b/runtime/acala/src/lib.rs
@@ -31,6 +31,7 @@
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use parity_scale_codec::{Decode, DecodeLimit, Encode};
+use polkadot_parachain_primitives::primitives::Sibling;
use scale_info::TypeInfo;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
@@ -51,11 +52,11 @@ use sp_version::RuntimeVersion;
use frame_system::{EnsureRoot, EnsureSigned, RawOrigin};
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping};
+use module_assethub::AssetHubCallBuilder;
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::BasicCurrencyAdapter;
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
-use module_relaychain::RelayChainCallBuilder;
use module_support::{AddressMapping, AssetIdMapping, DispatchableTask, PoolId};
use module_transaction_payment::TargetedFeeAdjustment;
@@ -86,7 +87,7 @@ pub use pallet_collective::MemberCount;
pub use sp_runtime::BuildStorage;
pub use authority::AuthorityConfigImpl;
-pub use constants::{fee::*, time::*};
+pub use constants::{fee::*, parachains, time::*};
use module_support::{ExchangeRateProvider, FractionalRate};
use primitives::currency::AssetIds;
pub use primitives::{
@@ -113,7 +114,6 @@ use runtime_common::{
Rate, Ratio, RuntimeBlockLength, RuntimeBlockWeights, TechnicalCommitteeInstance,
TechnicalCommitteeMembershipInstance, TimeStampedPrice, TipPerWeightStep, ACA, AUSD, DOT, LCDOT, LDOT, TAP,
};
-use xcm::v4::prelude::*;
mod authority;
mod benchmarking;
@@ -1571,7 +1571,7 @@ parameter_types! {
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account_truncating();
pub ActiveSubAccountsIndexList: Vec = vec![
- 0, // 15sr8Dvq3AT3Z2Z1y8FnQ4VipekAHhmQnrkgzegUr1tNgbcn
+ 0, // 12pw22Qyy3o28BLshjce9yrSMs3fhSiLsAjqLPAzGktbXYV7
];
pub MintThreshold: Balance = dollar(DOT);
pub RedeemThreshold: Balance = 5 * dollar(LDOT);
@@ -1605,7 +1605,7 @@ parameter_types! {
impl module_homa_validator_list::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
- type RelayChainAccountId = AccountId;
+ type ValidatorId = AccountId;
type LiquidTokenCurrency = module_currencies::Currency;
type MinBondAmount = MinBondAmount;
type BondingDuration = BondingDuration;
@@ -1638,37 +1638,28 @@ impl module_nominees_election::Config for Runtime {
type WeightInfo = weights::module_nominees_election::WeightInfo;
}
-pub fn create_x2_parachain_location(index: u16) -> Location {
- Location::new(
- 1,
- AccountId32 {
- network: None,
- id: Utility::derivative_account_id(ParachainInfo::get().into_account_truncating(), index).into(),
- },
- )
-}
-
-pub struct SubAccountIndexLocationConvertor;
-impl Convert for SubAccountIndexLocationConvertor {
- fn convert(sub_account_index: u16) -> Location {
- create_x2_parachain_location(sub_account_index)
+pub struct SubAccountIndexAccountIdConvertor;
+impl Convert for SubAccountIndexAccountIdConvertor {
+ fn convert(sub_account_index: u16) -> AccountId {
+ Utility::derivative_account_id(
+ Sibling::from(ParachainInfo::get()).into_account_truncating(),
+ sub_account_index,
+ )
}
}
parameter_types! {
- pub ParachainAccount: AccountId = ParachainInfo::get().into_account_truncating();
+ pub ParachainAccount: AccountId = Sibling::from(ParachainInfo::get()).into_account_truncating();
}
impl module_xcm_interface::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type UpdateOrigin = EnsureRootOrHalfGeneralCouncil;
- type StakingCurrencyId = GetStakingCurrencyId;
type ParachainAccount = ParachainAccount;
- type RelayChainUnbondingSlashingSpans = ConstU32<5>;
- type SovereignSubAccountLocationConvert = SubAccountIndexLocationConvertor;
- type RelayChainCallBuilder = RelayChainCallBuilder;
- type XcmTransfer = XTokens;
- type SelfLocation = xcm_config::SelfLocation;
+ type AssetHubUnbondingSlashingSpans = ConstU32<5>;
+ type SovereignSubAccountIdConvert = SubAccountIndexAccountIdConvertor;
+ type AssetHubCallBuilder = AssetHubCallBuilder;
+ type AssetHubLocation = xcm_config::AssetHubLocation;
type AccountIdToLocation = runtime_common::xcm_config::AccountIdToLocation;
}
diff --git a/runtime/acala/src/xcm_config.rs b/runtime/acala/src/xcm_config.rs
index 73d483e57..0d046562e 100644
--- a/runtime/acala/src/xcm_config.rs
+++ b/runtime/acala/src/xcm_config.rs
@@ -97,11 +97,11 @@ parameter_types! {
pub BaseRate: u128 = aca_per_second();
/// Location of Asset Hub
- pub AssetHubLocation: Location = Location::new(1, [Parachain(1000)]);
- pub RelayChainNativeAssetFromAssetHub: (AssetFilter, Location) = (
- RelayLocationFilter::get(),
- AssetHubLocation::get()
- );
+ pub AssetHubLocation: Location = Location::new(1, [Parachain(parachains::asset_hub_polkadot::ID)]);
+ pub RelayChainNativeAssetFromAssetHub: (AssetFilter, Location) = (
+ RelayLocationFilter::get(),
+ AssetHubLocation::get()
+ );
}
type Reserves = (
diff --git a/runtime/common/src/precompile/mock.rs b/runtime/common/src/precompile/mock.rs
index 4b4ab0a4f..208101e12 100644
--- a/runtime/common/src/precompile/mock.rs
+++ b/runtime/common/src/precompile/mock.rs
@@ -681,7 +681,7 @@ impl module_prices::Config for Test {
/// mock XCM transfer.
pub struct MockHomaSubAccountXcm;
impl HomaSubAccountXcm for MockHomaSubAccountXcm {
- type RelayChainAccountId = AccountId;
+ type NomineeId = AccountId;
fn transfer_staking_to_sub_account(sender: &AccountId, _: u16, amount: Balance) -> DispatchResult {
Currencies::withdraw(
StakingCurrencyId::get(),
@@ -703,7 +703,7 @@ impl HomaSubAccountXcm for MockHomaSubAccountXcm {
Ok(())
}
- fn nominate_on_sub_account(_: u16, _: Vec) -> DispatchResult {
+ fn nominate_on_sub_account(_: u16, _: Vec) -> DispatchResult {
Ok(())
}
diff --git a/runtime/integration-tests/Cargo.toml b/runtime/integration-tests/Cargo.toml
index e4c17899c..5c2421f7d 100644
--- a/runtime/integration-tests/Cargo.toml
+++ b/runtime/integration-tests/Cargo.toml
@@ -66,6 +66,7 @@ xcm = { workspace = true, features = ["std"] }
xcm-executor = { workspace = true, features = ["std"] }
xcm-builder = { workspace = true, features = ["std"] }
pallet-xcm = { workspace = true, features = ["std"] }
+polkadot-parachain-primitives = { workspace = true, features = ["std"] }
# orml
orml-auction = { workspace = true, features = ["std"] }
@@ -106,7 +107,7 @@ module-support = { workspace = true, features = ["std"] }
module-xcm-interface = { workspace = true, features = ["std"] }
module-homa = { workspace = true, features = ["std"] }
module-session-manager = { workspace = true, features = ["std"] }
-module-relaychain = { workspace = true, features = ["std"] }
+module-assethub = { workspace = true, features = ["std"] }
primitives = { workspace = true, features = ["std"] }
runtime-common = { workspace = true, features = ["std"] }
diff --git a/runtime/integration-tests/src/runtime.rs b/runtime/integration-tests/src/runtime.rs
index e578315fe..5cb74d80b 100644
--- a/runtime/integration-tests/src/runtime.rs
+++ b/runtime/integration-tests/src/runtime.rs
@@ -290,31 +290,26 @@ fn currency_id_convert() {
#[test]
fn parachain_subaccounts_are_unique() {
ExtBuilder::default().build().execute_with(|| {
- let parachain: AccountId = ParachainInfo::parachain_id().into_account_truncating();
+ let parachain: AccountId = ParachainInfo::get().into_account_truncating();
assert_eq!(
parachain,
hex_literal::hex!["70617261d0070000000000000000000000000000000000000000000000000000"].into()
);
+ let sibling: AccountId =
+ polkadot_parachain_primitives::primitives::Sibling::from(ParachainInfo::get()).into_account_truncating();
assert_eq!(
- create_x2_parachain_location(0),
- Location::new(
- 1,
- [Junction::AccountId32 {
- network: None,
- id: hex_literal::hex!["d7b8926b326dd349355a9a7cca6606c1e0eb6fd2b506066b518c7155ff0d8297"].into(),
- }]
- ),
+ sibling,
+ hex_literal::hex!["7369626cd0070000000000000000000000000000000000000000000000000000"].into()
);
+
assert_eq!(
- create_x2_parachain_location(1),
- Location::new(
- 1,
- [Junction::AccountId32 {
- network: None,
- id: hex_literal::hex!["74d37d762e06c6841a5dad64463a9afe0684f7e45245f6a7296ca613cca74669"].into(),
- }]
- ),
+ SubAccountIndexAccountIdConvertor::convert(0),
+ hex_literal::hex!["50ca9b6bf6c83ca2a918b9861788d6facd26e5fd78a07f9848070697683745b3"].into()
+ );
+ assert_eq!(
+ SubAccountIndexAccountIdConvertor::convert(1),
+ hex_literal::hex!["025f1ca0b76b0d646f33b799a040df9fc14e06b7486770656766e8e8381f6c6f"].into()
);
});
}
diff --git a/runtime/integration-tests/src/setup.rs b/runtime/integration-tests/src/setup.rs
index d5dc72b71..3ec410d11 100644
--- a/runtime/integration-tests/src/setup.rs
+++ b/runtime/integration-tests/src/setup.rs
@@ -60,17 +60,17 @@ mod mandala_imports {
pub use mandala_runtime::xcm_config::*;
use mandala_runtime::AlternativeFeeSurplus;
pub use mandala_runtime::{
- create_x2_parachain_location, get_all_module_accounts, AcalaOracle, AcalaSwap, AccountId, AggregatedDex,
- AssetRegistry, AuctionManager, Aura, AuraExt, Authority, AuthoritysOriginId, Authorship, Balance, Balances,
- BlockNumber, CDPEnginePalletId, CDPTreasuryPalletId, CdpEngine, CdpTreasury, CollatorSelection,
- CreateClassDeposit, CreateTokenDeposit, Currencies, CurrencyId, DataDepositPerByte, DealWithFees,
- DefaultDebitExchangeRate, DefaultExchangeRate, Dex, EmergencyShutdown, EvmAccounts, ExistentialDeposits,
- FinancialCouncil, GetNativeCurrencyId, Homa, Honzon, IdleScheduler, Loans, MinRewardDistributeAmount,
- MinimumDebitValue, NativeTokenExistentialDeposit, NftPalletId, OneDay, OriginCaller, ParachainInfo,
- ParachainSystem, Proxy, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, Session, SessionKeys,
- SessionManager, SevenDays, StableAsset, StableAssetPalletId, System, Timestamp, TokenSymbol, Tokens,
- TransactionPayment, TransactionPaymentPalletId, TreasuryAccount, TreasuryPalletId, UncheckedExtrinsic, Utility,
- Vesting, XcmInterface, EVM, NFT,
+ get_all_module_accounts, AcalaOracle, AcalaSwap, AccountId, AggregatedDex, AssetRegistry, AuctionManager, Aura,
+ AuraExt, Authority, AuthoritysOriginId, Authorship, Balance, Balances, BlockNumber, CDPEnginePalletId,
+ CDPTreasuryPalletId, CdpEngine, CdpTreasury, CollatorSelection, CreateClassDeposit, CreateTokenDeposit,
+ Currencies, CurrencyId, DataDepositPerByte, DealWithFees, DefaultDebitExchangeRate, DefaultExchangeRate, Dex,
+ EmergencyShutdown, EvmAccounts, ExistentialDeposits, FinancialCouncil, GetNativeCurrencyId, Homa, Honzon,
+ IdleScheduler, Loans, MinRewardDistributeAmount, MinimumDebitValue, NativeTokenExistentialDeposit, NftPalletId,
+ OneDay, OriginCaller, ParachainInfo, ParachainSystem, Proxy, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
+ Scheduler, Session, SessionKeys, SessionManager, SevenDays, StableAsset, StableAssetPalletId,
+ SubAccountIndexAccountIdConvertor, System, Timestamp, TokenSymbol, Tokens, TransactionPayment,
+ TransactionPaymentPalletId, TreasuryAccount, TreasuryPalletId, UncheckedExtrinsic, Utility, Vesting,
+ XcmInterface, EVM, NFT,
};
use primitives::TradingPair;
use runtime_common::{ACA, AUSD, DOT, LDOT};
@@ -106,16 +106,17 @@ mod karura_imports {
pub use karura_runtime::xcm_config::*;
use karura_runtime::AlternativeFeeSurplus;
pub use karura_runtime::{
- constants::parachains, create_x2_parachain_location, get_all_module_accounts, AcalaOracle, AcalaSwap,
- AccountId, AggregatedDex, AssetRegistry, AuctionManager, Aura, AuraExt, Authority, AuthoritysOriginId, Balance,
- Balances, BlockNumber, CDPEnginePalletId, CDPTreasuryPalletId, CdpEngine, CdpTreasury, CreateClassDeposit,
- CreateTokenDeposit, Currencies, CurrencyId, DataDepositPerByte, DefaultDebitExchangeRate, DefaultExchangeRate,
- Dex, EmergencyShutdown, EvmAccounts, ExistentialDeposits, FinancialCouncil, GetNativeCurrencyId, Homa, Honzon,
+ constants::parachains, get_all_module_accounts, AcalaOracle, AcalaSwap, AccountId, AggregatedDex,
+ AssetRegistry, AuctionManager, Aura, AuraExt, Authority, AuthoritysOriginId, Balance, Balances, BlockNumber,
+ CDPEnginePalletId, CDPTreasuryPalletId, CdpEngine, CdpTreasury, CreateClassDeposit, CreateTokenDeposit,
+ Currencies, CurrencyId, DataDepositPerByte, DefaultDebitExchangeRate, DefaultExchangeRate, Dex,
+ EmergencyShutdown, EvmAccounts, ExistentialDeposits, FinancialCouncil, GetNativeCurrencyId, Homa, Honzon,
IdleScheduler, KaruraFoundationAccounts, Loans, MinimumDebitValue, NativeTokenExistentialDeposit, NftPalletId,
OneDay, OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, Session, SessionManager, SevenDays, StableAsset,
- StableAssetPalletId, System, Timestamp, TokenSymbol, Tokens, TransactionPayment, TransactionPaymentPalletId,
- TreasuryPalletId, Utility, Vesting, XTokens, XcmInterface, EVM, NFT,
+ StableAssetPalletId, SubAccountIndexAccountIdConvertor, System, Timestamp, TokenSymbol, Tokens,
+ TransactionPayment, TransactionPaymentPalletId, TreasuryPalletId, Utility, Vesting, XTokens, XcmInterface, EVM,
+ NFT,
};
use primitives::TradingPair;
use runtime_common::{KAR, KSM, KUSD, LKSM};
@@ -150,17 +151,16 @@ mod acala_imports {
pub use acala_runtime::xcm_config::*;
use acala_runtime::AlternativeFeeSurplus;
pub use acala_runtime::{
- constants::parachains, create_x2_parachain_location, get_all_module_accounts, AcalaFoundationAccounts,
- AcalaOracle, AcalaSwap, AccountId, AggregatedDex, AssetRegistry, AuctionManager, Aura, AuraExt, Authority,
- AuthoritysOriginId, Balance, Balances, BlockNumber, CDPEnginePalletId, CDPTreasuryPalletId, CdpEngine,
- CdpTreasury, CreateClassDeposit, CreateTokenDeposit, Currencies, CurrencyId, DataDepositPerByte,
- DefaultDebitExchangeRate, DefaultExchangeRate, Dex, EmergencyShutdown, EvmAccounts, ExistentialDeposits,
- FinancialCouncil, GetNativeCurrencyId, Homa, Honzon, IdleScheduler, Loans, MinimumDebitValue,
- NativeTokenExistentialDeposit, NftPalletId, OneDay, OriginCaller, ParachainAccount, ParachainInfo,
- ParachainSystem, PolkadotXcm, Proxy, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Scheduler, Session,
- SessionManager, SevenDays, StableAsset, StableAssetPalletId, System, Timestamp, TokenSymbol, Tokens,
- TransactionPayment, TransactionPaymentPalletId, TreasuryPalletId, Utility, Vesting, XTokens, XcmInterface, EVM,
- NFT,
+ constants::parachains, get_all_module_accounts, AcalaFoundationAccounts, AcalaOracle, AcalaSwap, AccountId,
+ AggregatedDex, AssetRegistry, AuctionManager, Aura, AuraExt, Authority, AuthoritysOriginId, Balance, Balances,
+ BlockNumber, CDPEnginePalletId, CDPTreasuryPalletId, CdpEngine, CdpTreasury, CreateClassDeposit,
+ CreateTokenDeposit, Currencies, CurrencyId, DataDepositPerByte, DefaultDebitExchangeRate, DefaultExchangeRate,
+ Dex, EmergencyShutdown, EvmAccounts, ExistentialDeposits, FinancialCouncil, GetNativeCurrencyId, Homa, Honzon,
+ IdleScheduler, Loans, MinimumDebitValue, NativeTokenExistentialDeposit, NftPalletId, OneDay, OriginCaller,
+ ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, Runtime, RuntimeCall, RuntimeEvent,
+ RuntimeOrigin, Scheduler, Session, SessionManager, SevenDays, StableAsset, StableAssetPalletId,
+ SubAccountIndexAccountIdConvertor, System, Timestamp, TokenSymbol, Tokens, TransactionPayment,
+ TransactionPaymentPalletId, TreasuryPalletId, Utility, Vesting, XTokens, XcmInterface, EVM, NFT,
};
use frame_support::parameter_types;
use primitives::TradingPair;
diff --git a/runtime/karura/Cargo.toml b/runtime/karura/Cargo.toml
index da7130aef..ab9865017 100644
--- a/runtime/karura/Cargo.toml
+++ b/runtime/karura/Cargo.toml
@@ -120,7 +120,7 @@ module-incentives = { workspace = true }
module-loans = { workspace = true }
module-nft = { workspace = true }
module-prices = { workspace = true }
-module-relaychain = { workspace = true }
+module-assethub = { workspace = true }
module-session-manager = { workspace = true }
module-support = { workspace = true }
module-transaction-pause = { workspace = true }
@@ -261,7 +261,7 @@ std = [
"module-loans/std",
"module-nft/std",
"module-prices/std",
- "module-relaychain/std",
+ "module-assethub/std",
"module-session-manager/std",
"module-support/std",
"module-transaction-pause/std",
diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs
index dfd7e325a..63f6e238a 100644
--- a/runtime/karura/src/lib.rs
+++ b/runtime/karura/src/lib.rs
@@ -31,6 +31,7 @@
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use parity_scale_codec::{Decode, DecodeLimit, Encode};
+use polkadot_parachain_primitives::primitives::Sibling;
use scale_info::TypeInfo;
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
@@ -52,11 +53,11 @@ use sp_version::RuntimeVersion;
use frame_system::{EnsureRoot, EnsureSigned, RawOrigin};
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping};
+use module_assethub::AssetHubCallBuilder;
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::BasicCurrencyAdapter;
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
-use module_relaychain::RelayChainCallBuilder;
use module_support::{AddressMapping, AssetIdMapping, DispatchableTask, ExchangeRateProvider, FractionalRate, PoolId};
use module_transaction_payment::TargetedFeeAdjustment;
@@ -114,7 +115,6 @@ use runtime_common::{
Rate, Ratio, RuntimeBlockLength, RuntimeBlockWeights, TechnicalCommitteeInstance,
TechnicalCommitteeMembershipInstance, TimeStampedPrice, TipPerWeightStep, KAR, KSM, KUSD, LKSM, TAI,
};
-use xcm::v4::prelude::*;
/// Import the stable_asset pallet.
pub use nutsfinance_stable_asset;
@@ -1594,9 +1594,9 @@ parameter_types! {
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account_truncating();
pub ActiveSubAccountsIndexList: Vec = vec![
- 0, // HTAeD1dokCVs9MwnC1q9s2a7d2kQ52TAjrxE1y5mj5MFLLA
- 1, // FDVu3RdH5WsE2yTdXN3QMq6v1XVDK8GKjhq5oFjXe8wZYpL
- 2, // EMrKvFy7xLgzzdgruXT9oXERt553igEScqgSjoDm3GewPSA
+ 0, // EQFY1VnjdYUSJ9oWoNgunPHeqLFooyPF3r6ZkTbCU5a6Eez
+ 1, // CdRsH6LC4yVvSH4XC2qmtPhuAoQEqedBdmnfaYPSVh5TDZ7
+ 2, // HZyWwhbi8yWGK6HJGjgYWQtszPvggLUrQDX9PR6StbmPwHP
];
pub MintThreshold: Balance = 10 * cent(KSM);
pub RedeemThreshold: Balance = 50 * cent(LKSM);
@@ -1630,7 +1630,7 @@ parameter_types! {
impl module_homa_validator_list::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
- type RelayChainAccountId = AccountId;
+ type ValidatorId = AccountId;
type LiquidTokenCurrency = module_currencies::Currency;
type MinBondAmount = MinBondAmount;
type BondingDuration = BondingDuration;
@@ -1663,37 +1663,28 @@ impl module_nominees_election::Config for Runtime {
type WeightInfo = weights::module_nominees_election::WeightInfo;
}
-pub fn create_x2_parachain_location(index: u16) -> Location {
- Location::new(
- 1,
- AccountId32 {
- network: None,
- id: Utility::derivative_account_id(ParachainInfo::get().into_account_truncating(), index).into(),
- },
- )
-}
-
-pub struct SubAccountIndexLocationConvertor;
-impl Convert for SubAccountIndexLocationConvertor {
- fn convert(sub_account_index: u16) -> Location {
- create_x2_parachain_location(sub_account_index)
+pub struct SubAccountIndexAccountIdConvertor;
+impl Convert for SubAccountIndexAccountIdConvertor {
+ fn convert(sub_account_index: u16) -> AccountId {
+ Utility::derivative_account_id(
+ Sibling::from(ParachainInfo::get()).into_account_truncating(),
+ sub_account_index,
+ )
}
}
parameter_types! {
- pub ParachainAccount: AccountId = ParachainInfo::get().into_account_truncating();
+ pub ParachainAccount: AccountId = Sibling::from(ParachainInfo::get()).into_account_truncating();
}
impl module_xcm_interface::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type UpdateOrigin = EnsureRootOrHalfGeneralCouncil;
- type StakingCurrencyId = GetStakingCurrencyId;
type ParachainAccount = ParachainAccount;
- type RelayChainUnbondingSlashingSpans = ConstU32<5>;
- type SovereignSubAccountLocationConvert = SubAccountIndexLocationConvertor;
- type RelayChainCallBuilder = RelayChainCallBuilder;
- type XcmTransfer = XTokens;
- type SelfLocation = xcm_config::SelfLocation;
+ type AssetHubUnbondingSlashingSpans = ConstU32<5>;
+ type SovereignSubAccountIdConvert = SubAccountIndexAccountIdConvertor;
+ type AssetHubCallBuilder = AssetHubCallBuilder;
+ type AssetHubLocation = xcm_config::AssetHubLocation;
type AccountIdToLocation = runtime_common::xcm_config::AccountIdToLocation;
}
diff --git a/runtime/karura/src/xcm_config.rs b/runtime/karura/src/xcm_config.rs
index 41e8421da..3035860ea 100644
--- a/runtime/karura/src/xcm_config.rs
+++ b/runtime/karura/src/xcm_config.rs
@@ -139,7 +139,7 @@ parameter_types! {
pub BaseRate: u128 = kar_per_second();
/// Location of Asset Hub
- pub AssetHubLocation: Location = Location::new(1, [Parachain(1000)]);
+ pub AssetHubLocation: Location = Location::new(1, [Parachain(parachains::asset_hub_kusama::ID)]);
pub RelayChainNativeAssetFromAssetHub: (AssetFilter, Location) = (
RelayLocationFilter::get(),
AssetHubLocation::get()
@@ -149,7 +149,7 @@ parameter_types! {
type Reserves = (
// Assets bridged from different consensus systems held in reserve on Asset Hub.
IsBridgedConcreteAssetFrom,
- // Relaychain (DOT) from Asset Hub
+ // Relaychain (KSM) from Asset Hub
Case,
// Assets which the reserve is the same as the origin.
MultiNativeAsset,
diff --git a/runtime/mandala/Cargo.toml b/runtime/mandala/Cargo.toml
index 0a494d367..d490249da 100644
--- a/runtime/mandala/Cargo.toml
+++ b/runtime/mandala/Cargo.toml
@@ -128,7 +128,7 @@ module-homa-validator-list = { workspace = true }
module-xcm-interface = { workspace = true }
module-nominees-election = { workspace = true }
module-session-manager = { workspace = true }
-module-relaychain = { workspace = true }
+module-assethub = { workspace = true }
module-idle-scheduler = { workspace = true }
module-aggregated-dex = { workspace = true }
module-liquid-crowdloan = { workspace = true }
@@ -274,7 +274,7 @@ std = [
"module-nft/std",
"module-nominees-election/std",
"module-prices/std",
- "module-relaychain/std",
+ "module-assethub/std",
"module-session-manager/std",
"module-support/std",
"module-transaction-pause/std",
diff --git a/runtime/mandala/src/benchmarking/homa_validator_list.rs b/runtime/mandala/src/benchmarking/homa_validator_list.rs
index a50527b07..e9215078f 100644
--- a/runtime/mandala/src/benchmarking/homa_validator_list.rs
+++ b/runtime/mandala/src/benchmarking/homa_validator_list.rs
@@ -136,7 +136,7 @@ runtime_benchmarks! {
)?;
slashes.push(SlashInfo{
validator,
- relaychain_token_amount: ValidatorInsuranceThreshold::get() * 9
+ token_amount: ValidatorInsuranceThreshold::get() * 9
});
}
}: _(RawOrigin::Root, slashes)
diff --git a/runtime/mandala/src/constants.rs b/runtime/mandala/src/constants.rs
index e3c2d0357..51a9fd45a 100644
--- a/runtime/mandala/src/constants.rs
+++ b/runtime/mandala/src/constants.rs
@@ -91,6 +91,12 @@ pub mod fee {
}
}
+pub mod parachains {
+ pub mod asset_hub_polkadot {
+ pub const ID: u32 = 1000;
+ }
+}
+
#[cfg(test)]
mod tests {
use crate::{constants::fee::base_tx_in_aca, Balance};
diff --git a/runtime/mandala/src/lib.rs b/runtime/mandala/src/lib.rs
index dca63f971..3afc5db0e 100644
--- a/runtime/mandala/src/lib.rs
+++ b/runtime/mandala/src/lib.rs
@@ -48,14 +48,15 @@ use frame_support::{
};
use frame_system::{EnsureRoot, EnsureSigned, RawOrigin};
use module_asset_registry::{AssetIdMaps, EvmErc20InfoMapping};
+use module_assethub::AssetHubCallBuilder;
use module_cdp_engine::CollateralCurrencyIds;
use module_currencies::BasicCurrencyAdapter;
use module_evm::{runner::RunnerExtended, CallInfo, CreateInfo, EvmChainId, EvmTask};
use module_evm_accounts::EvmAddressMapping;
-use module_relaychain::RelayChainCallBuilder;
use module_support::{AddressMapping, AssetIdMapping, DispatchableTask, ExchangeRateProvider, FractionalRate, PoolId};
use module_transaction_payment::TargetedFeeAdjustment;
use parity_scale_codec::{Decode, DecodeLimit, Encode};
+use polkadot_parachain_primitives::primitives::Sibling;
use scale_info::TypeInfo;
use orml_tokens::CurrencyAdapter;
@@ -93,7 +94,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Percent, Permill, Perquintill};
pub use authority::AuthorityConfigImpl;
-pub use constants::{fee::*, time::*};
+pub use constants::{fee::*, parachains, time::*};
pub use primitives::{
currency::AssetIds,
evm::{BlockLimits, EstimateResourcesRequest},
@@ -114,7 +115,6 @@ use runtime_common::{
Rate, Ratio, RuntimeBlockLength, RuntimeBlockWeights, TechnicalCommitteeInstance,
TechnicalCommitteeMembershipInstance, TimeStampedPrice, TipPerWeightStep, ACA, AUSD, DOT, KSM, LCDOT, LDOT,
};
-use xcm::prelude::*;
/// Import the stable_asset pallet.
pub use nutsfinance_stable_asset;
@@ -1411,20 +1411,10 @@ parameter_types! {
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(10, 100); // 1 : 10
}
-pub fn create_x2_parachain_location(index: u16) -> Location {
- Location::new(
- 1,
- AccountId32 {
- network: None,
- id: Utility::derivative_account_id(ParachainInfo::get().into_account_truncating(), index).into(),
- },
- )
-}
-
parameter_types! {
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account_truncating();
pub ActiveSubAccountsIndexList: Vec = vec![
- 0, // 15sr8Dvq3AT3Z2Z1y8FnQ4VipekAHhmQnrkgzegUr1tNgbcn
+ 0, // 12pw22Qyy3o28BLshjce9yrSMs3fhSiLsAjqLPAzGktbXYV7
];
pub MintThreshold: Balance = dollar(DOT);
pub RedeemThreshold: Balance = 10 * dollar(LDOT);
@@ -1458,7 +1448,7 @@ parameter_types! {
impl module_homa_validator_list::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
- type RelayChainAccountId = AccountId;
+ type ValidatorId = AccountId;
type LiquidTokenCurrency = module_currencies::Currency;
type MinBondAmount = MinBondAmount;
type BondingDuration = BondingDuration;
@@ -1492,26 +1482,27 @@ impl module_nominees_election::Config for Runtime {
}
parameter_types! {
- pub ParachainAccount: AccountId = ParachainInfo::get().into_account_truncating();
+ pub ParachainAccount: AccountId = Sibling::from(ParachainInfo::get()).into_account_truncating();
}
-pub struct SubAccountIndexLocationConvertor;
-impl Convert for SubAccountIndexLocationConvertor {
- fn convert(sub_account_index: u16) -> Location {
- create_x2_parachain_location(sub_account_index)
+pub struct SubAccountIndexAccountIdConvertor;
+impl Convert for SubAccountIndexAccountIdConvertor {
+ fn convert(sub_account_index: u16) -> AccountId {
+ Utility::derivative_account_id(
+ Sibling::from(ParachainInfo::get()).into_account_truncating(),
+ sub_account_index,
+ )
}
}
impl module_xcm_interface::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type UpdateOrigin = EnsureRootOrHalfGeneralCouncil;
- type StakingCurrencyId = GetStakingCurrencyId;
type ParachainAccount = ParachainAccount;
- type RelayChainUnbondingSlashingSpans = ConstU32<5>;
- type SovereignSubAccountLocationConvert = SubAccountIndexLocationConvertor;
- type RelayChainCallBuilder = RelayChainCallBuilder;
- type XcmTransfer = XTokens;
- type SelfLocation = xcm_config::SelfLocation;
+ type AssetHubUnbondingSlashingSpans = ConstU32<5>;
+ type SovereignSubAccountIdConvert = SubAccountIndexAccountIdConvertor;
+ type AssetHubCallBuilder = AssetHubCallBuilder;
+ type AssetHubLocation = xcm_config::AssetHubLocation;
type AccountIdToLocation = xcm_config::AccountIdToLocation;
}
diff --git a/runtime/mandala/src/xcm_config.rs b/runtime/mandala/src/xcm_config.rs
index 9f595aaff..580009a8e 100644
--- a/runtime/mandala/src/xcm_config.rs
+++ b/runtime/mandala/src/xcm_config.rs
@@ -17,10 +17,11 @@
// along with this program. If not, see .
use super::{
- constants::fee::*, AccountId, AllPalletsWithSystem, AssetIdMapping, AssetIdMaps, Balance, Balances, Convert,
- Currencies, CurrencyId, EvmAddressMapping, ExistentialDeposits, GetNativeCurrencyId, MessageQueue,
- NativeTokenExistentialDeposit, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent,
- RuntimeOrigin, TreasuryAccount, UnknownTokens, XcmpQueue, ACA,
+ AccountId, AllPalletsWithSystem, AssetIdMapping, AssetIdMaps, Balance, Balances, Convert, Currencies, CurrencyId,
+ EvmAddressMapping, ExistentialDeposits, GetNativeCurrencyId, MessageQueue, NativeTokenExistentialDeposit,
+ ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TreasuryAccount,
+ UnknownTokens, XcmpQueue, ACA,
+ {constants::fee::*, parachains},
};
pub use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
pub use frame_support::{
@@ -330,6 +331,7 @@ impl Convert for AccountIdToLocation {
parameter_types! {
pub SelfLocation: Location = Location::new(1, Parachain(ParachainInfo::get().into()));
+ pub AssetHubLocation: Location = Location::new(1, [Parachain(parachains::asset_hub_polkadot::ID)]);
pub const BaseXcmWeight: XcmWeight = XcmWeight::from_parts(100_000_000, 0);
pub const MaxAssetsForTransfer: usize = 2;
}