Skip to content
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

Int64 overflow in Rational? #751

Closed
mossid opened this issue Mar 30, 2018 · 3 comments
Closed

Int64 overflow in Rational? #751

mossid opened this issue Mar 30, 2018 · 3 comments
Assignees

Comments

@mossid
Copy link
Contributor

mossid commented Mar 30, 2018

At line 71 of x/stake/tick.go:

inflation = pool.Inflation.Add(inflationRateChange)

Debugged variables value:

pool.Inflation: {Num:70008793 Denom:1000000000}
inflationRateChange: {Num:284048115403 Denom:32302968010554600}
inflation: {Num:1025127075753892381 Denom:-4851056627833949696}

Found while running tick_test.go

@cwgoes
Copy link
Contributor

cwgoes commented Mar 30, 2018

Possibly why the tests in #744 are failing, I'm seeing similar behaviour

mossid added a commit that referenced this issue Mar 30, 2018
@mossid
Copy link
Contributor Author

mossid commented Mar 30, 2018

ToRat at types/rational.go:127 calls big.Int.Int64() without overflow check

@rigelrozanski rigelrozanski self-assigned this Mar 30, 2018
@rigelrozanski
Copy link
Contributor

rigelrozanski commented Mar 30, 2018

Mhmm... good catch - this was introduced when modifying rational to be go-wire compliant (in a kind of hacky way of changing the Rat object to have a Num and Denom field instead just extending big.Rat) - unfortunately I think the real solution here is to wait for go-amino integration and then revert back to extending big.Rat - right now we just have to make sure that we use explicitly use the .Round() functionality... otherwise we should panic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants