IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.06k stars 720 forks source link

[BUG] - Inconsistent rewards across explorers and query results #4072

Closed jiagengliu closed 2 years ago

jiagengliu commented 2 years ago

Internal/External External

Area Other Query - Reward calculation

Summary Each explorer produces a different result for the same reward balance, and all are different from the result of cardano-cli query. I'm not sure who's responsible for the problem but it's weird how this is the case.

Steps to reproduce Steps to reproduce the behavior:

  1. Find the current pool operator of HEART pool across explorers (just an example; I'm not associated with HEART pool): Cardanoscan, Adapools, Adastat
  2. Get the reward balance of the same account with cardano-cli query ledger-state --mainnet > ledger-state.json. The JSON path is stateBefore - esLState - delegationState - dstate - rewards.
  3. Note the difference across the four results. Right now Cardanoscan says 5429 ADA; AdaPools says 5141 ADA; AdaStat says 5431 ADA; CLI query says 5042 ADA. Which one is the "true" value?

Expected behavior Explorers and Cardano CLI query should produce the same reward balance.

System info (please complete the following information):

Additional context The explorers report different rewards of the HEART pool for Epoch 322. Cardanoscan and PoolTool report 644 ADA. Adapools and AdaStat report 257 ADA. Cardano CLI doesn't seem to provide the data.

rdlrt commented 2 years ago

I am not sure if it's correct to have the issue on node repository. The problem is alignment between explorers (as they may use different backends, and/or similar queries).

It is one of the precise goals why Koios got created - to open source the queries used for a given backend (currently dbsync only, but hopefully others get added based on community interests and collaboration) and try to align, atleast between folks who would like to participate on an open-source backend.

To compare your query result:

  1. CLI:
    cardano-cli query stake-address-info --address stake1uy542q9e4d69waa9dukcdvledr8t45glz0tw9ww4c225m9cm836js --mainnet
    [
    {
        "delegation": "pool1lzupr43772kfux007sdt02vlx7uzmfcplrwmxntdztxmwv9myrj",
        "address": "stake1uy542q9e4d69waa9dukcdvledr8t45glz0tw9ww4c225m9cm836js",
        "rewardAccountBalance": 5042067918
    }
    ]
  2. DBSync queried using Koios (query here ):
    curl -X GET "https://api.koios.rest/api/v0/account_info?_address=stake1uy542q9e4d69waa9dukcdvledr8t45glz0tw9ww4c225m9cm836js"
    [
    {
    "status": "registered",
    "delegated_pool": "pool1lzupr43772kfux007sdt02vlx7uzmfcplrwmxntdztxmwv9myrj",
    "total_balance": "5140883928",
    "utxo": "98816010",
    "rewards": "5042067918",
    "withdrawals": "0",
    "rewards_available": "5042067918",
    "reserves": "0",
    "treasury": "0"
    }
    ]

As you'd see:

  1. CLI and Koios show exact amounts
  2. ADAPools shows total_balance (not just rewards part), which is exactly same again.

The explorers report different rewards of the HEART pool for Epoch 322. Cardanoscan and PoolTool report 644 ADA. Adapools and AdaStat report 257 ADA. Cardano CLI doesn't seem to provide the data.

From what I see, ADApools, ADAStat, Koios all report 257 ADA as delegator rewards for mentioned pool at epoch 322. We'd predominantly have to check with the respective explorers to see how they extract[ed] the reward information to look at the anomaly.

CarlosLopezDeLara commented 2 years ago

@jiagengliu

What @rdlrt just said is exactly right. So this is not a bug for this repository. I'm closing it. I guess explorers could make more explicit what is exactly what they are showing and the method they use to calculate it, so that it is clear for the users.