getbestblock returns empty(or stale) blockhash after reorg or invalidateblock #28

Closed
opened 2022-09-13 20:21:19 +02:00 by roylee17 · 0 comments
roylee17 commented 2022-09-13 20:21:19 +02:00 (Migrated from github.com)

Invalidate the current best block:

lbcctl --regtest getbestblock
{
  "hash": "50f165cf4349b9d6060e88fc43194a461d5ce662f9bcab3a53245ed239a94b67",
  "height": 91
}
lbcctl --wallet --regtest invalidateblock 50f165cf4349b9d6060e88fc43194a461d5ce662f9bcab3a53245ed239a94b67

The returned height is correct, but not the hash.

lbcctl --wallet --regtest getbestblock
{
  "hash": "0000000000000000000000000000000000000000000000000000000000000000",
  "height": 90
}

Query from the chain (without proxied by wallet) gives the correct result:

lbcctl --regtest getbestblock
{
  "hash": "809940cabb84b1089c3c470810572cab5b51bae601fea3a149c171db9b00c8e8",
  "height": 90
}

Generating new blocks to grow the chain back to its previous height (or higher) seems correct this issue.

lbcctl --regtest generatetoaddress 1 mqWsCbkAS23U7a6sxtfDdQqGPD5qpQAnMi
[
  "7bdab5bf8c3e256408c0fd44e898e01e5cca74d7ffcac0ff57a7c41667c2f31c"
]

lbcctl --regtest getbestblock
{
  "hash": "7bdab5bf8c3e256408c0fd44e898e01e5cca74d7ffcac0ff57a7c41667c2f31c",
  "height": 91
}

This creates a window for race conditions where the chain state is inconsistent after a reorg.

Invalidate the current best block: ``` lbcctl --regtest getbestblock { "hash": "50f165cf4349b9d6060e88fc43194a461d5ce662f9bcab3a53245ed239a94b67", "height": 91 } lbcctl --wallet --regtest invalidateblock 50f165cf4349b9d6060e88fc43194a461d5ce662f9bcab3a53245ed239a94b67 ``` The returned `height` is correct, but not the `hash`. ``` lbcctl --wallet --regtest getbestblock { "hash": "0000000000000000000000000000000000000000000000000000000000000000", "height": 90 } ``` Query from the chain (without proxied by wallet) gives the correct result: ``` lbcctl --regtest getbestblock { "hash": "809940cabb84b1089c3c470810572cab5b51bae601fea3a149c171db9b00c8e8", "height": 90 } ``` Generating new blocks to grow the chain back to its previous height (or higher) seems correct this issue. ``` lbcctl --regtest generatetoaddress 1 mqWsCbkAS23U7a6sxtfDdQqGPD5qpQAnMi [ "7bdab5bf8c3e256408c0fd44e898e01e5cca74d7ffcac0ff57a7c41667c2f31c" ] lbcctl --regtest getbestblock { "hash": "7bdab5bf8c3e256408c0fd44e898e01e5cca74d7ffcac0ff57a7c41667c2f31c", "height": 91 } ``` This creates a window for race conditions where the chain state is inconsistent after a reorg.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbcwallet#28
No description provided.