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:
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 https://github.com/theStack/bitcoin/commit/0aedf09ccc0ad4fff5956bdc012778534612c017 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).