Now that this path is no longer used after commit b51e60f91472da5216116626afc032acd5616e85, we can remove it.
Future code should reset CChain by simply discarding it and constructing a fresh one.
Now that this path is no longer used after commit b51e60f91472da5216116626afc032acd5616e85, we can remove it.
Future code should reset CChain by simply discarding it and constructing a fresh one.
ACK https://github.com/bitcoin/bitcoin/pull/25023/commits/faa7a1e62bc94081cf2ba688e5fec427733af9d8
Testing: IBD against Signet
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
2623 | @@ -2624,7 +2624,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr 2624 | } 2625 | } 2626 | 2627 | - m_chain.SetTip(pindexDelete->pprev); 2628 | + m_chain.SetTip(*Assert(pindexDelete->pprev));
In commit "Remove unused SetTip(nullptr) code" (faf57a6898590cecfbb918d73abbf2c100206b8e)
I think it would be good to add an assert to the top of the function to make it more obvious it will crash if called on the genesis block:
diff --git a/src/validation.cpp b/src/validation.cpp
index da18fec1d85..75d06841e3f 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2577,6 +2577,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, DisconnectedBlockTr
CBlockIndex *pindexDelete = m_chain.Tip();
assert(pindexDelete);
+ assert(pindexDelete->pprev);
// Read block from disk.
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
CBlock& block = *pblock;
Nice, done.
Code review ACK faf57a6898590cecfbb918d73abbf2c100206b8e
Code review ACK faab8dceb37a944d0763fcca390342111e6a9fcc. Just moved an assert statement since last review