Skip to content

consumed_by_tx_id has invalid value for byron tx_out entries #1821

@rdlrt

Description

@rdlrt

OS
Your OS: Linux (Debian 12)

Versions
The db-sync version (eg cardano-db-sync --version): cardano-db-sync 13.4.0.1
PostgreSQL version: 16.3

Build/Install Method
The method you use to build or install cardano-db-sync: cabal

Run method
The method you used to run cardano-db-sync (eg Nix/Docker/systemd/none): systemd

Additional context
We are using these config options for dbsync , particularly tx_out has consumed value set. These are applied across Koios instances (i.e. ~17 core instances + community ones), and we share snapshots with these options hosted ourselves. Thus, for the data integrity issue below, we're hoping to fix the values and re-host a snapshot with correct history.

Problem Report

For Byron tx_out entries, the tx_out => consumed_by_tx_id is incorrect. Consider transactions for address DdzFFzCqrhsvgjTLbbZNqacNLQpacoVnHM3AB5r8MiCHSnHx9ebH7Gjizg1KCt8Ba7hDmjA9q1gexs4yq787AQ2kCznVVqyAZNLxaMHr (notice how consumed_by and tx_id are same):

select id, tx_id, consumed_by_tx_id from tx_out where address = 'DdzFFzCqrhsvgjTLbbZNqacNLQpacoVnHM3AB5r8MiCHSnHx9ebH7Gjizg1KCt8Ba7hDmjA9q1gexs4yq787AQ2kCznVVqyAZNLxaMHr';
#  id   | tx_id | consumed_by_tx_id 
#-------+-------+-------------------
# 54176 | 39313 |             39313
# 72748 | 49094 |             49094
# 54166 | 39308 |             39308

Thus, we're not able to check where this address is used as input:

select id, tx_id, consumed_by_tx_id from tx_out where tx_id = (select id from tx where hash = '\x076c4ed6be00e8a330a348f2366add2d7c1e946dd6d5e9a2f099d5beeddf7a17';
#   id    | tx_id  | consumed_by_tx_id 
#---------+--------+-------------------
# 1733441 | 793834 |            793834

For those who are not using consumed flag, the tx_in did contain right transactions (eg: see adastat showing 4 transactions here ).

Ideally, we'd want this tagged (even if not released) so that the binary built can be used consistently across instances and snapshots we end up creating with fixed data are compatible.

We verified that this is true only for Byron-era:

select g.*, t.hash, b.time  from greg_tmp g inner join tx t on g.tx_id = t.id inner join block b on t.block_id = b.id order by 1 desc limit 5;
#   id    |  tx_id  |                                hash                                |        time         
#---------+---------+--------------------------------------------------------------------+---------------------
# 5933435 | 2415411 | \x897b71667aa115a18222f2cc235b50958a2ca9b3701a915a8a4ab6a15832ae52 | 2020-07-29 21:33:11
# 5933432 | 2415409 | \x916e2bbd0589904ceaecae13a3adc5c8307380bdf1dff9584795768a2876be60 | 2020-07-29 21:32:31
# 5933427 | 2415405 | \xec92fad8992d796b2628e4dff78d996de9199849a0fd1adc19485ac4faac9c21 | 2020-07-29 21:15:11
# 5933425 | 2415404 | \x9ce3ec1ac2c00960b1ffcb7441d6bc33f59e291fc558b3ac8002fc0b2a263de7 | 2020-07-29 21:13:31

Thanks to @hodlonaut for testing and providing query results

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions