Fixes #26245. 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.pytest. - Or, call
invalidateblockand compare thegetblockchaininfo()‘headers’ num value againstgetblockcount(), then do the same after callingreconsiderblock().