-
Notifications
You must be signed in to change notification settings - Fork 2.6k
used MaxUnlockingChunks from config #12289
used MaxUnlockingChunks from config #12289
Conversation
Solved issue #12227 |
Please follow this syntax to close the linked issue https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword. |
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.
You should document in the config type parameter that if this value is ever set, and then decreased, it leads to a corrupt state and a migration is needed. We also need a test to demonstrate this.
@Ank4n please note that we have the same story with MaxNominations
as well.
closes #12227 |
@MrishoLukamba Can you also add a test that documents what happens in the scenario where MaxUnlockingChunks is reduced without migration? |
Okey let me get into it, if anything I will ask |
@Ank4n @kianenigma There is an issue which I noticed, StakingLedger.staking BoundedVec does not push new object (UnlockingChunks) instead it just increments the value inside UnlockingChunks. So the MaxUnlockingChunks bound in boundedVec is not quite useful, |
Can you elaborate more? May be refer in the code. I see that when we unbond, a new UnlockChunk is pushed (or UnlockChunk for same era updated). |
In the code it shows that,a new UnlockChunk is being pushed but in testing it is not pushed it is just updated the value field. So the bound MaxUnlockChunk placed there is not used at all. You can see in the new test i've added |
@MrishoLukamba The behaviour looks correct to me. An @kianenigma Shouldn't we be able to keep the |
frame/staking/src/tests.rs
Outdated
@@ -1346,7 +1346,8 @@ fn too_many_unbond_calls_should_not_work() { | |||
ExtBuilder::default().build_and_execute(|| { | |||
let mut current_era = 0; | |||
// locked at era MaxUnlockingChunks - 1 until 3 | |||
for i in 0..MaxUnlockingChunks::get() - 1 { | |||
//maxunlockingchunks |
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.
//maxunlockingchunks |
frame/staking/src/tests.rs
Outdated
@@ -1346,7 +1346,8 @@ fn too_many_unbond_calls_should_not_work() { | |||
ExtBuilder::default().build_and_execute(|| { | |||
let mut current_era = 0; | |||
// locked at era MaxUnlockingChunks - 1 until 3 | |||
for i in 0..MaxUnlockingChunks::get() - 1 { | |||
//maxunlockingchunks | |||
for i in 0..<<Test as Config>::MaxUnlockingChunks as Get::<u32>>::get()- 1 { |
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.
for i in 0..<<Test as Config>::MaxUnlockingChunks as Get::<u32>>::get()- 1 { | |
for i in 0..<<Test as Config>::MaxUnlockingChunks as Get<u32>>::get()-1 { |
frame/staking/src/tests.rs
Outdated
@@ -1361,7 +1362,8 @@ fn too_many_unbond_calls_should_not_work() { | |||
assert_ok!(Staking::unbond(RuntimeOrigin::signed(10), 1)); | |||
assert_eq!( | |||
Staking::ledger(&10).unwrap().unlocking.len(), | |||
MaxUnlockingChunks::get() as usize | |||
|
|||
<<Test as Config>::MaxUnlockingChunks as Get::<u32>>::get() as usize |
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.
<<Test as Config>::MaxUnlockingChunks as Get::<u32>>::get() as usize | |
<<Test as Config>::MaxUnlockingChunks as Get<u32>>::get() as usize |
frame/staking/src/tests.rs
Outdated
//Concern is on validators only | ||
//By Default 11, 10 are stash and ctrl and 21,20 |
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.
//Concern is on validators only | |
//By Default 11, 10 are stash and ctrl and 21,20 | |
// Concern is on validators only | |
// By Default 11, 10 are stash and ctrl and 21,20 |
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.
Please fix all comments accordingly.
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.
Logic seems correct, but code needs to be formatted.
Done, and should i use cargo fmt? |
@MrishoLukamba I will close this PR and work on top of your code to get it merged. Pls add your Polkadot address in the PR for the tip. Super thanks for your contribution. Feel free to follow the new PR here: #12343 |
Thanks, will also continue contributing on other issues. |
/tip small |
@Ank4n You are not allowed to request a tip. Only shawntabrizi, gavofyork, rphmeier, athei, andresilva, arkpar, bkchr, eskimor, drahnr, dvdplm, robbepop, cmichi, tomaka, pepyakin, tomusdrw, kianenigma, jacogr, rossbulat are allowed. |
/tip small |
@kianenigma A small tip was successfully submitted for MrishoLukamba (133WyzJ4cEEbQ4twhT3nQpoXYeTCzeKn8kWfRfEi4XDF7wKh on polkadot). https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.polkadot.io#/treasury/tips |
Sorry @kianenigma @Ank4n https://polkadot.js.org/apps/#/treasury/tips, the tip didnt go through |
@kianenigma @ggwpez
Fixes #12227
Polkadot address: 133WyzJ4cEEbQ4twhT3nQpoXYeTCzeKn8kWfRfEi4XDF7wKh