While trying to set up ette for Avalanche C-Chain, I'm having a problem with it not being able to add blocks to the database due to foreign key constraint being violated. The reason seems to be that the blockhash
field in the block's transactions doesn't match the hash
field in the block itself. This seems to be happening for all blocks with at least one transaction.
{
"jsonrpc": "2.0",
"id": 300,
"result": {
"difficulty": "0x1",
"extraData": "0xd683010916846765746886676f312e3133856c696e7578820a2c7241a1364516998c572fd99cc06ca7f4bfcb10febe2ed3019ce17fc702",
"gasLimit": "0x458ecfe",
"gasUsed": "0xaa79",
"hash": "0x4aa30d54066664bbd8f06c39d1dc3e221df24b34d6f70f13ff70a9a602b9b386",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x0100000000000000000000000000000000000000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"number": "0x143",
"parentHash": "0x709b92a478eac8b472122343766c1f27ae279fb19af1ca17e8601c198675bc8f",
"receiptsRoot": "0x37de9c18b3cdadd7066c737c0a353fa86209d50bc1d565747a636a80140ec114",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x2e9",
"stateRoot": "0x8dbecfa700e97d335ff4f743592ae29078e1c48b50f9f2942cd6b58bad8934a3",
"timestamp": "0x5f89bfe8",
"totalDifficulty": "0x143",
"transactions": [{
"blockHash": "0x4aa30d54066664bbd8f06c39d1dc3e221df24b34d6f70f13ff70a9a602b9b386",
"blockNumber": "0x143",
"from": "0x4abef613822fb2031d897e792f89c896ddafc466",
"gas": "0xaa79",
"gasPrice": "0x6d6e2edc00",
"hash": "0xc98a2b320fc215202faf8a6fbd67a8e58ded4320234979f6b2da1cec97f9dc53",
"input": "0xa8cbe8850d892b7a4f1dc7edce9854d541db0cb91346f0d3615b2eebfae65b2c6eb93d96",
"nonce": "0x18",
"to": "0x448624cf94a47e34a1a694296c0de7b6f872be1d",
"transactionIndex": "0x0",
"value": "0x0",
"v": "0x150f7",
"r": "0x91daf0079e38117227be4a1862beb3739654f647dc1c5b99d40121aed08d93a1",
"s": "0x3fe81b66da434b165180306c44d319008ec664eff82b4524de5bebb7d4126d6c"
}],
"transactionsRoot": "0xaa8b37f5b3d4700ee10602effeea5305088ce9c2cf817867e72b1f0c6efbcb67",
"uncles": []
}
}
And this is a dump of the same block when ette attempts to store it in the database:
{
"Block": {
"Hash": "0xf81dbb7730c2f40cb39f382d9abd72fcd4fdae50bea86f126c95197a81ec6ec9",
"Number": 323,
"Time": 1602863080,
"ParentHash": "0x709b92a478eac8b472122343766c1f27ae279fb19af1ca17e8601c198675bc8f",
"Difficulty": "1",
"GasUsed": 43641,
"GasLimit": 72936702,
"Nonce": "0x0",
"Miner": "0x0100000000000000000000000000000000000000",
"Size": 710,
"StateRootHash": "0x8dbecfa700e97d335ff4f743592ae29078e1c48b50f9f2942cd6b58bad8934a3",
"UncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"TransactionRootHash": "0xaa8b37f5b3d4700ee10602effeea5305088ce9c2cf817867e72b1f0c6efbcb67",
"ReceiptRootHash": "0x37de9c18b3cdadd7066c737c0a353fa86209d50bc1d565747a636a80140ec114",
"ExtraData": "1oMBCRaEZ2V0aIZnbzEuMTOFbGludXiCCixyQaE2RRaZjFcv2ZzAbKf0v8sQ/r4u0wGc4X/HAg==",
"Transactions": {
"Hash": "",
"From": "",
"To": "",
"Contract": "",
"Value": "",
"Data": null,
"Gas": 0,
"GasPrice": "",
"Cost": "",
"Nonce": 0,
"State": 0,
"BlockHash": "",
"Events": {
"BlockHash": "",
"Index": 0,
"Origin": "",
"Topics": null,
"Data": null,
"TransactionHash": ""
}
},
"Events": {
"BlockHash": "",
"Index": 0,
"Origin": "",
"Topics": null,
"Data": null,
"TransactionHash": ""
}
},
"Transactions": [
{
"Tx": {
"Hash": "0xc98a2b320fc215202faf8a6fbd67a8e58ded4320234979f6b2da1cec97f9dc53",
"From": "0x0000000000000000000000000000000000000000",
"To": "0x448624CF94a47E34a1A694296c0De7B6f872Be1D",
"Contract": "",
"Value": "0",
"Data": "qMvohQ2JK3pPHcftzphU1UHbDLkTRvDTYVsu6/rmWyxuuT2W",
"Gas": 43641,
"GasPrice": "470000000000",
"Cost": "20511270000000000",
"Nonce": 24,
"State": 1,
"BlockHash": "0x4aa30d54066664bbd8f06c39d1dc3e221df24b34d6f70f13ff70a9a602b9b386",
"Events": {
"BlockHash": "",
"Index": 0,
"Origin": "",
"Topics": null,
"Data": null,
"TransactionHash": ""
}
},
"Events": []
}
]
}