bcoin icon indicating copy to clipboard operation
bcoin copied to clipboard

Reconsidering block will not reconsider its chain.

Open nodech opened this issue 8 years ago • 2 comments

When you invalidate block, say:

bcoin cli rpc invalidateblock 0000000000000dc9f431dc685214fab27a663e09028b3ebb3dc2abc8ac9c2c34. This block is on testnet, height: 1178740.

This will rewind blockchain to block 1178739 and add this to Invalid list (LRU). This is expected behavior.

When you receive new blocks that descended from that block, they will also end up in invalid block set.

But when you reconsider it: bcoin cli rpc reconsiderblock 0000000000000dc9f431dc685214fab27a663e09028b3ebb3dc2abc8ac9c2c34

It will only remove block 1178740 from the invalid list, it's descendants will be still invalid.

Workaround is simple right now: restart the node. (this will clear LRU) Or reconsider everyblock from invalid list.

nodech avatar Aug 16 '17 18:08 nodech

Yeah, the only easy workarounds I see here are to clear the entire LRU cache if a block is reconsidered, or to not add the proceeding blocks to the LRU cache in the first place if one of their parents is invalid.

In reality, the invalidateblock call is supposed to be persistent across restarts, which it is with Bitcoin Core. This is possible in Core because it tracks a ton of extra useless stuff on chain headers. Bcoin doesn't really bother with that since it's just extra bloat, and not necessary for a blockchain to function.

chjj avatar Aug 18 '17 02:08 chjj

Or to not add the proceeding blocks to the LRU cache in the first place if one of their parents is invalid.

The relevant lines there are at https://github.com/bcoin-org/bcoin/blob/99638ac1090402b6efe3364e0de3be3be903626d/lib/blockchain/chain.js#L1749-L1752.

braydonf avatar Oct 08 '19 22:10 braydonf