Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1251FUZZ_TARGET(clusterlin_postlinearize_moved_leaf)1252{1253// Verify that taking an existing linearization, and moving a leaf to the back, potentially1254// increasing its fee, and then post-linearizing, results in something as good as the1255// original. This guarantees that in an RBF that replaces a transaction with one of the same1256// size but higher fee, applying the "remove conflicts, append new transaction, postlinearize"1257// process will never worsen linearization quality.1259// Construct an arbitrary graph and a fee from the fuzz input.1260SpanReader reader(buffer);1261DepGraph<TestBitSet> depgraph;1262int32_t fee_inc{0};1263try {1264uint64_t fee_inc_code;1265reader >> Using<DepGraphFormatter>(depgraph) >> VARINT(fee_inc_code);1266fee_inc = fee_inc_code & 0x3ffff;1267} catch (const std::ios_base::failure&) {}1268if (depgraph.TxCount() == 0) return;1270// Retrieve two linearizations from the fuzz input.1271auto lin = ReadLinearization(depgraph, reader);1272auto lin_leaf = ReadLinearization(depgraph, reader);1274// Construct a linearization identical to lin, but with the tail end of lin_leaf moved to the1275// back.1276std::vector<DepGraphIndex> lin_moved;1277for (auto i : lin) {1278if (i != lin_leaf.back()) lin_moved.push_back(i);1279}1280lin_moved.push_back(lin_leaf.back());1282// Postlinearize lin_moved.1283PostLinearize(depgraph, lin_moved);1284SanityCheck(depgraph, lin_moved);1286// Compare diagrams (applying the fee delta after computing the old one).1287auto old_chunking = ChunkLinearization(depgraph, lin);1288depgraph.FeeRate(lin_leaf.back()).fee += fee_inc;1289auto new_chunking = ChunkLinearization(depgraph, lin_moved);1290auto cmp = CompareChunks(new_chunking, old_chunking);1291assert(cmp >= 0);1292}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.