-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
frame/support/src/traits.rs
Outdated
@@ -1664,6 +1665,70 @@ pub trait Instance: 'static { | |||
const PREFIX: &'static str ; | |||
} | |||
|
|||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
implementation looks good to me
Co-authored-by: Guillaume Thiolliere <[email protected]>
…/substrate into kiz-refactor-currency-to-vote
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.
lgtm
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.
lgtm % Gui's grumbles
…actor-currency-to-vote
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.
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
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 |
Keeping up to date; still needs an audit. |
Also needs a master merge :D |
Should be first audited anyhow. Hopefully next week |
We are done with our review for this PR and don't see any issues with it, lgtm! |
I want to do another self review tomorrow and then we proceed with the merge. |
…actor-currency-to-vote
bot merge |
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 CurrencyToVote
that helps them convertT::Currency::Balance
into u64. This values is then later on used for complex arithmetic where overflow might happen.This PR refactors this in a few ways:
Convert
to a custom trait that acceptstotal_issuance
as 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