Skip to content

Conversation

kianenigma
Copy link
Contributor

No description provided.

@bkontur
Copy link
Contributor

bkontur commented Sep 4, 2025

pallet_election_provider_multi_block::signed pallet_election_provider_multi_block::unsigned pallet_election_provider_multi_block::verifier

I think it should be:

pallet_election_provider_multi_block_verifier pallet_election_provider_multi_block_unsigned pallet_election_provider_multi_block_signed

according to the setup:

		[pallet_election_provider_multi_block_verifier, MultiBlockElectionVerifier]
		[pallet_election_provider_multi_block_unsigned, MultiBlockElectionUnsigned]
		[pallet_election_provider_multi_block_signed, MultiBlockElectionSigned]

@kianenigma
Copy link
Contributor Author

/cmd bench --runtime asset-hub-kusama --pallet pallet_election_provider_multi_block pallet_election_provider_multi_block_signed pallet_election_provider_multi_block_unsigned pallet_election_provider_multi_block_verifier pallet_staking_async --clean

@github-actions github-actions bot deleted a comment from kianenigma Sep 4, 2025
@bkontur
Copy link
Contributor

bkontur commented Sep 5, 2025

/cmd bench --runtime asset-hub-kusama --pallet pallet_election_provider_multi_block pallet_election_provider_multi_block_signed pallet_election_provider_multi_block_unsigned pallet_election_provider_multi_block_verifier pallet_staking_async --clean

Copy link

github-actions bot commented Sep 5, 2025

Command "bench --runtime asset-hub-kusama --pallet pallet_election_provider_multi_block pallet_election_provider_multi_block_signed pallet_election_provider_multi_block_unsigned pallet_election_provider_multi_block_verifier pallet_staking_async --clean" has started 🚀 See logs here

RuntimeParameters::Treasury(dynamic_params::treasury::Parameters::BurnPortion(
dynamic_params::treasury::BurnPortion,
Some(Permill::from_percent(0)),
// TODO: @kianenigma/!bkontur - is this ok?
Copy link
Contributor Author

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.

Copy link
Contributor

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.

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

Copy link
Member

@ggwpez ggwpez Sep 5, 2025

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.

type UnixTime = Timestamp;
type PointsPerBlock = ConstU32<20>;
// TODO @kianenigma
type MaxOffenceBatchSize = ConstU32<50>;
Copy link
Member

Choose a reason for hiding this comment

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

.

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);
Copy link
Member

Choose a reason for hiding this comment

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

This is defensive or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

// 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);
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

@@ -69,7 +69,7 @@ fn asset_hub_kusama_genesis(
},
"staking": {
"validatorCount": 1000,
"devStakers": Some((2_000, 25_000)),
"devStakers": Some((4_000, 15_000)),
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this is correct now and no benchmarks shoulf fail.

/// Parameters used to calculate staking era payouts.
#[dynamic_pallet_params]
#[codec(index = 0)]
pub mod inflation {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

noted and fixed.

Comment on lines 1346 to 1347
// TODO: @kianenigma/!bkontur - do we want to allow StakingAdmin here?
Inflation(_) => frame_system::ensure_root(origin.clone()),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// 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.

Copy link
Contributor Author

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.

// NOTES:
// * a lot of the parameters are defined as `storage` such that they can be upgraded with a smaller
// overhead by the root origin, as opposed to a code upgrade. We expect to remove them. If all
// goes well in Kusama AHM, we can stop using `storage` in Polkadot.
Copy link
Member

Choose a reason for hiding this comment

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

They could also be in the parameter pallet

/// At the time of writing, Kusama has 1000 active validators, and ~2k validator candidates.
///
/// Safety note: This increases the weight of `on_initialize_into_snapshot_msp` weight. Double check TODO @kianenigma.
pub storage TargetSnapshotPerBlock: u32 = 3000;
Copy link
Member

Choose a reason for hiding this comment

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

.

5
} else {
if matches!(
pallet_ah_migrator::AhMigrationStage::<Runtime>::get(),
Copy link
Member

@ggwpez ggwpez Sep 5, 2025

Choose a reason for hiding this comment

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

Suggested change
pallet_ah_migrator::AhMigrationStage::<Runtime>::get(),
pallet_ah_migrator::AhMigrationStage::<Runtime>::get().is_finished()

There should be a function like this, but it would do the same.

use crate::dynamic_params;

// TODO @kianenigma one sanity check test for this as we had in the RC
let params = polkadot_runtime_common::impls::EraPayoutParams {
Copy link
Member

Choose a reason for hiding this comment

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

yes please

/// confused in case AH block times change. Ideally, this value should be updated alongside AH's
/// block time. If AH blocks progress faster, our eras will become shorter, which is not a
/// critical issue.
pub const RelaySessionDuration: BlockNumber = 1 * HOURS;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub const RelaySessionDuration: BlockNumber = 1 * HOURS;
pub const RelaySessionDuration: BlockNumber = 1 * RC_HOURS;

Or some renamed import to distinguish please.

for InitiateStakingAsync<EXPECTED_SPEC>
{
fn on_runtime_upgrade() -> Weight {
if crate::VERSION.spec_version == EXPECTED_SPEC {
Copy link
Member

Choose a reason for hiding this comment

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

These spec migrations have gone wrong so many time 🙈, would be happy if we can avoid it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough :D

let minimum_score = sp_npos_elections::ElectionScore {
minimal_stake: 2957640724907066,
sum_stake: 3471819933857856584,
sum_stake_squared: 78133097080615021100202963085417458,
Copy link
Member

Choose a reason for hiding this comment

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

So this value should be larger than recent election sum_stake_squared? Recent election event here https://kusama.subscan.io/event/29967817-0 looks like about 2^115.7, whereas the value here is 2^115.9.

Just asking since i thought this should be a lower bound.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, this value should be larger. The reason being that the lower this value, the better the election is (smaller variance). So the the "lower bound (aka. worst bound)" in this case is a larger value.

use super::*;

// TODO: @kianenigma
mod message_sizes {
Copy link
Member

@ggwpez ggwpez Sep 5, 2025

Choose a reason for hiding this comment

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

and more TODOs below

@@ -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(),
Copy link
Contributor

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

Copy link
Contributor Author

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.

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Copy link

github-actions bot commented Sep 5, 2025

Command "bench --runtime asset-hub-kusama --pallet pallet_election_provider_multi_block pallet_election_provider_multi_block_signed pallet_election_provider_multi_block_unsigned pallet_election_provider_multi_block_verifier pallet_staking_async --clean" has failed ❌! See logs here

@ggwpez
Copy link
Member

ggwpez commented Sep 6, 2025

We should benchmark on top of this #856

@ggwpez ggwpez merged commit 71ace0f into oty-dev-asset-hub-migration-2506 Sep 6, 2025
45 of 46 checks passed
@bkontur
Copy link
Contributor

bkontur commented Sep 6, 2025

We should benchmark on top of this #856

Ok, I started new PR#887 for AHM weights and I started with this ones for staking, because they took cca 14-15 hours

kianenigma added a commit that referenced this pull request Sep 10, 2025
Follow up to #883, addressing some review comments. 

- Inflation -> Issuance rename 
- More use of parameters pallet for scheduler, MQ, and staking elections
- Migration to initialize staking-async is not reliant on spec version

---------

Co-authored-by: Oliver Tale-Yazdi <[email protected]>
@ggwpez ggwpez deleted the kiz-staking-ahm-kusama branch September 11, 2025 10:47
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.

4 participants