Block decrement can put claimtrie in erroneous state #243
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
hard fork
help wanted
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
soft fork
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
work in progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbrycrd#243
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue found by @BrannonKing
When there is a claim/support in the queue (has not been activated yet, and has activation height X), it can be put into the claimtrie at some height Y less than X if a takeover is triggered (some other claim wins the name, or winning claim abandoned). This condition shall be called "early activation".
If an active block contains a claim with "early activation" and was decremented, the undo information for that claim with early activation was incorrectly applied. If correctly applied, the claim would go back into the queue with its original activation height X. There are also two queues, one that is indexed on "name" and has the activation height as one of its value, and one that is indexed on "activation height".
However, for a claim we would incorrectly put the claim back into the queue. In the "name" indexed queue we put it back with the early activation height Y and than in the "activation height" indexed queue, we put it back with the activation height X. This discrepancy would cause lbrycrdd to crash on the assert below once this claim became active again and it needed to be deleted from the queue
e89d748b2f/src/claimtrie.cpp (L2115)
Thus if a block containing a claim with early activation was reorged, it will cause the node to eventually crash once the claim became activated again. A reindex should wipe out the incorrect state of the claimtrie, and should allow the node to continue (assuming a similar reorg does not happen again)
For a support, we would incorrectly put it back in both queues with the early activation height Y. Thus, it would incorrectly activate on the next increment. This may cause the node to get stuck as the claimtrie may end up in an incorrect state. Worse, this can be used to split consensus.
Fix here: https://github.com/lbryio/lbrycrd/pull/244