Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace homa lite #1789

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

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

10 changes: 6 additions & 4 deletions runtime/acala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ module-nft = { path = "../../modules/nft", default-features = false }
module-prices = { path = "../../modules/prices", default-features = false }
module-incentives = { path = "../../modules/incentives", default-features = false }
module-support = { path = "../../modules/support", default-features = false }
module-homa-lite = { path = "../../modules/homa-lite", default-features = false }
module-homa = { path = "../../modules/homa", default-features = false }
module-homa-xcm = { path = "../../modules/homa-xcm", default-features = false }
module-session-manager = { path = "../../modules/session-manager", default-features = false }
module-relaychain = { path = "../../modules/relaychain", default-features = false, features = ["polkadot"] }
module-idle-scheduler = { path = "../../modules/idle-scheduler", default-features = false }
Expand Down Expand Up @@ -219,7 +220,8 @@ std = [
"module-prices/std",
"module-incentives/std",
"module-support/std",
"module-homa-lite/std",
"module-homa/std",
"module-homa-xcm/std",
"module-session-manager/std",
"module-relaychain/std",
"module-idle-scheduler/std",
Expand All @@ -245,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 @@ -315,6 +316,7 @@ try-runtime = [
"module-nft/try-runtime",
"module-prices/try-runtime",
"module-incentives/try-runtime",
"module-homa-lite/try-runtime",
"module-homa/try-runtime",
"module-homa-xcm/try-runtime",
"module-session-manager/try-runtime",
]
3 changes: 3 additions & 0 deletions runtime/acala/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pub mod evm {
pub mod evm_accounts {
include!("../../../mandala/src/benchmarking/evm_accounts.rs");
}
pub mod homa {
include!("../../../mandala/src/benchmarking/homa.rs");
}
pub mod honzon {
include!("../../../mandala/src/benchmarking/honzon.rs");
}
Expand Down
89 changes: 45 additions & 44 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ parameter_types! {
pub const LoansPalletId: PalletId = PalletId(*b"aca/loan");
pub const DEXPalletId: PalletId = PalletId(*b"aca/dexm");
pub const CDPTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt");
pub const HomaPalletId: PalletId = PalletId(*b"aca/homa");
pub const HonzonTreasuryPalletId: PalletId = PalletId(*b"aca/hztr");
pub const HomaTreasuryPalletId: PalletId = PalletId(*b"aca/hmtr");
pub const IncentivesPalletId: PalletId = PalletId(*b"aca/inct");
Expand All @@ -175,6 +176,7 @@ pub fn get_all_module_accounts() -> Vec<AccountId> {
CDPTreasuryPalletId::get().into_account(),
CollatorPotId::get().into_account(),
DEXPalletId::get().into_account(),
HomaPalletId::get().into_account(),
HomaTreasuryPalletId::get().into_account(),
HonzonTreasuryPalletId::get().into_account(),
IncentivesPalletId::get().into_account(),
Expand Down Expand Up @@ -829,7 +831,7 @@ impl module_prices::Config for Runtime {
type GetStakingCurrencyId = GetStakingCurrencyId;
type GetLiquidCurrencyId = GetLiquidCurrencyId;
type LockOrigin = EnsureRootOrTwoThirdsGeneralCouncil;
type LiquidStakingExchangeRateProvider = HomaLite;
type LiquidStakingExchangeRateProvider = Homa;
type DEX = Dex;
type Currency = Currencies;
type Erc20InfoMapping = EvmErc20InfoMapping<Runtime>;
Expand Down Expand Up @@ -1158,7 +1160,7 @@ impl module_evm_accounts::Config for Runtime {
impl module_asset_registry::Config for Runtime {
type Event = Event;
type Currency = Balances;
type LiquidCroadloanCurrencyId = DOTCurrencyId;
type LiquidCroadloanCurrencyId = GetStakingCurrencyId;
type EVMBridge = module_evm_bridge::EVMBridge<Runtime>;
type RegisterOrigin = EnsureRootOrHalfGeneralCouncil;
type WeightInfo = weights::module_asset_registry::WeightInfo<Runtime>;
Expand Down Expand Up @@ -1564,51 +1566,53 @@ pub fn create_x2_parachain_multilocation(index: u16) -> MultiLocation {
}

parameter_types! {
pub const DOTCurrencyId: CurrencyId = CurrencyId::Token(TokenSymbol::DOT);
pub const LDOTCurrencyId: CurrencyId = CurrencyId::Token(TokenSymbol::LDOT);
pub MinimumMintThreshold: Balance = 5 * dollar(DOT);
pub MinimumRedeemThreshold: Balance = 50 * dollar(LDOT);
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.0004996359
pub MintFee: Balance = 20 * millicent(DOT); // 2x XCM fee on Polkadot TODO: identify xcm fee
pub DefaultExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub BaseWithdrawFee: Permill = Permill::from_rational(14_085u32, 1_000_000u32); // 20% yield per year, unbounding period = 28 days. 1.2^(28/365) = 1.014085
pub MaximumRedeemRequestMatchesForMint: u32 = 20;
pub RelayChainUnbondingSlashingSpans: u32 = 5;
pub MaxScheduledUnbonds: u32 = 35;
pub ParachainAccount: AccountId = ParachainInfo::get().into_account();
pub SubAccountIndex: u16 = RelayChainSubAccountId::HomaLite as u16;
pub XcmUnbondFee: Balance = 60 * millicent(DOT); // TODO identify unbond fee
pub HomaTreasuryAccount: AccountId = HomaTreasuryPalletId::get().into_account();
pub ActiveSubAccountsIndexList: Vec<u16> = vec![RelayChainSubAccountId::HomaLite as u16];
pub BondingDuration: EraIndex = 28;
pub MintThreshold: Balance = 5 * dollar(DOT);
pub RedeemThreshold: Balance = 50 * dollar(LDOT);
}

impl module_homa_lite::Config for Runtime {
impl module_homa::Config for Runtime {
type Event = Event;
type WeightInfo = weights::module_homa_lite::WeightInfo<Runtime>;
type Currency = Currencies;
type StakingCurrencyId = DOTCurrencyId;
type LiquidCurrencyId = LDOTCurrencyId;
type GovernanceOrigin = EnsureRootOrHalfGeneralCouncil;
type MinimumMintThreshold = MinimumMintThreshold;
type MinimumRedeemThreshold = MinimumRedeemThreshold;
type XcmTransfer = XTokens;
type SovereignSubAccountLocation = RelayChainSovereignSubAccount;
type SubAccountIndex = SubAccountIndex;
type StakingCurrencyId = GetStakingCurrencyId;
type LiquidCurrencyId = GetLiquidCurrencyId;
type PalletId = HomaPalletId;
type TreasuryAccount = HomaTreasuryAccount;
type DefaultExchangeRate = DefaultExchangeRate;
type MaxRewardPerEra = MaxRewardPerEra;
type MintFee = MintFee;
type RelayChainCallBuilder = RelayChainCallBuilder<Runtime, ParachainInfo>;
type BaseWithdrawFee = BaseWithdrawFee;
type XcmUnbondFee = XcmUnbondFee;
type ActiveSubAccountsIndexList = ActiveSubAccountsIndexList;
type BondingDuration = BondingDuration;
type MintThreshold = MintThreshold;
type RedeemThreshold = RedeemThreshold;
type RelayChainBlockNumber = RelayChainBlockNumberProvider<Runtime>;
type HomaXcm = HomaXcm;
type WeightInfo = weights::module_homa::WeightInfo<Runtime>;
}

pub struct SubAccountIndexMultiLocationConvertor;
impl Convert<u16, MultiLocation> for SubAccountIndexMultiLocationConvertor {
fn convert(sub_account_index: u16) -> MultiLocation {
create_x2_parachain_multilocation(sub_account_index)
}
}

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;
type StakingCurrencyId = GetStakingCurrencyId;
type ParachainAccount = ParachainAccount;
type MaximumRedeemRequestMatchesForMint = MaximumRedeemRequestMatchesForMint;
type RelayChainUnbondingSlashingSpans = RelayChainUnbondingSlashingSpans;
type MaxScheduledUnbonds = MaxScheduledUnbonds;
type StakingUpdateFrequency = OneDay;
type SovereignSubAccountLocationConvert = SubAccountIndexMultiLocationConvertor;
type RelayChainCallBuilder = RelayChainCallBuilder<Runtime, ParachainInfo>;
type XcmTransfer = XTokens;
}

pub type LocalAssetTransactor = MultiCurrencyAdapter<
Expand Down Expand Up @@ -1837,7 +1841,8 @@ 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,

// Acala Other
Incentives: module_incentives::{Pallet, Storage, Call, Event<T>} = 120,
Expand Down Expand Up @@ -2129,21 +2134,19 @@ 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);
orml_list_benchmark!(list, extra, module_auction_manager, benchmarking::auction_manager);
orml_list_benchmark!(list, extra, module_cdp_engine, benchmarking::cdp_engine);
orml_list_benchmark!(list, extra, module_emergency_shutdown, benchmarking::emergency_shutdown);
orml_list_benchmark!(list, extra, module_evm, benchmarking::evm);
orml_list_benchmark!(list, extra, module_homa, benchmarking::homa);
orml_list_benchmark!(list, extra, module_honzon, benchmarking::honzon);
orml_list_benchmark!(list, extra, module_cdp_treasury, benchmarking::cdp_treasury);
orml_list_benchmark!(list, extra, module_collator_selection, benchmarking::collator_selection);
Expand All @@ -2170,9 +2173,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 @@ -2195,14 +2196,14 @@ 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);
orml_add_benchmark!(params, batches, module_auction_manager, benchmarking::auction_manager);
orml_add_benchmark!(params, batches, module_cdp_engine, benchmarking::cdp_engine);
orml_add_benchmark!(params, batches, module_emergency_shutdown, benchmarking::emergency_shutdown);
orml_add_benchmark!(params, batches, module_evm, benchmarking::evm);
orml_add_benchmark!(params, batches, module_homa, benchmarking::homa);
orml_add_benchmark!(params, batches, module_honzon, benchmarking::honzon);
orml_add_benchmark!(params, batches, module_cdp_treasury, benchmarking::cdp_treasury);
orml_add_benchmark!(params, batches, module_collator_selection, benchmarking::collator_selection);
Expand Down
2 changes: 1 addition & 1 deletion runtime/acala/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod module_dex;
pub mod module_emergency_shutdown;
pub mod module_evm;
pub mod module_evm_accounts;
pub mod module_homa_lite;
pub mod module_homa;
pub mod module_honzon;
pub mod module_incentives;
pub mod module_nft;
Expand Down
102 changes: 102 additions & 0 deletions runtime/acala/src/weights/module_homa.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// This file is part of Acala.

// Copyright (C) 2020-2022 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 <https://www.gnu.org/licenses/>.

//! Autogenerated weights for module_homa
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-12-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("acala-latest"), DB CACHE: 128

// Executed Command:
// target/release/acala
// benchmark
// --chain=acala-latest
// --steps=50
// --repeat=20
// --pallet=module_homa
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --template=./templates/runtime-weight-template.hbs
// --output=./runtime/acala/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.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> module_homa::WeightInfo for WeightInfo<T> {
fn on_initialize() -> Weight {
(5_884_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
}
fn on_initialize_with_bump_era() -> Weight {
(490_360_000 as Weight)
.saturating_add(T::DbWeight::get().reads(32 as Weight))
.saturating_add(T::DbWeight::get().writes(16 as Weight))
}
fn mint() -> Weight {
(150_048_000 as Weight)
.saturating_add(T::DbWeight::get().reads(11 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
fn request_redeem() -> Weight {
(84_397_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn fast_match_redeems(n: u32, ) -> Weight {
(593_000 as Weight)
// Standard Error: 217_000
.saturating_add((114_002_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes(5 as Weight))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(n as Weight)))
}
fn claim_redemption() -> Weight {
(132_187_000 as Weight)
.saturating_add(T::DbWeight::get().reads(10 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
fn update_homa_params() -> Weight {
(63_205_000 as Weight)
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn update_bump_era_params() -> Weight {
(26_983_000 as Weight)
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn reset_ledgers(n: u32, ) -> Weight {
(22_598_000 as Weight)
// Standard Error: 604_000
.saturating_add((18_501_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(n as Weight)))
}
fn reset_current_era() -> Weight {
(21_189_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
Loading