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

Reconsidering block will not reconsider its chain. #277

Open
nodech opened this issue Aug 16, 2017 · 2 comments
Open

Reconsidering block will not reconsider its chain. #277

nodech opened this issue Aug 16, 2017 · 2 comments
Labels
bug Unexpected or incorrect behavior rpc
Milestone

Comments

@nodech
Copy link
Member

nodech commented Aug 16, 2017

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.

@bucko13 bucko13 added the bug Unexpected or incorrect behavior label Aug 16, 2017
@chjj
Copy link
Member

chjj commented Aug 18, 2017

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.

@braydonf
Copy link
Contributor

braydonf commented Oct 8, 2019

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

bcoin/lib/blockchain/chain.js

Lines 1749 to 1752 in 99638ac

if (this.invalid.has(block.prevBlock)) {
this.setInvalid(hash);
return true;
}
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect behavior rpc
Projects
None yet
Development

No branches or pull requests

4 participants