Split-off from #20277
This PR halts the processing of unrequested transactions in Bitcoin at TX message reception. An unrequested transaction is one defined by which a “getdata” message for its specific identifier (either txid or wtxid) has not been previously issued by the node.
This change is motivated by reducing the CPU DoS surface of Bitcoin Core around mempool acceptance. Currently, an attacker can open multiple inbound connections to a node and send expensive to validate, junk transactions. Once the canonical INV/GETDATA sequence is enforced on the network, a further protection would be to deprioritize bandwidth and validation resources allocation, or even to wither connections with such DoSy peers. A permissioned peer (PF_RELAY) will still be able to bypass such restrictions.
Few high-level questions to go through :
- Is this change ease any privacy attack, such as transaction origin inference or tx-relay connection graph leaks ?
- Is this change ease observation of internal tx-requester configuration, such as preferred peers ?
- As one identified downside of this change is the potential breaking of tx-relay capabilities of non-compliant Bitcoin clients, should we offer them a wider adaptation period ?
See mailing proposal and discussions: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-February/018391.html
Note, our tx-relay functional test framework wasn’t at all compliant with the canonical inv-getdata sequence. This change modifies some tx-relay tests by introducing INV-GETDATA sequence enforcement (wait_for_getdata
). It comes with a meaningful delay of running the framework (e.g +4min to run p2p_segwit.py
)
Better could be either to label such tested nodes with PF_RELAY and such bypass the new restriction but I fear it might mask some behaviors verified and silently break tests (e.g PF_RELAY impacts the max announcements per-peer buffer). Or either to switch the whitelisting of the new restriction under the more-scoped PF_FORCERELAY
permission or even some new one (e.g PF_FORCETXPROCESS
) ?