RPC node sometimes don't return the full transaction metadata
Strangely enough, in an isolated number of transactions, it seems that the tezos transaction metadata stored by djwebdapp isn't the full one. Here is a example of a transaction that was stored, witness its metadata:
In [3]: tx = TezosTransaction.objects.filter(hash="onuvWkrTyyCBHgvqjb3KmGuV8DHKs5Fc25VnKKEeLzsJWVMRcy1").first()
In [4]: tx.function
Out[4]:
"assignMetadata"
In [5]: tx.metadata
Out[5]:
{'fee': '1507',
'kind': 'transaction',
'amount': '0',
'source': 'tz1NFij9qDMNvLSYzg6kvF7MCAQheACnaA8B',
'counter': '69554137',
'gas_limit': '11939',
'parameters': {'value': {'int': '8274'}, 'entrypoint': 'assignMetadata'},
'destination': 'KT1TjHyHTnL4VMQQyD75pr3ZTemyPvQxRPpA',
'storage_limit': '0'}
Now if we retrieve this transaction from the appropriate block using pytezos, we see that there is an extra metadata
key in contents
that contains a lot of information:
In [67]: pytezos.using(shell="mainnet").shell.blocks[tx.level:tx.level].find_operation("onuvWkrTyyCBHgvqjb3KmGuV8DHKs5Fc25VnKKEeLzsJWVMRcy1")
Out[67]:
{'protocol': 'PtJakart2xVj7pYXJBXrqHgd82rdkLey5ZeeGwDgPp9rhQUbSqY',
'chain_id': 'NetXdQprcVkpaWU',
'hash': 'onuvWkrTyyCBHgvqjb3KmGuV8DHKs5Fc25VnKKEeLzsJWVMRcy1',
'branch': 'BL2gQvk8Lc4K6H74cQj45HMgpe4uVRT9MrTPorwN1eodDaaumV8',
'contents': [{'kind': 'transaction',
'source': 'tz1NFij9qDMNvLSYzg6kvF7MCAQheACnaA8B',
'fee': '1507',
'counter': '69554137',
'gas_limit': '11939',
'storage_limit': '0',
'amount': '0',
'destination': 'KT1TjHyHTnL4VMQQyD75pr3ZTemyPvQxRPpA',
'parameters': {'entrypoint': 'assignMetadata', 'value': {'int': '8274'}},
'metadata': {'balance_updates': [{'kind': 'contract',
'contract': 'tz1NFij9qDMNvLSYzg6kvF7MCAQheACnaA8B',
'change': '-1507',
'origin': 'block'},
{'kind': 'accumulator',
'category': 'block fees',
'change': '1507',
'origin': 'block'}],
'operation_result': {'status': 'applied',
'storage': [{'prim': 'False'},
{'bytes': '0148c094b504e3ffe57d6535b8eca856ec5cabeddf00'},
{'bytes': '0198a70d32be28c022b66b20de2bfd0eed7adc1bc000'},
{'bytes': '0162973eb7780358871be6b69e18e066e868fb2c3500'},
{'bytes': '0000b079ac99e9a2803f92d29e61de2513a963201afc'},
{'prim': 'True'},
{'int': '122200000'},
{'int': '12000'},
{'int': '184775'},
{'int': '1'},
{'int': '1654020000'},
{'int': '1654254000'},
{'int': '1655900520'},
{'int': '182092'},
{'int': '182093'},
{'int': '1045'},
{'int': '182094'},
{'int': '1164'},
{'int': '182095'},
{'int': '1689'},
{'int': '12001'},
[{'bytes': '00000b543f8daf2a45cf23100caea8deb694b8f68749'},
{'bytes': '000025682076db62e35e77240be47c4414df480ee87a'},
{'bytes': '00002602bf76c95ebf46d10f6730e60e1b98a9704431'},
{'bytes': '000035b343b8f0bd25997dc1bfc30bdec1ab9575307f'},
{'bytes': '000035e01ed594b7d9ea11ed2f0072eea18575b593af'},
{'bytes': '0000372134f8594a1f2a831feb831cd19d50f4d42e96'},
{'bytes': '0000447a097b1d61141a9dc048ebb2340753997a0a34'},
{'bytes': '000044b86d3dee79b9d216d24206910b50f2bb194440'},
{'bytes': '0000a44ddb58ec06ca09e37862943ac0627ea6fc0c54'},
{'bytes': '0000b198dabd74e5368a46d4501a39bb1640706c2022'},
{'bytes': '0000b9c04b83308f50e8e2dcefe4631ff3936120c165'},
{'bytes': '0000c5568528ec1f41551a0901f22c8da5f96f76cb34'},
{'bytes': '0000d09ab64376dc32415cb596b9b403c82742613d64'},
{'bytes': '0000d756c4987a62094c88690c394850000e366c911a'},
{'bytes': '0000db20ee4f8d103715eb1e082200805f82cc9ad81b'},
{'bytes': '0000f9a82724675ed7b592285d1dc90f09b699c171bb'},
{'bytes': '0000fc883f51eb0a791f0c72d1ad04abce41dae66cf6'}],
{'int': '182096'},
{'bytes': '01dbc8b536f0075d16d62df174b74e442e1b4fe83400'},
{'string': 'ipfs://hash'}],
'consumed_gas': '11839',
'consumed_milligas': '11838637',
'storage_size': '1161644',
'lazy_storage_diff': [{'kind': 'big_map',
'id': '182096',
'diff': {'action': 'update', 'updates': []}},
{'kind': 'big_map',
'id': '182095',
'diff': {'action': 'update',
'updates': [{'key_hash': 'exprv7v47Lhsurt6DzJSYWLFeTapo4G8kkZPNk3qBWbvo7bS6NBsif',
'key': {'int': '8274'},
'value': {'int': '1689'}}]}},
{'kind': 'big_map',
'id': '182094',
'diff': {'action': 'update',
'updates': [{'key_hash': 'expruroVPtUA3L52nMEji6chHsVPpo466qXBUNHiBy3Fy1LBXhAJKs',
'key': {'int': '218'},
'value': {'int': '1165'}},
{'key_hash': 'expruLLGU8Ua5nVpcwhr1LNG7A6PS563VDLwuobHZtdnapg6UML74K',
'key': {'int': '1165'}}]}},
{'kind': 'big_map',
'id': '182093',
'diff': {'action': 'update', 'updates': []}},
{'kind': 'big_map',
'id': '182092',
'diff': {'action': 'update', 'updates': []}},
{'kind': 'big_map',
'id': '184775',
'diff': {'action': 'update', 'updates': []}}]}}}],
'signature': 'sigbRjPRz9TEB2eCoZLp5k1cxvqwERFDQhskxzUUuaciD98DyRhBUpX8dRJxkJNiX8JhRhyquqEsbSgfQ5T9YMBWcXLDNqBd'}
What's really weird is that this is how the djwebapp tezos indexer works, using a pytezos shell to parse blocks. So it must be that this transaction was updated afterwards by the RPC node?
Somehow, this is not the general behavior. Here is an random tezos transaction for the same entrypoint on the same contract and we see that the metadata way properly stored:
In [11]: TezosTransaction.objects.filter(function="assignMetadata").first().metadata
Out[11]:
{'fee': '1506',
'kind': 'transaction',
'amount': '0',
'source': 'tz1irDqkPPWzfjFCcEcU1h3bctFBmC9eCnnJ',
'counter': '47918884',
'metadata': {'balance_updates': [{'kind': 'contract',
'change': '-1506',
'origin': 'block',
'contract': 'tz1irDqkPPWzfjFCcEcU1h3bctFBmC9eCnnJ'},
{'kind': 'accumulator',
'change': '1506',
'origin': 'block',
'category': 'block fees'}],
'operation_result': {'status': 'applied',
'storage': [{'prim': 'False'},
{'bytes': '0148c094b504e3ffe57d6535b8eca856ec5cabeddf00'},
{'bytes': '0198a70d32be28c022b66b20de2bfd0eed7adc1bc000'},
{'bytes': '0162973eb7780358871be6b69e18e066e868fb2c3500'},
{'bytes': '0000b079ac99e9a2803f92d29e61de2513a963201afc'},
{'prim': 'True'},
{'int': '122200000'},
{'int': '12000'},
{'int': '184775'},
{'int': '1'},
{'int': '1654020000'},
{'int': '1654254000'},
{'int': '1655900520'},
{'int': '182092'},
{'int': '182093'},
{'int': '1044'},
{'int': '182094'},
{'int': '1152'},
{'int': '182095'},
{'int': '3863'},
{'int': '12001'},
[{'bytes': '00000b543f8daf2a45cf23100caea8deb694b8f68749'},
{'bytes': '000025682076db62e35e77240be47c4414df480ee87a'},
{'bytes': '00002602bf76c95ebf46d10f6730e60e1b98a9704431'},
{'bytes': '000035b343b8f0bd25997dc1bfc30bdec1ab9575307f'},
{'bytes': '000035e01ed594b7d9ea11ed2f0072eea18575b593af'},
{'bytes': '0000372134f8594a1f2a831feb831cd19d50f4d42e96'},
{'bytes': '0000447a097b1d61141a9dc048ebb2340753997a0a34'},
{'bytes': '000044b86d3dee79b9d216d24206910b50f2bb194440'},
{'bytes': '0000a44ddb58ec06ca09e37862943ac0627ea6fc0c54'},
{'bytes': '0000b198dabd74e5368a46d4501a39bb1640706c2022'},
{'bytes': '0000b9c04b83308f50e8e2dcefe4631ff3936120c165'},
{'bytes': '0000c5568528ec1f41551a0901f22c8da5f96f76cb34'},
{'bytes': '0000d09ab64376dc32415cb596b9b403c82742613d64'},
{'bytes': '0000d756c4987a62094c88690c394850000e366c911a'},
{'bytes': '0000db20ee4f8d103715eb1e082200805f82cc9ad81b'},
{'bytes': '0000f9a82724675ed7b592285d1dc90f09b699c171bb'},
{'bytes': '0000fc883f51eb0a791f0c72d1ad04abce41dae66cf6'}],
{'int': '182096'},
{'bytes': '01dbc8b536f0075d16d62df174b74e442e1b4fe83400'},
{'string': 'ipfs://hash'}],
'consumed_gas': '11839',
'storage_size': '1161644',
'consumed_milligas': '11838637',
'lazy_storage_diff': [{'id': '182096',
'diff': {'action': 'update', 'updates': []},
'kind': 'big_map'},
{'id': '182095',
'diff': {'action': 'update',
'updates': [{'key': {'int': '9250'},
'value': {'int': '3863'},
'key_hash': 'exprvEgT5KABJ7qfXsbe8DEVeCMbkS1DMifT9Pz9eve4uMkShpMmSC'}]},
'kind': 'big_map'},
{'id': '182094',
'diff': {'action': 'update',
'updates': [{'key': {'int': '285'},
'value': {'int': '2152'},
'key_hash': 'exprtqHbUnaHtTz44nNbM21aGJzUJzD9BcYBBKJ6FVPTUDyxKGKiT7'},
{'key': {'int': '1153'},
'key_hash': 'exprtdmDpVGMpSWifRV8v8mGPrGnsCDGp5RMhETAW1r6jtA3zF6d3S'}]},
'kind': 'big_map'},
{'id': '182093',
'diff': {'action': 'update', 'updates': []},
'kind': 'big_map'},
{'id': '182092',
'diff': {'action': 'update', 'updates': []},
'kind': 'big_map'},
{'id': '184775',
'diff': {'action': 'update', 'updates': []},
'kind': 'big_map'}]}},
'gas_limit': '11939',
'parameters': {'value': {'int': '9250'}, 'entrypoint': 'assignMetadata'},
'destination': 'KT1TjHyHTnL4VMQQyD75pr3ZTemyPvQxRPpA',
'storage_limit': '0'}
Maybe the RPC nodes sometimes don't respond with the entire metadata associated to a transaction?