Merge bitcoin/bitcoin#35972: fuzz: Fix assertion in txorphan

01dde6b205 fuzz: Fix assertion in txorphan (marcofleon)

Pull request description:

  `EraseTx()` calls `LimitOrphans()`, which may evict announcements from a peer that didn't announce the erased transaction, causing that peer's usage to decrease. Relax the assertion in the `EraseTx()` branch that claimed usage of a non-announcer peer should be unchanged. Also, add assertions for the other cases.

ACKs for top commit:
  dergoegge:
    utACK 01dde6b205
  instagibbs:
    ACK 01dde6b205

Tree-SHA512: 2e597b85fd41058c2fa79fa55f0d37e12505065b5e27aba7b9680e0c249a5450e6fa97b45394d6ffe1318f42538134ffa9c423b126c455f6f8e6d8ca59eed4b6
This commit is contained in:
merge-script
2026-08-17 12:04:02 +01:00

View File

@@ -173,11 +173,13 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
{
auto bytes_from_peer_before{orphanage->UsageByPeer(peer_id)};
Assert(have_tx == orphanage->EraseTx(tx->GetWitnessHash()));
// After EraseTx, the orphanage may trim itself, so all peers' usage may have gone up or down.
if (have_tx) {
if (!have_tx_and_peer) {
Assert(orphanage->UsageByPeer(peer_id) == bytes_from_peer_before);
}
// After EraseTx, the orphanage may trim itself, so any peer's usage may decrease.
if (!have_tx) {
Assert(orphanage->UsageByPeer(peer_id) == bytes_from_peer_before);
} else if (have_tx_and_peer) {
Assert(orphanage->UsageByPeer(peer_id) <= bytes_from_peer_before - tx_weight);
} else {
Assert(orphanage->UsageByPeer(peer_id) <= bytes_from_peer_before);
}
}
have_tx = orphanage->HaveTx(tx->GetWitnessHash());