clusterlin: remove unused FixLinearization (cleanup)
What changed, and why it matters
This commit simply deletes an unused internal function called FixLinearization and its associated test. There is no security relevance: no bug is fixed, no behavior changes, and no live code path is altered.
No action needed; this is a routine code-cleanup commit with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch removes the FixLinearization template function from src/cluster_linearize.h and the clusterlin_fix_linearization fuzz target from src/test/fuzz/cluster_linearize.cpp. The function was already unused (a TODO comment even noted callers should use Linearize directly), and the fuzz target only tested that removed function. No runtime logic in Bitcoin Core is affected.
Changed components
src/cluster_linearize.hsrc/test/fuzz/cluster_linearize.cppInspect captured patch +0 / −54
diff --git a/src/cluster_linearize.h b/src/cluster_linearize.h
index 9b7fd6a2..c397e879 100644
--- a/src/cluster_linearize.h
+++ b/src/cluster_linearize.h
@@ -1575,16 +1575,6 @@ void PostLinearize(const DepGraph<SetType>& depgraph, std::span<DepGraphIndex> l
}
}
-/** Make linearization topological, reusing information from the old linearization where possible. */
-template<typename SetType>
-void FixLinearization(const DepGraph<SetType>& depgraph, std::span<DepGraphIndex> linearization) noexcept
-{
- // TODO: update call sites to use Linearize directly.
- auto [new_lin, _opt, _steps] = Linearize(depgraph, /*max_iterations=*/0, /*rng_seed=*/0, linearization, /*is_topological=*/false);
- Assume(new_lin.size() == linearization.size());
- std::copy(new_lin.begin(), new_lin.end(), linearization.begin());
-}
-
} // namespace cluster_linearize
#endif // BITCOIN_CLUSTER_LINEARIZE_H
diff --git a/src/test/fuzz/cluster_linearize.cpp b/src/test/fuzz/cluster_linearize.cpp
index 9bd42805..cb5267a4 100644
--- a/src/test/fuzz/cluster_linearize.cpp
+++ b/src/test/fuzz/cluster_linearize.cpp
@@ -58,8 +58,6 @@
* - clusterlin_postlinearize
* - clusterlin_postlinearize_tree
* - clusterlin_postlinearize_moved_leaf
- * - FixLinearization tests:
- * - clusterlin_fix_linearization
* - MakeConnected tests (a test-only function):
* - clusterlin_make_connected
*/
@@ -1202,45 +1200,3 @@ FUZZ_TARGET(clusterlin_postlinearize_moved_leaf)
auto cmp = CompareChunks(new_chunking, old_chunking);
assert(cmp >= 0);
}
-
-FUZZ_TARGET(clusterlin_fix_linearization)
-{
- // Verify expected properties of FixLinearization() on arbitrary linearizations.
-
- // Retrieve a depgraph from the fuzz input.
- SpanReader reader(buffer);
- DepGraph<TestBitSet> depgraph;
- try {
- reader >> Using<DepGraphFormatter>(depgraph);
- } catch (const std::ios_base::failure&) {}
-
- // Construct an arbitrary linearization (not necessarily topological for depgraph).
- std::vector<DepGraphIndex> linearization = ReadLinearization(depgraph, reader, /*topological=*/false);
- assert(linearization.size() == depgraph.TxCount());
-
- // Determine what prefix of linearization is topological, i.e., the position of the first entry
- // in linearization which corresponds to a transaction that is not preceded by all its
- // ancestors.
- size_t topo_prefix = 0;
- auto todo = depgraph.Positions();
- while (topo_prefix < linearization.size()) {
- DepGraphIndex idx = linearization[topo_prefix];
- todo.Reset(idx);
- if (todo.Overlaps(depgraph.Ancestors(idx))) break;
- ++topo_prefix;
- }
-
- // Then make a fixed copy of linearization.
- auto linearization_fixed = linearization;
- FixLinearization(depgraph, linearization_fixed);
- // Sanity check it (which includes testing whether it is topological).
- SanityCheck(depgraph, linearization_fixed);
-
- // If linearization was entirely topological, FixLinearization cannot worsen it.
- if (topo_prefix == linearization.size()) {
- auto chunking = ChunkLinearization(depgraph, linearization);
- auto chunking_fixed = ChunkLinearization(depgraph, linearization_fixed);
- auto cmp = CompareChunks(chunking_fixed, chunking);
- assert(cmp >= 0);
- }
-}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.