Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin/bitcoin#30110: refactor: TxDownloadManager + fuzzing
0f4bc63 [fuzz] txdownloadman and txdownload_impl (glozow) 699643f [unit test] MempoolRejectedTx (glozow) fa584cb [p2p] add TxDownloadOptions bool to make TxRequestTracker deterministic (glozow) f803c8c [p2p] filter 1p1c for child txid in recent rejects (glozow) 5269d57 [p2p] don't process orphan if in recent rejects (glozow) 2266eba [p2p] don't find 1p1cs for reconsiderable txns that are AlreadyHaveTx (glozow) fa7027d [refactor] add CheckIsEmpty and GetOrphanTransactions, remove access to TxDownloadMan internals (glozow) 969b072 [refactor] wrap {Have,Get}TxToReconsider in txdownload (glozow) f150fb9 [refactor] make AlreadyHaveTx and Find1P1CPackage private to TxDownloadImpl (glozow) 1e08195 [refactor] move new tx logic to txdownload (glozow) 257568e [refactor] move invalid package processing to TxDownload (glozow) c4ce0c1 [refactor] move invalid tx processing to TxDownload (glozow) c6b2174 [refactor] move valid tx processing to TxDownload (glozow) a8cf3b6 [refactor] move Find1P1CPackage to txdownload (glozow) f497414 [refactor] put peerman tasks at the end of ProcessInvalidTx (glozow) 6797bc4 [p2p] restrict RecursiveDynamicUsage of orphans added to vExtraTxnForCompact (glozow) 798cc8f [refactor] move Find1P1CPackage into ProcessInvalidTx (glozow) 416fbc9 [refactor] move new orphan handling to ProcessInvalidTx (glozow) c8e67b9 [refactor] move ProcessInvalidTx and ProcessValidTx definitions down (glozow) 3a41926 [refactor] move notfound processing to txdownload (glozow) 042a97c [refactor] move tx inv/getdata handling to txdownload (glozow) 58e09f2 [p2p] don't log tx invs when in IBD (glozow) 2888653 [refactor] rename maybe_add_extra_compact_tx to first_time_failure (glozow) f48d36c [refactor] move peer (dis)connection logic to TxDownload (glozow) f61d9e4 [refactor] move AlreadyHaveTx to TxDownload (glozow) 84e4ef8 [txdownload] add read-only reference to mempool (glozow) af91834 [refactor] move ValidationInterface functions to TxDownloadManager (glozow) f6c860e [doc] fix typo in m_lazy_recent_confirmed_transactions doc (glozow) 5f9004e [refactor] add TxDownloadManager wrapping TxOrphanage, TxRequestTracker, and bloom filters (glozow) Pull request description: Part of #27463. This PR does 3 things: (1) It modularizes transaction download logic into a `TxDownloadManager`. Transaction download logic refers to the process of deciding what transactions to request, download, and validate.[1] There should be no behavior changes. Using `--color_moved=dimmed_zebra -w` may help. (2) It adds unit and fuzz (:magic_wand:) testing for transaction download. (3) It makes a few small behavioral changes: - Stop (debug-only) logging tx invs during IBD - Just like all other transactions, require orphans have RecursiveDynamicUsage < 100k before adding to vExtraTxnForCompact - Don't return a 1p1c that contains a parent or child in recent rejects. Don't process any orphan already in recent rejects. These cases should not happen in actual node operation; it's just to allow tighter sanity checks during fuzzing. There are several benefits to this interface, such as: - Unit test coverage and fuzzing for logic that currently isn't feasible to test as thoroughly (without lots of overhead) and/or currently only lightly tested through `assert_debug_log` (not good) in functional tests. - When we add more functionality (e.g. package relay messages, more robust orphan handling), the vast majority of it will be within `TxDownloadManager` instead of `PeerManager`, making it easier to review and test. See #28031 for what this looks like. - `PeerManager` will no longer know anything about / have access to `TxOrphanage`, `TxRequestTracker` or the rejection caches. Its primary interface with `TxDownloadManager` would be much simpler: - Passing on `ValidationInterface` callbacks - Telling `txdownloadman` when a peer {connects, disconnects} - Telling `txdownloadman`when a {transaction, package} is {accepted, rejected} from mempool - Telling `txdownloadman` when invs, notfounds, and txs are received. - Getting instructions on what to download. - Getting instructions on what {transactions, packages, orphans} to validate. - Get whether a peer `HaveMoreWork` for the `ProessMessages` loop - (todo) Thread-safety can be handled internally. [1]: This module is concerned with tx *download*, not upload. It excludes transaction announcements/gossip which happens after we download/accept a transaction. Txreconciliation (erlay) is excluded from this module, as it only relates to deciding which `inv`s to send or helping the other peer decide which `inv`s to send. It is independent from this logic. ACKs for top commit: achow101: light ACK 0f4bc63 theStack: ACK 0f4bc63 instagibbs: reACK 0f4bc63 naumenkogs: ACK 0f4bc63 Tree-SHA512: 84ab8ef8a0fc705eb829d7f7d6885f28944aaa42b03172f256a42605677b3e783919bb900d4e3b8589f85a0c387dfbd972bcd61d252d44a88c6aaa90e4bf920f
- Loading branch information