mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-24 10:21:22 +02:00
Merge bitcoin/bitcoin#33132: fuzz: txgraph: fix real_is_optimal
flag propagation in CommitStaging
444dcb2f99
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:83a2216f52/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] see0aedf09ccc
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: ACK444dcb2f99
glozow: ACK444dcb2f99
Tree-SHA512: c20580e14628fcdc34dabb646a097e02e95b26c5740fcd5ce50f3472e4ee08f20b9a146c9ff16c85e19e57b05af1560e41a9220289c60c15083ad897dc62a0f0
This commit is contained in:
@@ -668,7 +668,10 @@ FUZZ_TARGET(txgraph)
|
||||
} else if (block_builders.empty() && sims.size() > 1 && command-- == 0) {
|
||||
// CommitStaging.
|
||||
real->CommitStaging();
|
||||
// Resulting main level is only guaranteed to be optimal if all levels are
|
||||
const bool main_optimal = std::all_of(sims.cbegin(), sims.cend(), [](const auto &sim) { return sim.real_is_optimal; });
|
||||
sims.erase(sims.begin());
|
||||
sims.front().real_is_optimal = main_optimal;
|
||||
break;
|
||||
} else if (sims.size() > 1 && command-- == 0) {
|
||||
// AbortStaging.
|
||||
|
Reference in New Issue
Block a user