From d70a5c44ebd1f55bcaa873183e370e04a0ff0f95 Mon Sep 17 00:00:00 2001 From: wangjj9219 <183318287@qq.com> Date: Wed, 5 Jan 2022 10:06:10 +0800 Subject: [PATCH] Remove homa-lite from karura runtime (#1744) --- Cargo.lock | 1 - runtime/integration-tests/src/lib.rs | 2 +- runtime/integration-tests/src/prices.rs | 8 +- .../src/relaychain/relay_chain.rs | 6 +- runtime/integration-tests/src/runtime.rs | 2 +- runtime/integration-tests/src/setup.rs | 14 +- runtime/karura/Cargo.toml | 4 - runtime/karura/src/lib.rs | 65 +--------- runtime/karura/src/weights/mod.rs | 1 - .../karura/src/weights/module_homa_lite.rs | 120 ------------------ 10 files changed, 22 insertions(+), 201 deletions(-) delete mode 100644 runtime/karura/src/weights/module_homa_lite.rs diff --git a/Cargo.lock b/Cargo.lock index b25765f895..b54fe68298 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3888,7 +3888,6 @@ dependencies = [ "module-evm-bridge", "module-evm-rpc-runtime-api", "module-homa", - "module-homa-lite", "module-homa-xcm", "module-honzon", "module-idle-scheduler", diff --git a/runtime/integration-tests/src/lib.rs b/runtime/integration-tests/src/lib.rs index 0dd7d73f17..9353b6d25f 100644 --- a/runtime/integration-tests/src/lib.rs +++ b/runtime/integration-tests/src/lib.rs @@ -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")] diff --git a/runtime/integration-tests/src/prices.rs b/runtime/integration-tests/src/prices.rs index 22bf3aeedc..c4d7fb0d63 100644 --- a/runtime/integration-tests/src/prices.rs +++ b/runtime/integration-tests/src/prices.rs @@ -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) @@ -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) diff --git a/runtime/integration-tests/src/relaychain/relay_chain.rs b/runtime/integration-tests/src/relaychain/relay_chain.rs index 076e5eec90..62d86d164a 100644 --- a/runtime/integration-tests/src/relaychain/relay_chain.rs +++ b/runtime/integration-tests/src/relaychain/relay_chain.rs @@ -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::::send_xcm(Here, Parent, msg)); @@ -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::::send_xcm(Here, Parent, msg)); diff --git a/runtime/integration-tests/src/runtime.rs b/runtime/integration-tests/src/runtime.rs index e217fbd67a..d5f0436cf2 100644 --- a/runtime/integration-tests/src/runtime.rs +++ b/runtime/integration-tests/src/runtime.rs @@ -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) diff --git a/runtime/integration-tests/src/setup.rs b/runtime/integration-tests/src/setup.rs index 12d525ed59..9a9923a7f3 100644 --- a/runtime/integration-tests/src/setup.rs +++ b/runtime/integration-tests/src/setup.rs @@ -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}; diff --git a/runtime/karura/Cargo.toml b/runtime/karura/Cargo.toml index c962a6b32b..08cee88165 100644 --- a/runtime/karura/Cargo.toml +++ b/runtime/karura/Cargo.toml @@ -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 } @@ -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", @@ -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", @@ -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", ] diff --git a/runtime/karura/src/lib.rs b/runtime/karura/src/lib.rs index 3d48cbd938..a67b817525 100644 --- a/runtime/karura/src/lib.rs +++ b/runtime/karura/src/lib.rs @@ -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, @@ -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; @@ -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; - 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; - type BaseWithdrawFee = BaseWithdrawFee; - type XcmUnbondFee = XcmUnbondFee; - type RelayChainBlockNumber = RelayChainBlockNumberProvider; - 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 = vec![RelayChainSubAccountId::HomaLite as u16]; pub KusamaBondingDuration: EraIndex = 28; @@ -1718,6 +1669,11 @@ impl Convert 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; @@ -1997,7 +1953,6 @@ construct_runtime!( EmergencyShutdown: module_emergency_shutdown::{Pallet, Storage, Call, Event} = 105, // Homa - HomaLite: module_homa_lite::{Pallet, Call, Storage, Event} = 115, Homa: module_homa::{Pallet, Call, Storage, Event} = 116, HomaXcm: module_homa_xcm::{Pallet, Call, Storage, Event} = 117, @@ -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::::new(); list_benchmark!(list, extra, module_nft, NftBench::); - list_benchmark!(list, extra, module_homa_lite, HomaLiteBench::); orml_list_benchmark!(list, extra, module_dex, benchmarking::dex); orml_list_benchmark!(list, extra, module_asset_registry, benchmarking::asset_registry); @@ -2358,9 +2310,7 @@ impl_runtime_apis! { ) -> Result, 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 = vec![ // Block Number @@ -2383,7 +2333,6 @@ impl_runtime_apis! { let params = (&config, &whitelist); add_benchmark!(params, batches, module_nft, NftBench::); - add_benchmark!(params, batches, module_homa_lite, HomaLiteBench::); orml_add_benchmark!(params, batches, module_dex, benchmarking::dex); orml_add_benchmark!(params, batches, module_asset_registry, benchmarking::asset_registry); diff --git a/runtime/karura/src/weights/mod.rs b/runtime/karura/src/weights/mod.rs index f87f3d631e..3461c7f9a9 100644 --- a/runtime/karura/src/weights/mod.rs +++ b/runtime/karura/src/weights/mod.rs @@ -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; diff --git a/runtime/karura/src/weights/module_homa_lite.rs b/runtime/karura/src/weights/module_homa_lite.rs deleted file mode 100644 index 063c3f0314..0000000000 --- a/runtime/karura/src/weights/module_homa_lite.rs +++ /dev/null @@ -1,120 +0,0 @@ -// This file is part of Acala. - -// Copyright (C) 2020-2021 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 . - -//! Autogenerated weights for module_homa_lite -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-12-01, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("karura-dev"), DB CACHE: 128 - -// Executed Command: -// target/release/acala -// benchmark -// --chain=karura-dev -// --steps=50 -// --repeat=20 -// --pallet=module-homa-lite -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --template=./templates/runtime-weight-template.hbs -// --output=./runtime/karura/src/weights/ - - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; - -/// Weight functions for module_homa_lite. -pub struct WeightInfo(PhantomData); -impl module_homa_lite::WeightInfo for WeightInfo { - fn on_initialize() -> Weight { - (23_693_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn on_initialize_without_work() -> Weight { - (3_316_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - } - fn mint() -> Weight { - (274_097_000 as Weight) - .saturating_add(T::DbWeight::get().reads(19 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) - } - fn mint_for_requests() -> Weight { - (287_530_000 as Weight) - .saturating_add(T::DbWeight::get().reads(21 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) - } - fn set_total_staking_currency() -> Weight { - (21_938_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn adjust_total_staking_currency() -> Weight { - (21_729_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn adjust_available_staking_balance_with_no_matches() -> Weight { - (35_462_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - fn set_minting_cap() -> Weight { - (19_728_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_xcm_dest_weight() -> Weight { - (19_019_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn request_redeem() -> Weight { - (65_757_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } - fn schedule_unbond() -> Weight { - (23_258_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn replace_schedule_unbond() -> Weight { - (20_333_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn set_staking_interest_rate_per_update() -> Weight { - (18_762_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn redeem_with_available_staking_balance() -> Weight { - (10_751_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - fn xcm_unbond() -> Weight { - (60_300_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } -}