Skip to content

Conversation

jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Feb 12, 2021

This continues the work of moving application layer data into net_processing, by moving all tx data into the new Peer object added in #19607.

For motivation, see #19398.

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 12, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24545 (BIP324: Enable v2 P2P encrypted transport by dhruv)
  • #24543 (net processing: Move remaining globals into PeerManagerImpl by dergoegge)
  • #24531 (Use designated initializers by MarcoFalke)
  • #24474 (Additional thread safety annotations for CNode/Peer by ajtowns)
  • #24220 (validation: don't re-acquire cs_main during IBD in CChainState::IsInitialBlockDownload() by jonatack)
  • #24125 (p2p: Replace RecursiveMutex cs_tx_inventory with Mutex and rename it by w0xlt)
  • #21527 (net_processing: lock clean up by ajtowns)
  • #20726 (p2p: Add DISABLETX message for negotiating block-relay-only connections by sdaftuar)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@jnewbery
Copy link
Contributor Author

Rebased on master to pick up fix for interface_zmq.py in #21008.

@jnewbery
Copy link
Contributor Author

Rebase resulted in silent merge conflict with 9476886. I'll fix tomorrow.

Copy link
Member

@glozow glozow left a comment

Choose a reason for hiding this comment

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

utACK 1066d10

@fanquake fanquake merged commit 9344697 into bitcoin:master Mar 25, 2022
@jnewbery
Copy link
Contributor Author

jnewbery commented Mar 25, 2022

There are still a few outstanding review comments that could be responded to or addressed in a follow-up. Leaving this here mostly as a reminder to myself:

@jnewbery jnewbery deleted the 2021-02-tx-in-peer branch March 25, 2022 17:55
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 28, 2022
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require
the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the
lock scope.

See bitcoin#21160 (comment)
and bitcoin#21160 (comment).
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 28, 2022
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 28, 2022
The Peer reference was only needed to check whether the peer was a
blocks relay only peer, so instead just pass in a boolean.

See bitcoin#21160 (comment).
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 28, 2022
MaybeSendFeeFilter() doesn't need acess to the entire peer object, so
only pass a pointer to the TxFilter struct.

See bitcoin#21160 (comment).
@jnewbery
Copy link
Contributor Author

There are still a few outstanding review comments that could be responded to or addressed in a follow-up. Leaving this here mostly as a reminder to myself:

I believe I've now addressed all outstanding review comments on this PR, either here or in #24692.

@maflcko
Copy link
Member

maflcko commented Mar 28, 2022

See also #24691

jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 28, 2022
The Peer reference was only needed to check whether the peer was a
blocks relay only peer, so instead just pass in a boolean.

See bitcoin#21160 (comment).
jnewbery added a commit to jnewbery/bitcoin that referenced this pull request Mar 28, 2022
MaybeSendFeeFilter() doesn't need acess to the entire peer object, so
only pass a pointer to the TxFilter struct.

See bitcoin#21160 (comment).
fanquake added a commit that referenced this pull request Mar 30, 2022
a40978d [fuzz] Assert that Peer.m_tx_relay.m_relay_txs has been set correctly (John Newbery)
0bca5f2 [net processing] PushNodeVersion() takes a const Peer& (John Newbery)
21154ff net_processing: move CNode data access out of lock (John Newbery)

Pull request description:

  #21160 ([net/net processing]: Move tx inventory into net_processing) had some unaddressed review comments when it was merged. This branch addresses those comments.

ACKs for top commit:
  MarcoFalke:
    review ACK a40978d
  dergoegge:
    ACK a40978d
  ajtowns:
    ACK a40978d

Tree-SHA512: 46624e275f918c5f32d0adab0766e9b3ef8ebdbc74a3c8886d8a2e2ff1079029dcc371b40ef0d787609e9c05219b7456f3e2dfe4fb0cb7bf23ef966769aef1a1
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 2, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 3, 2022
…oin#21160

a40978d [fuzz] Assert that Peer.m_tx_relay.m_relay_txs has been set correctly (John Newbery)
0bca5f2 [net processing] PushNodeVersion() takes a const Peer& (John Newbery)
21154ff net_processing: move CNode data access out of lock (John Newbery)

Pull request description:

  bitcoin#21160 ([net/net processing]: Move tx inventory into net_processing) had some unaddressed review comments when it was merged. This branch addresses those comments.

ACKs for top commit:
  MarcoFalke:
    review ACK a40978d
  dergoegge:
    ACK a40978d
  ajtowns:
    ACK a40978d

Tree-SHA512: 46624e275f918c5f32d0adab0766e9b3ef8ebdbc74a3c8886d8a2e2ff1079029dcc371b40ef0d787609e9c05219b7456f3e2dfe4fb0cb7bf23ef966769aef1a1
} else {
stats.m_relay_txs = false;
stats.m_fee_filter_received = 0;
}
Copy link
Member

@jonatack jonatack May 20, 2022

Choose a reason for hiding this comment

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

Moving fRelayTxes/m_relay_txs from CNodeStats to CNodeStateStats broke -netinfo (and perhaps other clients that expect this field to be non-null). Proposing a fix.

Copy link
Member

Choose a reason for hiding this comment

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

Moving fRelayTxes/m_relay_txs from CNodeStats to CNodeStateStats broke -netinfo (and perhaps other clients that expected this field to be non-null). Proposing a fix.

