Skip to content
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

Fixes clearAuthorities in chainspec when staking genesis is defined #1711

Merged
merged 5 commits into from
Feb 6, 2024

Conversation

gpestana
Copy link
Contributor

This PR fixes the clearAuthorities operation in chainspec when staking genesis is defined. I'm not 100% sure if the fix is correct, but at least is does not break when the staking pallet has some genesis configs defined as before.

if (runtimeConfig?.staking) {
stakingBond = BigInt(runtimeConfig.staking.stakers[0][2]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the staking genesis is set but with an empty vec of stakers (which is totally OK), accessing stakers[0][2] would panic.

Comment on lines 79 to 83
stakingBond = BigInt(0);
for (const staker in runtimeConfig.staking.stakers) {
stakingBond += BigInt(runtimeConfig.staking.stakers[staker][2]);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
stakingBond = BigInt(0);
for (const staker in runtimeConfig.staking.stakers) {
stakingBond += BigInt(runtimeConfig.staking.stakers[staker][2]);
}
if ( runtimeConfig.staking.stakers[0] ) stakingBond = BigInt(runtimeConfig.staking.stakers[0][2]);

Hi @gpestana, in the current code we only use the value of the first staker for adding the nodes later (without add them). Something like this should work and we can change the first if condition to make the code more clean.
Thx!

@pepoviola pepoviola merged commit 7632580 into main Feb 6, 2024
23 checks passed
@pepoviola pepoviola deleted the gpestana/staking-chainspec-fix branch February 6, 2024 12:50
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