Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Jan 22, 2020

This removes the code that supposedly handled the forced relay of txs from a permissioned peer that were rejected from our mempool. The removal should be fine, because it is dead code for the following reasons:

  • While RelayTransaction enqueues the inv for all peers, the inv is never processed because it can not be found in the mempool. See

    bitcoin/src/net_processing.cpp

    Lines 3862 to 3866 in 4a07233

    // Not in the mempool anymore? don't bother sending it.
    auto txinfo = mempool.info(hash);
    if (!txinfo.tx) {
    continue;
    }

  • Even if the peers we intended to send the inv to can somehow reply with a getdata to the never-received inv, they won't receive the tx as a reply because it was never added to the "relay memory" (mapRelay)

The dead code is (obviously) untested: https://marcofalke.github.io/btc_cov/total.coverage/src/net_processing.cpp.gcov.html#2574

This feature was (intentionally or accidentally) removed in 4d8993b, which was released in Bitcoin Core 0.13.0. So all currently supported versions of Bitcoin Core ship without this feature. I am not aware of any complaints about this feature or actual documented use-cases. So instead of reviving an unneeded feature, just remove the dead code.

@maflcko maflcko added the P2P label Jan 22, 2020
@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 23, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@fanquake fanquake requested a review from sdaftuar January 23, 2020 02:00
@luke-jr
Copy link
Member

luke-jr commented Jan 29, 2020

While RelayTransaction enqueues the inv for all peers, the inv is never processed because it can not be found in the mempool.

Does that mean #17303 is redundant?

@maflcko
Copy link
Member Author

maflcko commented Jan 30, 2020

@luke-jr No, #17303 is different and not redundant. That other one is about transactions that have been in the mempool, but a are no longer. For example they could have been mined.

@maflcko
Copy link
Member Author

maflcko commented Jan 30, 2020

A test for forcerelay has been merged here 3b69310. The test should still pass after the changes here.

@laanwj
Copy link
Member

laanwj commented Feb 10, 2020

code review ACK fab08e0caa029aaaa683ad5a17b23f2dc0d66c56

@ajtowns
Copy link
Contributor

ajtowns commented Feb 11, 2020

ACK fab08e0caa029aaaa683ad5a17b23f2dc0d66c56

Might be good to keep a LogPrintf("Not relaying tx %s as not present in mempool") error though?

@maflcko
Copy link
Member Author

maflcko commented Feb 11, 2020

Thanks for the review. Added the logprint back. Also, I've rebased this to be able to extend the existing test case

@maflcko
Copy link
Member Author

maflcko commented Feb 11, 2020

Force pushed to fixup the documentation

@hebasto
Copy link
Member

hebasto commented Feb 17, 2020

Concept ACK

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK facb715, locally running the unit and functional tests.

@laanwj laanwj merged commit 89a97a7 into bitcoin:master Feb 26, 2020
@maflcko maflcko deleted the 2001-p2pNoDeadCode branch February 26, 2020 18:23
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 26, 2020
facb715 net: Remove forcerelay of rejected txs (MarcoFalke)

Pull request description:

  This removes the code that supposedly handled the forced relay of txs from a permissioned peer that were rejected from our mempool. The removal should be fine, because it is dead code for the following reasons:

  * While `RelayTransaction` enqueues the inv for all peers, the inv is never processed because it can not be found in the mempool. See https://github.com/bitcoin/bitcoin/blob/4a072330763b3ff2d1b5c5b8d30a9517873ac6de/src/net_processing.cpp#L3862-L3866

  * Even if the peers we intended to send the inv to can somehow reply with a getdata to the never-received inv, they won't receive the tx as a reply because it was never added to the "relay memory" (`mapRelay`)

  The dead code is (obviously) untested: https://marcofalke.github.io/btc_cov/total.coverage/src/net_processing.cpp.gcov.html#2574

  This feature was (intentionally or accidentally) removed in 4d8993b, which was released in Bitcoin Core 0.13.0. So all currently supported versions of Bitcoin Core ship without this feature. I am not aware of any complaints about this feature or actual documented use-cases. So instead of reviving an unneeded feature, just remove the dead code.

ACKs for top commit:
  hebasto:
    ACK facb715, locally running the unit and functional tests.

Tree-SHA512: bfceae6f2983c1510fa0649a9a63c343cbbc1c4ab3a3698039cccf454c81e58c8f5114b147ed42a1bc867da74c43a5b53764ab14f942e191b6f59079044108b5
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
facb715 net: Remove forcerelay of rejected txs (MarcoFalke)

Pull request description:

  This removes the code that supposedly handled the forced relay of txs from a permissioned peer that were rejected from our mempool. The removal should be fine, because it is dead code for the following reasons:

  * While `RelayTransaction` enqueues the inv for all peers, the inv is never processed because it can not be found in the mempool. See https://github.com/bitcoin/bitcoin/blob/4a072330763b3ff2d1b5c5b8d30a9517873ac6de/src/net_processing.cpp#L3862-L3866

  * Even if the peers we intended to send the inv to can somehow reply with a getdata to the never-received inv, they won't receive the tx as a reply because it was never added to the "relay memory" (`mapRelay`)

  The dead code is (obviously) untested: https://marcofalke.github.io/btc_cov/total.coverage/src/net_processing.cpp.gcov.html#2574

  This feature was (intentionally or accidentally) removed in 4d8993b, which was released in Bitcoin Core 0.13.0. So all currently supported versions of Bitcoin Core ship without this feature. I am not aware of any complaints about this feature or actual documented use-cases. So instead of reviving an unneeded feature, just remove the dead code.

ACKs for top commit:
  hebasto:
    ACK facb715, locally running the unit and functional tests.

Tree-SHA512: bfceae6f2983c1510fa0649a9a63c343cbbc1c4ab3a3698039cccf454c81e58c8f5114b147ed42a1bc867da74c43a5b53764ab14f942e191b6f59079044108b5
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Aug 30, 2021
Summary:
> This removes the code that supposedly handled the forced relay of txs from a permissioned peer that were rejected from our mempool. The removal should be fine, because it is dead code for the following reasons:
> - While RelayTransaction enqueues the inv for all peers, the inv is never processed because it can not be found in the mempool.
> - Even if the peers we intended to send the inv to can somehow reply with a getdata to the never-received inv, they won't receive the tx as a reply because it was never added to the "relay memory" (mapRelay)
>
> This feature was (intentionally or accidentally) removed in 4d8993b, which was released in Bitcoin Core 0.13.0. So all currently supported versions of Bitcoin Core ship without this feature. I am not aware of any complaints about this feature or actual documented use-cases. So instead of reviving an unneeded feature, just remove the dead code.

This is a backport of [[bitcoin/bitcoin#17985 | core#17985]]

Some comments were already updated on our side via D9325 and D9042.

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D9831
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants