Skip to content

Apply CurrencyToVote scaling for correct stake weights - #8

Closed
sigurpol wants to merge 1 commit into
martinmsb:mainfrom
sigurpol:sigurpol-fix-scaling
Closed

sigurpol wants to merge 1 commit into
martinmsb:mainfrom
sigurpol:sigurpol-fix-scaling

Conversation

@sigurpol

Copy link
Copy Markdown
Contributor

Kusama/Polkadot use U128CurrencyToVote which scales stake based on total issuance: vote = stake / max(issuance/u64::MAX, 1). If total issuance exceeds u64::MAX, scaling factor > 1.

Previously the tool used stake.active directly, causing stake weight discrepancies on Kusama compared to on-chain snapshots.

Kusama/Polkadot use U128CurrencyToVote which scales stake based on
total issuance: vote = stake / max(issuance/u64::MAX, 1).
If total issuance exceeds u64::MAX, scaling factor > 1.

Previously the tool used stake.active directly, causing stake weight
discrepancies on Kusama compared to on-chain snapshots.
@sigurpol

Copy link
Copy Markdown
Contributor Author

an attempt to fix the issue, @martinmsb @filippoweb3

@filippoweb3

Copy link
Copy Markdown
Contributor

@sigurpol thank you for the suggestion. It seems these changes do not change the simulations, i.e. built snapshot shows the tiny differences in stake compared to the fetched one, and predictions using the fetched snapshot are still inaccurate

@sigurpol

Copy link
Copy Markdown
Contributor Author

Yeah I got it wrong, double checked and

  • Relay chain: type CurrencyToVote = U128CurrencyToVote (scales by issuance) => the old legacy staking
  • Asset Hub (parachain): type CurrencyToVote = SaturatingCurrencyToVote (ignores issuance, just saturates to u64)
    fn to_vote(value: B, _: B) -> u64 {
    value.unique_saturated_into() // ignores issuance!
    }

Dropping this PR

@sigurpol sigurpol closed this Jan 21, 2026
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.

2 participants