Skip to content

Few fixes to KAH Staking Configs + Preliminary PAH Configs#907

Merged
kianenigma merged 18 commits intooty-dev-asset-hub-migration-2506from
kiz-polkadot-ahm-configs
Sep 15, 2025
Merged

Few fixes to KAH Staking Configs + Preliminary PAH Configs#907
kianenigma merged 18 commits intooty-dev-asset-hub-migration-2506from
kiz-polkadot-ahm-configs

Conversation

@kianenigma
Copy link
Copy Markdown
Contributor

Would be happy to approve the base branch after this.

//
// After which this limit can be increased again.
pallet_staking_async::ValidatorCount::<Runtime>::put(2500);
pallet_staking_async::MaxValidatorsCount::<Runtime>::put(2500);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man, this would have been a bad mistake 🙈 @Ank4n @sigurpol

/// warning event in case an era is longer than this amount.
///
/// Under normal conditions, this upper bound is never needed, and eras would be 24h each exactly. Yet, since this is the first deployment of pallet-staking-async, there might be misconfiguration, so we allow up to 12h more in each era.
pub const MaxEraDuration: u64 = 36 * (1000 * 60 * 60);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sanity check plz

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the rationale of having 3h extra on Kusama and 12h here? Just a reasonable buffer and no more than that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is 1/2 of the corresponding era.

Actually I had a hard time deciding this, because MaxEraDuration is doing two things:

  • Cap the inflation by this amount
  • Emit an event

Ideally, I wanted to have two different values:

  • expected_era_duration + small_epsilon should emit the event that something is wrong
  • expected_era_duration + large_buffer should be the cap for inflation.

So for example if we have a bug and an era is 3 days long, we still inflate in accordance to 3 days, but emit events.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity checked this. Here are two consecutive eras in Polkadot RC:

{
  index: 1,927
  start: 1,757,518,578,001
}
{
  index: 1,928
  start: 1,757,604,978,001
}

The diff is 86400000. Which is exactly 24 * 1000 * 60 * 60.

So our value here is fine.

// https://kusama.subscan.io/account/FyrGiYDGVxg5UUpN3qR5nxKGMxCe5Ddfkb3BXjxybG6j8gX
let acc = hex_literal::hex!(
"bea06e6ad606b2a80822a72aaae84a9a80bec27f1beef1880ad4970b72227601"
"96a6df31a112d610277c818fd9a8443d265fb5ab83cba47c5e89cff16cf9e011"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you have double-checked with our devops friends that this is the one we are going to use, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, I checked again the ones in devops, and they have more funds + the old miner keys likely have more compromised seed accounts, as they have been in use for many years, so I reverted back to using the parity-controlled accounts

/// warning event in case an era is longer than this amount.
///
/// Under normal conditions, this upper bound is never needed, and eras would be 24h each exactly. Yet, since this is the first deployment of pallet-staking-async, there might be misconfiguration, so we allow up to 12h more in each era.
pub const MaxEraDuration: u64 = 36 * (1000 * 60 * 60);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the rationale of having 3h extra on Kusama and 12h here? Just a reasonable buffer and no more than that?

// leave plenty of time for solution mining and submission.
parameter_types! {
// alias for the ones backed by parameters-pallet.
pub MaxSignedSubmissions: u32 = dynamic_params::staking_election::MaxSignedSubmissions::get();
Copy link
Copy Markdown
Member

@ggwpez ggwpez Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm do you think these gets will be re-evaluated every time or it will just use the default value?
I dont think we tested this before?

But you can just do a use dynamic_params::staking_election::MaxSignedSubmissions; to have it handy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah, what I am doing here is kinda stupid code-wise, I am optimizing for being able to read all parameters in one place. I will change it, use makes sense.


impl frame_support::traits::OnRuntimeUpgrade for InitiateStakingAsync {
fn on_runtime_upgrade() -> Weight {
if Self::needs_init() {
Copy link
Copy Markdown
Member

@ggwpez ggwpez Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if Self::needs_init() {
if !Self::needs_init() {
return;

Nit for less indentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, fixed.

let minimum_score = sp_npos_elections::ElectionScore {
minimal_stake: 8474057820699941,
sum_stake: 3276970719352749444,
sum_stake_squared: 244059208045236715654727835467163294,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OT: These are basically our POW Parameters? But we have to fix lower bounds still it seems.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, it is the worst validator set that we accept.

Copy link
Copy Markdown
Member

@ggwpez ggwpez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one concern about the parameter_types wrapping the dynamic_params.

kianenigma and others added 2 commits September 12, 2025 18:33
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@kianenigma
Copy link
Copy Markdown
Contributor Author

Will be merged once CI runs one more time to check nothing major is broken

@kianenigma kianenigma merged commit 88f4aaf into oty-dev-asset-hub-migration-2506 Sep 15, 2025
40 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants