Fix treasury kept and spend when emptied#3880
Conversation
| fn on_unbalanced(amount: NegativeImbalanceOf<T>) { | ||
| T::Currency::resolve_creating(&Self::account_id(), amount); | ||
| // Must resolve into existing but better be safe. | ||
| let _ = T::Currency::resolve_creating(&Self::account_id(), amount); |
There was a problem hiding this comment.
Now that we have better runtime logging I do get tempted to do something like resolve_exisiting().unwrap_or_else(|_| { log("CODE RED, SOS"); resolve_creating() ).
But I assume it depends on the proof. If it is logically impossible to cause account creation then this is also good.
There was a problem hiding this comment.
interesting indeed a lot of such safe operation could be logged 🤔
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
kianenigma
left a comment
There was a problem hiding this comment.
PR looks good already;
Maybe we can add a test case to make sure:
- Real pot (before subtracting ed) is always above ed even if more is requested to spend
- Integration test fo the proper creation of treasury account similar to what will happen in KSM
|
I would very suspect that treasury does exist already in kusama, but anyway it is fine. and I added both tests. another solution would be to lazily create the account if it happens that it doesn't exist but whatever is OK |
|
test are failing at least because of some CI issue, let's retry them |
kianenigma
left a comment
There was a problem hiding this comment.
Could use the suggestion for test otherwise LGTM and ready to merge.
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Fix #3879
Superseed #3797
Done:
TODO:
Alternatives:
Notes:
Also in case someone forget to include Config in construct runtime (thus account is not created) then this account can be created later as well.