From 7b09365c56ec528955c33ddf414a3322382053f0 Mon Sep 17 00:00:00 2001 From: Edwin Date: Sat, 20 Jan 2024 01:19:39 -0600 Subject: [PATCH] Bifrost v0.9.92 (#1143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bifrost v0.9.92 * feat: 🎸 prod_or_fast (#1144) * feat: 🎸 prod_or_fast * fix: 🐛 default-features * Fix DelegatorVotes removal (#1147) * Fix DelegatorVotes removal * Fix * fix-vtoken-channel-shares-creation (#1150) * Remove `bifrost_channel_commission` pallet (#1155) * [skip ci]:artiface with git sha (#1156) Co-authored-by: TomatoAres * Add timeunit revise function (#1157) * add recreate_currency_ongoing_timeunit function * fixes --------- Co-authored-by: yooml Co-authored-by: Herry Ho <45537372+herryho@users.noreply.github.com> Co-authored-by: 战神西红柿 <34213033+TomatoAres@users.noreply.github.com> Co-authored-by: TomatoAres --- .github/workflows/srtool.yml | 2 +- Cargo.lock | 4 +- Cargo.toml | 1 + node/cli/Cargo.toml | 2 +- pallets/channel-commission/src/lib.rs | 3 + pallets/channel-commission/src/tests.rs | 23 +++ pallets/vtoken-minting/src/lib.rs | 21 ++ pallets/vtoken-minting/src/tests.rs | 19 ++ pallets/vtoken-minting/src/weights.rs | 7 + pallets/vtoken-voting/src/lib.rs | 4 +- pallets/vtoken-voting/src/mock.rs | 19 +- pallets/vtoken-voting/src/tests.rs | 183 ++++++++++++++++-- runtime/bifrost-kusama/Cargo.toml | 1 + runtime/bifrost-kusama/src/lib.rs | 57 +++--- .../src/weights/bifrost_vtoken_minting.rs | 6 + runtime/bifrost-polkadot/Cargo.toml | 1 + runtime/bifrost-polkadot/src/lib.rs | 45 ++--- .../src/weights/bifrost_vtoken_minting.rs | 6 + runtime/common/src/lib.rs | 18 -- 19 files changed, 334 insertions(+), 88 deletions(-) diff --git a/.github/workflows/srtool.yml b/.github/workflows/srtool.yml index 6b3b59ce8..44617bf37 100644 --- a/.github/workflows/srtool.yml +++ b/.github/workflows/srtool.yml @@ -67,7 +67,7 @@ jobs: - name: Archive Subwasm results uses: actions/upload-artifact@v4 with: - name: ${{ matrix.chain }}-runtime + name: ${{ matrix.chain }}-runtime-${{ github.sha }} path: | ${{ matrix.chain }}-info.json ${{ matrix.chain }}-info_compressed.json diff --git a/Cargo.lock b/Cargo.lock index 12dafafbe..938014972 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -917,7 +917,7 @@ dependencies = [ [[package]] name = "bifrost-cli" -version = "0.9.90" +version = "0.9.92" dependencies = [ "bifrost-primitives", "bifrost-service", @@ -1259,6 +1259,7 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-primitives", + "polkadot-runtime-common", "scale-info", "smallvec", "sp-api", @@ -1427,6 +1428,7 @@ dependencies = [ "parity-scale-codec", "polkadot-parachain-primitives", "polkadot-primitives", + "polkadot-runtime-common", "scale-info", "smallvec", "sp-api", diff --git a/Cargo.toml b/Cargo.toml index 418f5a419..ea27da7c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -228,6 +228,7 @@ kusama-runtime = { package = "staging-kusama-runtime", git = "https kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } polkadot-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } +polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" } diff --git a/node/cli/Cargo.toml b/node/cli/Cargo.toml index e2f9192e3..1ae1c3033 100644 --- a/node/cli/Cargo.toml +++ b/node/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bifrost-cli" -version = "0.9.90" +version = "0.9.92" authors = ["Liebi Technologies "] description = "Bifrost Parachain Node" build = "build.rs" diff --git a/pallets/channel-commission/src/lib.rs b/pallets/channel-commission/src/lib.rs index 08b120469..054d55692 100644 --- a/pallets/channel-commission/src/lib.rs +++ b/pallets/channel-commission/src/lib.rs @@ -332,6 +332,9 @@ pub mod pallet { vtoken, DEFAULT_COMMISSION_RATE, ); + + // for each vtoken, add the 0 share to ChannelVtokenShares storage + ChannelVtokenShares::::insert(channel_id, vtoken, Permill::zero()); }); Self::deposit_event(Event::ChannelRegistered { diff --git a/pallets/channel-commission/src/tests.rs b/pallets/channel-commission/src/tests.rs index 4b1bc3304..5fd889bf3 100644 --- a/pallets/channel-commission/src/tests.rs +++ b/pallets/channel-commission/src/tests.rs @@ -69,6 +69,20 @@ fn set_commission_tokens_should_work() { #[test] fn register_channel_should_work() { ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| { + // set commission tokens: VKSM -> KSM + assert_ok!(ChannelCommission::set_commission_tokens( + RuntimeOrigin::signed(ALICE), + VKSM, + KSM, + )); + + // set commission tokens: VBNC -> BNC + assert_ok!(ChannelCommission::set_commission_tokens( + RuntimeOrigin::signed(ALICE), + VBNC, + BNC, + )); + assert_ok!(ChannelCommission::register_channel( RuntimeOrigin::signed(ALICE), CHANNEL_A_NAME.to_vec(), @@ -83,6 +97,15 @@ fn register_channel_should_work() { // next channel id has been increased assert_eq!(ChannelNextId::::get(), 1); + + // ChannelCommissionTokenRates have been set for Channel A in both VKSM and VBNC + assert_eq!(ChannelCommissionTokenRates::::get(0, VKSM), DEFAULT_COMMISSION_RATE); + assert_eq!(ChannelCommissionTokenRates::::get(0, VBNC), DEFAULT_COMMISSION_RATE); + + // ChannelVtokenShares has been initialized for Channel A in both VKSM and VBNC + assert_eq!(ChannelVtokenShares::::get(0, VKSM), Permill::from_percent(0)); + + assert_eq!(ChannelVtokenShares::::get(0, VBNC), Permill::from_percent(0)); }); } diff --git a/pallets/vtoken-minting/src/lib.rs b/pallets/vtoken-minting/src/lib.rs index 0b46582f6..d40a79999 100644 --- a/pallets/vtoken-minting/src/lib.rs +++ b/pallets/vtoken-minting/src/lib.rs @@ -219,6 +219,10 @@ pub mod pallet { FastRedeemFailed { err: DispatchError, }, + CurrencyTimeUnitRecreated { + token_id: CurrencyIdOf, + time_unit: TimeUnit, + }, } #[pallet::error] @@ -802,6 +806,23 @@ pub mod pallet { Self::deposit_event(Event::MinTimeUnitSet { token_id, time_unit }); Ok(()) } + + #[pallet::call_index(13)] + #[pallet::weight({0})] + pub fn recreate_currency_ongoing_time_unit( + origin: OriginFor, + token_id: CurrencyIdOf, + time_unit: TimeUnit, + ) -> DispatchResult { + T::ControlOrigin::ensure_origin(origin)?; + + OngoingTimeUnit::::mutate(&token_id, |old_time_unit| { + *old_time_unit = Some(time_unit.clone()) + }); + + Self::deposit_event(Event::CurrencyTimeUnitRecreated { token_id, time_unit }); + Ok(()) + } } impl Pallet { diff --git a/pallets/vtoken-minting/src/tests.rs b/pallets/vtoken-minting/src/tests.rs index f2d91c3e7..55825f508 100644 --- a/pallets/vtoken-minting/src/tests.rs +++ b/pallets/vtoken-minting/src/tests.rs @@ -489,3 +489,22 @@ fn fast_redeem_for_fil() { ); }); } + +#[test] +fn recreate_currency_ongoing_time_unit_should_work() { + ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| { + env_logger::try_init().unwrap_or(()); + + // set KSM ongoing time unit to be Era(1) + OngoingTimeUnit::::insert(KSM, TimeUnit::Era(1)); + assert_eq!(VtokenMinting::ongoing_time_unit(KSM), Some(TimeUnit::Era(1))); + + // recreate_currency_ongoing_time_unit the ongoing time unit of KSM to be Round(2) + assert_ok!(VtokenMinting::recreate_currency_ongoing_time_unit( + RuntimeOrigin::signed(ALICE), + KSM, + TimeUnit::Round(2) + )); + assert_eq!(VtokenMinting::ongoing_time_unit(KSM), Some(TimeUnit::Round(2))); + }) +} diff --git a/pallets/vtoken-minting/src/weights.rs b/pallets/vtoken-minting/src/weights.rs index f83fd7ca5..2cdc0f2de 100644 --- a/pallets/vtoken-minting/src/weights.rs +++ b/pallets/vtoken-minting/src/weights.rs @@ -65,6 +65,7 @@ pub trait WeightInfo { fn rebond() -> Weight; fn rebond_by_unlock_id() -> Weight; fn on_initialize() -> Weight; + fn recreate_currency_ongoing_time_unit() -> Weight; } // For backwards compatibility and tests @@ -278,4 +279,10 @@ impl WeightInfo for () { Weight::from_parts(15_243_000, 3492) .saturating_add(RocksDbWeight::get().reads(1_u64)) } + + fn recreate_currency_ongoing_time_unit() -> Weight { + Weight::from_parts(70_238_000, 4197) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } } diff --git a/pallets/vtoken-voting/src/lib.rs b/pallets/vtoken-voting/src/lib.rs index 2da8c53a2..b515e5bae 100644 --- a/pallets/vtoken-voting/src/lib.rs +++ b/pallets/vtoken-voting/src/lib.rs @@ -721,7 +721,7 @@ pub mod pallet { if !VoteDelegatorFor::::contains_key((&who, vtoken, poll_index)) { VoteDelegatorFor::::insert((&who, vtoken, poll_index), derivative_index); } - let _ = DelegatorVotes::::clear(u32::MAX, None); + DelegatorVotes::::remove(vtoken, poll_index); DelegatorVotes::::try_mutate( vtoken, poll_index, @@ -796,7 +796,7 @@ pub mod pallet { { let success = Response::DispatchResult(MaybeErrorCode::Success) == response; if success { - let _ = DelegatorVotes::::clear(u32::MAX, None); + DelegatorVotes::::remove(vtoken, poll_index); } PendingRemoveDelegatorVote::::remove(query_id); Self::deposit_event(Event::::DelegatorVoteRemovedNotified { diff --git a/pallets/vtoken-voting/src/mock.rs b/pallets/vtoken-voting/src/mock.rs index d924363f3..9d0106b7e 100644 --- a/pallets/vtoken-voting/src/mock.rs +++ b/pallets/vtoken-voting/src/mock.rs @@ -308,15 +308,30 @@ impl BlockNumberProvider for RelaychainDataProvider { } } +parameter_types! { + pub static VTokenSupply: Balance = u64::MAX.into(); + pub static TokenSupply: Balance = u64::MAX.into(); +} + pub struct SimpleVTokenSupplyProvider; +impl SimpleVTokenSupplyProvider { + pub fn set_vtoken_supply(supply: Balance) { + VTokenSupply::set(supply); + } + + pub fn set_token_supply(supply: Balance) { + TokenSupply::set(supply); + } +} + impl VTokenSupplyProvider for SimpleVTokenSupplyProvider { fn get_vtoken_supply(_: CurrencyId) -> Option { - Some(u64::MAX.into()) + Some(VTokenSupply::get()) } fn get_token_supply(_: CurrencyId) -> Option { - Some(u64::MAX.into()) + Some(TokenSupply::get()) } } diff --git a/pallets/vtoken-voting/src/tests.rs b/pallets/vtoken-voting/src/tests.rs index 1d70ea26d..789f38e34 100644 --- a/pallets/vtoken-voting/src/tests.rs +++ b/pallets/vtoken-voting/src/tests.rs @@ -1046,6 +1046,115 @@ fn compute_delegator_total_vote_works() { assert_eq!(VtokenVoting::compute_delegator_total_vote(vtoken, nay(2, 4)), Ok(nay(80, 0))); assert_eq!(VtokenVoting::compute_delegator_total_vote(vtoken, nay(2, 5)), Ok(nay(100, 0))); assert_eq!(VtokenVoting::compute_delegator_total_vote(vtoken, nay(2, 6)), Ok(nay(120, 0))); + + SimpleVTokenSupplyProvider::set_token_supply(10_000_000); + assert_eq!(VtokenVoting::vote_cap(vtoken), Ok(1_000_000)); + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(1_000_000, 0)), + Ok(aye(1_000_000, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote( + vtoken, + aye(10_000_000 * i as Balance, 0) + ), + Ok(aye(1_000_000, i)) + ); + } + + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(100_000, 1)), + Ok(aye(1_000_000, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote( + vtoken, + aye(1_000_000 * i as Balance, 1) + ), + Ok(aye(1_000_000, i)) + ); + } + assert_noop!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(6_000_006, 1)), + Error::::InsufficientFunds + ); + + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(50_000, 2)), + Ok(aye(1_000_000, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(500_000 * i as Balance, 2)), + Ok(aye(1_000_000, i)) + ); + } + assert_noop!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(3_000_003, 2)), + Error::::InsufficientFunds + ); + + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(33_333, 3)), + Ok(aye(999_990, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(333_333 * i as Balance, 3)), + Ok(aye(999_999, i)) + ); + } + assert_noop!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(2_000_002, 3)), + Error::::InsufficientFunds + ); + + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(25_000, 4)), + Ok(aye(1_000_000, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(250_000 * i as Balance, 4)), + Ok(aye(1_000_000, i)) + ); + } + assert_noop!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(1_500_002, 4)), + Error::::InsufficientFunds + ); + + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(20_000, 5)), + Ok(aye(1_000_000, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(200_000 * i as Balance, 5)), + Ok(aye(1_000_000, i)) + ); + } + assert_noop!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(1_200_002, 5)), + Error::::InsufficientFunds + ); + + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(16_666, 6)), + Ok(aye(999_960, 0)) + ); + for i in 1..=6_u8 { + assert_eq!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(166_666 * i as Balance, 6)), + Ok(aye(999_996, i)) + ); + } + assert_noop!( + VtokenVoting::compute_delegator_total_vote(vtoken, aye(1_000_001, 6)), + Error::::InsufficientFunds + ); }); } @@ -1063,19 +1172,67 @@ fn allocate_delegator_votes_works() { new_test_ext().execute_with(|| { let vtoken = VKSM; let poll_index = 3; - let vote = aye(5e9 as Balance, 2); - let delegator_votes = VtokenVoting::allocate_delegator_votes(vtoken, poll_index, vote); - assert_eq!(delegator_votes, Ok(vec![(0, aye(4294967295, 2)), (1, aye(705032705, 2))])); - assert_eq!( - delegator_votes.unwrap().into_iter().map(|(_derivative_index, vote)| vote).fold( - aye(0, 2), - |mut acc, vote| { - let _ = acc.checked_add(vote); - acc - }, - ), - vote - ); + for conviction in 0..=6 { + let vote = aye(5e9 as Balance, conviction); + let delegator_votes = VtokenVoting::allocate_delegator_votes(vtoken, poll_index, vote); + assert_eq!( + delegator_votes, + Ok(vec![(0, aye(4294967295, conviction)), (1, aye(705032705, conviction))]) + ); + assert_eq!( + delegator_votes.unwrap().into_iter().map(|(_derivative_index, vote)| vote).fold( + aye(0, conviction), + |mut acc, vote| { + let _ = acc.checked_add(vote); + acc + }, + ), + vote + ); + } + + for conviction in 0..=6 { + let vote = aye(3e10 as Balance, conviction); + let delegator_votes = VtokenVoting::allocate_delegator_votes(vtoken, poll_index, vote); + assert_eq!( + delegator_votes, + Ok(vec![ + (0, aye(4294967295, conviction)), + (1, aye(4294967295, conviction)), + (2, aye(4294967295, conviction)), + (3, aye(4294967295, conviction)), + (4, aye(4294967295, conviction)), + (5, aye(4294967295, conviction)), + (10, aye(4230196230, conviction)) + ]) + ); + assert_eq!( + delegator_votes.unwrap().into_iter().map(|(_derivative_index, vote)| vote).fold( + aye(0, conviction), + |mut acc, vote| { + let _ = acc.checked_add(vote); + acc + }, + ), + vote + ); + } }); } + +#[test] +fn tally_convert_works() { + assert_eq!( + TallyOf::::from_parts(10, 9, 0).account_vote(Conviction::Locked1x), + aye(1, 1) + ); + assert_eq!( + TallyOf::::from_parts(10, 11, 0).account_vote(Conviction::Locked1x), + nay(1, 1) + ); + assert_eq!( + TallyOf::::from_parts(10, 10, 0).account_vote(Conviction::Locked1x), + aye(0, 1) + ); +} diff --git a/runtime/bifrost-kusama/Cargo.toml b/runtime/bifrost-kusama/Cargo.toml index 8340f6e9e..12291eb84 100644 --- a/runtime/bifrost-kusama/Cargo.toml +++ b/runtime/bifrost-kusama/Cargo.toml @@ -80,6 +80,7 @@ parachain-info = { workspace = true } pallet-xcm = { workspace = true } polkadot-parachain-primitives = { workspace = true } polkadot-primitives = { workspace = true } +polkadot-runtime-common = { workspace = true } xcm = { workspace = true } xcm-builder = { workspace = true } xcm-executor = { workspace = true } diff --git a/runtime/bifrost-kusama/src/lib.rs b/runtime/bifrost-kusama/src/lib.rs index cb0644d5b..fc5b8cc69 100644 --- a/runtime/bifrost-kusama/src/lib.rs +++ b/runtime/bifrost-kusama/src/lib.rs @@ -79,9 +79,9 @@ pub use bifrost_primitives::{ Ratio, RpcContributionStatus, Shortfall, TimeUnit, TokenSymbol, }; pub use bifrost_runtime_common::{ - cent, constants::time::*, dollar, micro, milli, millicent, prod_or_test, AuraId, - CouncilCollective, EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil, - SlowAdjustingFeeUpdate, TechnicalCollective, + cent, constants::time::*, dollar, micro, milli, millicent, AuraId, CouncilCollective, + EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil, SlowAdjustingFeeUpdate, + TechnicalCollective, }; use bifrost_slp::QueryId; use constants::currency::*; @@ -95,6 +95,7 @@ use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned}; use hex_literal::hex; use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use polkadot_runtime_common::prod_or_fast; // zenlink imports use zenlink_protocol::{ @@ -133,7 +134,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bifrost"), impl_name: create_runtime_str!("bifrost"), authoring_version: 1, - spec_version: 990, + spec_version: 992, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -976,7 +977,7 @@ parameter_types! { /// Minimum round length is 2 minutes (10 * 12 second block times) pub const MinBlocksPerRound: u32 = 10; /// Blocks per round - pub const DefaultBlocksPerRound: u32 = prod_or_test!(2 * HOURS, 10); + pub const DefaultBlocksPerRound: u32 = prod_or_fast!(2 * HOURS, 10); /// Rounds before the collator leaving the candidates request can be executed pub const LeaveCandidatesDelay: u32 = 84; /// Rounds before the candidate bond increase/decrease can be executed @@ -990,7 +991,7 @@ parameter_types! { /// Rounds before the reward is paid pub const RewardPaymentDelay: u32 = 2; /// Minimum collators selected per round, default at genesis and minimum forever after - pub const MinSelectedCandidates: u32 = prod_or_test!(16,6); + pub const MinSelectedCandidates: u32 = prod_or_fast!(16,6); /// Maximum top delegations per candidate pub const MaxTopDelegationsPerCandidate: u32 = 300; /// Maximum bottom delegations per candidate @@ -1008,7 +1009,7 @@ parameter_types! { /// Minimum stake required to be reserved to be a delegator pub MinDelegatorStk: u128 = 50 * BNCS; pub AllowInflation: bool = false; - pub ToMigrateInvulnables: Vec = prod_or_test!(vec![ + pub ToMigrateInvulnables: Vec = prod_or_fast!(vec![ hex!["8cf80f0bafcd0a3d80ca61cb688e4400e275b39d3411b4299b47e712e9dab809"].into(), hex!["40ac4effe39181731a8feb8a8ee0780e177bdd0d752b09c8fd71047e67189022"].into(), hex!["624d6a004c72a1abcf93131e185515ebe1410e43a301fe1f25d20d8da345376e"].into(), @@ -1392,7 +1393,7 @@ impl bifrost_slp::Config for Runtime { type XcmTransfer = XTokens; type MaxLengthLimit = MaxLengthLimit; type XcmWeightAndFeeHandler = XcmInterface; - type ChannelCommission = ChannelCommission; + type ChannelCommission = (); } impl bifrost_vstoken_conversion::Config for Runtime { @@ -1426,7 +1427,7 @@ impl bifrost_farming::Config for Runtime { } parameter_types! { - pub const BlocksPerRound: u32 = prod_or_test!(1500, 50); + pub const BlocksPerRound: u32 = prod_or_fast!(1500, 50); pub const MaxTokenLen: u32 = 500; pub const MaxFarmingPoolIdLen: u32 = 100; } @@ -1634,7 +1635,7 @@ impl bifrost_vtoken_minting::Config for Runtime { type MoonbeamParachainId = ConstU32<2023>; type HydradxParachainId = ConstU32<2034>; type InterlayParachainId = ConstU32<2092>; - type ChannelCommission = ChannelCommission; + type ChannelCommission = (); } impl bifrost_slpx::Config for Runtime { @@ -1785,22 +1786,22 @@ impl leverage_staking::Config for Runtime { type CurrencyIdConversion = AssetIdMaps; } -parameter_types! { - pub const ClearingDuration: u32 = 7 * DAYS; - pub const NameLengthLimit: u32 = 20; - pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating(); -} - -impl bifrost_channel_commission::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MultiCurrency = Currencies; - type ControlOrigin = EitherOfDiverse; - type CommissionPalletId = CommissionPalletId; - type BifrostCommissionReceiver = BifrostCommissionReceiver; - type WeightInfo = weights::bifrost_channel_commission::BifrostWeight; - type ClearingDuration = ClearingDuration; - type NameLengthLimit = NameLengthLimit; -} +// parameter_types! { +// pub const ClearingDuration: u32 = prod_or_fast!(7 * DAYS, 10 * MINUTES); +// pub const NameLengthLimit: u32 = 20; +// pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating(); +// } +// +// impl bifrost_channel_commission::Config for Runtime { +// type RuntimeEvent = RuntimeEvent; +// type MultiCurrency = Currencies; +// type ControlOrigin = EitherOfDiverse; +// type CommissionPalletId = CommissionPalletId; +// type BifrostCommissionReceiver = BifrostCommissionReceiver; +// type WeightInfo = weights::bifrost_channel_commission::BifrostWeight; +// type ClearingDuration = ClearingDuration; +// type NameLengthLimit = NameLengthLimit; +// } // Below is the implementation of tokens manipulation functions other than native token. pub struct LocalAssetAdaptor(PhantomData); @@ -1988,7 +1989,7 @@ construct_runtime! { Oracle: orml_oracle:: = 133, OracleMembership: pallet_membership:: = 134, LeverageStaking: leverage_staking = 135, - ChannelCommission: bifrost_channel_commission = 136, + // ChannelCommission: bifrost_channel_commission = 136, } } @@ -2104,7 +2105,7 @@ mod benches { [bifrost_vtoken_voting, VtokenVoting] [lend_market, LendMarket] [leverage_staking, LeverageStaking] - [bifrost_channel_commission, ChannelCommission] + // [bifrost_channel_commission, ChannelCommission] ); } diff --git a/runtime/bifrost-kusama/src/weights/bifrost_vtoken_minting.rs b/runtime/bifrost-kusama/src/weights/bifrost_vtoken_minting.rs index 357805ee9..5868cdd65 100644 --- a/runtime/bifrost-kusama/src/weights/bifrost_vtoken_minting.rs +++ b/runtime/bifrost-kusama/src/weights/bifrost_vtoken_minting.rs @@ -263,4 +263,10 @@ impl bifrost_vtoken_minting::WeightInfo for BifrostWeig Weight::from_parts(16_763_000, 3492) .saturating_add(T::DbWeight::get().reads(1)) } + + fn recreate_currency_ongoing_time_unit() -> Weight { + Weight::from_parts(70_238_000, 4197) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } diff --git a/runtime/bifrost-polkadot/Cargo.toml b/runtime/bifrost-polkadot/Cargo.toml index 680f70952..18f2c4b17 100644 --- a/runtime/bifrost-polkadot/Cargo.toml +++ b/runtime/bifrost-polkadot/Cargo.toml @@ -80,6 +80,7 @@ parachain-info = { workspace = true } pallet-xcm = { workspace = true } polkadot-parachain-primitives = { workspace = true } polkadot-primitives = { workspace = true } +polkadot-runtime-common = { workspace = true } xcm = { workspace = true } xcm-builder = { workspace = true } xcm-executor = { workspace = true } diff --git a/runtime/bifrost-polkadot/src/lib.rs b/runtime/bifrost-polkadot/src/lib.rs index 8ba43fe96..ca1004e8f 100644 --- a/runtime/bifrost-polkadot/src/lib.rs +++ b/runtime/bifrost-polkadot/src/lib.rs @@ -78,7 +78,7 @@ pub use bifrost_primitives::{ GLMR_TOKEN_ID, }; use bifrost_runtime_common::{ - constants::time::*, dollar, micro, milli, prod_or_test, AuraId, CouncilCollective, + constants::time::*, dollar, micro, milli, AuraId, CouncilCollective, EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil, SlowAdjustingFeeUpdate, TechnicalCollective, }; @@ -103,6 +103,7 @@ use zenlink_protocol::{ pub mod xcm_config; use orml_traits::{currency::MutationHooks, location::RelativeReserveProvider}; use pallet_xcm::{EnsureResponse, QueryStatus}; +use polkadot_runtime_common::prod_or_fast; use static_assertions::const_assert; use xcm::v3::prelude::*; use xcm_config::{ @@ -132,7 +133,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("bifrost_polkadot"), impl_name: create_runtime_str!("bifrost_polkadot"), authoring_version: 0, - spec_version: 990, + spec_version: 992, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -1220,7 +1221,7 @@ impl bifrost_slp::Config for Runtime { type XcmTransfer = XTokens; type MaxLengthLimit = MaxLengthLimit; type XcmWeightAndFeeHandler = XcmInterface; - type ChannelCommission = ChannelCommission; + type ChannelCommission = (); } parameter_types! { @@ -1258,7 +1259,7 @@ impl bifrost_farming::Config for Runtime { } parameter_types! { - pub const BlocksPerRound: u32 = prod_or_test!(1500, 50); + pub const BlocksPerRound: u32 = prod_or_fast!(1500, 50); pub const MaxTokenLen: u32 = 500; pub const MaxFarmingPoolIdLen: u32 = 100; } @@ -1469,7 +1470,7 @@ impl bifrost_vtoken_minting::Config for Runtime { type MoonbeamParachainId = ConstU32<2004>; type HydradxParachainId = ConstU32<2034>; type InterlayParachainId = ConstU32<2032>; - type ChannelCommission = ChannelCommission; + type ChannelCommission = (); } parameter_types! { @@ -1593,22 +1594,22 @@ impl leverage_staking::Config for Runtime { type CurrencyIdConversion = AssetIdMaps; } -parameter_types! { - pub const ClearingDuration: u32 = 7 * DAYS; - pub const NameLengthLimit: u32 = 20; - pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating(); -} - -impl bifrost_channel_commission::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MultiCurrency = Currencies; - type ControlOrigin = EitherOfDiverse; - type CommissionPalletId = CommissionPalletId; - type BifrostCommissionReceiver = BifrostCommissionReceiver; - type WeightInfo = weights::bifrost_channel_commission::BifrostWeight; - type ClearingDuration = ClearingDuration; - type NameLengthLimit = NameLengthLimit; -} +// parameter_types! { +// pub const ClearingDuration: u32 = prod_or_fast!(7 * DAYS, 10 * MINUTES); +// pub const NameLengthLimit: u32 = 20; +// pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating(); +// } +// +// impl bifrost_channel_commission::Config for Runtime { +// type RuntimeEvent = RuntimeEvent; +// type MultiCurrency = Currencies; +// type ControlOrigin = EitherOfDiverse; +// type CommissionPalletId = CommissionPalletId; +// type BifrostCommissionReceiver = BifrostCommissionReceiver; +// type WeightInfo = weights::bifrost_channel_commission::BifrostWeight; +// type ClearingDuration = ClearingDuration; +// type NameLengthLimit = NameLengthLimit; +// } // Below is the implementation of tokens manipulation functions other than native token. pub struct LocalAssetAdaptor(PhantomData); @@ -1793,7 +1794,7 @@ construct_runtime! { Oracle: orml_oracle:: = 133, OracleMembership: pallet_membership:: = 134, LeverageStaking: leverage_staking = 135, - ChannelCommission: bifrost_channel_commission = 136, + // ChannelCommission: bifrost_channel_commission = 136, } } diff --git a/runtime/bifrost-polkadot/src/weights/bifrost_vtoken_minting.rs b/runtime/bifrost-polkadot/src/weights/bifrost_vtoken_minting.rs index 357805ee9..5868cdd65 100644 --- a/runtime/bifrost-polkadot/src/weights/bifrost_vtoken_minting.rs +++ b/runtime/bifrost-polkadot/src/weights/bifrost_vtoken_minting.rs @@ -263,4 +263,10 @@ impl bifrost_vtoken_minting::WeightInfo for BifrostWeig Weight::from_parts(16_763_000, 3492) .saturating_add(T::DbWeight::get().reads(1)) } + + fn recreate_currency_ongoing_time_unit() -> Weight { + Weight::from_parts(70_238_000, 4197) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 3f4b184e2..3d5ed2397 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -132,21 +132,3 @@ impl BlockNumberProvider .unwrap_or_default() } } - -#[macro_export] -macro_rules! prod_or_test { - ($prod:expr, $test:expr) => { - if cfg!(feature = "fast-runtime") { - $test - } else { - $prod - } - }; - ($prod:expr, $test:expr, $env:expr) => { - if cfg!(feature = "fast-runtime") { - core::option_env!($env).map(|s| s.parse().ok()).flatten().unwrap_or($test) - } else { - $prod - } - }; -}