Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Remove g_relay_txes #20217

Merged
merged 5 commits into from
Dec 10, 2020
Merged

Conversation

jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Oct 22, 2020

g_relay_txes is only required inside net_processing and is set only once at startup. Instead of having a global, move it to be a const member of PeerManager.

This requires moving PushNodeVersion() into PeerManager, which also allows us to remove the connman argument.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Left some style questions. Feel free to ignore, obviously.

Concept ACK on the change.

src/init.cpp Outdated Show resolved Hide resolved
src/net_processing.h Outdated Show resolved Hide resolved
@jnewbery jnewbery force-pushed the 2020-10-remove-grelaytxes branch from 45e81e1 to a5c8535 Compare October 22, 2020 12:34
@jnewbery
Copy link
Contributor Author

Thanks for the review @MarcoFalke. I've taken your suggested name change.

@practicalswift
Copy link
Contributor

Concept ACK: globals going down is good!

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 22, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

@fanquake
Copy link
Member

Concept ACK

Copy link

@ervanipank88 ervanipank88 left a comment

Choose a reason for hiding this comment

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

.

@jnewbery
Copy link
Contributor Author

jnewbery commented Nov 4, 2020

Rebased

@jnewbery jnewbery force-pushed the 2020-10-remove-grelaytxes branch from a5c8535 to 179616f Compare November 4, 2020 14:51
@sipa
Copy link
Member

sipa commented Nov 5, 2020

utACK 179616f

@narula
Copy link
Contributor

narula commented Nov 14, 2020

code review ACK.

I was confused about the relationship between g_relay_txes (now m_ignore_incoming_txs) and m_tx_relay. I think it's if m_tx_relay is null, this is a blocks-only peer, and if m_ignore_incoming_txs is true, I am a blocks-only peer. Is that right? I think unifying everything under names with "blocks-only" would be clearer but is out of scope for this change.

@jnewbery
Copy link
Contributor Author

Yes, this has been confusing for people, which is why I think it's important to be precise with terminology:

  • a block-relay-only connection is a type of connection to a peer where we only send and process blocks. We do not send or process transactions or addresses to/from that peer. We'll request that the peer not send us transactions by setting relay to 0 in the version message that we send to them. We also won't initialize the m_tx_relay data structure for that peer, since we're not doing tx relay with them.
  • -blocksonly mode is a configuration option where we don't process transactions from any of our peers. We'll set relay to 0 in all of our version messages. It's mostly used to reduce bandwidth usage for people who don't need a mempool.

think unifying everything under names with "blocks-only" would be clearer

I think that's probably less clear since it would confuse those two concepts.

@narula
Copy link
Contributor

narula commented Nov 16, 2020

  • a block-relay-only connection is a type of connection to a peer where we only send and process blocks. We do not send or process transactions or addresses to/from that peer. We'll request that the peer not send us transactions by setting relay to 0 in the version message that we send to them. We also won't initialize the m_tx_relay data structure for that peer, since we're not doing tx relay with them.
  • -blocksonly mode is a configuration option where we don't process transactions from any of our peers. We'll set relay to 0 in all of our version messages. It's mostly used to reduce bandwidth usage for people who don't need a mempool.

Hmm, these still seem like the same concept to me but I'm probably missing something; let me ask the question in a different way: What is the difference between me being a -blocksonly node and me setting all of my connections to block-relay-only (let's hypothetically say you could)? Is it how the node addresses incoming transactions? If there is no difference, I would say they are the same concept?

@jnewbery
Copy link
Contributor Author

What is the difference between me being a -blocksonly node and me setting all of my connections to block-relay-only (let's hypothetically say you could)?

Some differences:

  • block-relay-only isn't a configuration option. The user has no control over how many block-relay-only connections the node makes, or to which addresses.
  • in -blocksonly mode, we still participate in address relay (we send getaddr messages to our peers, process the addr messages in response, and gossip new incoming addresses). block-relay-only connections do not participate in address relay, to preserve the privacy of those connections.
  • in -blocksonly mode, we could theoretically turn off other components, such as the fee estimator (which relies on participating in p2p transaction relay). Disable fee estimation in blocksonly mode (by removing the fee estimates global) #18766 does that.
  • block-relay-only connections are persisted across restart as 'anchor connections'.

There may be others.

@narula
Copy link
Contributor

narula commented Nov 16, 2020

What is the difference between me being a -blocksonly node and me setting all of my connections to block-relay-only (let's hypothetically say you could)?

Some differences:

  • block-relay-only isn't a configuration option. The user has no control over how many block-relay-only connections the node makes, or to which addresses.
  • in -blocksonly mode, we still participate in address relay (we send getaddr messages to our peers, process the addr messages in response, and gossip new incoming addresses). block-relay-only connections do not participate in address relay, to preserve the privacy of those connections.
  • in -blocksonly mode, we could theoretically turn off other components, such as the fee estimator (which relies on participating in p2p transaction relay). Disable fee estimation in blocksonly mode (by removing the fee estimates global) #18766 does that.
  • block-relay-only connections are persisted across restart as 'anchor connections'.

There may be others.

Thank you, that's very helpful! Just to wrap up, it sounds like in my thought experiment (a hypothetical node with all block-relay-only connections vs. a node with -blocksonly) the applicable differences are bullet points 2 and 4, in that the -blocksonly node would still send around and process addrs and its connections would not be persisted across restart.

This makes sense because in -blocksonly mode a node still needs to learn about other nodes, so processing addrs is important. block-relay-only connections were never designed to be all of the connections, so it's fine for them not to process addrs because the node can rely on the other connections to do that.

We wouldn't want to persist all connections across a restart (#17326 (comment)), but because block-relay-only connections are more privacy-preserving and they are extra connections (we can rely on the other connections cycling) it's fine for them to be persisted. And persisting them sort of helps with eclipse attacks (#17326).

I think I'm confused because the check for block-relay-only connections in the code is sometimes to see if m_tx_relay exists, which is non-intuitive because block-relay-only also implies that addrs are not gossiped with this peer either, not just transactions, and sometimes to call IsBlockOnlyConn().

I think the new name for !g_relay_txes, m_ignore_incoming_txs, is much clearer.

@jnewbery
Copy link
Contributor Author

I think I'm confused because the check for block-relay-only connections in the code is sometimes to see if m_tx_relay exists, which is non-intuitive because block-relay-only also implies that addrs are not gossiped with this peer either, not just transactions, and sometimes to call IsBlockOnlyConn().

IsBlockOnlyConn() was added later, and I think is much clearer since it's instantly obvious what the test is for, rather than if (m_tx_relay), which might just be defensive code to ensure that a null ptr isn't dererenced. I'd support a PR that made changes like:

diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index a69efa4fc0..3ea2c1a1f9 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1657,7 +1657,7 @@ void static ProcessGetData(CNode& pfrom, Peer& peer, const CChainParams& chainpa
 
         const CInv &inv = *it++;
 
-        if (pfrom.m_tx_relay == nullptr) {
+        if (peer.IsBlockOnlyConn()) {
             // Ignore GETDATA requests for transactions from blocks-only peers.
             continue;
         }

That's out of scope for this PR.

I think the new name for !g_relay_txes, m_ignore_incoming_txs, is much clearer.

Great. @MarcoFalke gets credit for that!

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

review ACK 179616f nice cleanup! 🚔

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

review ACK 179616f8211883739df6e06852bd976dcdd0c3c9 nice cleanup! 🚔
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhgiwv8DdUGvchEGZlcyNFDb/+qNnq3WawkfpGWNb6Ncw1UhyOpoKtyLHCU8YtX
8KFBToEOqMSQw9vljAJx9oRYEd/ugMBJgCxpdlLMuFeOpw9q7DIxGCUxJdtte3sU
HQUPMduUvIb3PD6AXZC0uiTJk7S2DtZ7GhdPiVC1MK9prUZv/t17EA4o2daYFYZQ
2kz5vsvRXk2I5oh56sk0IlXr2Wid0+m6XDLj1Nf1CKZntg1DrR7+FeF9KN+pDuu5
FV6hUE7Enqnv67MY8L2qDegLAxdHGhCoS6wWwZIciahEtXbUHPLexERdE7Mm38pp
nHyidWXW1BVpYPIu8EssHboMreNxiX2BN4kyA2YPlKwmsmQjprBil+SnYaIVAWD4
8B5hxjH+f+DIxDliIphn3ABiLvJmXXh7GVG1XKKGdoBv5Po+YXh0UezPli6Fon49
gqWmaqYeRfD1gxFAdMaM0Bl1bbFUuDKarN1knvU99h87t7u4op6PcxDl52r2mb93
ePmRESnn
=hNL8
-----END PGP SIGNATURE-----

python: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

src/net_processing.cpp Outdated Show resolved Hide resolved
src/net_processing.h Outdated Show resolved Hide resolved
src/init.cpp Outdated Show resolved Hide resolved
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

re-ACK ceedf23 only change is rebase 🏑

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK ceedf230fd only change is rebase 🏑
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgCvAv+K3VviMunaCVXNAeZ/hZH34QUHITi3yW5mVjRux8HD/eTowDKtm+kMo/p
t2+ADIT+xufMOh4xBjJ/tk18daxL7IHceABiNuAP/uDUVOn+QeCYbfueVj0UBepS
G1mBS750Cy/frouSFD2Gn35H/8fNBtSTyAggKAveJ27cSK9h/nk2pp7xiyo+pG27
8+KoEt//u44zMRlLKFiEkMG6O60/RtxIndpLuU0t+T3qUv8CFyJYaWVjMng8ZA5B
2CvEI/7reaSWzyvfLakbkPdUtX6YqMixGSphq2U0AjcKShOSGF6wRnpo3bspsHXy
aBo8OOp/E3X74Ui8DaAEnXP7VQj6wYLZsCKAsv/f0Dn3AohEawRPkiNG/4pgArbH
iN746lD/VpJIABh3LdgY2FsyQ+lvf0mwol7WpNzMzIpy3qzvs8mixN+2HAuDWo02
/XNDqfOP2sb22+leSeiujZTm0YmkLdBfJbjSpVeLWBmEbHZ8aUY4GTewFe0CvULf
GcvKddFt
=+MY6
-----END PGP SIGNATURE-----

Timestamp of file with hash c72658247447f9b3ea4dd216ccb2048076b4de79b559adad9feea0a1f8001eea -

src/init.cpp Outdated Show resolved Hide resolved
@jnewbery jnewbery force-pushed the 2020-10-remove-grelaytxes branch from ceedf23 to 4fdca52 Compare December 7, 2020 15:00
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Would be nice if the previous feedback about MakeUnique was addressed, but looks fine already.

re-ACK 4fdca52 🎞

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK 4fdca52007 🎞
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjHMAv/ZPMhJbZefHl6UIHBCAxBD64CT2DiBLoPw/GmGmgxq1vBr8LIPR1RYfvB
tr8VcMtrqa+WaMszsEE3f+WAC86C49rbGn4r1MIEkFMiBZWn4N1nno5thhtCv9h8
mfnFpJUqlgeFv+5ZXh63Y0mA1PbA4B7KQ1V1hc9WXK+tTzTN06B7wKJGf9/PJWUl
sCWYpN5KBr4KGjlw6eJB9C141aIyUOgXzzep7waYeQqA4kUaJ6h7xk2g/1pLRA2f
v5Ds/DrHY5wHfdLEv82Jdpmi+GC2DZ+buiuo+CpHMli3VdclrOtPLEVkAwPJTSMu
UMOLzgZ9cOm0B9yCm2DtgRh1bVLJfAN3lzKpv2NObVZgW1sUQYHg1AFBJDMtj7dA
0zssUKJWLkbwKrND5LAocCHWlu0hBoYeM2wycWNRNvTUJlO8b9tzwrh2jpFlmVBK
AjM40R1MbjIl3SirWjbB7a4DD0ubl9KPCYCm6eGEZryT5VuIvOAfDz7IeC6iKjrq
uQVHH7b8
=1TZV
-----END PGP SIGNATURE-----

Timestamp of file with hash 7771d7eb2920b1e3060dc2d3e986607c8393b9886bc4213c99ec34be0994af1c -

@jnewbery
Copy link
Contributor Author

jnewbery commented Dec 7, 2020

@MarcoFalke addressed your review comments. Sorry for dropping them earlier.

@jnewbery jnewbery force-pushed the 2020-10-remove-grelaytxes branch from 4fdca52 to a21667a Compare December 7, 2020 18:17
@maflcko
Copy link
Member

maflcko commented Dec 7, 2020

re-ACK a21667a 🖱

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK a21667ace8 🖱
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhcBAwAqm9wdxwAE32mOhS0kcpLhVxGPmTuZ3Xwxca3DJNo20MX3qzUkmfG+izj
0it+s6TycxiPR0EXKDutg3qWxUcu0Js2pAcYnYrNAbUx91SwcT31kQ/VCSU/5MNj
xrrMKZLJ5nVeKSMnF76jvpc8yoQO6wJpbWCnt5w38noa9BhwDU2pvHQF9vhVA7V1
wZsqtr8z3gR54Ov7fQbN1DQ7eX/K8MjAjuUZvWTuEWVZPLUp5ewbm4r1iFQzskBJ
JhjwoIfg/dxAscOQzrXhwlt1aVHQPygQAICNw06W41jxZpVyGVsIOOd6h7nWc5O4
uSMF6W1HWuS12JhfCLl6W6HCRFt6/vt1pHu5sdTCpyFZPy66nTlDpbJBT7XnBh3T
3JGJTq+h5EP/p8A4Fh3bBnWmSqTGX4b3vCTcejO6nq4Knn2BGVjy4irYirXAkR//
ReIsxEwclRLo0iCl9LgmOGV25MUASd1BKlGl4NknohG3LoIra7ZJeuQW6ZnoWqhZ
GvvZqsbN
=mv04
-----END PGP SIGNATURE-----

Timestamp of file with hash 0174d24f81d7b43cdafd8412778651b9496d8a3add89e495cf7fddb037bd18f1 -

@jnewbery jnewbery force-pushed the 2020-10-remove-grelaytxes branch from a21667a to 22d960b Compare December 9, 2020 11:36
@jnewbery
Copy link
Contributor Author

jnewbery commented Dec 9, 2020

rebased

@jnewbery
Copy link
Contributor Author

jnewbery commented Dec 9, 2020

At different times, this PR has had ACKs from @sipa @narula and @MarcoFalke. There have only been minor changes and rebases since those ACKs. Some reACKs at the same commit hash would be very appreciated!

@maflcko
Copy link
Member

maflcko commented Dec 9, 2020

re-ACK 22d960b 🥃

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK 22d960b124 🥃
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjh9wv9GVZefOvKGq4C4k3P+5QHVrXbC5F9CYF6K/n+QKgIole9iTT5rRNT0C+o
WHb2Q3I3cdyo8WirtL/pBytgn3wBKu1Ap2v4Wygzb1p9+KbM/e2lcQLhGH7hfrKo
yt30H+V+mnAqiln7iPc9BtskrIcL/hMvgkyU01p7UguvPzKzfo+2wVNkJFialPqe
VrdpDO2cHbIexxD7Fjr12Q3Gdo2SRR66qo0poHNZkLZ1FRhzlRFsaixAwJTdDz9j
YG3qZl7QuZtEIwqlDDZSoGiplqA7zvNSxxlcEGCPHvHuPkHnv2Fc51iu+q0VduQA
H0hBpIVHeezSZpCAKbPz2f1dBPvRgw2H3Y5dReAuP8AFnJQmEqSmqIKMct7cqYR0
eUJCauczOLfaNCB6iiEP6aUXgzIv9GWcumx0LSh46JHuMUk690lj3uwMrqOFNjbv
WXEMx9a318Mu/nZNIkxItEJ579qhRyt7L/blV+hhUfupezceehR57UKP6oZVXJWq
yDQK6uHW
=altt
-----END PGP SIGNATURE-----

Timestamp of file with hash 63b2a105ac69ff10887f137cd6a439977e3e14920cb1b46d6faaf934b73581b9 -

@maflcko
Copy link
Member

maflcko commented Dec 9, 2020

needs rebase 🗡️

@jnewbery jnewbery force-pushed the 2020-10-remove-grelaytxes branch from 22d960b to 34e33ab Compare December 9, 2020 18:22
@jnewbery
Copy link
Contributor Author

jnewbery commented Dec 9, 2020

rebased

@narula
Copy link
Contributor

narula commented Dec 9, 2020

utACK 34e33ab

@maflcko
Copy link
Member

maflcko commented Dec 10, 2020

re-ACK 34e33ab 💐

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

re-ACK 34e33ab85 💐
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjrNwwAhgjzJwknztCmt65CG19czsI/ftTRBzjJQ2dkkxI/DpPNtVRdzMyiDX7C
kG7nZI+4PS2/DmzD46EwllFvndY3vLqVuGvr4I7/JIwAA49caGSABfY+5dW95BNp
sc3N0/w8TpM/HEsW71xoz2ebRMG7tV0WoY4rYuQm3ynQltQ51uk+DYB997QKqI4/
WRPyK0tXb0rG8nLj3zUBHBB4V1+4Qsjn22KS1O0MhSJh8/zrmooHcL4d1Z+GC3At
BkcyzLRWbAq5uVnqHgJyQcZsakWR/fUAx4LMjw4D4n7WV/ja2BOL3NlCtMKarqvO
88Ts9JcuI03rDfagB1K7JzpoSVDwpzP2E/7eE7fyB3Bo8mzNZ9OrwyoHDu957ydp
rUvZj7jzyg4LBFxwxvVEf0AvGCID4rYMDxdqjYNs5dLKee2UaqNaB6VY76lrj7fJ
szECMByBUJmqj0uZJNGVlzd3KcrfySW9KRAT+EoRPDSByehI6hfJtzJS/phOQ1Je
ngdR9Lq0
=kxdj
-----END PGP SIGNATURE-----

Timestamp of file with hash 50413236396d5df336002d2266fca66543a43dc9ee2cb2ba69a71db2cca5df6a -

@maflcko maflcko merged commit f5b2ea3 into bitcoin:master Dec 10, 2020
@jnewbery jnewbery deleted the 2020-10-remove-grelaytxes branch December 10, 2020 09:13
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 10, 2020
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jan 25, 2022
Summary:
```
g_relay_txes is only required inside net_processing and is set only once at startup. Instead of having a global, move it to be a const member of PeerManager.

This requires moving PushNodeVersion() into PeerManager, which also allows us to remove the connman argument.
```

Backport of [[bitcoin/bitcoin#20217 | core#20217]].

Ref T1696.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Maniphest Tasks: T1696

Differential Revision: https://reviews.bitcoinabc.org/D10884
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants