0

I'm listening for new records added on block table and have noticed that sometimes two blocks are added almost at the same time with basically the same info except for block hash (maybe a slot battle/rollback, since eventually one of the blocks gets removed?).

The thing is when asking for the block's transactions UTXOS the block got removed return transactions with the same hash that the one who finally stays on chain but the transaction inputs/outputs are different (empty in this case).

So essentially the process is the following:

  1. New block gets added into dbsync
  2. Get block info (pool, transactions)
  3. Get block transactions utxos which are empty. Probably empty is just one case and the important here is the fact that the tx for the two blocks are different but has the same hash.
  4. Another block gets added into dbsync
  5. Repeat step 2
  6. Get block transactions utxos which aren't empty but have the same tx hash of the one returned by previous block

How is this posible, I think blocks is ok that enter into dbsync and the get removed due to rollbacks/slot battles but why the two blocks ended up with different txs (inputs/outputs) but the same hash?.

here is an example:

// arrive time [2022-10-28 13:40:52 UTC]
block info:
{
    "id": "7956798",
    "hash": "4eafa57522c951c571ef7f1f4f6c834b033ad2183121e4a02c9fd6f46ab91b8f",
    "epoch_no": 372,
    "slot_no": "75398161",
    "epoch_slot_no": 57361,
    "block_no": 7941775,
    "previous_block": 7941774,
    "next_block": null,
    "slot_leader": "pool17kew7rtakc7g6qzydntann5umw08xq3ll2j7spk7en4kvff69fa",
    "size": 58863,
    "time": "2022-10-28T13:40:52.000Z",
    "tx_count": "36",
    "out_sum": "6189878553712",
    "fees": "11268611",
    "confirmations": 1,
    "op_cert": "bf9af4d99bb361e89db95bde6303f756d864f85142691f92d897bafd986df8a9",
    "vrf_key": "vrf_vk1ygptnml8rkgw9dmguft6dr8dnjaapk80lsynqdwzl9aap08qg6mslll3fc",
    "pool": {
        "pool_id": "pool17kew7rtakc7g6qzydntann5umw08xq3ll2j7spk7en4kvff69fa",
        "raw_id": "f5b2ef0d7db63c8d00446cd7d9ce9cdb9e73023ffaa5e806decceb66",
        "url": "https://bloompool.io/bloom-3.metadata.json",
        "hash": "3cdd486927f8819dadb60ad8e9be691b8ba0ffa94b0356c38fe031b8f55b905f",
        "name": "Bloom Three",
        "ticker": "BLOOM",
        "homepage": "https://bloompool.io/",
        "description": "Bloom is committed to providing top quality staking services to our delegates through low latency, 24/7 uptime, and the highest return on stake. Operated by bigpey."
    },
    "transactions": [
        {
            "id": "53459220",
            "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
            "block_id": "7956798",
            "block_index": 25,
            "out_sum": "107197930",
            "fee": "183849",
            "deposit": "0",
            "size": 642,
            "invalid_before": null,
            "invalid_hereafter": "75408970",
            "valid_contract": true,
            "script_size": 0,
            "outputs": [],
            "inputs": []
        }
    ]
}

// arrive time [2022-10-28 13:40:53 UTC]
block info:
{
    "id": "7956799",
    "hash": "4d8296d03f2a0a471a16e34f2204026ac3c82311dfa2569fbb7f680e4cf3e66b",
    "epoch_no": 372,
    "slot_no": "75398161",
    "epoch_slot_no": 57361,
    "block_no": 7941775,
    "previous_block": 7941774,
    "next_block": null,
    "slot_leader": "pool1ddg6t2h9kj6lqlec4ncjs945lzj43m3ggrgdhf5sgzhtygpkznz",
    "size": 58863,
    "time": "2022-10-28T13:40:52.000Z",
    "tx_count": "36",
    "out_sum": "6189878553712",
    "fees": "11268611",
    "confirmations": 1,
    "op_cert": "d5b849f9757cd2ef60c883b092a7e985d27c22f89aac7648b13d3cfd4cce4737",
    "vrf_key": "vrf_vk1m5tnjq3exhpu8mfcy6rl5xe5jedd8adzx6n5syju3vj8p5yhfels900hls",
    "pool": {
        "pool_id": "pool1ddg6t2h9kj6lqlec4ncjs945lzj43m3ggrgdhf5sgzhtygpkznz",
        "raw_id": "6b51a5aae5b4b5f07f38acf12816b4f8a558ee2840d0dba69040aeb2",
        "url": "https://fairpool.eu/fair01.json",
        "hash": "8127f98bbad5af53a473e609d11e90f4135c2ae8cc86f27fafada12681a25d37",
        "name": "Fair Pool #01",
        "ticker": "FAIR",
        "homepage": "https://fairpool.eu",
        "description": "Highly available pool with a fair margin of 0.5%"
    },
    "transactions": [
        {
            "id": "53459256",
            "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
            "block_id": "7956799",
            "block_index": 25,
            "out_sum": "107197930",
            "fee": "183849",
            "deposit": "0",
            "size": 642,
            "invalid_before": null,
            "invalid_hereafter": "75408970",
            "valid_contract": true,
            "script_size": 0,
            "outputs": [
                {
                    "address": "addr1qydesz3sg492xwwynmv9hq4jn5t9fw4gz9gm8z7vxzzssa5m4mchcz7v3u7xrhssl83yah25vxgcjahdlp5u03t3sd2sx48u9r",
                    "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
                    "index": 1,
                    "value": "72197930",
                    "smart_contract": false,
                    "assets": [
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5933",
                            "fingerprint": "asset1mnj2sgz8jufya0t9q3ccv8k5xxzsmwafzcvptc"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands6359",
                            "fingerprint": "asset154fae8j77qnn99ku6k507h5plltrfmey9ap4ff"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4121",
                            "fingerprint": "asset13ul3yk367rgsn6jn9dcyflm6vel4rf0gns86kr"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1482",
                            "fingerprint": "asset1cwllcee0vm2630skuxhnkqchz8rel2qpl0nxwy"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5324",
                            "fingerprint": "asset1wr6uxxamarkwmg5thf0f0dmwy06r7trse3xwp2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5160",
                            "fingerprint": "asset13pk5cux9xue205w52vjl66xgu428tz63rhn4u3"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5682",
                            "fingerprint": "asset1wmw0pw6ft3f5myajkvxfwd5d884u9hhqj49dhz"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1990",
                            "fingerprint": "asset1ha6at2s482re94tqazh5hlq28tv9nu6z4t3jwx"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5777",
                            "fingerprint": "asset122ue962qgvy3kc0qazlpn2ljdnlsdczl8l7a9t"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4925",
                            "fingerprint": "asset18lhkp5al2xs5zu5pq7zjehymnne8md5ypy7nhp"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands7245",
                            "fingerprint": "asset1usc3r3rmthdpgs3894z6s8vc926vwjcxzd7te2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands3366",
                            "fingerprint": "asset1mua39yqstznzxwscuql2krmrayh0f7achj0qzx"
                        }
                    ]
                },
                {
                    "address": "addr1v97783v9dgj5vh6xlgwxazmgem2mpm0lz90vmgjs0kpz24sjc0usf",
                    "hash": "d868dc0cde2733aa5ee87db7b5ac2ae0e82aadec4aff71ee70d8e95cbf330307",
                    "index": 0,
                    "value": "35000000",
                    "smart_contract": false,
                    "assets": []
                }
            ],
            "inputs": [
                {
                    "address": "addr1q8j27e5gt6jwy3nqx9x2g85c5zmwlfdvqnv3v9xer2dymh5m4mchcz7v3u7xrhssl83yah25vxgcjahdlp5u03t3sd2s86ucr3",
                    "hash": "9589e00ac142b8a42813efc01da95f52fe8d3cac5263ef7d4888e02a072b250b",
                    "index": 1,
                    "value": "107381779",
                    "smart_contract": false,
                    "assets": [
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5160",
                            "fingerprint": "asset13pk5cux9xue205w52vjl66xgu428tz63rhn4u3"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4121",
                            "fingerprint": "asset13ul3yk367rgsn6jn9dcyflm6vel4rf0gns86kr"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands3366",
                            "fingerprint": "asset1mua39yqstznzxwscuql2krmrayh0f7achj0qzx"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5777",
                            "fingerprint": "asset122ue962qgvy3kc0qazlpn2ljdnlsdczl8l7a9t"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5324",
                            "fingerprint": "asset1wr6uxxamarkwmg5thf0f0dmwy06r7trse3xwp2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands6359",
                            "fingerprint": "asset154fae8j77qnn99ku6k507h5plltrfmey9ap4ff"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands7245",
                            "fingerprint": "asset1usc3r3rmthdpgs3894z6s8vc926vwjcxzd7te2"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands4925",
                            "fingerprint": "asset18lhkp5al2xs5zu5pq7zjehymnne8md5ypy7nhp"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5682",
                            "fingerprint": "asset1wmw0pw6ft3f5myajkvxfwd5d884u9hhqj49dhz"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1482",
                            "fingerprint": "asset1cwllcee0vm2630skuxhnkqchz8rel2qpl0nxwy"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands5933",
                            "fingerprint": "asset1mnj2sgz8jufya0t9q3ccv8k5xxzsmwafzcvptc"
                        },
                        {
                            "quantity": "1",
                            "policy_id": "b7761c472eef3b6e0505441efaf940892bb59c01be96070b0a0a89b3",
                            "asset_name": "CardanoWarriorsIslands1990",
                            "fingerprint": "asset1ha6at2s482re94tqazh5hlq28tv9nu6z4t3jwx"
                        }
                    ]
                }
            ]
        }
    ]
}


1 Answer 1

2

I'm listening for new records added on block table and have noticed that sometimes two blocks are added almost at the same time with basically the same info except for block hash.

Yes this is a result of a rollback which is often (but not always) a result of a slot battle. As part of this rollback, db-sync will end up deleting one of these blocks.

... why the two blocks ended up with different txs (inputs/outputs) but the same hash?.

But the hashes are not the same. For the first its 4eafa57522c951c571ef7f1f4f6c834b033ad2183121e4a02c9fd6f46ab91b8f and for the second its 4d8296d03f2a0a471a16e34f2204026ac3c82311dfa2569fbb7f680e4cf3e66b. The both start with a 4 but are not the same.

2
  • 1
    Hi, thanks for the quick reply. About the same hash I was referring to the tx hash no block hash. It seems the issue is some gaps between my logic fetching the data and the slot battle/rollback happening. Oct 31, 2022 at 20:14
  • Two blocks targeting the same block height are likely to have predominantly the same set of transactions. If one of these blocks gets rolled back, all the transactions in that block will also be rolled back. Nov 1, 2022 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.