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

go-kosu: update scaling methods to be consistent #243

Merged
merged 7 commits into from Aug 29, 2019

go-kosu: update overflow check for consistency

  • Loading branch information
hrharder committed Aug 28, 2019
commit 9c82c0793c157109b3dbc13e4f4346d3a0fa770a
@@ -112,8 +112,8 @@ func scaleBalance(balance *big.Int) int64 {
ether.Exp(big.NewInt(10), big.NewInt(18), big.NewInt(0))
scaled.Div(balance, ether)

if scaled.IsInt64() {
return scaled.Int64()
if !scaled.IsInt64() {
return math.MaxInt64
This conversation was marked as resolved by gchaincl

This comment has been minimized.

Copy link
@gchaincl

gchaincl Aug 29, 2019

Contributor

what are the implications of this?

This comment has been minimized.

Copy link
@hrharder

hrharder Aug 29, 2019

Author Member

If someone has aquired a balance of Kosu (in full ether units) >= MaxInf64, they will just be given MaxInt64 power on the chain, rather than what they "should" get.

This is a highly unlikely edge case IMO, given the parameterization of our bonding curve. It will be very hard (essentially impossible) to ever get that many tokens.

}
return math.MaxInt64
return scaled.Int64()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.