From 1808b5aaf7c4910122fcd088e03d790189907438 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 16 Sep 2025 13:36:36 -0400 Subject: [PATCH] clusterlin: remove unused FixLinearization (cleanup) --- src/cluster_linearize.h | 10 ------- src/test/fuzz/cluster_linearize.cpp | 44 ----------------------------- 2 files changed, 54 deletions(-) diff --git a/src/cluster_linearize.h b/src/cluster_linearize.h index 9b7fd6a2f33..c397e879de9 100644 --- a/src/cluster_linearize.h +++ b/src/cluster_linearize.h @@ -1575,16 +1575,6 @@ void PostLinearize(const DepGraph& depgraph, std::span l } } -/** Make linearization topological, reusing information from the old linearization where possible. */ -template -void FixLinearization(const DepGraph& depgraph, std::span 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 9bd4280512f..cb5267a4ff0 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 depgraph; - try { - reader >> Using(depgraph); - } catch (const std::ios_base::failure&) {} - - // Construct an arbitrary linearization (not necessarily topological for depgraph). - std::vector 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); - } -}