[steem] 14 week powerdown bug fix

in #utopian-io5 years ago (edited)

Repository

https://github.com/steemit/steem

Issue: https://github.com/steemit/steem/issues/3237
Local PR: https://github.com/steemit/steem/pull/3238
Master PR: https://github.com/steemit/steem/pull/3292

The PR has been merged and waiting for HF21 :) While I contributed to many Steem related projects, I'm quite pleased, since this is my first contribution to the Steem blockchain core (except for the build doc fix :)

Thanks to mvandeberg and sgerbino for making test codes and merging!

Bug Fixes - 14 week powerdown bug

Powerdown may take 14 weeks (instead of 13 weeks) due to an error from the floor operation, and this fixes the problem.

Specifically this bug occurs to a user whose 1/13 of powerdown amount in vests isn't an integer.

Code

It's better to explain with an example.

Here is the Ned's 13 week powerdown that should have finished on 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

Sort:  
  • Good contribution to the Steem core and fixing the code to support the intent of the smart contract.
  • Article could have used an intro image and other images like in your git issue.
  • Code has no comment unfortunately.
  • Big congratulation on your persistence and getting code merged on Steem core repo.

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? Chat with us on Discord.

[utopian-moderator]

Regarding the comments, it think he was following the style of the steem code. Normally you don't see comments there to explain few lines.

Hi @jga! Thank you for defending me! @helo, thank you for reviewing too!

I usually include that kind of justifying argument in dev post (as an external contributor, i believe i should follow the PO's practice.), but I forgot this time.

I also didn't spend much time on making the post more detailed, but it seems quite important :) Since it's quite rare to make a contribution to the core, I honestly expected more, but this became my first dev post that got lower vote than idea post. lol! While it might have been better to give a second chance to improve (by a comment before the official review), that's fine. I'm still happy with the merging. Thanks!

Thank you for your review, @helo! Keep up the good work!

Korean: 사소하지만 파워다운과 관련된 버그라서 사소하지만은 않은 (마치 헤어컷에도 스달 1%나오는 버그처럼 돈 관련버그는 전 사소해도 중요하다고 생각합니다. 다른덴 정말 문제없을까 하는 의구심을 불러일으키니까요.) 파워다운이 14주가 걸릴 수 있는 버그 이전에 수정한게 마스터에 머지되었더군요.

마스터에도 올라가서 HF21 대기중입니다! 그동안 스팀관련 나름 코드 기여가 많아져서 이젠 저도 제가 뭐뭐했는지 다 기억 못하지 싶은데ㅎㅎ 블록체인 코어에 코드 기여는 이번이 처음이라 나름 또 기쁘네요. 이게 뭐라고ㅎㅎ

물론 HF21날짜는 알 수 없습니다. 원래 미리미리 이렇게 코드를 만들어서 준비해놓고 하는거라. HF21에서 이상이 생겨도 저 찾지 마세요^^ 제 코드에서 문제 있을 확률도 거의 없고 생겨도 파워다운 양에 관한거라 아무문제 없습니다.

로컬머지는 며칠전 보긴 했었는데 MIRA주로 작업한 직원이 테스트 코드도 써넣고 해서 금새 반영했네요. 요새 자잘한 건 일 좀 하는데요? 일단 할 수 있는 것들부터 집중하는 전략인가 봅니다. SMT는 워낙 큰 건이다보니 SMT끝나고 하기엔 하세월이죠.

!dramatoken

Congratulations for your work in the steem code! nice to see it.

@blockchainstudio님 곰돌이가 1.2배로 보팅해드리고 가요~! 영차~

thanks @blockchainstudio Efforts ! :) to Support Steem BlockChain especially steemit ♥♩♬♬

Posted using Partiko Android


You're upping the drama to new levels! Have a DRAMA.

To view or trade DRAMA go to steem-engine.com.

Hi @blockchainstudio!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @blockchainstudio!

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

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

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

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 63750.99
ETH 3130.22
USDT 1.00
SBD 3.95