Beem 0.19.52 - calculation error in vests_to_rshares

in #utopian-io6 years ago

Project Information

Expected behavior

The vests_to_rshares function of the beem.steem module should return the number of rshares a vote by an account dependent on the vests and the voting power the account has, and the vote percentage that account uses for voting.

Actual behavior

Instead, that function returns the rshares that it should return, but 1e6 times smaller. This issue happens because the vests would need to be multiplied with 1e6 in order to be in the right scope for the calculation (relevant tutorial) This would need to be added here.

How to reproduce

  1. from beem.steem import Steem
  2. Get a Steem() instance. (e.g. stm = Steem())
  3. Run the vests_to_rshares function on any number of vests. (e.g. stm.vests_to_rshares(10000000))
  4. Transform the value point 2. returned to SBD using the rshares_to_sbd function. (e.g. stm.rshares_to_sbd(200000))
  5. Run the vests_to_sbd function on the same number of vests as before. (e.g. stm.vests_to_sbd(10000000))
  6. Compare the two values you got in point 3. and 4., and see that the one you got in point 3 is 1e6 times smaller than the other one.

It looks like this in a REPL:

>>> from beem.steem import Steem
>>> stm = Steem()
>>> stm.vests_to_rshares(10000000)
200000

^This is where the issue is. That should be 200000000000 instead

>>> stm.rshares_to_sbd(200000)
3.3005542087518333e-07
>>> stm.vests_to_sbd(10000000)
0.33005542087518336

After applying a fix, it would look like that:

>>> from beem.steem import Steem
>>> stm = Steem()
>>> stm.vests_to_rshares(10000000)
200000000000
>>> stm.rshares_to_sbd(200000000000)
0.33005542087518336
>>> stm.vests_to_sbd(10000000)
0.33005542087518336
  • beem version: 0.19.52
  • Operating system: Windows 10

I provided this issue on GitHub right here, and opened a pull request while opening the issue as well. My fix was merged, and is already live in version 0.19.53

GitHub Account

https://github.com/flugschwein

Sort:  

Hi @flugschwein, thanks for making this contribution.

Going through the issue on github, I could see your pull request was accepted and merged to the master branch, which is a great thing. Relieves the PO the time and stress, good job.

  • The steps you provided, contain sufficient detail to guide the reader through reproduction
  • The expected and actual behaviors have just the right detail needed by the PO or any tester to notice the contrasting result in vests_to_rshares calculation. It was helpful of you to have included a link to the "helpful tutorial".

Thanks again for the contribution. It adds significant value to the open source community. I look forward to your next report.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @fego!

So far this week you've reviewed 1 contributions. Keep up the good work!

Hi,

can you suggest any good beem tutorials?

Kind regards

The Secret Service

The beem documentation is a pretty good starting point. Other than that, @emrebeyler made a few tutorials some time ago...
If you encounter issues, you can also come into the beem discord and ask for help there. :D

Congratulations @flugschwein! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments received

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Hey @flugschwein
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.21
TRX 0.20
JST 0.034
BTC 98129.50
ETH 3322.67
USDT 1.00
SBD 3.05