create account

Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions by blockchainstudio

View this thread on: hive.blogpeakd.comecency.com
· @blockchainstudio · (edited)
$10.86
Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions
#### Project Information
* Repository: https://github.com/steemit/steem
* Project Name: Steem

https://github.com/steemit/steem/issues/3184

#### Expected behavior
- SBD print rate should be 0% now.

I believe this bug itself must be well-known now, so this is mainly for explanation in detail, and more importantly, some suggestions. This is a very important issue, so it shouldn't be fixed by a temporary measure.

While I'm not sure this is intended or not, `get_feed_history()` shows `current_median_history` as the value already **discounted by the so-called haircut**. I think this is highly confusing and where all the mess begins. You shouldn't do that way.

##### Suggestions
- Use non-haircut value for ``current_median_history`` for consistency
  - All other real history values are non-haircut values, as you can see on https://api.steemjs.com/get_feed_history. This inconsistency can create lots of confusions, e.g., recent asset value error (steemit.com) / voting value error (busy.org which they still have)
  - Witnesses still need to report non-haircut prices, which again is very inconsistent and confusing. (https://steemd.com/witnesses)

- Introduce a new variable such as `"haircut discount"` and show the value on steemd and `get_feed_history` as well.
  - For instance, https://api.steemjs.com/get_feed_history should show "base": "0.328 SBD", "quote": "1.000 STEEM", "haircut": "0.796" 
  - This makes the code much more readable and much less prone to bugs such as the current one.

In reality, it might be already late to change the behavior of ``current_median_history`` in the code. Then introduce a new variable. In any case, UI (e.g., steemd.com) should show non-haircut value for the current feed price with haircut discount separately.

#### Actual behavior
SBD print rate is still 1%.

This bug is due to separate and inconsistent calculations for `current_median_history` and `sbd_print_rate`.

The `sbd_print_rate` is calculated here
https://github.com/steemit/steem/blob/7ebe3f8bddf9e58c943618f55136db6330dd95a0/libraries/chain/database.cpp#L3761-L3783

The first problem is `current_median_history` is already haircut (which I don't recommend doing so in Expected bahavior), so `percent_sbd` can never surpass 10%. 

The second problem is due to the inflation between the time when `current_median_history` is calculated and the time when `update_virtual_supply()` (which updates `sbd_print_rate`) is called, `percent_sbd` is always strictly less than 10% just a bit.

I explain this in more detail below.


#### High-level
> **update_median_feed()**;
> **update_virtual_supply()**;
>
> clear_null_account_balance();
**process_funds()**;
process_conversions();
process_comment_cashout();
process_vesting_withdrawals();
process_savings_withdraws();
process_subsidized_accounts();
pay_liquidity_reward();
**update_virtual_supply()**;

> https://github.com/steemit/steem/blob/7ebe3f8bddf9e58c943618f55136db6330dd95a0/libraries/chain/database.cpp#L3093-L3104

As you can see in the above, `update_virtual_supply()` (which updates `sbd_print_rate`) is called twice.

The problem is `update_median_feed()` limit the `current_median_history` so that `sbd_print_rate` at most 10% already.
```
price min_price( asset( 9 * gpo.current_sbd_supply.amount, SBD_SYMBOL ), gpo.current_supply );

if( min_price > fho.current_median_history )
   fho.current_median_history = min_price;
```
> https://github.com/steemit/steem/blob/7ebe3f8bddf9e58c943618f55136db6330dd95a0/libraries/chain/database.cpp#L3269-L3272

Unless you're very lucky due to floating point precision error, `sbd_print_rate` is already strictly less than 10% in the first call of `update_virtual_supply()`.

But even if you were very lucky,  now `process_funds()` inflates the supply.

(While there are other functions that change `virtual_supply` or `current_sbd_supply`, they don't change them in the direction of the `sbd_print_rate` increase. So let me skip too much details here.)

Thus, in the second `update_virtual_supply()`, sbd_print_rate is always strictly less than 10% regardless of your luck :)


#### How to reproduce
Don't need to explain, since it's always happening now.

#### Recording Of The Bug
![](https://ipfs.busy.org/ipfs/QmYnPcSiKX9KWi1DBFBJSnSqmrU4Gro2NQ9ieNwB4H9N7r) ![](https://ipfs.busy.org/ipfs/QmVTTC8nzCPFvMc3wBvUhXjCa1XYWsNXXWdMaV1khSzccG)
> steemd.com




#### GitHub Account
https://github.com/economicstudio
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorblockchainstudio
permlinkwhy-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions
categoryutopian-io
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["utopian-io","bug-hunting","steemit","steem","busy"],"users":[],"links":["https://github.com/steemit/steem","https://github.com/steemit/steem/issues/3184","https://api.steemjs.com/get_feed_history","https://steemd.com/witnesses","https://api.steemjs.com/get_feed_history","https://github.com/steemit/steem/blob/7ebe3f8bddf9e58c943618f55136db6330dd95a0/libraries/chain/database.cpp#L3761-L3783","https://github.com/steemit/steem/blob/7ebe3f8bddf9e58c943618f55136db6330dd95a0/libraries/chain/database.cpp#L3093-L3104","https://github.com/steemit/steem/blob/7ebe3f8bddf9e58c943618f55136db6330dd95a0/libraries/chain/database.cpp#L3269-L3272","https://github.com/economicstudio"],"image":["https://ipfs.busy.org/ipfs/QmVTTC8nzCPFvMc3wBvUhXjCa1XYWsNXXWdMaV1khSzccG"]}
created2018-11-28 19:56:30
last_update2018-12-01 19:10:09
depth0
children9
last_payout2018-12-05 19:56:30
cashout_time1969-12-31 23:59:59
total_payout_value8.230 HBD
curator_payout_value2.632 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,433
author_reputation178,988,499,015,921
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,059,060
net_rshares17,783,388,895,287
author_curate_reward""
vote details (53)
@bukio ·
짱짱맨 ν˜ΈμΆœμ— μ‘λ‹΅ν•˜μ—¬ λ³΄νŒ…ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

였늘 λ…μžκ°€ λ§Œλ“œλŠ” λ² μŠ€νŠΈμ…€λŸ¬, [μŠ€νŒ€λ‹¬λŸ¬ μ—μ–΄λ“œλž ν”„λ‘œλͺ¨μ…˜](https://steemit.com/bukio/@bukio/46npo8)의 첫번째 λ„μ„œ νŒλ§€κ°€ μ‹œμž‘λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 뢁이였(@bukio)의 [[μŠ€νŒ€λ‹¬λŸ¬ μ—μ–΄λ“œλž] μŠ€νŒ€μž‡ 프리세일 γ€Œμ˜μ–΄ μž˜ν•˜κ³  μ‹Άλ‹ˆ?」](https://steemit.com/bukio/@bukio/7pazmx)λ₯Ό ν™•μΈν•˜μ—¬, μ—¬λŸ¬λΆ„μ΄ λ² μŠ€νŠΈμ…€λŸ¬λ₯Ό λ§Œλ“€κ³  μˆ˜μ΅μ„ 같이 λˆ„λ¦¬μ„Έμš”.

<center>**[γ€Œμ˜μ–΄ μž˜ν•˜κ³  μ‹Άλ‹ˆ?」 νŒλ§€νŽ˜μ΄μ§€](https://buk.io/@ka2279)**</center>
properties (22)
authorbukio
permlinkre-bukio-jjangjjangman-1543435905016
categoryutopian-io
json_metadata"{"tags":["bukio", "jjangjjangman"],"app":"steemer/1.0"}"
created2018-11-28 20:11:45
last_update2018-11-28 20:11:45
depth1
children0
last_payout2018-12-05 20:11:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length312
author_reputation11,545,563,591,097
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,059,675
net_rshares0
@crokkon · (edited)
$6.85
properties (23)
authorcrokkon
permlinkre-blockchainstudio-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181201t190417398z
categoryutopian-io
json_metadata"{"app": ""}"
created2018-12-01 19:04:18
last_update2022-09-18 10:08:30
depth1
children4
last_payout2018-12-08 19:04:18
cashout_time1969-12-31 23:59:59
total_payout_value5.223 HBD
curator_payout_value1.628 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1
author_reputation81,214,366,861,104
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,209,662
net_rshares11,306,496,831,312
author_curate_reward""
vote details (9)
@blockchainstudio · (edited)
Thanks a lot for your comment. Now I included github issue in my posts. This is my first utopian-io post so I'm not even sure I followed the direction well :)

BTW, floating point isn't my main point at all :) I just mentioned that there is a very tiny chance that the bug may **not** occur due to floating point precision problem. I know, internal calculation is mostly done by integers, but A/B is basically floating point operation even if both A and B are integers, which may lead to some unavoidable error. Again that's not my main point at all.

I agree that 1% isn't a big issue in practice. But in theory it's a big issue I believe. If one thing doesn't work as intended, who can believe the others work well? And that's why I suggested fixing it very carefully with enough time, not by a temporary measure. I still believe that the current inconsistent and not self-contained feed history is a pretty bad idea. I know Steemit is having a hard time, so maybe they don't have enough resources to handle this. I'm very sorry about it.

I'm not sure if you work for Steemit too or not, but I presume you're close to them. One suggestion is that Steemit should admit that it isn't sustainable without ads. I worked at facebook before (now I'm in the academia) and that's why I have much interests in Steemit. A decentralized SNS/Blog without ads is too unrealistic to me. While Steemit pretends to be decentralized, they are actually very centralized imho. Then why not having ads before it's too late? Let's face the reality.
properties (22)
authorblockchainstudio
permlinkre-crokkon-re-blockchainstudio-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181201t192621166z
categoryutopian-io
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["utopian-io"],"users":[],"links":[],"image":[]}
created2018-12-01 19:24:39
last_update2018-12-01 19:26:24
depth2
children2
last_payout2018-12-08 19:24:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,530
author_reputation178,988,499,015,921
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,210,263
net_rshares0
@crokkon · (edited)
.
.
properties (22)
authorcrokkon
permlinkre-blockchainstudio-re-crokkon-re-blockchainstudio-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181201t194223918z
categoryutopian-io
json_metadata"{"app": ""}"
created2018-12-01 19:42:24
last_update2022-09-18 10:08:21
depth3
children1
last_payout2018-12-08 19:42:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1
author_reputation81,214,366,861,104
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,210,813
net_rshares0
@utopian-io ·
Thank you for your review, @crokkon! Keep up the good work!
properties (22)
authorutopian-io
permlinkre-re-blockchainstudio-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181201t190417398z-20181203t205647z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-12-03 20:56:48
last_update2018-12-03 20:56:48
depth2
children0
last_payout2018-12-10 20:56:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length59
author_reputation152,955,367,999,756
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,312,377
net_rshares0
@steem-ua ·
#### Hi @blockchainstudio!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your **UA** account score is currently 4.223 which ranks you at **#2804** across all Steem accounts.
Your rank has improved 4 places in the last three days (old rank 2808).

In our last Algorithmic Curation Round, consisting of 339 contributions, your post is ranked at **#58**.
##### Evaluation of your UA score:

* Some people are already following you, keep going!
* The readers like your work!
* Good user engagement!


**Feel free to join our [@steem-ua Discord server](https://discord.gg/KpBNYGz)**
properties (22)
authorsteem-ua
permlinkre-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181129t133430z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-11-29 13:34:33
last_update2018-11-29 13:34:33
depth1
children0
last_payout2018-12-06 13:34:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length635
author_reputation23,214,230,978,060
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,096,163
net_rshares0
@utopian-io ·
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](https://chrome.google.com/webstore/detail/steemplus/mjbkjgcplmaneajhcbegoffkedeankaj?hl=en) or [Steeditor](https://steeditor.app)).

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

<a href='https://steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181202t000822z
categoryutopian-io
json_metadata"{"app": "beem/0.20.9"}"
created2018-12-02 00:08:24
last_update2018-12-02 00:08:24
depth1
children1
last_payout2018-12-09 00:08:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length598
author_reputation152,955,367,999,756
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,219,366
net_rshares0
@blockchainstudio ·
Thank you and I just voted for @utopian-io :)
properties (22)
authorblockchainstudio
permlinkre-utopian-io-re-why-sbd-print-rate-is-still-1-despite-the-haircut-bug-report-explanation-and-suggestions-20181202t000822z-20181202t123157461z
categoryutopian-io
json_metadata{"community":"busy","app":"busy/2.5.6","format":"markdown","tags":["utopian-io"],"users":["utopian-io"],"links":["/@utopian-io"],"image":[]}
created2018-12-02 12:32:00
last_update2018-12-02 12:32:00
depth2
children0
last_payout2018-12-09 12:32:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length45
author_reputation178,988,499,015,921
root_title"Why SBD print rate is still 1% despite the haircut? Bug report, explanation, and suggestions"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id76,240,361
net_rshares0