Uh oh!
There was an error while loading. Please reload this page.
Refactor CurrencyToVote - #6896
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /// A trait similar to `Convert` to convert values from `B` (i.e. the `Balance` type of the chain) | ||
| /// into u64, which is the standard numeric types used in election and other places where complex | ||
| /// calculation over balance type is needed. |
There was a problem hiding this comment.
Should the trait docs hint what to do with overflows? It seems that this might be a lossy conversion and it's not clear to me how to implement such trait for say U256 balance type just by looking at the trait definition.
There was a problem hiding this comment.
I think end of the day that depends on the chain's logic and their builders decision.
In other words, I cannot give them a definitive advise here of what to do :D so I will just leave it open.
Uh oh!
There was an error while loading. Please reload this page.
gui1117
left a comment
There was a problem hiding this comment.
implementation looks good to me
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
…/substrate into kiz-refactor-currency-to-vote
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
shawntabrizi
left a comment
There was a problem hiding this comment.
afaict looks good, although if anyone uses this new currency to vote in storage, bad things may happen. user discretion advised.
…actor-currency-to-vote
kianenigma
commented
Aug 21, 2020
I am being a bit conservative here with the audit request. The PR itself really only duplicates the previous code, in a nicer and more optimised way. Nonetheless, I think the old logic of |
kianenigma
commented
Sep 10, 2020
Keeping up to date; still needs an audit. |
bkchr
commented
Oct 1, 2020
Also needs a master merge :D |
kianenigma
commented
Oct 2, 2020
Should be first audited anyhow. Hopefully next week |
viniul
commented
Oct 7, 2020
We are done with our review for this PR and don't see any issues with it, lgtm! |
kianenigma
commented
Oct 7, 2020
I want to do another self review tomorrow and then we proceed with the merge. |
kianenigma
commented
Oct 8, 2020
bot merge |
ghost
commented
Oct 8, 2020
Trying merge. |
…up-updates * master: Async keystore + Authority-Discovery async/await (#7000) Fixes logging of target names with dashes (#7281) seal: Add automated weights for contract API calls (#7017) add ss58 id for nodle (#7279) Refactor CurrencyToVote (#6896) bump-allocator: document & poison (#7277) Reset flaming fir network (#7274) reschedule (#6860) Drop system cache for trie benchmarks (#7242) client: improve log formatting (#7272) Rework `InspectState` (#7271) SystemOrigin trait (#7226) Update ss58 registry for Dock network (#7263) .maintain/monitoring: Add alert when continuous task ends (#7250) Rename `TRANSACTION_VERSION` to `EXTRINSIC_VERSION` (#7258) Split block announce processing into two parts (#6958) Fix offchain election to respect the weight (#7215)
Both staking and elections-phragmen need
Type CurrencyToVotethat helps them convertT::Currency::Balanceinto u64. This values is then later on used for complex arithmetic where overflow might happen.This PR refactors this in a few ways:
Convertto a custom trait that acceptstotal_issuanceas parameter. This avoid all the numerous calls toT::Currency::TotalIssuance(). Indeed, these calls will be a hit in the overlay cache but still it will incur some overhead, given that we were calling it many many many times (i.e. once per nominator, multiple times -- this is the order).polkadot companion: paritytech/polkadot#1610