[steem][0.20.7-9] 14-week powerdown - powerdown can't finish in 13 weeks

Project Information

I reported the issue and made the fix and PR.

Expected behavior

Powerdown should finish in 13 weeks.

Actual behavior

Powerdown may take 14 weeks due to an error from the floor operation.

How to reproduce

  • Pick any amount of powerdown such that 1/13 of its VESTS isn't an integer.
  • Start powerdown.
  • Wait 13 weeks (This may be unrealistic, so see the Recording Of The Bug).
  • Check if there is any pending withdrawal.
  • steem version: 0.20.7-9 (but may applicable to earlier versions)
  • Browser/App version: Any
  • Operating system: Any

Recording Of The Bug

https://steemd.com/@ned Ned had finished the 13 week powerdown last week! But steemd says that Ned is still powering down.

Steemit also says that Ned's still powering down.

Cause and Fix

This bug is due to the floor operation in the calculation of weekly powerdown amount, as shown below.

https://github.com/steemit/steem/blob/c6b865b6f27999cba38f3840151c8306f14f3371/libraries/chain/steem_evaluator.cpp#L1157


Here is the Ned's 13 week powerdown that should have finished last week, 2019-01-17.

2019-01-17T23:09:06: 140713.254 STEEM 282571030.409516 VESTS
2019-01-10T23:09:06: 140658.536 STEEM 282571030.409516 VESTS
2019-01-03T23:09:06: 140603.702 STEEM 282571030.409516 VESTS
2018-12-27T23:09:06: 140548.951 STEEM 282571030.409516 VESTS
2018-12-20T23:09:06: 140494.342 STEEM 282571030.409516 VESTS
2018-12-13T23:09:06: 140439.801 STEEM 282571030.409516 VESTS
2018-12-06T23:09:06: 140385.066 STEEM 282571030.409516 VESTS
2018-11-29T23:09:06: 140330.198 STEEM 282571030.409516 VESTS
2018-11-22T23:09:06: 140275.269 STEEM 282571030.409516 VESTS
2018-11-15T23:09:06: 140221.320 STEEM 282571030.409516 VESTS
2018-11-08T23:09:06: 140168.509 STEEM 282571030.409516 VESTS
2018-11-01T23:09:06: 140115.866 STEEM 282571030.409516 VESTS
2018-10-25T23:09:06: 140063.249 STEEM 282571030.409516 VESTS
Total withdrawn: 1,825,018.063 STEEM
Total withdrawn: 3673423395.323708 VESTS
Total requested: 3673423395.323719 VESTS

Note that "3673423395.323719 VESTS" is actually in MVESTS so it is in fact 3673423395323719 VESTS (integer).

Thus, total requested vests/13 should be 3673423395323719/13 = 282571030409516.9xxx but 0.9xxx is discarded by the floor operation. And 282571030409516*13 = 3673423395323708 (not 3673423395323719), so 11 vests still needs to be powered down for 1 additional week.

Basically what we need is ceiling, which can be implemented without importing math library in my PR. For efficiency, I've also combined it with the existing code that prevents 0 weekly withdrawal.

GitHub Account

https://github.com/economicstudio

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
12 Comments