lbryio / hub

MIT License
16 stars 15 forks source link

Incorrect address statuses in the address status index #61

Closed jackrobison closed 2 years ago

jackrobison commented 2 years ago

There is a bug in the address status index, it's not clear yet how many addresses are impacted, and can result in clients not fully syncing their histories (which can result in them erroneously and unsuccessfully trying to spend already spent utxos).

For the address bSeWnSKTiQRtQ76jkz4pru2XXnw9wchmqb the history is correct but the precalculated status omits the last transaction when it's hashed, ie it's supposed to be

sha256('3c1b765b412703a9f02d0328886df43fe9516ecfea66e70be61658f79b48d70a:1142400:32ddebefc0620d020d91b0f9de5a93082b636905b5b934675e90dbd26b6f7141:1176287:'.encode()).hex()
'49050a8ffaf514cbae321f21e8ab9649da3743ccaeda102fb107fbde491f7971'

but it actually contains

sha256('3c1b765b412703a9f02d0328886df43fe9516ecfea66e70be61658f79b48d70a:1142400:'.encode()).hex()
'9ad3840619ee1ba015c29ce78cd7bb1b4c89d40c5c682bd2c646e476599003a9'

This needs to be reproduced in a test, the bug is probably in the startup / initial catchup code (or else it would be far more common).

tzarebczan commented 2 years ago

on top of balance issues, this also causes channels or content to become unavialable.

tzarebczan commented 2 years ago

example wth a local wallet I had - had to connect to 16 to get these txes:

2022-08-23 12:06:07,051 INFO     lbry.wallet.ledger:503: finished subscribing to 6 addresses on 51.81.208.135:50001
2022-08-23 12:06:07,159 INFO     lbry.wallet.ledger:135: (lbc_mainnet) on_transaction: address=bU9RraZGaxqnWfKPTTCEYzzN69u5ty3RWp, height=1169309, is_verified=True, tx.id=8786ef5842e329c9049562bbc421ec845696f5913e80d8822ed401e705e4fefc
2022-08-23 12:06:07,159 INFO     lbry.wallet.ledger:560: Sync finished for address bU9RraZGaxqnWfKPTTCEYzzN69u5ty3RWp: 1/1
2022-08-23 12:06:07,224 INFO     lbry.wallet.ledger:135: (lbc_mainnet) on_transaction: address=bUemWWN5Rp6cMgm6wd7JL15noxZsbU9eFW, height=1176360, is_verified=True, tx.id=7d7b48d4e36b552e9e13da6e66e6e63d4b60909df6710203c154be92678d1cd1
2022-08-23 12:06:07,224 INFO     lbry.wallet.ledger:560: Sync finished for address bUemWWN5Rp6cMgm6wd7JL15noxZsbU9eFW: 1/1
2022-08-23 12:06:07,231 INFO     lbry.wallet.ledger:135: (lbc_mainnet) on_transaction: address=baS5DVbBLizs8omuRdpFGTRCHL5r7v3yPj, height=1169352, is_verified=True, tx.id=b271cd2ad690767b577a75b7ad305d3c4dd58da0943b35cd275a53a3c69f00ec
2022-08-23 12:06:07,231 INFO     lbry.wallet.ledger:560: Sync finished for address baS5DVbBLizs8omuRdpFGTRCHL5r7v3yPj: 1/1
2022-08-23 12:06:07,306 INFO     lbry.wallet.ledger:135: (lbc_mainnet) on_transaction: address=bK4ZEF9sy2s5rWgoYfR5ePTE4UvqKvSnZF, height=1169352, is_verified=True, tx.id=b271cd2ad690767b577a75b7ad305d3c4dd58da0943b35cd275a53a3c69f00ec
2022-08-23 12:06:07,307 INFO     lbry.wallet.ledger:135: (lbc_mainnet) on_transaction: address=bK4ZEF9sy2s5rWgoYfR5ePTE4UvqKvSnZF, height=1169309, is_verified=True, tx.id=8786ef5842e329c9049562bbc421ec845696f5913e80d8822ed401e705e4fefc
2022-08-23 12:06:07,307 INFO     lbry.wallet.ledger:560: Sync finished for address bK4ZEF9sy2s5rWgoYfR5ePTE4UvqKvSnZF: 2/2
2022-08-23 12:06:07,900 INFO     lbry.wallet.ledger:933: Loaded account bEApqqArHAgehLzdB8SoezUa4Nu2LnGDtD with 2.864672 LBC, 467 receiving addresses (gap: 20), 472 change addresses (gap: 6), 0 channels, 2 certificates and 433 claims.
2022-08-23 12:06:07,902 INFO     lbry.wallet.ledger:933: Loaded account bH9nRdgbrAFKZLLxKbW1wTCKwdoa1jWvHY with 0.0 LBC, 20 receiving addresses (gap: 20), 6 change addresses (gap: 6), 0 channels, 0 certificates and 0 claims.
2022-08-23 12:06:07,907 INFO     lbry.wallet.ledger:933: Loaded account bHbKbPFVUpq2aqhkFBnqzrMNJqXyhKHTUU with 0.65781 LBC, 140 receiving addresses (gap: 20), 119 change addresses (gap: 6), 8 channels, 9 certificates and 108 claims.