cardano-db-sync
cardano-db-sync copied to clipboard
Db sync record inconsistent with Ledger state
On preprod netword with cardano-node version: 1.35.3 with dbsync version 13.0.5
When I extracted ledger state from cardano-cli to dump data for each epoch then I saw inconsistent from epoch 32 in tables (Epoch Param, Epoch Stake etc.).
Can your guy provide me the logic or SQL query to calculate amount of stake address delegation to a pool ( 1 record in Epoch Stake table). How to insert Epoch Param table .
Could you provide a more spicific example which was inconsistent? Btw there are newer release with a number of improvements, butr afaik nothing related to Epoch Param, Epoch Stake
oh yes, The inconsistent is between epoch stake records. For example: In preprod network, table epoch stake, epoch 56. with stake address: e04bec2d4e59e40ffc8ac4ed7e3b1e5b32cdc821f5f4b8447cc06d021f( address hash) delegate to pool : 7facad662e180ce45e5c504957cd1341940c72a708728f7ecfc6e349 (pool hash).
The stake amount :
- in dbsync :83,307,794,628
- in ledger dump: 86,027,102,326
You also can see ledger dump in here: Epoch 57
Seems to match here (since you've sent dump for epoch 57, assume you meant to check active stake at epoch 57)?
select es.amount, encode(ph.hash_raw,'hex') as pool from epoch_stake es inner join pool_hash ph on es.pool_id=ph.id where es.addr_id in (select id from stake_address where hash_raw = decode('e04bec2d4e59e40ffc8ac4ed7e3b1e5b32cdc821f5f4b8447cc06d021f','hex')) and epoch_no=57;
amount | pool
-------------+----------------------------------------------------------
86027102326 | 7facad662e180ce45e5c504957cd1341940c72a708728f7ecfc6e349
(1 row)
I think when i dump epoch 57, the 'pstakeSet' stake would be insert for active epoch 56, right ?
select es.amount, encode(ph.hash_raw,'hex') as pool from epoch_stake es inner join pool_hash ph on es.pool_id=ph.id where es.addr_id in (select id from stake_address where hash_raw = decode('e04bec2d4e59e40ffc8ac4ed7e3b1e5b32cdc821f5f4b8447cc06d021f','hex')) and epoch_no=57;
May I ask, which version of node and dbsync you use ? Because when i use your query mine db return 84261213980 7facad662e180ce45e5c504957cd1341940c72a708728f7ecfc6e349
which version of node and dbsync you use ?
For this instance, node 1.35.7 w/dbsync 13.1.0.0
which version of node and dbsync you use ?
For this instance, node 1.35.7 w/dbsync 13.1.0.0
With your node and dbsync version, I tried the above query but the result is the same with @dodinhvit23f
As documented in https://github.com/input-output-hk/cardano-db-sync/blob/master/doc/schema.md#epoch_stake the epoch_stake
table is populated incrementally in the first blocks of each epoch. So the result of this query is not stable until the epoch changes or a few blocks pass.