Beem: used power calculation may treat downvotes incorrectly
Project Information
- Repository: https://github.com/holgern/beem
- Project Name: Beem
- Publisher: @holger80
A GitHub issue was created: https://github.com/holgern/beem/issues/46
A PR to fix the bug has been accepted by the PO: https://github.com/holgern/beem/pull/47
Expected behavior
The used power
calculation via steem._calc_resulting_vote()
should handle both up- and downvotes in the same way and both should consume the same amount of voting power.
Actual behavior
Upvotes are handled correctly, but downvotes may give incorrect/different results in some cases.
How to reproduce
- Plotting the voting power over time using the example script provided with beem:
cd examples
python plot_vp_over_time.py crokkon
Output:
The voting power is partly shown with values above 100.
Another effect is that rshares_to_vote_pct()
may give different absolute vote percentages for up- and downvotes for the same absolute amount of rshares:
>>> s.rshares_to_vote_pct(1e12, vests=412125123351512)
1250
>>> s.rshares_to_vote_pct(-1e12, vests=412125123351512)
-1200
The reason is that steem._calc_resulting_vote()
treats the voting percentage as a signed value. A negative voting percentage (=flag/downvote) gives a negative used_power
, while this number has to be positive in any case. This value is subtracted from the previous voting power for plotting, eventually giving VP values > 100%.
Environment
- Python 3.6.5
- beem master at rev. 8d0e364
Thanks for the contribution.
I see its been closed by the PO cause you already provided a fix in a PR, which he accepted.
The post follows the set guidelines. Your explanation of the bug and the reason for it giving an incorrect or different result is very detailed. The PO would have had it easy(which is clearly the point) if you had not fixed it yourself.
Thanks again for the contribution, this adds value to the open source community. I look forward to your future reports.
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]
Hey @stmdev
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!