Skip to content

Commit 0cb1ed2

Browse files
committed
Merge bitcoin/bitcoin#33132: fuzz: txgraph: fix real_is_optimal flag propagation in CommitStaging
444dcb2 fuzz: txgraph: fix `real_is_optimal` flag propagation in `CommitStaging` (Sebastian Falbesoner) Pull request description: In the `txgraph` fuzz test, the `CommitStaging` step updates the `SimTxGraph` levels simply by erasing the front (=main) one in the `sims` vector, i.e. the staging level instance takes the place of the main level instance: https://github.com/bitcoin/bitcoin/blob/83a2216f5278c1123ba740f1c8a055652e033ddd/src/test/fuzz/txgraph.cpp#L668-L672 This also includes the `real_is_optimal` flag (reflecting whether the corresponding real graph is known to be optimally linearized), without taking into account that this flag should only be set if _both_ levels before the commiting are optimal. E.g. in case of #33097, at this point the main level is not optimally linearized, while the staging level is, and due to the incorrect propagation of the latter the simulation incorrectly assumes that the main level is optimal after, leading to the assertion fail in the additional checks that are ran in this case[1]. Fix this by setting the flag in the resulting main level explicitly. This is done in a generic way, in case there will ever be more than two levels (not sure what is planned in this direction), a simpler alternative would be e.g. `main_optimal = sim[0].real_is_optimal && sim[1].real_is_optimal`. Fixes #33097. [1] see theStack/bitcoin@0aedf09 for the printf-debug-session-clutter, if that is useful/interesting for anyone (most of the output turned out to be irrelevant to the actual cause of #33097, but it was an entertaining way to discover the interface and get a first glimpse of `TxGraph` internals as a cluster-mempool newbie). ACKs for top commit: sipa: ACK 444dcb2 glozow: ACK 444dcb2 Tree-SHA512: c20580e14628fcdc34dabb646a097e02e95b26c5740fcd5ce50f3472e4ee08f20b9a146c9ff16c85e19e57b05af1560e41a9220289c60c15083ad897dc62a0f0
2 parents 83a2216 + 444dcb2 commit 0cb1ed2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/test/fuzz/txgraph.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,10 @@ FUZZ_TARGET(txgraph)
668668
} else if (block_builders.empty() && sims.size() > 1 && command-- == 0) {
669669
// CommitStaging.
670670
real->CommitStaging();
671+
// Resulting main level is only guaranteed to be optimal if all levels are
672+
const bool main_optimal = std::all_of(sims.cbegin(), sims.cend(), [](const auto &sim) { return sim.real_is_optimal; });
671673
sims.erase(sims.begin());
674+
sims.front().real_is_optimal = main_optimal;
672675
break;
673676
} else if (sims.size() > 1 && command-- == 0) {
674677
// AbortStaging.

0 commit comments

Comments
 (0)