New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reward table off by a few lovelaces #405
Comments
We've also noticed this in Yoroi Here are the results for 7 different instances of cardano-db-sync where the real value is 30428426
As you can see, only 1/7 backends got the correct result We've double-checked that these incorrect values are stored in the SQL database, so we know this issue isn't in our part of the stack |
@SebastienGllmt What? Different |
@xdzurman Would you be able to simplify that SQL query? It would be nice to have three columns, reward, reserve and difference. |
I suspect that query is actually wrong. The rewards table looks like this (my instance is not currently synced):
So for each epoch there is a reward amount (ie a snapshot of the rewards for the epoch) and without exploring it properly, i am not even sure what is in the |
@erikd This is the query we ran on the 7 different backends that gave different results. They're all the same version of cardano-db-sync and same node version
The address specified in this SQL query has only ever earned rewards once so it's easier to work with. |
We discovered similar issues. 137 delegators has withdraw exactly 500 ADA. Shown inside db-sync db in the table withdrawal. Some of them got a negative balance after that. Either this is connected to this issue or we are doing something wrong on our end. For example: One has withdrawn 500 ADA but got only 200 ADA according to db-sync. My Example is for Epoche at or after 214 |
Does #413 fixes this as well? |
@mmahut This is across separate instances? I need an easy way to produce this and having more than one instance is not an easy reproduction case. |
Sorry, I did call it prematurely. It looks like the problem is fixed, I'm monitoring it and will report back in few days. |
It looks fixed for me as well, closing for now. Feel free to reopen if any problems occur. |
I could not send a transaction through cardano-submit-api, it said "WithdrawalsNotInRewardsDELEGS", implying wrong rewards, or trying to withdraw not all rewards. I checked all parts, where it could have gone wrong. After that, I compared rewards for random addresses gotten from db-sync and from yoroi api. These are the mismatches for a few (in lovelaces):
Each row represents db-sync rewards from this SQL:
SELECT (SELECT COALESCE(SUM(rewards.amount), 0) FROM ( SELECT amount FROM reward WHERE addr_id=$1 UNION ALL SELECT amount FROM reserve WHERE addr_id=$1 ) rewards ) - ( SELECT COALESCE(SUM(amount), 0) FROM withdrawal WHERE addr_id=$1 ) AS "remainingRewards"
minus rewards from yoroi api.
What's going on @erikd ?
Edit: yoroi also gets it from db-sync, so these are possibly diffs of two wrong values. Either way, the error originates in db-sync
The text was updated successfully, but these errors were encountered: