-
Notifications
You must be signed in to change notification settings - Fork 170
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
Use uint32 instead of sdk.Dec #1107
Comments
Seems any storage benefits we get from using Also we'd need to write Overall, I don't think the storage changes are worth the extra boilerplate. Closing for now. |
Let's don't close the issue before discussing it.
|
I've created #1149 to demonstrate how this can be done. Exactly same thing can be applied for Convertion to Dec is easy and fast (as fast as converting sdk.Int) - I've created a helper method to that. |
Another motivation for this is to potentially switch sdk.Dec computation to General Decimal Arithmetic, which will provide more performance gains over sdk.Dec and configurable precision, without changing the state (so we can do updates in code, without a need to update the state). |
Some things to watch out for if we go through with this:
I think the long term benefit of being able to change our internal math types without modifying state is worth considering as well - but that benefit is only realized if we convert all our decimals in state, which I do not expect will happen. If there will inevitable be at least some |
We can lift that limitation, and change to 100'000'000% (100k times) which is more than enough. I created FixedBP type for 0-1 values. We can have another type: BP for 0-100k values. |
We can easily convert all params and token params from x/leverage to uint. We will need to continue using sdk.Dec for some internal operations, before a bigger Dec refactoring, without changing the state. I think the bigger question is if we want to use per-cent, per-mil or basis point. |
How about for a sequence of events:
Notably, this line will be omitted - proto and the generated
And a single This would eliminate the need for custom types and math functions while making the minimum future-minded changes to proto. |
OK for #1159 For the other part:
|
Disadvantages were
The |
I see this is an advantage. I added it to control the value range using the type system, which can be checked at compilation time. It's optional though.
This is neutral - we are already doing it with
You mean the new package? The |
I'm going to try to keep threads in the Issue rather than the PR, since there's some bouncing back and forth. The problem I had with #1149 is it was leaving the territory of minimum proto changes, and started creating the math for computations without Dec in general. Things like
These changes would need design discussion instead of going straight to code. For example, the current Also we would need to consider potential consequences of setting a field as To contrast, a minimal |
We will need to decide if we are going that route or not. |
Summary
For % values, we should use
uint32
rather thansdk.Dec
:Dec
is not even a part of the new cosmos-sdkmath
module.Ref: #1096 (comment)
For Admin Use
The text was updated successfully, but these errors were encountered: