Skip to content

bugfix: update chainman best_header after block reconsideration

Fixes #26245 (closed). I'm doing it because it came to my mind after reviewing #28339.

Inside the invalidateblock process, we update the best_header by manually calling InvalidChainFound after disconnecting blocks.

We need to do the same for reconsiderblock and update the chain best_header field after finishing the process.

Note: the only difference between this two commands is that reconsiderblock does not have its own separate function, it's a plain RPC command that resets the block index flag and calls ActivateBestChain.

The only place we forwardly update the best_header field is within AddToBlockIndex which is not called by reconsiderblock since the block is already in the block index. Thus why we need to manually update it after reconsidering a block.

Testing Notes:

  • Comment the fix line and run the rpc_invalidateblock.py test.
  • Or, call invalidateblock and compare the getblockchaininfo() 'headers' num value against getblockcount(), then do the same after calling reconsiderblock().

Merge request reports

Loading