create account

Discrepancies with Ecency Delegation API by themarkymark

View this thread on: hive.blogpeakd.comecency.com
· @themarkymark ·
$32.00
Discrepancies with Ecency Delegation API
 https://i.imgur.com/D5Me55a.png 

Since HiveSQL is down, I had to make some changes to some code to accomidate alternative ways to gather data. I have a few bots I run to help out some communities and I already did this work a while ago but never actually deployed the changes as I never fully tested them.

I have tested in the past using Ecency's delegation API.  It all looked good, but I never got around  to fully verifying it so I never actually updated my code to use it for fail over.  Now it is harder to do this as HiveSQL is down and getting delegation data directly from the blockchain is kind of a pain in the ass.

Most people are using HiveSQL for this data because it is just easy.  With it down though, it's hard to replace it as you want to verify you have the correct data before commiting to something (ideally, at least I do).

In this case, I help @raymondspeaks with his BroFi bot where it distributes BRO tokens for delegations.  The bot queries HiveSQL for how much curation rewards @brofi earned in the last 24 hours, then pulls up a list of who delegates to @brofi and figures out how much they should receive based on past curation plus the additional 10% bonus distributed.

Since HiveSQL is up 99% of the time, it hasn't been a priority, especially since I just do this as a favor to help out the community.  Now that HiveSQL has been down for almost a week, I didn't want everyone waiting for their BRO tokens, so I revisited my fail over code and manually sent out distributions to catch up.

Then I noticed there was an issue, one particular user received BRO even though he doesn't currently delegate.  It was only 0.01 BRO, so it isn't a big deal but it got me thinking there was an issue with the source of data.

I already have code to pull delegation from three different sources that I know works.  I just never bothered to compare their results for accuracy.

I have three functions:

* getHiveDelegatorsFromHAFSQL(account)
* getHiveDelegatorsFromHiveSQL(account)
* getHiveDelegatorsFromEcency(account)

In theory, these all should report the same information.  I was curious how far off the api is, so I know what the end result was.  For the one user I know was receiving API even though he didn't have an active delegation, I queried the API and looked manually.

The Ecency API reports this:

```
 {
    delegator: 'bulliontools',
    delegatee: 'brofi',
    vesting_shares: '435957.734106 VESTS',
    timestamp: '2024-01-05T02:41:48+00:00',
    vests: 435957.734106
  }
```

This is actually accurate, @bulliontools did delegate to @brofi back in January, but a few weeks later he removed his delegation but the API indexer never picked up on this.  To see how many other errors there are, I created a simple function to compare the results.

```
function compareResults(result1, result2) {
    const differences = [];

    // Iterate over result1
    result1.forEach(entry1 => {
        // Find matching entry in result2 based on delegator
        const matchingEntry2 = result2.find(entry2 => entry2.delegator === entry1.delegator);
        
        // If there's no matching entry in result2, or if vests values are different, add to differences
        if (!matchingEntry2 || parseFloat(entry1.vests) !== parseFloat(matchingEntry2.vests)) {
            differences.push(entry1);
        }
    });

    // Iterate over result2 to find any delegators that are not in result1
    result2.forEach(entry2 => {
        const matchingEntry1 = result1.find(entry1 => entry1.delegator === entry2.delegator);
        if (!matchingEntry1) {
            differences.push(entry2);
        }
    });

    return differences;
}
```

This code compares to lists and adds the differences to an array and then prints the array at the end.

The end result was this:

```
Differences found in vests values for the following delegators: [
  { delegator: 'fiberfrau', delegatee: 'brofi', vests: '81372.507328' },
  {
    delegator: 'bulliontools',
    delegatee: 'brofi',
    vesting_shares: '435957.734106 VESTS',
    timestamp: '2024-01-05T02:41:48+00:00',
    vests: 435957.734106
  }
]
```

The result was a very insignificant discrepancy, and has almost no financial impact in this case.  It could however have a pretty significant impact if a larger delegation was incorrectly tracked.  Moral of the story, whenever possible, try to verify data before depending on it blindly.

