-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
R4R: remove rationals in endblock #1751
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1751 +/- ##
===========================================
- Coverage 63.46% 63.46% -0.01%
===========================================
Files 117 117
Lines 6922 6927 +5
===========================================
+ Hits 4393 4396 +3
- Misses 2274 2276 +2
Partials 255 255 |
x/stake/types/inflation_test.go
Outdated
@@ -82,41 +82,6 @@ func TestProcessProvisions(t *testing.T) { | |||
checkFinalPoolValues(t, pool, sdk.NewRat(initialTotalTokens), cumulativeExpProvs) | |||
} | |||
|
|||
// Benchmark precision | |||
func BenchmarkProcessProvisions10000(b *testing.B) { |
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.
Could this be easily adapted to just a benchmark of the inflation calculation? I think thats valuable, regardless of whether or not we're doing rational math.
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.
removed couldn't get the benchmarking to work as expected - should add benchmarks in a separate PR
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.
But yeah I mean the inflation calculation is within here, we could benchmark both, but honestly think it's probably enough to benchmark processing provisions because it's so tightly coupled with the inflation calculation (and is the higher level calculation)
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.
Sounds good! Thanks for looking into it!
inflationRateChangePerYear := sdk.OneRat().Sub(p.BondedRatio().Quo(params.GoalBonded)).Mul(params.InflationRateChange) | ||
inflationRateChangePerYear := sdk.OneRat(). | ||
Sub(p.BondedRatio().Round(precision). | ||
Quo(params.GoalBonded)). |
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.
Not super related, but we should benchmark if the order of quotient and multiplication affects performance. Such testing could be done in the rational package.
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.
utACK
If there are any edge cases (particular choices of inflation parameters) where this rounding leads to substantial divergence from the "pure" model, would be nice to document.
After thinking about it a bit more, I think the rational calculation actually makes a bunch of sense, we were just using outrageous precision, I drastically reduced the precision to acceptable amount as well as added rounding in all the appropriate places to improve performance.
Additionally, there was an unnecessary store read and write in the end-blocker which was isolated to it's required location.
closes #1743
docs/
)CHANGELOG.md
cmd/gaia
andexamples/
For Admin Use: