Skip to content

net/net processing: Move tx inventory into net_processing#21160

Merged
fanquake merged 4 commits intobitcoin:masterfrom
jnewbery:2021-02-tx-in-peer
Mar 25, 2022
Merged

net/net processing: Move tx inventory into net_processing#21160
fanquake merged 4 commits intobitcoin:masterfrom
jnewbery:2021-02-tx-in-peer

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.

We'll move the transaction relay data into Peer in subsequent commits,
but the inbound eviction logic needs to know if the peer is relaying
txs and if the peer has loaded a bloom filter.

This is currently redundant information with m_tx_relay->fRelayTxes,
but when m_tx_relay is moved into net_processing, then we'll need these
separate fields in CNode.
Also, remove cs_main guard from m_wtxid_relay_peers and make it atomic.
This should be fine since we don't need m_wtxid_relay_peers to be
synchronized with m_wtxid_relay exactly at all times.

After this change, RelayTransaction no longer requires cs_main.
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); }

ren cs_filter             m_bloom_filter_mutex
ren fRelayTxes            m_relay_txs
ren pfilter               m_bloom_filter
ren cs_tx_inventory       m_tx_inventory_mutex
ren filterInventoryKnown  m_tx_inventory_known_filter
ren setInventoryTxToSend  m_tx_inventory_to_send
ren fSendMempool          m_send_mempool
ren nNextInvSend          m_next_inv_send_time
ren minFeeFilter          m_fee_filter_received
ren lastSentFeeFilter     m_fee_filter_sent
-END VERIFY SCRIPT-
@jnewbery
Copy link
Contributor Author

Rebased

Copy link
Member

@dergoegge dergoegge left a comment

Choose a reason for hiding this comment

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

ACK 1066d10 - This is a good layer separation improvement with no behavior changes.

Are you still planning to address Cory's comments?


/** Send a version message to a peer */
void PushNodeVersion(CNode& pnode);
void PushNodeVersion(CNode& pnode, Peer& peer);
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
void PushNodeVersion(CNode& pnode, Peer& peer);
void PushNodeVersion(CNode& pnode, const Peer& peer);

Or like cory suggested this could also just be a bool.

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
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

} 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.

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.