diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c0c760e05..48939176a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Update foreign asset ids in Asset Hub Polkadot and Asset Hub Kusama from v3 to v4 locations ([polkadot-fellows/runtimes#472](https://github.com/polkadot-fellows/runtimes/pull/472)) - Lower Parachain and Data Deposits to Encourage Experimentation on Kusama ([polkadot-fellows/runtimes#501](https://github.com/polkadot-fellows/runtimes/pull/501)) +### Fixed + +- Fix `experimental_inflation_info` in Polkadot and remove unused code (https://github.com/polkadot-fellows/runtimes/pull/497) + ## [1.3.3] 01.10.2024 ### Changed diff --git a/Cargo.lock b/Cargo.lock index a5789d7b41..da338aa398 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10108,7 +10108,6 @@ dependencies = [ "pallet-nomination-pools-runtime-api", "pallet-offences", "pallet-offences-benchmarking", - "pallet-parameters", "pallet-preimage", "pallet-proxy", "pallet-referenda", diff --git a/relay/common/src/lib.rs b/relay/common/src/lib.rs index 0f0e119f25..e38d994081 100644 --- a/relay/common/src/lib.rs +++ b/relay/common/src/lib.rs @@ -27,6 +27,7 @@ pub mod apis { /// Both fields should be treated as best-effort, given that the inflation rate might not be /// fully predict-able. #[derive(scale_info::TypeInfo, codec::Encode, codec::Decode)] + #[cfg_attr(feature = "std", derive(Debug))] pub struct InflationInfo { /// The rate of inflation estimated per annum. pub inflation: sp_runtime::Perquintill, diff --git a/relay/polkadot/Cargo.toml b/relay/polkadot/Cargo.toml index ed69433257..a1b2c8bb5e 100644 --- a/relay/polkadot/Cargo.toml +++ b/relay/polkadot/Cargo.toml @@ -61,7 +61,6 @@ pallet-multisig = { workspace = true } pallet-nomination-pools = { workspace = true } pallet-nomination-pools-runtime-api = { workspace = true } pallet-offences = { workspace = true } -pallet-parameters = { workspace = true } pallet-preimage = { workspace = true } pallet-proxy = { workspace = true } pallet-referenda = { workspace = true } @@ -168,7 +167,6 @@ std = [ "pallet-nomination-pools/std", "pallet-offences-benchmarking?/std", "pallet-offences/std", - "pallet-parameters/std", "pallet-preimage/std", "pallet-proxy/std", "pallet-referenda/std", @@ -247,7 +245,6 @@ runtime-benchmarks = [ "pallet-nomination-pools/runtime-benchmarks", "pallet-offences-benchmarking/runtime-benchmarks", "pallet-offences/runtime-benchmarks", - "pallet-parameters/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-referenda/runtime-benchmarks", @@ -300,7 +297,6 @@ try-runtime = [ "pallet-multisig/try-runtime", "pallet-nomination-pools/try-runtime", "pallet-offences/try-runtime", - "pallet-parameters/try-runtime", "pallet-preimage/try-runtime", "pallet-proxy/try-runtime", "pallet-referenda/try-runtime", diff --git a/relay/polkadot/src/lib.rs b/relay/polkadot/src/lib.rs index 7f12e15f38..82e14f18dc 100644 --- a/relay/polkadot/src/lib.rs +++ b/relay/polkadot/src/lib.rs @@ -31,6 +31,7 @@ use polkadot_runtime_common::{ traits::OnSwap, BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate, }; +use relay_common::apis::InflationInfo; use runtime_parachains::{ assigner_coretime as parachains_assigner_coretime, @@ -60,7 +61,6 @@ use frame_election_provider_support::{ }; use frame_support::{ construct_runtime, - dynamic_params::{dynamic_pallet_params, dynamic_params}, genesis_builder_helper::{build_state, get_preset}, parameter_types, traits::{ @@ -85,7 +85,7 @@ use polkadot_primitives::{ GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment, NodeFeatures, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, - LOWEST_PUBLIC_ID, PARACHAIN_KEY_TYPE_ID, + PARACHAIN_KEY_TYPE_ID, }; use sp_core::{OpaqueMetadata, H256}; use sp_runtime::{ @@ -93,7 +93,7 @@ use sp_runtime::{ traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Extrinsic as ExtrinsicT, IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion, - Saturating, Verify, + Verify, }, transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug, @@ -619,88 +619,6 @@ impl pallet_bags_list::Config for Runtime { type Score = sp_npos_elections::VoteWeight; } -/// Dynamic params that can be adjusted at runtime. -#[dynamic_params(RuntimeParameters, pallet_parameters::Parameters::)] -pub mod dynamic_params { - use super::*; - - /// Parameters used to calculate era payouts, see - /// [`polkadot_runtime_common::impls::EraPayoutParams`]. - #[dynamic_pallet_params] - #[codec(index = 0)] - pub mod inflation { - /// Minimum inflation rate used to calculate era payouts. - #[codec(index = 0)] - pub static MinInflation: Perquintill = Perquintill::from_rational(25u64, 1000); - - /// Maximum inflation rate used to calculate era payouts. - #[codec(index = 1)] - pub static MaxInflation: Perquintill = Perquintill::from_percent(10); - - /// Ideal stake ratio used to calculate era payouts. - #[codec(index = 2)] - pub static IdealStake: Perquintill = Perquintill::from_percent(75); - - /// Falloff used to calculate era payouts. - #[codec(index = 3)] - pub static Falloff: Perquintill = Perquintill::from_percent(5); - - /// Whether to use auction slots or not in the calculation of era payouts, then we subtract - /// `num_auctioned_slots.min(60) / 300` from `ideal_stake`. - /// - /// That is, we assume up to 60 parachains that are leased can reduce the ideal stake by a - /// maximum of 20%. - /// - /// With the move to agile-coretime, this parameter does not make much sense and should - /// generally be set to false. - #[codec(index = 4)] - pub static UseAuctionSlots: bool = true; - } -} - -#[cfg(feature = "runtime-benchmarks")] -impl Default for RuntimeParameters { - fn default() -> Self { - RuntimeParameters::Inflation(dynamic_params::inflation::Parameters::MinInflation( - dynamic_params::inflation::MinInflation, - Some(Perquintill::from_rational(25u64, 1000u64)), - )) - } -} - -/// Defines what origin can modify which dynamic parameters. -pub struct DynamicParameterOrigin; -impl frame_support::traits::EnsureOriginWithArg - for DynamicParameterOrigin -{ - type Success = (); - - fn try_origin( - origin: RuntimeOrigin, - key: &RuntimeParametersKey, - ) -> Result { - use crate::RuntimeParametersKey::*; - - match key { - Inflation(_) => frame_system::ensure_root(origin.clone()), - } - .map_err(|_| origin) - } - - #[cfg(feature = "runtime-benchmarks")] - fn try_successful_origin(_key: &RuntimeParametersKey) -> Result { - // Provide the origin for the parameter returned by `Default`: - Ok(RuntimeOrigin::root()) - } -} - -impl pallet_parameters::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeParameters = RuntimeParameters; - type AdminOrigin = DynamicParameterOrigin; - type WeightInfo = weights::pallet_parameters::WeightInfo; -} - /// Defines how much should the inflation be for an era given its duration. pub struct EraPayout; impl pallet_staking::EraPayout for EraPayout { @@ -1641,7 +1559,6 @@ construct_runtime! { Referenda: pallet_referenda = 21, Origins: pallet_custom_origins = 22, Whitelist: pallet_whitelist = 23, - Parameters: pallet_parameters = 27, // Claims. Usable initially. Claims: claims = 24, @@ -2272,7 +2189,6 @@ mod benches { ); } -use relay_common::apis::InflationInfo; impl Runtime { fn impl_experimental_inflation_info() -> InflationInfo { use pallet_staking::{ActiveEra, EraPayout, ErasTotalStake}; @@ -2281,20 +2197,6 @@ impl Runtime { .unwrap_or((0, 0)); let stake_able_issuance = Balances::total_issuance(); - let ideal_staking_rate = dynamic_params::inflation::IdealStake::get(); - let inflation = if dynamic_params::inflation::UseAuctionSlots::get() { - let auctioned_slots = parachains_paras::Parachains::::get() - .into_iter() - // all active para-ids that do not belong to a system chain is the number of - // parachains that we should take into account for inflation. - .filter(|i| *i >= LOWEST_PUBLIC_ID) - .count() as u64; - ideal_staking_rate - .saturating_sub(Perquintill::from_rational(auctioned_slots.min(60), 300u64)) - } else { - ideal_staking_rate - }; - // We assume un-delayed 24h eras. let era_duration = 24 * (HOURS as Moment) * MILLISECS_PER_BLOCK; let next_mint = ::EraPayout::era_payout( @@ -2302,6 +2204,12 @@ impl Runtime { stake_able_issuance, era_duration, ); + // reverse-engineer the current inflation by looking at the total minted against the total + // issuance. + let inflation = Perquintill::from_rational( + (next_mint.0 + next_mint.1) * 36525 / 100, + stake_able_issuance, + ); InflationInfo { inflation, next_mint } } @@ -3750,9 +3658,6 @@ mod remote_tests { // timestamp now hex!("f0c365c3cf59d671eb72da0e7a4113c49f1f0515f462cdcf84e0f1d6045dfcbb") .to_vec(), - // para-ids - hex!("cd710b30bd2eab0352ddcc26417aa1940b76934f4cc08dee01012d059e1b83ee") - .to_vec(), ], ..Default::default() })) @@ -3783,13 +3688,9 @@ mod remote_tests { log::info!(target: LOG_TARGET, "total-issuance = {:?}", token.amount(total_issuance)); log::info!(target: LOG_TARGET, "staking-rate = {:?}", Perquintill::from_rational(total_staked, total_issuance)); log::info!(target: LOG_TARGET, "era-duration = {:?}", average_era_duration_millis); - log::info!(target: LOG_TARGET, "min-inflation = {:?}", dynamic_params::inflation::MinInflation::get()); - log::info!(target: LOG_TARGET, "max-inflation = {:?}", dynamic_params::inflation::MaxInflation::get()); - log::info!(target: LOG_TARGET, "falloff = {:?}", dynamic_params::inflation::Falloff::get()); - log::info!(target: LOG_TARGET, "useAuctionSlots = {:?}", dynamic_params::inflation::UseAuctionSlots::get()); - log::info!(target: LOG_TARGET, "idealStake = {:?}", dynamic_params::inflation::IdealStake::get()); log::info!(target: LOG_TARGET, "maxStakingRewards = {:?}", pallet_staking::MaxStakedRewards::::get()); log::info!(target: LOG_TARGET, "💰 Inflation ==> staking = {:?} / leftover = {:?}", token.amount(staking), token.amount(leftover)); + log::info!(target: LOG_TARGET, "inflation_rate runtime API: {:?}", Runtime::impl_experimental_inflation_info()); }); } } diff --git a/relay/polkadot/src/weights/mod.rs b/relay/polkadot/src/weights/mod.rs index 303bd12451..190b254db2 100644 --- a/relay/polkadot/src/weights/mod.rs +++ b/relay/polkadot/src/weights/mod.rs @@ -29,7 +29,6 @@ pub mod pallet_indices; pub mod pallet_message_queue; pub mod pallet_multisig; pub mod pallet_nomination_pools; -pub mod pallet_parameters; pub mod pallet_preimage; pub mod pallet_proxy; pub mod pallet_referenda; diff --git a/relay/polkadot/src/weights/pallet_parameters.rs b/relay/polkadot/src/weights/pallet_parameters.rs deleted file mode 100644 index 4ecc2b213c..0000000000 --- a/relay/polkadot/src/weights/pallet_parameters.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md -// for a list of specific contributors. -// SPDX-License-Identifier: Apache-2.0 - -//! Autogenerated weights for `pallet_parameters` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2024-04-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `runner-anb7yjbi-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polkadot-dev")`, DB CACHE: 1024 - -// Executed Command: -// target/production/polkadot -// benchmark -// pallet -// --steps=50 -// --repeat=20 -// --extrinsic=* -// --wasm-execution=compiled -// --heap-pages=4096 -// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json -// --pallet=pallet_parameters -// --chain=polkadot-dev -// --header=./polkadot/file_header.txt -// --output=./polkadot/runtime/polkadot/src/weights/ - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_parameters`. -pub struct WeightInfo(PhantomData); -impl pallet_parameters::WeightInfo for WeightInfo { - /// Storage: `Parameters::Parameters` (r:1 w:1) - /// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`) - fn set_parameter() -> Weight { - // Proof Size summary in bytes: - // Measured: `4` - // Estimated: `3493` - // Minimum execution time: 6_937_000 picoseconds. - Weight::from_parts(7_242_000, 0) - .saturating_add(Weight::from_parts(0, 3493)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } -}