fix(rc-runtime): remove old pezpallet_staking and related pallets for RC 1_020_006

StakingAhClient (index 67) is now Active — old NPoS staking on RC is unused.

Removed pallets:
- Staking (pezpallet_staking, index 9)
- FastUnstake (pezpallet_fast_unstake, index 15)
- VoterBagsList (pezpallet_bags_list Instance1, index 100)

Changes:
- Added NoopFallback struct for ah_client::Config::Fallback
- Updated validator_manager to use StakingAhClient
- Added RemovePallet migrations for on-chain storage cleanup
- Removed StakingConfig from genesis presets
- Cleaned up unused imports and dependencies
- Updated upgrade scripts (ah_upgrade, rc_upgrade, people_upgrade, set_ah_client_active)
This commit is contained in:
2026-02-21 00:22:12 +03:00
parent 90a6917616
commit a516ffec65
9 changed files with 776 additions and 361 deletions
-12
View File
@@ -54,7 +54,6 @@ pezframe-system-rpc-runtime-api = { workspace = true }
pezpallet-authority-discovery = { workspace = true }
pezpallet-authorship = { workspace = true }
pezpallet-babe = { workspace = true }
pezpallet-bags-list = { workspace = true }
pezpallet-balances = { workspace = true }
pezpallet-beefy = { workspace = true }
pezpallet-beefy-mmr = { workspace = true }
@@ -63,7 +62,6 @@ pezpallet-conviction-voting = { workspace = true }
# pezpallet-democracy removed - pezpallet-welati implements custom governance
# pezpallet-election-provider-multi-phase removed - using OnChain election
# pezpallet-elections-phragmen removed - pezpallet-welati implements custom elections
pezpallet-fast-unstake = { workspace = true }
pezpallet-grandpa = { workspace = true }
pezpallet-indices = { workspace = true }
pezpallet-message-queue = { workspace = true }
@@ -80,7 +78,6 @@ pezpallet-referenda = { workspace = true }
pezpallet-root-testing = { workspace = true }
pezpallet-scheduler = { workspace = true }
pezpallet-session = { workspace = true }
pezpallet-staking = { workspace = true }
pezpallet-staking-async-ah-client = { workspace = true }
pezpallet-staking-async-rc-client = { workspace = true }
pezpallet-staking-runtime-api = { workspace = true }
@@ -157,14 +154,12 @@ std = [
"pezpallet-authority-discovery/std",
"pezpallet-authorship/std",
"pezpallet-babe/std",
"pezpallet-bags-list/std",
"pezpallet-balances/std",
"pezpallet-beefy-mmr/std",
"pezpallet-beefy/std",
"pezpallet-collective/std",
"pezpallet-conviction-voting/std",
"pezpallet-election-provider-support-benchmarking?/std",
"pezpallet-fast-unstake/std",
"pezpallet-grandpa/std",
"pezpallet-indices/std",
"pezpallet-message-queue/std",
@@ -187,7 +182,6 @@ std = [
"pezpallet-staking-async-ah-client/std",
"pezpallet-staking-async-rc-client/std",
"pezpallet-staking-runtime-api/std",
"pezpallet-staking/std",
"pezpallet-state-trie-migration/std",
"pezpallet-sudo/std",
"pezpallet-timestamp/std",
@@ -251,14 +245,12 @@ runtime-benchmarks = [
"pezpallet-authority-discovery/runtime-benchmarks",
"pezpallet-authorship/runtime-benchmarks",
"pezpallet-babe/runtime-benchmarks",
"pezpallet-bags-list/runtime-benchmarks",
"pezpallet-balances/runtime-benchmarks",
"pezpallet-beefy-mmr/runtime-benchmarks",
"pezpallet-beefy/runtime-benchmarks",
"pezpallet-collective/runtime-benchmarks",
"pezpallet-conviction-voting/runtime-benchmarks",
"pezpallet-election-provider-support-benchmarking/runtime-benchmarks",
"pezpallet-fast-unstake/runtime-benchmarks",
"pezpallet-grandpa/runtime-benchmarks",
"pezpallet-indices/runtime-benchmarks",
"pezpallet-message-queue/runtime-benchmarks",
@@ -281,7 +273,6 @@ runtime-benchmarks = [
"pezpallet-staking-async-ah-client/runtime-benchmarks",
"pezpallet-staking-async-rc-client/runtime-benchmarks",
"pezpallet-staking-runtime-api/runtime-benchmarks",
"pezpallet-staking/runtime-benchmarks",
"pezpallet-state-trie-migration/runtime-benchmarks",
"pezpallet-sudo/runtime-benchmarks",
"pezpallet-timestamp/runtime-benchmarks",
@@ -336,14 +327,12 @@ try-runtime = [
"pezpallet-authority-discovery/try-runtime",
"pezpallet-authorship/try-runtime",
"pezpallet-babe/try-runtime",
"pezpallet-bags-list/try-runtime",
"pezpallet-balances/try-runtime",
"pezpallet-beefy-mmr/try-runtime",
"pezpallet-beefy/try-runtime",
"pezpallet-collective/try-runtime",
"pezpallet-conviction-voting/try-runtime",
"pezpallet-election-provider-support-benchmarking?/try-runtime",
"pezpallet-fast-unstake/try-runtime",
"pezpallet-grandpa/try-runtime",
"pezpallet-indices/try-runtime",
"pezpallet-message-queue/try-runtime",
@@ -365,7 +354,6 @@ try-runtime = [
"pezpallet-session/try-runtime",
"pezpallet-staking-async-ah-client/try-runtime",
"pezpallet-staking-async-rc-client/try-runtime",
"pezpallet-staking/try-runtime",
"pezpallet-state-trie-migration/try-runtime",
"pezpallet-sudo/try-runtime",
"pezpallet-timestamp/try-runtime",
@@ -29,7 +29,7 @@
use crate::{
BabeConfig, BalancesConfig, ConfigurationConfig, RegistrarConfig, RuntimeGenesisConfig,
SessionConfig, SessionKeys, StakingConfig, SudoConfig, BABE_GENESIS_EPOCH_CONFIG,
SessionConfig, SessionKeys, SudoConfig, BABE_GENESIS_EPOCH_CONFIG,
};
#[cfg(not(feature = "std"))]
use alloc::format;
@@ -37,7 +37,6 @@ use alloc::{vec, vec::Vec};
use pezframe_support::build_struct_json_patch;
use pezkuwi_primitives::{AccountId, AssignmentId, SchedulerParams, ValidatorId};
use pezkuwichain_runtime_constants::currency::UNITS as TYR;
use pezpallet_staking::{Forcing, StakerStatus};
use pezsp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use pezsp_consensus_babe::AuthorityId as BabeId;
use pezsp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
@@ -45,7 +44,6 @@ use pezsp_consensus_grandpa::AuthorityId as GrandpaId;
use pezsp_core::{crypto::get_public_from_string_or_panic, sr25519};
use pezsp_genesis_builder::PresetId;
use pezsp_keyring::Sr25519Keyring;
use pezsp_runtime::Perbill;
// ============================================================================
// HEZ TOKEN GENESIS CONSTANTS (Total Supply: 200 Million HEZ)
@@ -1020,17 +1018,6 @@ fn pezkuwichain_genesis_config() -> serde_json::Value {
))
.collect::<Vec<_>>(),
},
staking: StakingConfig {
minimum_validator_count: 1,
validator_count: initial_authorities.len() as u32,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
.collect::<Vec<_>>(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
force_era: Forcing::ForceAlways,
slash_reward_fraction: Perbill::from_percent(10),
},
babe: BabeConfig { epoch_config: BABE_GENESIS_EPOCH_CONFIG },
sudo: SudoConfig { key: Some(founder_account) },
configuration: ConfigurationConfig { config: default_teyrchains_host_configuration() },
@@ -1135,17 +1122,6 @@ fn pezkuwichain_mainnet_simulation_genesis() -> serde_json::Value {
})
.collect::<Vec<_>>(),
},
staking: StakingConfig {
minimum_validator_count: 1,
validator_count: initial_authorities.len() as u32,
stakers: initial_authorities
.iter()
.map(|x| (x.0.clone(), x.0.clone(), STASH, StakerStatus::<AccountId>::Validator))
.collect::<Vec<_>>(),
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect::<Vec<_>>(),
force_era: Forcing::ForceAlways,
slash_reward_fraction: Perbill::from_percent(10),
},
babe: BabeConfig { epoch_config: BABE_GENESIS_EPOCH_CONFIG },
sudo: SudoConfig { key: Some(founder_account) },
configuration: ConfigurationConfig { config: default_teyrchains_host_configuration() },
+69 -160
View File
@@ -93,7 +93,7 @@ use pezframe_support::{
parameter_types,
traits::{
fungible::HoldConsideration, EitherOf, EitherOfDiverse, EnsureOriginWithArg,
InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice, Nothing, PrivilegeCmp,
InstanceFilter, KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp,
ProcessMessage, ProcessMessageError, WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
@@ -105,7 +105,7 @@ use pezpallet_session::historical as session_historical;
use pezpallet_staking_async_ah_client as ah_client;
use pezpallet_staking_async_rc_client as rc_client;
use pezpallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use pezsp_core::{ConstBool, ConstU128, ConstUint, Get, OpaqueMetadata, H256};
use pezsp_core::{ConstUint, Get, OpaqueMetadata, H256};
use pezsp_runtime::{
generic, impl_opaque_keys,
traits::{
@@ -174,7 +174,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: alloc::borrow::Cow::Borrowed("pezkuwichain"),
impl_name: alloc::borrow::Cow::Borrowed("parity-pezkuwichain"),
authoring_version: 0,
spec_version: 1_020_005,
spec_version: 1_020_006,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 26,
@@ -454,20 +454,55 @@ impl pezpallet_session::Config for Runtime {
type KeyDeposit = ();
}
/// Returns staking exposure for historical session tracking.
/// Falls back to a default empty exposure when none exists yet (e.g. at genesis),
/// preventing validators from being filtered out of the authority set.
/// Returns a default empty exposure for historical session tracking.
/// Exposure data is now on Asset Hub — RC returns default to keep validators in authority set.
pub struct ExposureOfOrDefault;
impl pezsp_runtime::traits::Convert<AccountId, Option<pezsp_staking::Exposure<AccountId, Balance>>>
for ExposureOfOrDefault
{
fn convert(validator: AccountId) -> Option<pezsp_staking::Exposure<AccountId, Balance>> {
Some(
<pezpallet_staking::DefaultExposureOf<Runtime>>::convert(validator).unwrap_or_default(),
)
fn convert(_validator: AccountId) -> Option<pezsp_staking::Exposure<AccountId, Balance>> {
Some(Default::default())
}
}
/// No-op fallback for StakingAhClient. Required at compile time but never called
/// since Mode is Active — all session/offence/reward logic goes through StakingAhClient.
pub struct NoopFallback;
impl pezpallet_session::SessionManager<AccountId> for NoopFallback {
fn new_session(_: SessionIndex) -> Option<Vec<AccountId>> {
None
}
fn start_session(_: SessionIndex) {}
fn end_session(_: SessionIndex) {}
}
impl pezsp_staking::offence::OnOffenceHandler<
AccountId,
(AccountId, pezsp_staking::Exposure<AccountId, Balance>),
Weight,
> for NoopFallback
{
fn on_offence(
_offenders: &[pezsp_staking::offence::OffenceDetails<
AccountId,
(AccountId, pezsp_staking::Exposure<AccountId, Balance>),
>],
_slash_fraction: &[Perbill],
_session: SessionIndex,
) -> Weight {
Weight::zero()
}
}
impl pezframe_support::traits::RewardsReporter<AccountId> for NoopFallback {
fn reward_by_ids(_: impl IntoIterator<Item = (AccountId, u32)>) {}
}
impl pezpallet_authorship::EventHandler<AccountId, BlockNumber> for NoopFallback {
fn note_author(_: AccountId) {}
}
impl pezpallet_session::historical::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type FullIdentification = pezsp_staking::Exposure<AccountId, Balance>;
@@ -475,106 +510,11 @@ impl pezpallet_session::historical::Config for Runtime {
}
// =====================================================
// STAKING CONFIGURATION
// STAKING CONFIGURATION (async — managed by StakingAhClient)
// =====================================================
parameter_types! {
pub const SessionsPerEra: SessionIndex = 6;
pub const BondingDuration: pezsp_staking::EraIndex = 28;
pub const SlashDeferDuration: pezsp_staking::EraIndex = 27;
pub const HistoryDepth: u32 = 84;
pub const MaxWinners: u32 = 100;
pub const MaxElectingVoters: u32 = 22_500;
pub const MaxActiveValidators: u32 = 1000;
// Limits for election provider.
pub const ElectionBounds: pezframe_election_provider_support::bounds::ElectionBounds =
pezframe_election_provider_support::bounds::ElectionBounds {
voters: pezframe_election_provider_support::bounds::DataProviderBounds {
size: Some(pezframe_election_provider_support::bounds::SizeBound(20_000)),
count: Some(pezframe_election_provider_support::bounds::CountBound(1_000)),
},
targets: pezframe_election_provider_support::bounds::DataProviderBounds {
size: Some(pezframe_election_provider_support::bounds::SizeBound(1_500)),
count: Some(pezframe_election_provider_support::bounds::CountBound(200)),
},
};
}
pub struct OnChainSeqPhragmen;
impl pezframe_election_provider_support::onchain::Config for OnChainSeqPhragmen {
type Sort = ConstBool<true>;
type System = Runtime;
type Solver = pezframe_election_provider_support::SequentialPhragmen<AccountId, Perbill>;
type DataProvider = Staking;
type WeightInfo = pezframe_election_provider_support::weights::BizinikiwiWeight<Runtime>;
type MaxBackersPerWinner = MaxElectingVoters;
type MaxWinnersPerPage = MaxWinners;
type Bounds = ElectionBounds;
}
/// Era payout calculation for staking rewards.
pub struct EraPayout;
impl pezpallet_staking::EraPayout<Balance> for EraPayout {
fn era_payout(
_total_staked: Balance,
_total_issuance: Balance,
era_duration_millis: u64,
) -> (Balance, Balance) {
const MILLISECONDS_PER_YEAR: u64 = (1000 * 3600 * 24 * 36525) / 100;
let relative_era_len =
FixedU128::from_rational(era_duration_millis.into(), MILLISECONDS_PER_YEAR.into());
// Fixed baseline: 200M HEZ (12 decimals) — prevents compound inflation
let fixed_total_issuance: i128 = 200_000_000_000_000_000_000;
let fixed_inflation_rate = FixedU128::from_rational(8, 100);
let yearly_emission = fixed_inflation_rate.saturating_mul_int(fixed_total_issuance);
let era_emission = relative_era_len.saturating_mul_int(yearly_emission);
// 15% to treasury, 85% to stakers
let to_treasury = FixedU128::from_rational(15, 100).saturating_mul_int(era_emission);
let to_stakers = era_emission.saturating_sub(to_treasury);
(to_stakers.saturated_into(), to_treasury.saturated_into())
}
}
pub struct PezkuwiStakingBenchmarkingConfig;
impl pezpallet_staking::BenchmarkingConfig for PezkuwiStakingBenchmarkingConfig {
type MaxValidators = ConstU32<1000>;
type MaxNominators = ConstU32<1000>;
}
impl pezpallet_staking::Config for Runtime {
type Currency = Balances;
type CurrencyBalance = Balance;
type UnixTime = Timestamp;
type CurrencyToVote = pezsp_staking::currency_to_vote::U128CurrencyToVote;
type RewardRemainder = ();
type RuntimeEvent = RuntimeEvent;
type Slash = ();
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type SlashDeferDuration = SlashDeferDuration;
type SessionInterface = ();
type EraPayout = EraPayout;
type NextNewSession = Session;
type MaxExposurePageSize = ConstU32<512>;
type MaxValidatorSet = MaxActiveValidators;
type ElectionProvider =
pezframe_election_provider_support::onchain::OnChainExecution<OnChainSeqPhragmen>;
type GenesisElectionProvider =
pezframe_election_provider_support::onchain::OnChainExecution<OnChainSeqPhragmen>;
type VoterList = VoterBagsList;
type TargetList = pezpallet_staking::UseValidatorsMap<Self>;
type MaxControllersInDeprecationBatch = ConstU32<5_900>;
type AdminOrigin = EnsureRoot<AccountId>;
type EventListeners = ();
type WeightInfo = pezpallet_staking::weights::BizinikiwiWeight<Runtime>;
type RuntimeHoldReason = RuntimeHoldReason;
type HistoryDepth = HistoryDepth;
type NominationsQuota = pezpallet_staking::FixedNominationsQuota<16>;
type MaxUnlockingChunks = ConstU32<32>;
type Filter = Nothing;
type OldCurrency = Balances;
type BenchmarkingConfig = PezkuwiStakingBenchmarkingConfig;
}
// =====================================================
@@ -703,25 +643,11 @@ impl ah_client::Config for Runtime {
type UnixTime = Timestamp;
type PointsPerBlock = ConstU32<20>;
type MaxOffenceBatchSize = ConstU32<50>;
type Fallback = Staking;
type Fallback = NoopFallback;
type MaximumValidatorsWithPoints = ConstU32<{ MaxActiveValidators::get() * 4 }>;
type MaxSessionReportRetries = ConstU32<64>;
}
// =====================================================
// FAST UNSTAKE CONFIGURATION
// =====================================================
impl pezpallet_fast_unstake::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BatchSize = ConstU32<64>;
type Deposit = ConstU128<{ UNITS }>;
type ControlOrigin = EnsureRoot<AccountId>;
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
type WeightInfo = pezpallet_fast_unstake::weights::BizinikiwiWeight<Runtime>;
}
// =====================================================
// VALIDATOR POOL CONFIGURATION (TNPoS Shadow Mode)
@@ -782,35 +708,6 @@ impl pezpallet_validator_pool::Config for Runtime {
type MinStakeAmount = ValidatorPoolMinStakeAmount;
}
// =====================================================
// VOTER BAGS LIST CONFIGURATION
// =====================================================
parameter_types! {
pub const VoterBagThresholds: &'static [u64] = &[
100 * UNITS as u64,
200 * UNITS as u64,
500 * UNITS as u64,
1_000 * UNITS as u64,
2_000 * UNITS as u64,
5_000 * UNITS as u64,
10_000 * UNITS as u64,
20_000 * UNITS as u64,
50_000 * UNITS as u64,
100_000 * UNITS as u64,
];
}
pub type VoterBagsListInstance = pezpallet_bags_list::Instance1;
impl pezpallet_bags_list::Config<VoterBagsListInstance> for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pezpallet_bags_list::weights::BizinikiwiWeight<Runtime>;
type ScoreProvider = Staking;
type BagThresholds = VoterBagThresholds;
type Score = u64;
type MaxAutoRebagPerBlock = ConstU32<10>;
}
// =====================================================
// COUNCIL CONFIGURATION
// =====================================================
@@ -902,7 +799,8 @@ impl pezpallet_authority_discovery::Config for Runtime {
}
parameter_types! {
pub const MaxSetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
// BondingDuration(2) * SessionsPerEra(6) — matches AH staking config
pub const MaxSetIdSessionEntries: u32 = 2 * 6;
}
impl pezpallet_grandpa::Config for Runtime {
@@ -1479,7 +1377,8 @@ impl pezpallet_parameters::Config for Runtime {
}
parameter_types! {
pub BeefySetIdSessionEntries: u32 = BondingDuration::get() * SessionsPerEra::get();
// BondingDuration(2) * SessionsPerEra(6) — matches AH staking config
pub BeefySetIdSessionEntries: u32 = 2 * 6;
}
impl pezpallet_beefy::Config for Runtime {
@@ -1561,7 +1460,7 @@ impl assigned_slots::Config for Runtime {
impl validator_manager::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PrivilegedOrigin = EnsureRoot<AccountId>;
type Staking = Staking;
type Staking = StakingAhClient;
}
parameter_types! {
@@ -1623,13 +1522,9 @@ construct_runtime! {
Historical: session_historical = 34,
Session: pezpallet_session = 8,
Staking: pezpallet_staking = 9,
Grandpa: pezpallet_grandpa = 10,
AuthorityDiscovery: pezpallet_authority_discovery = 12,
// Staking extensions.
FastUnstake: pezpallet_fast_unstake = 15,
// Governance stuff; uncallable initially.
Council: pezpallet_collective::<Instance1> = 17,
Treasury: pezpallet_treasury = 18,
@@ -1713,9 +1608,6 @@ construct_runtime! {
// Root testing pezpallet.
RootTesting: pezpallet_root_testing = 249,
// VoterBagsList pezpallet.
VoterBagsList: pezpallet_bags_list::<Instance1> = 100,
// Sudo.
Sudo: pezpallet_sudo = 255,
}
@@ -1799,6 +1691,10 @@ pub mod migrations {
pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
pub const TipsPalletName: &'static str = "Tips";
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
// Old staking ecosystem pallets (replaced by StakingAhClient + AH staking)
pub const StakingPalletName: &'static str = "Staking";
pub const FastUnstakePalletName: &'static str = "FastUnstake";
pub const VoterBagsListPalletName: &'static str = "VoterBagsList";
/// Weight for balance unreservations
pub BalanceUnreserveWeight: Weight = weights::pezpallet_balances_balances::WeightInfo::<Runtime>::force_unreserve();
pub BalanceTransferAllowDeath: Weight = weights::pezpallet_balances_balances::WeightInfo::<Runtime>::transfer_allow_death();
@@ -1874,6 +1770,19 @@ pub mod migrations {
teyrchains_inclusion::migration::MigrateToV1<Runtime>,
teyrchains_shared::migration::MigrateToV1<Runtime>,
teyrchains_scheduler::migration::MigrateV2ToV3<Runtime>,
// Remove old staking ecosystem pallets (replaced by StakingAhClient + AH staking)
pezframe_support::migrations::RemovePallet<
StakingPalletName,
<Runtime as pezframe_system::Config>::DbWeight,
>,
pezframe_support::migrations::RemovePallet<
FastUnstakePalletName,
<Runtime as pezframe_system::Config>::DbWeight,
>,
pezframe_support::migrations::RemovePallet<
VoterBagsListPalletName,
<Runtime as pezframe_system::Config>::DbWeight,
>,
);
}