Repository navigation
Conversation
catches validated chainstates being passed to ActivateBestChains, which previously went undetected. kills mutant https://mutanthub.space/mutants/4388 diff --git a/src/validation.cpp b/src/validation.cpp index 6bed39b..d965254192 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -6482,7 +6482,7 @@ util::Result<void> ChainstateManager::ActivateBestChains() LOCK(GetMutex()); chainstates.reserve(m_chainstates.size()); for (const auto& chainstate : m_chainstates) { - if (chainstate && chainstate->m_assumeutxo != Assumeutxo::INVALID && !chainstate->m_target_utxohash) { + if (chainstate || chainstate->m_assumeutxo != Assumeutxo::INVALID && !chainstate->m_target_utxohash) { chainstates.push_back(chainstate.get()); } }
kills mutants https://mutanthub.space/mutants/4385 and https://mutanthub.space/mutants/4386 checks prune range before a snapshot chain gets validated ensures that pruning does not start before the snapshot block or within the last 288 blocks. diff --git a/src/validation.cpp b/src/validation.cpp index 6bed39b..a51e1595aa 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -6447,7 +6447,7 @@ std::pair<int, int> Chainstate::GetPruneRange(int last_height_can_prune) const // Only prune blocks _after_ the snapshot if this is a snapshot chain // that has not been fully validated yet. The earlier blocks need to be // kept to validate the snapshot - prune_start = Assert(SnapshotBase())->nHeight + 1; + prune_start = Assert(SnapshotBase())->nHeight - 1; } int max_prune = std::max<int>( diff --git a/src/validation.cpp b/src/validation.cpp index 6bed39b..99238dfa73 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -6451,7 +6451,7 @@ std::pair<int, int> Chainstate::GetPruneRange(int last_height_can_prune) const } int max_prune = std::max<int>( - 0, m_chain.Height() - static_cast<int>(MIN_BLOCKS_TO_KEEP)); + 0, m_chain.Height() + static_cast<int>(MIN_BLOCKS_TO_KEEP)); // last block to prune is the lesser of (caller-specified height, MIN_BLOCKS_TO_KEEP from the tip) //
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, 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. |
|
cc @brunoerg |
|
Can you drop all those html tags in the PR description? It makes it hard to read anywhere else. |
done |
|
Moved CI failure to #36828 |
| return chainman.ActiveTip()->GetBlockHash()); | ||
|
|
||
| auto prune_range = WITH_LOCK(::cs_main, return active_cs.GetPruneRange(active_cs.m_chain.Height())); | ||
| BOOST_CHECK_EQUAL(prune_range.first, 111); |
There was a problem hiding this comment.
nit: I'd add a comment explaining these expected numbers. 111 only makes sense if you know the snapshot base is at 110, for example.
ViniciusCestarii
left a comment
There was a problem hiding this comment.
ACK 190f103
Nice! Verified it kills the mutants.

This PR kills 3 mutants from https://mutanthub.space/mutants in validation.cpp
I batched them together because the assertions are within the same test
Mutants killed:
Mutant 4388: validation.cpp ActivateBestChains, && → ||
Mutant 4385: validation.cpp GetPruneRange, + 1 → - 1
Mutant 4386: validation.cpp GetPruneRange, - → + MIN_BLOCKS_TO_KEEP