diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2020-06-29 17:14:40 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2020-07-19 02:10:42 -0400 |
commit | 0a4f1422cd1c20e12a05d7ff1a2ef1d5e7c654bb (patch) | |
tree | 92b741547b8b5875b769c45cb5c8a06bf8aca223 /src | |
parent | 0e20cfedb704c1f76bb727e2009867d3d503a03d (diff) | |
download | bitcoin-0a4f1422cd1c20e12a05d7ff1a2ef1d5e7c654bb.tar.xz |
Further improve comments around recentRejects
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c6eeeabbcc..5f1e7318f3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -190,6 +190,15 @@ namespace { * million to make it highly unlikely for users to have issues with this * filter. * + * We only need to add wtxids to this filter. For non-segwit + * transactions, the txid == wtxid, so this only prevents us from + * re-downloading non-segwit transactions when communicating with + * non-wtxidrelay peers -- which is important for avoiding malleation + * attacks that could otherwise interfere with transaction relay from + * non-wtxidrelay peers. For communicating with wtxidrelay peers, having + * the reject filter store wtxids is exactly what we want to avoid + * redownload of a rejected transaction. + * * Memory used: 1.3 MB */ std::unique_ptr<CRollingBloomFilter> recentRejects GUARDED_BY(cs_main); @@ -2033,6 +2042,7 @@ void static ProcessOrphanTx(CConnman& connman, CTxMemPool& mempool, std::set<uin // Probably non-standard or insufficient fee LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n", orphanHash.ToString()); if (orphan_state.GetResult() != TxValidationResult::TX_WITNESS_STRIPPED) { + // We can add the wtxid of this transaction to our reject filter. // Do not add txids of witness transactions or witness-stripped // transactions to the filter, as they can have been malleated; // adding such txids to the reject filter would potentially @@ -3004,11 +3014,16 @@ void ProcessMessage( LogPrint(BCLog::MEMPOOL, "not keeping orphan with rejected parents %s\n",tx.GetHash().ToString()); // We will continue to reject this tx since it has rejected // parents so avoid re-requesting it from other peers. + // Here we add both the txid and the wtxid, as we know that + // regardless of what witness is provided, we will not accept + // this, so we don't need to allow for redownload of this txid + // from any of our non-wtxidrelay peers. recentRejects->insert(tx.GetHash()); recentRejects->insert(tx.GetWitnessHash()); } } else { if (state.GetResult() != TxValidationResult::TX_WITNESS_STRIPPED) { + // We can add the wtxid of this transaction to our reject filter. // Do not add txids of witness transactions or witness-stripped // transactions to the filter, as they can have been malleated; // adding such txids to the reject filter would potentially |