Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale block address indexing bug #11

Closed
mononaut opened this issue Jun 5, 2023 · 2 comments · Fixed by #12 or #44
Closed

Stale block address indexing bug #11

mononaut opened this issue Jun 5, 2023 · 2 comments · Fixed by #12 or #44
Assignees

Comments

@mononaut
Copy link
Contributor

mononaut commented Jun 5, 2023

Electrs appears to double-count certain transactions during address indexing, which produces incorrect chain stats (funded_txo_sum etc) and therefore incorrect balances displayed on mempool.space.

Screenshot 2023-06-05 at 11 39 08 AM

Specifically, the error seems to occur when a transaction is included in a stale block, but not the "winning" block at the same height.

For example, transaction 3738...e88e
was included in a recent stale block 000000000000000000032956cbfd8721abe0572d81542e75e38e6185312bee09 at height 792379, but eventually entered the main chain in block 792380.

The transaction is then double-counted during address indexing,
causing address 132kFhZzkFytWAefWy7nCYgJHcU84RjJNa
to show a negative balance.

Similarly, transaction 3264...d9cb appears in the same stale block, enters the main chain in block 792382, and is counted twice towards address bc1qzuupxjkwv4dj69m3xzack5sdqtacn6l8czndlf, causing a positive balance to display when in fact the address should be empty.

Screenshot 2023-06-05 at 12 05 33 PM

Transactions which appear at the same height on both sides of a chain split appear to be handled correctly.

For example, address bc1pfajpg0fp0a62wjrax682hkzvrczxx7j3htrtm0ae6cnx72ye2rnscarxrp has a transaction which is included in both versions of block 792379, but reports the correct balance.

@mononaut
Copy link
Contributor Author

As seen in mempool/mempool#4196, this still seems to be reproducing in production on multiple servers in all sites, e.g.

https://node203.fra.mempool.space/address/38A4VFuFs95QaxTPUec9jEVqW5rFE7z7jx
https://node204.tk7.mempool.space/address/38A4VFuFs95QaxTPUec9jEVqW5rFE7z7jx
https://node202.fmt.mempool.space/address/38A4VFuFs95QaxTPUec9jEVqW5rFE7z7jx

Screenshot 2023-08-25 at 1 47 40 AM

In this case transaction 20f7...3e8c was included in that same stale block at height 792379, and again in the main chain in block 792380, and so counted twice towards the address totals.

@junderw
Copy link
Sponsor Member

junderw commented Aug 24, 2023

The solution is #28

Which I'm currently working on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants