Skip to content

Commit

Permalink
Remove homa-lite from karura runtime (#1744)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjj9219 authored Jan 5, 2022
1 parent df09171 commit d70a5c4
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 201 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion runtime/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mod dex;
))]
mod evm;

#[cfg(any(feature = "with-karura-runtime", feature = "with-acala-runtime"))]
#[cfg(feature = "with-acala-runtime")]
mod homa_lite;

#[cfg(feature = "with-karura-runtime")]
Expand Down
8 changes: 4 additions & 4 deletions runtime/integration-tests/src/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ fn test_update_liquid_currency_price() {

set_oracle_price(vec![(RELAY_CHAIN_CURRENCY, relaychain_price)]);

#[cfg(feature = "with-mandala-runtime")]
#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime"))]
assert_ok!(Homa::reset_ledgers(
Origin::root(),
vec![(0, Some(100 * dollar(RELAY_CHAIN_CURRENCY)), None)]
));
#[cfg(any(feature = "with-acala-runtime", feature = "with-karura-runtime"))]
#[cfg(feature = "with-acala-runtime")]
assert_ok!(HomaLite::set_total_staking_currency(
Origin::root(),
100 * dollar(RELAY_CHAIN_CURRENCY)
Expand All @@ -106,12 +106,12 @@ fn test_update_liquid_currency_price() {
Some(Ratio::saturating_from_rational(100, 1000))
);

#[cfg(feature = "with-mandala-runtime")]
#[cfg(any(feature = "with-mandala-runtime", feature = "with-karura-runtime"))]
assert_ok!(Homa::reset_ledgers(
Origin::root(),
vec![(0, Some(110 * dollar(RELAY_CHAIN_CURRENCY)), None)]
));
#[cfg(any(feature = "with-acala-runtime", feature = "with-karura-runtime"))]
#[cfg(feature = "with-acala-runtime")]
assert_ok!(HomaLite::set_total_staking_currency(
Origin::root(),
110 * dollar(RELAY_CHAIN_CURRENCY)
Expand Down
6 changes: 2 additions & 4 deletions runtime/integration-tests/src/relaychain/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ mod karura_tests {
let xcm_message =
KusamaCallBuilder::utility_as_derivative_call(KusamaCallBuilder::staking_withdraw_unbonded(5), 0);

let msg =
KusamaCallBuilder::finalize_call_into_xcm_message(xcm_message, XcmUnbondFee::get(), 10_000_000_000);
let msg = KusamaCallBuilder::finalize_call_into_xcm_message(xcm_message, 600_000_000, 10_000_000_000);

// Withdraw unbonded
assert_ok!(pallet_xcm::Pallet::<Runtime>::send_xcm(Here, Parent, msg));
Expand Down Expand Up @@ -148,8 +147,7 @@ mod karura_tests {
// Transfer all remaining, but leave enough fund to pay for the XCM transaction.
let xcm_message = KusamaCallBuilder::balances_transfer_keep_alive(ALICE.into(), 1_990_000_000_000);

let msg =
KusamaCallBuilder::finalize_call_into_xcm_message(xcm_message, XcmUnbondFee::get(), 10_000_000_000);
let msg = KusamaCallBuilder::finalize_call_into_xcm_message(xcm_message, 600_000_000, 10_000_000_000);

// Withdraw unbonded
assert_ok!(pallet_xcm::Pallet::<Runtime>::send_xcm(Here, Parent, msg));
Expand Down
2 changes: 1 addition & 1 deletion runtime/integration-tests/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fn parachain_subaccounts_are_unique() {
hex_literal::hex!["70617261d0070000000000000000000000000000000000000000000000000000"].into()
);

#[cfg(any(feature = "with-karura-runtime", feature = "with-acala-runtime"))]
#[cfg(feature = "with-acala-runtime")]
assert_eq!(
RelayChainSovereignSubAccount::get(),
create_x2_parachain_multilocation(0)
Expand Down
14 changes: 7 additions & 7 deletions runtime/integration-tests/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ mod karura_imports {
AssetRegistry, AuctionManager, Authority, AuthoritysOriginId, Balance, Balances, BlockNumber, Call, CdpEngine,
CdpTreasury, CreateClassDeposit, CreateTokenDeposit, Currencies, CurrencyId, CurrencyIdConvert,
DataDepositPerByte, DefaultExchangeRate, Dex, EmergencyShutdown, Event, EvmAccounts, ExistentialDeposits,
FeePoolSize, FinancialCouncil, Get, GetNativeCurrencyId, Homa, HomaLite, HomaXcm, Honzon, IdleScheduler,
KarPerSecond, KaruraFoundationAccounts, KsmPerSecond, KusamaBondingDuration, KusdPerSecond, Loans,
MaxTipsOfPriority, MinimumDebitValue, MultiLocation, NativeTokenExistentialDeposit, NetworkId, NftPalletId,
OneDay, Origin, OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, ProxyType,
Ratio, RelayChainBlockNumberProvider, RelayChainSovereignSubAccount, Runtime, Scheduler, Session,
SessionManager, SevenDays, SwapBalanceThreshold, System, Timestamp, TipPerWeightStep, TokenSymbol, Tokens,
TreasuryPalletId, Utility, Vesting, XTokens, XcmConfig, XcmExecutor, XcmUnbondFee, EVM, NFT,
FeePoolSize, FinancialCouncil, Get, GetNativeCurrencyId, Homa, HomaXcm, Honzon, IdleScheduler, KarPerSecond,
KaruraFoundationAccounts, KsmPerSecond, KusamaBondingDuration, KusdPerSecond, Loans, MaxTipsOfPriority,
MinimumDebitValue, MultiLocation, NativeTokenExistentialDeposit, NetworkId, NftPalletId, OneDay, Origin,
OriginCaller, ParachainAccount, ParachainInfo, ParachainSystem, PolkadotXcm, Proxy, ProxyType, Ratio,
RelayChainBlockNumberProvider, Runtime, Scheduler, Session, SessionManager, SevenDays, SwapBalanceThreshold,
System, Timestamp, TipPerWeightStep, TokenSymbol, Tokens, TreasuryPalletId, Utility, Vesting, XTokens,
XcmConfig, XcmExecutor, EVM, NFT,
};
pub use primitives::TradingPair;
pub use runtime_common::{calculate_asset_ratio, cent, dollar, millicent, KAR, KSM, KUSD, LKSM};
Expand Down
4 changes: 0 additions & 4 deletions runtime/karura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ module-incentives = { path = "../../modules/incentives", default-features = fals
module-support = { path = "../../modules/support", default-features = false }
module-homa = { path = "../../modules/homa", default-features = false }
module-homa-xcm = { path = "../../modules/homa-xcm", default-features = false }
module-homa-lite = { path = "../../modules/homa-lite", default-features = false }
module-session-manager = { path = "../../modules/session-manager", default-features = false }
module-relaychain = { path = "../../modules/relaychain", default-features = false, features = ["kusama"] }
module-idle-scheduler = { path = "../../modules/idle-scheduler", default-features = false }
Expand Down Expand Up @@ -223,7 +222,6 @@ std = [
"module-support/std",
"module-homa/std",
"module-homa-xcm/std",
"module-homa-lite/std",
"module-session-manager/std",
"module-relaychain/std",
"module-idle-scheduler/std",
Expand All @@ -249,7 +247,6 @@ runtime-benchmarks = [
"pallet-xcm/runtime-benchmarks",

"module-nft/runtime-benchmarks",
"module-homa-lite/runtime-benchmarks",
"module-evm-accounts/runtime-benchmarks",

"sp-api/disable-logging",
Expand Down Expand Up @@ -321,6 +318,5 @@ try-runtime = [
"module-incentives/try-runtime",
"module-homa/try-runtime",
"module-homa-xcm/try-runtime",
"module-homa-lite/try-runtime",
"module-session-manager/try-runtime",
]
65 changes: 7 additions & 58 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("karura"),
impl_name: create_runtime_str!("karura"),
authoring_version: 1,
spec_version: 2012,
spec_version: 2013,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -833,10 +833,7 @@ impl module_prices::Config for Runtime {
type GetStakingCurrencyId = GetStakingCurrencyId;
type GetLiquidCurrencyId = GetLiquidCurrencyId;
type LockOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
// In the second runtime upgrade of the migration, delete this line
type LiquidStakingExchangeRateProvider = HomaLite;
// In the second runtime upgrade of the migration, use this line
//type LiquidStakingExchangeRateProvider = Homa;
type LiquidStakingExchangeRateProvider = Homa;
type DEX = Dex;
type Currency = Currencies;
type Erc20InfoMapping = EvmErc20InfoMapping<Runtime>;
Expand Down Expand Up @@ -1639,53 +1636,7 @@ pub fn create_x2_parachain_multilocation(index: u16) -> MultiLocation {
}

parameter_types! {
pub MinimumMintThreshold: Balance = 50 * cent(KSM);
pub MinimumRedeemThreshold: Balance = 5 * dollar(LKSM);
pub RelayChainSovereignSubAccount: MultiLocation = create_x2_parachain_multilocation(RelayChainSubAccountId::HomaLite as u16);
pub RelayChainSovereignSubAccountId: AccountId = Utility::derivative_account_id(
ParachainInfo::get().into_account(),
RelayChainSubAccountId::HomaLite as u16
);
pub MaxRewardPerEra: Permill = Permill::from_rational(500u32, 1_000_000u32); // 1.2 ^ (1/365) - 1 ≈ 0.05%
pub MintFee: Balance = 20 * millicent(KSM); // 2x XCM fee on Kusama
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub BaseWithdrawFee: Permill = Permill::from_rational(35u32, 10_000u32); // 20% yield per year, unbonding period = 7 days. 1.2^(7 / 365) - 1 ≈ 0.35%
pub MaximumRedeemRequestMatchesForMint: u32 = 20;
pub RelayChainUnbondingSlashingSpans: u32 = 5;
pub MaxScheduledUnbonds: u32 = 14;
pub ParachainAccount: AccountId = ParachainInfo::get().into_account();
pub SubAccountIndex: u16 = RelayChainSubAccountId::HomaLite as u16;
// Calculated from polkadot/xcm/xcm-builder: fn buy_weight
// We must charge higher than what Kusama required (533_333_300, obtained from integration test)
pub XcmUnbondFee: Balance = 60 * millicent(KSM);
}
impl module_homa_lite::Config for Runtime {
type Event = Event;
type WeightInfo = weights::module_homa_lite::WeightInfo<Runtime>;
type Currency = Currencies;
type StakingCurrencyId = GetStakingCurrencyId;
type LiquidCurrencyId = GetLiquidCurrencyId;
type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil;
type MinimumMintThreshold = MinimumMintThreshold;
type MinimumRedeemThreshold = MinimumRedeemThreshold;
type XcmTransfer = XTokens;
type SovereignSubAccountLocation = RelayChainSovereignSubAccount;
type SubAccountIndex = SubAccountIndex;
type DefaultExchangeRate = DefaultExchangeRate;
type MaxRewardPerEra = MaxRewardPerEra;
type MintFee = MintFee;
type RelayChainCallBuilder = RelayChainCallBuilder<Runtime, ParachainInfo>;
type BaseWithdrawFee = BaseWithdrawFee;
type XcmUnbondFee = XcmUnbondFee;
type RelayChainBlockNumber = RelayChainBlockNumberProvider<Runtime>;
type ParachainAccount = ParachainAccount;
type MaximumRedeemRequestMatchesForMint = MaximumRedeemRequestMatchesForMint;
type RelayChainUnbondingSlashingSpans = RelayChainUnbondingSlashingSpans;
type MaxScheduledUnbonds = MaxScheduledUnbonds;
type StakingUpdateFrequency = OneDay;
}

parameter_types! {
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account();
pub ActiveSubAccountsIndexList: Vec<u16> = vec![RelayChainSubAccountId::HomaLite as u16];
pub KusamaBondingDuration: EraIndex = 28;
Expand Down Expand Up @@ -1718,6 +1669,11 @@ impl Convert<u16, MultiLocation> for SubAccountIndexMultiLocationConvertor {
}
}

parameter_types! {
pub RelayChainUnbondingSlashingSpans: u32 = 5;
pub ParachainAccount: AccountId = ParachainInfo::get().into_account();
}

impl module_homa_xcm::Config for Runtime {
type Event = Event;
type UpdateOrigin = EnsureRootOrHalfGeneralCouncil;
Expand Down Expand Up @@ -1997,7 +1953,6 @@ construct_runtime!(
EmergencyShutdown: module_emergency_shutdown::{Pallet, Storage, Call, Event<T>} = 105,

// Homa
HomaLite: module_homa_lite::{Pallet, Call, Storage, Event<T>} = 115,
Homa: module_homa::{Pallet, Call, Storage, Event<T>} = 116,
HomaXcm: module_homa_xcm::{Pallet, Call, Storage, Event<T>} = 117,

Expand Down Expand Up @@ -2316,14 +2271,11 @@ impl_runtime_apis! {
use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};
use frame_support::traits::StorageInfoTrait;
use orml_benchmarking::list_benchmark as orml_list_benchmark;

use module_nft::benchmarking::Pallet as NftBench;
use module_homa_lite::benchmarking::Pallet as HomaLiteBench;

let mut list = Vec::<BenchmarkList>::new();

list_benchmark!(list, extra, module_nft, NftBench::<Runtime>);
list_benchmark!(list, extra, module_homa_lite, HomaLiteBench::<Runtime>);

orml_list_benchmark!(list, extra, module_dex, benchmarking::dex);
orml_list_benchmark!(list, extra, module_asset_registry, benchmarking::asset_registry);
Expand Down Expand Up @@ -2358,9 +2310,7 @@ impl_runtime_apis! {
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
use orml_benchmarking::{add_benchmark as orml_add_benchmark};

use module_nft::benchmarking::Pallet as NftBench;
use module_homa_lite::benchmarking::Pallet as HomaLiteBench;

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
Expand All @@ -2383,7 +2333,6 @@ impl_runtime_apis! {
let params = (&config, &whitelist);

add_benchmark!(params, batches, module_nft, NftBench::<Runtime>);
add_benchmark!(params, batches, module_homa_lite, HomaLiteBench::<Runtime>);

orml_add_benchmark!(params, batches, module_dex, benchmarking::dex);
orml_add_benchmark!(params, batches, module_asset_registry, benchmarking::asset_registry);
Expand Down
1 change: 0 additions & 1 deletion runtime/karura/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pub mod module_emergency_shutdown;
pub mod module_evm;
pub mod module_evm_accounts;
pub mod module_homa;
pub mod module_homa_lite;
pub mod module_honzon;
pub mod module_incentives;
pub mod module_nft;
Expand Down
120 changes: 0 additions & 120 deletions runtime/karura/src/weights/module_homa_lite.rs

This file was deleted.

0 comments on commit d70a5c4

Please sign in to comment.