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

cmd, eth: fix floating point math for eth<=>wei conversions #1243

Merged
merged 3 commits into from
Dec 13, 2019

Conversation

kyriediculous
Copy link
Contributor

@kyriediculous kyriediculous commented Dec 4, 2019

What does this pull request do? Explain your changes. (required)

This PR attempts to fix floating point math rounding errors caused when depositing broadcasting funds with the CLI. To fix this we are no longer using floating point math but arbitrary-precision fixed-point decimal numbers instead (up to 2^31 decimals).

Specific updates (required)

  • removed eth.FromBaseUnit and eth.ToBaseUnit
  • added github.com/shopspring/decimal third-party library
  • introduce eth.WeiToEth(interface{}) decimal.Decimal and eth.EthToWei(interface{}) *big.Int

How did you test each of these updates (required)

Does this pull request close any open issues?
Fixes #1211

Checklist:

  • README and other documentation updated
  • Node runs in OSX and devenv
  • All tests in ./test.sh pass

cmd/livepeer_cli/wizard_ticketbroker.go Outdated Show resolved Hide resolved
cmd/livepeer_cli/wizard_ticketbroker.go Outdated Show resolved Hide resolved
eth/helpers.go Outdated Show resolved Hide resolved
eth/helpers.go Outdated Show resolved Hide resolved
eth/helpers.go Outdated Show resolved Hide resolved
eth/helpers.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved
eth/helpers.go Show resolved Hide resolved
eth/helpers.go Outdated Show resolved Hide resolved
eth/helpers.go Outdated Show resolved Hide resolved
@kyriediculous
Copy link
Contributor Author

submitted fixups, I'll reword the commit messages during rebase

cmd/livepeer_cli/wizard_ticketbroker.go Outdated Show resolved Hide resolved
go.sum Show resolved Hide resolved
cmd/livepeer_cli/wizard.go Show resolved Hide resolved
Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! Let's rebase

@kyriediculous
Copy link
Contributor Author

kyriediculous commented Dec 13, 2019 via email

Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@kyriediculous kyriediculous merged commit dc878b5 into master Dec 13, 2019
@kyriediculous kyriediculous deleted the nv/float-fix branch December 13, 2019 17:01
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

Successfully merging this pull request may close these issues.

livepeer_cli taking more than requested for reserve when calling fundDepositAndReserve
2 participants