Fixed in #25176.

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request May 23, 2022
…etpeerinfo#relaytxes

a17c5e9 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay (Jon Atack)
f0bb7db Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes (Jon Atack)

Pull request description:

  CLI -netinfo frequently returns "error: JSON value is not a boolean as expected" since the merge of bitcoin#21160, which moved fRelayTxes (renamed to m_relay_txs in that pull) from CNodeStats to CNodeStateStats.

  This change made getpeerinfo "relaytxes" an optional field that can return UniValue IsNull(). It is the only optional field consumed by -netinfo where the latter didn't already handle that case. See also bitcoin#24691.

  Also rename the NetinfoRequestHandler::is_block_relay data member to is_tx_relay and inverse its boolean logic. The naming is out of date and incorrect, as lack of request of tx relay does not imply block relay, and a preference for tx relay doesn't imply that block relay isn't happening. Thanks to Marco Falke and Martin Zumsande for their feedback on this.

  (I may look at reducing the number of optional node stats fields via refactoring at the net processing level, but ongoing refactoring there may make that slow or complicated and this is a one-line fix that works now.)

ACKs for top commit:
  mzumsande:
    Code review ACK a17c5e9

Tree-SHA512: dc54ce80b78122874a6794555f99e5b328a1574b52bb3e7f974c699c2b759a60ea0807a6483c5bc0414a950d853c0eeeb13dcc1b790d3917c6ee4c9c99fe159f
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 28, 2022
…etpeerinfo#relaytxes

a17c5e9 Rename NetinfoRequestHandler::is_block_relay data member to is_tx_relay (Jon Atack)
f0bb7db Fix frequent -netinfo JSON errors from null getpeerinfo#relaytxes (Jon Atack)

Pull request description:

  CLI -netinfo frequently returns "error: JSON value is not a boolean as expected" since the merge of bitcoin#21160, which moved fRelayTxes (renamed to m_relay_txs in that pull) from CNodeStats to CNodeStateStats.

  This change made getpeerinfo "relaytxes" an optional field that can return UniValue IsNull(). It is the only optional field consumed by -netinfo where the latter didn't already handle that case. See also bitcoin#24691.

  Also rename the NetinfoRequestHandler::is_block_relay data member to is_tx_relay and inverse its boolean logic. The naming is out of date and incorrect, as lack of request of tx relay does not imply block relay, and a preference for tx relay doesn't imply that block relay isn't happening. Thanks to Marco Falke and Martin Zumsande for their feedback on this.

  (I may look at reducing the number of optional node stats fields via refactoring at the net processing level, but ongoing refactoring there may make that slow or complicated and this is a one-line fix that works now.)

ACKs for top commit:
  mzumsande:
    Code review ACK a17c5e9

Tree-SHA512: dc54ce80b78122874a6794555f99e5b328a1574b52bb3e7f974c699c2b759a60ea0807a6483c5bc0414a950d853c0eeeb13dcc1b790d3917c6ee4c9c99fe159f
janus pushed a commit to BitgesellOfficial/bitgesell that referenced this pull request Aug 4, 2022
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require
the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the
lock scope.

See bitcoin/bitcoin#21160 (comment)
and bitcoin/bitcoin#21160 (comment).
fanquake added a commit that referenced this pull request Dec 2, 2022
…or fully connected peers

8f2dac5 [test] Add p2p_tx_privacy.py (dergoegge)
ce63fca [net processing] Assume that TxRelay::m_tx_inventory_to_send is empty pre-verack (dergoegge)
845e3a3 [net processing] Ensure transaction announcements are only queued for fully connected peers (dergoegge)

Pull request description:

  `TxRelay::m_next_inv_send_time` is initialized to 0, which means that any txids in `TxRelay::m_tx_inventory_to_send` will be announced on the first call to `PeerManagerImpl::SendMessages` for a fully connected peer (i.e. it completed the version handshake).

  Prior to #21160, `TxRelay::m_tx_inventory_to_send` was guaranteed to be empty on the first `SendMessages` call, as transaction announcements were only queued for fully connected peers. #21160 replaced a `CConnman::ForEachNode` call with a loop over `PeerManagerImpl::m_peer_map`, in which the txid for a transaction to be relayed is added to `TxRelay::m_tx_inventory_to_send` for all peers. Even for those peers that have not completed the version handshake. Prior to the PR this was not the case as `ForEachNode` has a "fully connected check" before calling a function for each node.

ACKs for top commit:
  MarcoFalke:
    ACK 8f2dac5 🔝
  jnewbery:
    utACK 8f2dac5

Tree-SHA512: e9eaccf7e00633ee0806fff1068b0e413a69a5e389d96c9659f68079915a6381ad5040c61f716cfcde77931d1b563b1049da97a232a95c6cd8355bd3d13404b9
gitcoindev pushed a commit to gitcoindev/bitgesell that referenced this pull request May 19, 2023
CNode::m_relays_tx and CNode::m_bloom_filter_loaded access don't require
the Peer::TxRelay::m_bloom_filter_mutex lock, so move them out of the
lock scope.

See bitcoin/bitcoin#21160 (comment)
and bitcoin/bitcoin#21160 (comment).
@bitcoin bitcoin locked and limited conversation to collaborators Aug 24, 2023
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.