-
Notifications
You must be signed in to change notification settings - Fork 91
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
Conversation
if (runtimeConfig?.staking) { | ||
stakingBond = BigInt(runtimeConfig.staking.stakers[0][2]); |
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.
if the staking genesis is set but with an empty vec of stakers (which is totally OK), accessing stakers[0][2]
would panic.
stakingBond = BigInt(0); | ||
for (const staker in runtimeConfig.staking.stakers) { | ||
stakingBond += BigInt(runtimeConfig.staking.stakers[staker][2]); | ||
} | ||
|
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.
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!
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.