-
Notifications
You must be signed in to change notification settings - Fork 147
[AHM] Final Staking Configs for Kusama #883
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
Changes from 7 commits
39f91be
ccf10b3
0678d32
604c8c3
575cb4f
2e31953
c78913c
46ad2b1
f7e9de7
7999deb
fcbd0ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,8 +121,8 @@ pub use sp_runtime::BuildStorage; | |
| use sp_runtime::{ | ||
| generic, impl_opaque_keys, | ||
| traits::{ | ||
| AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Get, | ||
| IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion, Saturating, Verify, | ||
| AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, | ||
| Get, IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion, Saturating, Verify, | ||
| }, | ||
| transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity}, | ||
| ApplyExtrinsicResult, FixedU128, KeyTypeId, OpaqueValue, Perbill, Percent, Permill, | ||
|
|
@@ -485,6 +485,7 @@ impl pallet_timestamp::Config for Runtime { | |
|
|
||
| impl pallet_authorship::Config for Runtime { | ||
| type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>; | ||
| // Era points are now reported to ah-client, to be sent to AH on next session. | ||
| type EventHandler = StakingAhClient; | ||
| } | ||
|
|
||
|
|
@@ -510,6 +511,8 @@ impl pallet_session::Config for Runtime { | |
| type ValidatorIdOf = ConvertInto; | ||
| type ShouldEndSession = Babe; | ||
| type NextSessionRotation = Babe; | ||
| // Sessions are now managed by the staking-ah client, giving us validator sets, and sending | ||
| // session report. | ||
| type SessionManager = session_historical::NoteHistoricalRoot<Self, StakingAhClient>; | ||
| type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders; | ||
| type Keys = SessionKeys; | ||
|
|
@@ -522,6 +525,10 @@ impl pallet_session::Config for Runtime { | |
|
|
||
| impl pallet_session::historical::Config for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| // Note: while the identification of each validators for historical reasons is still an | ||
| // exposure, we actually don't need this data, and `DefaultExposureOf` always uses | ||
| // `Default::default`. Retaining this type + keeping a default value is only for historical | ||
| // reasons and backwards compatibility. | ||
| type FullIdentification = pallet_staking::Exposure<AccountId, Balance>; | ||
| type FullIdentificationOf = pallet_staking::DefaultExposureOf<Runtime>; | ||
| } | ||
|
|
@@ -803,7 +810,7 @@ impl pallet_staking::EraPayout<Balance> for EraPayout { | |
|
|
||
| let params = relay_common::EraPayoutParams { | ||
| total_staked, | ||
| total_stakable: 0, // TODO: double check | ||
| total_stakable: Balances::total_issuance(), | ||
| ideal_stake: dynamic_params::inflation::IdealStake::get(), | ||
| max_annual_inflation: dynamic_params::inflation::MaxInflation::get(), | ||
| min_annual_inflation: dynamic_params::inflation::MinInflation::get(), | ||
|
|
@@ -1030,6 +1037,8 @@ impl pallet_child_bounties::Config for Runtime { | |
| impl pallet_offences::Config for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>; | ||
| // Offences are now reported to ah-client, to be forwarded to AH, after potentially disabling | ||
| // validators. | ||
| type OnOffenceHandler = StakingAhClient; | ||
| } | ||
|
|
||
|
|
@@ -1340,8 +1349,7 @@ impl InstanceFilter<RuntimeCall> for TransparentProxyType { | |
| matches!( | ||
| c, | ||
| RuntimeCall::Staking(..) | | ||
| RuntimeCall::Session(..) | | ||
| RuntimeCall::Utility(..) | | ||
| RuntimeCall::Session(..) | RuntimeCall::Utility(..) | | ||
| RuntimeCall::FastUnstake(..) | | ||
| RuntimeCall::VoterList(..) | | ||
| RuntimeCall::NominationPools(..) | ||
|
|
@@ -1426,6 +1434,7 @@ impl parachains_session_info::Config for Runtime { | |
| impl parachains_inclusion::Config for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| type DisputesHandler = ParasDisputes; | ||
| // parachain consensus points are now reported to ah-client, to be sent to AH on next session. | ||
| type RewardValidators = | ||
| parachains_reward_points::RewardValidatorsWithEraPoints<Runtime, StakingAhClient>; | ||
| type MessageQueue = MessageQueue; | ||
|
|
@@ -1712,6 +1721,8 @@ impl pallet_nomination_pools::Config for Runtime { | |
| parameter_types! { | ||
| pub const DelegatedStakingPalletId: PalletId = PalletId(*b"py/dlstk"); | ||
| pub const SlashRewardFraction: Perbill = Perbill::from_percent(1); | ||
| // Kusama always wants 1000 validators, we reject anything smaller than that. | ||
| pub storage MinimumValidatorSetSize: u32 = 1000; | ||
| } | ||
|
|
||
| impl pallet_delegated_staking::Config for Runtime { | ||
|
|
@@ -1732,9 +1743,10 @@ impl pallet_staking_async_ah_client::Config for Runtime { | |
| type AdminOrigin = EnsureRoot<AccountId>; | ||
| type SessionInterface = Self; | ||
| type SendToAssetHub = StakingXcmToAssetHub; | ||
| type MinimumValidatorSetSize = ConstU32<400>; | ||
| type MinimumValidatorSetSize = MinimumValidatorSetSize; | ||
| type UnixTime = Timestamp; | ||
| type PointsPerBlock = ConstU32<20>; | ||
| // TODO @kianenigma | ||
| type MaxOffenceBatchSize = ConstU32<50>; | ||
|
||
| type Fallback = Staking; | ||
| type WeightInfo = pallet_staking_async_ah_client::weights::SubstrateWeight<Runtime>; | ||
|
|
@@ -1762,6 +1774,7 @@ impl frame_support::traits::EnsureOrigin<RuntimeOrigin> for EnsureAssetHub { | |
|
|
||
| #[derive(Encode, Decode)] | ||
| enum AssetHubRuntimePallets<AccountId> { | ||
| // index of the rc-client pallet in ksm-ah. | ||
| #[codec(index = 84)] | ||
| RcClient(RcClientCalls<AccountId>), | ||
| } | ||
|
|
@@ -1802,12 +1815,12 @@ impl pallet_staking_async_ah_client::SendToAssetHub for StakingXcmToAssetHub { | |
| fn relay_session_report( | ||
| session_report: pallet_staking_async_rc_client::SessionReport<Self::AccountId>, | ||
| ) { | ||
| pallet_staking_async_rc_client::XCMSender::< | ||
| xcm_config::XcmRouter, | ||
| AssetHubLocation, | ||
| pallet_staking_async_rc_client::SessionReport<AccountId>, | ||
| SessionReportToXcm, | ||
| >::split_then_send(session_report, Some(8)); | ||
| // TODO: after https://github.com/paritytech/polkadot-sdk/pull/9619, use `XCMSender::send` and handle error | ||
| let message = SessionReportToXcm::convert(session_report); | ||
| let dest = AssetHubLocation::get(); | ||
| let _ = xcm::prelude::send_xcm::<xcm_config::XcmRouter>(dest, message).inspect_err(|err| { | ||
| log::error!(target: "runtime::ah-client", "Failed to send relay session report: {:?}", err); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is defensive or not?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't handle the error before paritytech/polkadot-sdk#9619 We might be able to merge it next week, let's see. |
||
| }); | ||
| } | ||
|
|
||
| fn relay_new_offence( | ||
|
|
@@ -1830,9 +1843,12 @@ impl pallet_staking_async_ah_client::SendToAssetHub for StakingXcmToAssetHub { | |
| .into(), | ||
| }, | ||
| ]); | ||
| if let Err(err) = send_xcm::<xcm_config::XcmRouter>(AssetHubLocation::get(), message) { | ||
| log::error!(target: "runtime::ah-client", "Failed to send relay offence message: {:?}", err); | ||
| } | ||
| // TODO: after https://github.com/paritytech/polkadot-sdk/pull/9619, use `XCMSender::send` and handle error | ||
| let _ = send_xcm::<xcm_config::XcmRouter>(AssetHubLocation::get(), message).inspect_err( | ||
| |err| { | ||
| log::error!(target: "runtime::ah-client", "Failed to send relay offence message: {:?}", err); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't handle the error before paritytech/polkadot-sdk#9619 We might be able to merge it next week, let's see. |
||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2005,6 +2021,7 @@ construct_runtime! { | |
| // Staking extension for delegation | ||
| DelegatedStaking: pallet_delegated_staking = 47, | ||
|
|
||
| // staking client to communicate with AH. | ||
| StakingAhClient: pallet_staking_async_ah_client = 48, | ||
|
|
||
| // Parachains pallets. Start indices at 50 to leave room. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ fn asset_hub_kusama_genesis( | |
| }, | ||
| "staking": { | ||
| "validatorCount": 1000, | ||
| "devStakers": Some((2_000, 25_000)), | ||
| "devStakers": Some((4_000, 15_000)), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had some TODO in a checklist for you to set some Genesis config values for Kusama, is this it? Can i Check that off?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this is correct now and no benchmarks shoulf fail. |
||
| }, | ||
| "foreignAssets": ForeignAssetsConfig { | ||
| assets: foreign_assets | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -92,10 +92,10 @@ use sp_runtime::{ | |||||||
| generic, impl_opaque_keys, | ||||||||
| traits::{ | ||||||||
| AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertInto, | ||||||||
| Verify, | ||||||||
| Get, Verify, | ||||||||
| }, | ||||||||
| transaction_validity::{TransactionSource, TransactionValidity}, | ||||||||
| ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug, | ||||||||
| ApplyExtrinsicResult, Perbill, Permill, Perquintill, RuntimeDebug, | ||||||||
| }; | ||||||||
| #[cfg(feature = "std")] | ||||||||
| use sp_version::NativeVersion; | ||||||||
|
|
@@ -661,8 +661,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |||||||
| RuntimeCall::Utility { .. } | | ||||||||
| RuntimeCall::Multisig { .. } | | ||||||||
| RuntimeCall::NftFractionalization { .. } | | ||||||||
| RuntimeCall::Nfts { .. } | | ||||||||
| RuntimeCall::Uniques { .. } | ||||||||
| RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } | ||||||||
| ) | ||||||||
| }, | ||||||||
| ProxyType::AssetOwner => matches!( | ||||||||
|
|
@@ -750,8 +749,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |||||||
| matches!( | ||||||||
| c, | ||||||||
| RuntimeCall::Staking(..) | | ||||||||
| RuntimeCall::Session(..) | | ||||||||
| RuntimeCall::Utility(..) | | ||||||||
| RuntimeCall::Session(..) | RuntimeCall::Utility(..) | | ||||||||
| RuntimeCall::NominationPools(..) | | ||||||||
| RuntimeCall::VoterList(..) | ||||||||
| ) | ||||||||
|
|
@@ -1345,6 +1343,8 @@ impl EnsureOriginWithArg<RuntimeOrigin, RuntimeParametersKey> for DynamicParamet | |||||||
| use crate::RuntimeParametersKey::*; | ||||||||
|
|
||||||||
| match key { | ||||||||
| // TODO: @kianenigma/!bkontur - do we want to allow StakingAdmin here? | ||||||||
| Inflation(_) => frame_system::ensure_root(origin.clone()), | ||||||||
|
||||||||
| // TODO: @kianenigma/!bkontur - do we want to allow StakingAdmin here? | |
| Inflation(_) => frame_system::ensure_root(origin.clone()), | |
| Inflation(_) => frame_system::ensure_root(origin.clone()), |
I think root is okay, there should only be changes needed to this rarely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, inflation should be root-only, will fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if you saw Gavs recent interview, but he basically argued that Inflation is not the right terminology, but rather Interest or Issuance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted and fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed to begin with? some benchmarks fail without it? I though the default for MinInflation is already defined above in all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed to begin with? some benchmarks fail without it? I though the default for
MinInflationis already defined above in all cases.
I don't know, this impl Default is kind of confusing, but something on the way requires that.
I just copy this according to actual relay/kusama: https://github.com/polkadot-fellows/runtimes/blob/main/relay/kusama/src/lib.rs#L753-L756
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmarks have a where bound for RuntimeParameters: Default. So you just return any variant, does not matter which. Otherwise the benchmark would have no way to construct this opaque type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this used to be Nis total issuance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, and NIS is not part of KAH anymore. Balances TI is the right alternative, and what we have been using in Polkadot all the while.