Most services on Hive use HiveSQL and don't have fail over methods in place as it is just a pain in the ass to create 2-3 copies of every function when the service is usually available and the methods to retreive the data vary dramatically.  If you do use alternative data sources, spend some time doing some sanity checks.

Posted Using [InLeo Alpha](https://inleo.io/@themarkymark/discrepancies-with-ecency-delegation-api)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 648 others
👎  
properties (23)
authorthemarkymark
permlinkdiscrepancies-with-ecency-delegation-api
categoryleofinance
json_metadata{"app":"leothreads/0.3","format":"markdown","tags":["leofinance","ecency","technology","development","hive-engine","vyb","pob","cent","palnet","neoxian"],"canonical_url":"https://inleo.io/@themarkymark/discrepancies-with-ecency-delegation-api","links":["https://inleo.io/@themarkymark/discrepancies-with-ecency-delegation-api)"],"images":["https://i.imgur.com/D5Me55a.png"],"dimensions":{"https://i.imgur.com/D5Me55a.png":{"width":1024,"height":1024}}}
created2024-02-18 23:12:03
last_update2024-02-18 23:12:03
depth0
children15
last_payout2024-02-25 23:12:03
cashout_time1969-12-31 23:59:59
total_payout_value16.058 HBD
curator_payout_value15.939 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,836
author_reputation1,669,704,010,439,681
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,405,452
net_rshares70,738,948,964,034
author_curate_reward""
vote details (713)
@bala41288 ·
I also noticed this issue while using Ecency API today. 
👍  , , ,
properties (23)
authorbala41288
permlinkre-themarkymark-2024219t151529403z
categoryleofinance
json_metadata{"type":"comment","tags":["leofinance","ecency","technology","development","hive-engine","vyb","pob","cent","palnet","neoxian"],"app":"ecency/3.0.46-mobile","format":"markdown+html"}
created2024-02-19 09:45:30
last_update2024-02-19 09:45:30
depth1
children0
last_payout2024-02-26 09:45:30
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_length56
author_reputation1,082,596,661,285,790
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,414,623
net_rshares98,656,617
author_curate_reward""
vote details (4)
@brofund ·
It's weird that I understood your code. Even when using ChatGPT to write most of mine I'm still learning from it.

Thanks for sorting it out though. That was really cool that you helped. Again!
👍  , , ,
properties (23)
authorbrofund
permlinkre-themarkymark-s92s99
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-18 23:36:45
last_update2024-02-18 23:36:45
depth1
children0
last_payout2024-02-25 23:36: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_length193
author_reputation469,500,421,313,201
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,405,800
net_rshares100,092,769
author_curate_reward""
vote details (4)
@bulliontools · (edited)
$0.03
I'm glad there wasn't a major financial impact because of it. 🙂

Hopefully there aren't any major issues with other projects either.
👍  , , , ,
properties (23)
authorbulliontools
permlinkre-themarkymark-2024218t161520682z
categoryleofinance
json_metadata{"type":"post","tags":["leofinance","ecency","technology","development","hive-engine","vyb","pob","cent","palnet","neoxian"],"app":"ecency/3.0.46-mobile","format":"markdown+html"}
created2024-02-18 23:15:21
last_update2024-02-18 23:16:09
depth1
children2
last_payout2024-02-25 23:15:21
cashout_time1969-12-31 23:59:59
total_payout_value0.014 HBD
curator_payout_value0.014 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length132
author_reputation66,001,245,301,959
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,405,508
net_rshares67,763,635,566
author_curate_reward""
vote details (5)
@themarkymark ·
I think most people are using HiveSQL, so it likely doesn't affect them.  The Ecency API isn't really a public API either, so a lot of people don't likely use it if anyone other than Ecency.
👍  , ,
properties (23)
authorthemarkymark
permlinkre-bulliontools-s92rcz
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-18 23:17:24
last_update2024-02-18 23:17:24
depth2
children1
last_payout2024-02-25 23:17: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_length190
author_reputation1,669,704,010,439,681
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,405,540
net_rshares86,397,966
author_curate_reward""
vote details (3)
@bulliontools ·
$0.03
Ah, ok. Good deal.

I didn't realize you helped with the BroFi bot. Thanks for doing that! 🙂
👍  , , ,
properties (23)
authorbulliontools
permlinkre-themarkymark-2024218t162049812z
categoryleofinance
json_metadata{"type":"comment","tags":["leofinance"],"app":"ecency/3.0.46-mobile","format":"markdown+html"}
created2024-02-18 23:20:48
last_update2024-02-18 23:20:48
depth3
children0
last_payout2024-02-25 23:20:48
cashout_time1969-12-31 23:59:59
total_payout_value0.014 HBD
curator_payout_value0.014 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length92
author_reputation66,001,245,301,959
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,405,600
net_rshares67,518,990,815
author_curate_reward""
vote details (4)
@ecency ·
$0.19
It is fixed. We will check why indexer didn't pick it up. This API is used within Ecency apps just for displaying purpose. It was never public, always best to use your own copy of api/data.
👍  , , , , , , ,
properties (23)
authorecency
permlinkre-themarkymark-2024219t8307938z
categoryleofinance
json_metadata{"tags":["leofinance","ecency","technology","development","hive-engine","vyb","pob","cent","palnet","neoxian"],"app":"ecency/3.0.37-vision","format":"markdown+html"}
created2024-02-19 03:00:09
last_update2024-02-19 03:00:09
depth1
children0
last_payout2024-02-26 03:00:09
cashout_time1969-12-31 23:59:59
total_payout_value0.094 HBD
curator_payout_value0.093 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length189
author_reputation549,971,547,212,413
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,408,747
net_rshares414,743,200,013
author_curate_reward""
vote details (8)
@roleerob ·
With a background in systems analysis, I enjoyed reading what did here, @themarkymark, to verify  whether or not 3 different methods of querying the data produced an identical outcome.  And, if not, why not?

Before retiring, I did a lot of similar analysis, with some major ... "surprises" ... produced for my employers.  Long story ...

---

In your position as one of our top Witnesses, would you please provide your perspective on this latest challenge to our Hive blockchain, with HiveSQL going down?  In general, what in your judgment would be the best course of action to avoid any reoccurrence of a "single point of failure" having this sort of impact?

And maybe, specifically, since I see reference to HAFSQL as one of your 3 methods, whether or not this is an adequate (superior?) substitute that would serve to avoid a repeat?
👍  , , ,
properties (23)
authorroleerob
permlinkre-themarkymark-s93qx1
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-19 12:05:27
last_update2024-02-19 12:05:27
depth1
children3
last_payout2024-02-26 12:05:27
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_length838
author_reputation118,854,660,752,275
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,417,685
net_rshares97,246,133
author_curate_reward""
vote details (4)
@roleerob ·
P.S. Thank you for reblogging news of the passing of Eric Burgoyne. 🫡
👍  , ,
properties (23)
authorroleerob
permlinkre-roleerob-s93r25
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-19 12:08:30
last_update2024-02-19 12:08:30
depth2
children0
last_payout2024-02-26 12:08:30
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_length69
author_reputation118,854,660,752,275
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,417,740
net_rshares85,749,374
author_curate_reward""
vote details (3)
@themarkymark ·
$0.04
> In your position as one of our top Witnesses, would you please provide your perspective on this latest challenge to our Hive blockchain, with HiveSQL going down? In general, what in your judgment would be the best course of action to avoid any reoccurrence of a "single point of failure" having this sort of impact?

HiveSQL is just a convienience factor, everything is available on chain, but some things are just easier through a standard database.  I am not sure if HiveSQL has backup servers and lost them both in this attack or it is just one server.

> And maybe, specifically, since I see reference to HAFSQL as one of your 3 methods, whether or not this is an adequate (superior?) substitute that would serve to avoid a repeat?

HAFSQL is only beta right now and doesn't include everything HiveSQL does, but is generally a lot faster in some cases as you don't have to wait over an hour for the db to be updated.  I believe it also is only one server.
👍  
properties (23)
authorthemarkymark
permlinkre-roleerob-s94ey9
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-19 20:44:33
last_update2024-02-19 20:44:33
depth2
children1
last_payout2024-02-26 20:44:33
cashout_time1969-12-31 23:59:59
total_payout_value0.018 HBD
curator_payout_value0.018 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length961
author_reputation1,669,704,010,439,681
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,429,023
net_rshares84,016,141,207
author_curate_reward""
vote details (1)
@roleerob ·
Okay, thank you.  Sounds then, in either case, we are still faced with a single point of failure ...

From the disruptive nature of this attack on HiveSQL, underscoring the benefit it provides to our Hive blockchain, I hope that gets addressed at some point.
properties (22)
authorroleerob
permlinkre-themarkymark-s94izs
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-19 22:11:54
last_update2024-02-19 22:11:54
depth3
children0
last_payout2024-02-26 22:11:54
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_length258
author_reputation118,854,660,752,275
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,430,780
net_rshares0
@singularity.zero ·
For those who don't know — (me) — what happened to HiveSQL?
properties (22)
authorsingularity.zero
permlinkre-themarkymark-s9gfsc
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-26 08:33:54
last_update2024-02-26 08:33:54
depth1
children2
last_payout2024-03-04 08:33:54
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_reputation422,050,847,495
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,590,836
net_rshares0
@themarkymark ·
It got hacked with ransomware
👍  ,
properties (23)
authorthemarkymark
permlinkre-singularityzero-s9gmpx
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-26 11:03:33
last_update2024-02-26 11:03:33
depth2
children1
last_payout2024-03-04 11:03: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_length29
author_reputation1,669,704,010,439,681
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,592,887
net_rshares2,498,163,236
author_curate_reward""
vote details (2)
@singularity.zero ·
*damn*

Thanks...
properties (22)
authorsingularity.zero
permlinkre-themarkymark-s9hvt0
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-27 03:17:24
last_update2024-02-27 03:17:24
depth3
children0
last_payout2024-03-05 03:17: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_length17
author_reputation422,050,847,495
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,613,966
net_rshares0
@steevc ·
We need some redundancy with such essential tools. I see the Leo people have set up some alternative for their delegation checks. I only use HiveSQL for some little scripts I run, but it's part of the Hive infrastructure. I've not looked at alternatives for my stuff yet, but then it's not critical.
👍  , , , , , ,
properties (23)
authorsteevc
permlinkre-themarkymark-s93ktj
categoryleofinance
json_metadata{"tags":["leofinance"],"app":"peakd/2024.1.1"}
created2024-02-19 09:53:45
last_update2024-02-19 09:53:45
depth1
children0
last_payout2024-02-26 09:53: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_length299
author_reputation1,047,128,286,396,400
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,415,248
net_rshares1,873,954,450
author_curate_reward""
vote details (7)
@stemsocial ·
re-themarkymark-discrepancies-with-ecency-delegation-api-20240219t041600532z
<div class='text-justify'> <div class='pull-left'>
 <img src='https://stem.openhive.network/images/stemsocialsupport7.png'> </div>

Thanks for your contribution to the <a href='/trending/hive-196387'>STEMsocial community</a>. Feel free to join us on <a href='https://discord.gg/9c7pKVD'>discord</a> to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.&nbsp;<br />&nbsp;<br />
</div>
properties (22)
authorstemsocial
permlinkre-themarkymark-discrepancies-with-ecency-delegation-api-20240219t041600532z
categoryleofinance
json_metadata{"app":"STEMsocial"}
created2024-02-19 04:16:00
last_update2024-02-19 04:16:00
depth1
children0
last_payout2024-02-26 04:16: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_length565
author_reputation22,460,334,324,555
root_title"Discrepancies with Ecency Delegation API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id131,409,706
net_rshares0