Skip to content

Conversation

@glozow
Copy link
Member

@glozow glozow commented Jun 12, 2020

Nodes that don't have bloomfilters turned on (i.e. no NODE_BLOOM service) should disconnect peers that send them filterclear P2P messages.

Non-bloomfilter nodes already disconnect peers for filteradd and filterload, but #8709 removed filterclear so it could be used to reset tx relay. This isn't needed now because using feefilter message is much better for this purpose (See #19204).

Also refactors existing disconnect logic for filteradd and filterload into respective message handlers and removes banning for them.

@maflcko
Copy link
Member

maflcko commented Jun 12, 2020

Concept ACK. There shouldn't be a reason for a node to send filterclear when we haven't offered them bloom services to them.

See also BIP 111:

If a node does not support bloom filters but receives a "filterload", "filteradd", or "filterclear" message from a peer the node should disconnect that peer immediately

https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki

nit: I think this is a good opportunity to move the disconnect handling of NetMsgType::FILTERLOAD and NetMsgType::FILTERADD into the respective scope of the switch statement instead of having it at the top of the function, disconnected from the actual filter message handling.

@maflcko maflcko removed the Tests label Jun 12, 2020
@glozow glozow force-pushed the filterclear-disconnect branch from dbc7d30 to 8207e3b Compare June 12, 2020 21:06
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 13, 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.

@jnewbery
Copy link
Contributor

Code review ACK 18a2e0a3f7071b8df6b20ecc1b34b3f2abb13cfc

Great tidy-up. Thanks Gloria!

@naumenkogs
Copy link
Contributor

naumenkogs commented Jun 14, 2020

utACK 18a2e0a

I was somewhat confused by the last commit, because the description of the PR is about filterclear, but the last commit has absolutely nothing to do with filterclear.
Not sure if we want to do anything about it :)

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.

ACK 18a2e0a3f7071b8df6b20ecc1b34b3f2abb13cfc nice cleanup 🌫

Show signature and timestamp

Signature:

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

ACK 18a2e0a3f7071b8df6b20ecc1b34b3f2abb13cfc nice cleanup 🌫
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhzKAv/ejpwEnqSww3TRDRR7fvVaVti9v81jtyV0QVIwfjHvYw3MD3BSifUI8KF
KCWYTX/MVDobco2GQR3Iw1Xnc1oGgH8416c5ehDMTiO9T7+DftefLR1hHb8nidXs
bPrsTfbwvh7TkPsEwVWjSu+lVL1CtYDHDcdyP/t2u8p/r/RpCq1WxEwmSQgqybTK
rCIdWUNQ1yrNd5/gkpydpzIZPLpui19aA+lxwndwuWiME0hTc2li/qE9acsFSLSI
PXM/gClEJ6aKDyVX2AOGfpQv1KEY5OReDsUBi2jdXRXI7n3/1D6kz9YGar4DIhVy
nuVcQFEEMGvGEclQVeIp5ik5JHPta0bFm/i6rSdHSk1Y+b5zqgYmSeNqnUwcUxcG
5jyVXszUw0p61yVgy/7CFaFvIr8oa2xjAt8vvLogdePIjH320j2TA3UBhOWLBkfU
bcWafRJwm13cB3VtSB00HNZ7LBb5mS8AmsV0sY4U4a9//RbgBv/HHgrTkjbFmiCQ
gqH6/zVZ
=Wizi
-----END PGP SIGNATURE-----

Timestamp of file with hash 76972080cdb7d6db860684d9cc7ddc281674c2c67368d5f83cad36c0fa0849c0 -

@glozow glozow changed the title p2p: disconnect peers that send filterclear p2p: disconnect peers that send filterclear + update existing filter msg disconnect logic Jun 14, 2020
glozow added 3 commits June 14, 2020 11:47
-nodes not serving bloomfilters should disconnect peers
that send filterclear, just like filteradd and filterload
-nodes that want to enable/disable txrelay should use
feefilter
-Increasing the banscore and/or banning is too harsh,
just disconnecting is enough.
-Return true from ProcessMessage because we already log
receipt of filterclear and disconnect.
@glozow glozow force-pushed the filterclear-disconnect branch from 18a2e0a to 3a10d93 Compare June 14, 2020 18:55
@maflcko
Copy link
Member

maflcko commented Jun 15, 2020

re-ACK 3a10d93 only change is replacing false with true 🚝

Show signature and timestamp

Signature:

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

re-ACK 3a10d935ac only change is replacing false with true 🚝
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiicAwAuImcvIy26lnaw4VoTkzdS0iEgf2zA6xyuFKb3zUCSKpX80mPbnrdDxue
32BIzcZfgyy5FvhWuJddItl3wEdmnyJK/1vZqRogs/Q4oljfVaDxzdIPKc3lhoG/
GNOut9oyn0WAhL26QQDdqWwCq94GFJ7DSClIfsozyXQcs61ylKQULEBpP039uR1R
/PQEKZoS8t2ThDQXHgcLmC04QYARp8PX5RvSBbxFQz75Kl9vUD9Qfs3/KlCHBThU
dKwWnLt/yQp3w0Wz4XVgjborfhgeLVVzmvkBRZboFEMXJPaC1OkinxS3nydh6MYz
7fMTVM61b95qy21pBSr0iT8T/gslbr7sj2H9OEkfU7t8s096qnPfVgd/qTtMmneR
v5NN9WVf9SXq8nmhGZQPLL/gehW1RGC99vSL3MwrQQwspz13lU+3wAXEGV16k7Py
uFKUrHkUlNitTxn9vFWoeTLIlWFtJ6Qc2B6dc3wMJ7k1KHfv2yI1CA1OcdO4osNv
pRAS6UPd
=ZuJt
-----END PGP SIGNATURE-----

Timestamp of file with hash d49fb833782cb07ba218eb5ea866b2c2f12e58a1ac6670b3a225942fdd3a8e52 -

@jnewbery
Copy link
Contributor

Code review ACK 3a10d93

@gillichu
Copy link

Concept ACK, I just learned a lot about how bloom filters are used in Bitcoin.

@gillichu
Copy link

gillichu commented Jun 15, 2020

tested ACK: quick test_runner on macOS 3a10d93

@glozow
Copy link
Member Author

glozow commented Jun 15, 2020

😂 Thanks @gillichu, I really appreciate the effort 🙏

It's [`commit`](link)

@jnewbery
Copy link
Contributor

It's [`commit`](link)

No need to use markdown for links to the commit hash. Just paste the full hash and github will automatically convert it to a link to commit.

@glozow
Copy link
Member Author

glozow commented Jun 15, 2020

Just paste the full hash and github will automatically convert it to a link to commit.

WHAT I've been using markdown this whole time 😭

@naumenkogs
Copy link
Contributor

utACK 3a10d93

@fanquake fanquake merged commit 28ce05d into bitcoin:master Jun 16, 2020
@glozow glozow deleted the filterclear-disconnect branch July 25, 2020 14:47
@rebroad
Copy link
Contributor

rebroad commented May 3, 2021

Concept ACK. There shouldn't be a reason for a node to send filterclear when we haven't offered them bloom services to them.

See also BIP 111:

If a node does not support bloom filters but receives a "filterload", "filteradd", or "filterclear" message from a peer the node should disconnect that peer immediately

https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki

nit: I think this is a good opportunity to move the disconnect handling of NetMsgType::FILTERLOAD and NetMsgType::FILTERADD into the respective scope of the switch statement instead of having it at the top of the function, disconnected from the actual filter message handling.

filterclear was also available to request a node sends TXs after IBD had completed, and using blocksonly at connection handshake - this worked better than using feefilter as it was part of the connection handshake, unlike feefilter, which requires a message later.

Anyway, not a big issue, but seems like a lot of work to change something that already worked.

Also, bloom filters were introduced before feefilter, so older nodes are now being disrespected by not having TXs sent to them when they ask for them. We shouldn't really be breaking backwards compatibility, IMHO, unless we actually want to on purpose - e.g. is there a reason not to send TXs to old nodes?

@maflcko
Copy link
Member

maflcko commented May 3, 2021

@rebroad Please, there is no reason to leave comments on three pull requests to ask questions. The thread you created in #21839 is sufficient.

deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2021
… existing filter msg disconnect logic

Summary:
3a10d935ac8ebabdfd336569d943f042ff84b13e [p2p/refactor] move disconnect logic and remove misbehaving (gzhao408)
ff8c430c6589ea72b9e169455cf6437c8623cc52 [test] test disconnect for filterclear (gzhao408)
1c6b787e0319c44f0e0bede3f4a77ac7c2089db2 [netprocessing] disconnect node that sends filterclear (gzhao408)

Pull request description:

  Nodes that don't have bloomfilters turned on (i.e. no `NODE_BLOOM` service) should disconnect peers that send them `filterclear` P2P messages.

  Non-bloomfilter nodes already disconnect peers for [`filteradd` and `filterload`](https://github.com/bitcoin/bitcoin/blob/19e919217e6d62e3640525e4149de1a4ae04e74f/src/net_processing.cpp#L2218), but #8709 removed `filterclear` so it could be used to reset tx relay. This isn't needed now because using `feefilter` message is much better for this purpose (See #19204).

  Also refactors existing disconnect logic for `filteradd` and `filterload` into respective message handlers and removes banning for them.

---

Backport of [[bitcoin/bitcoin#19260 | core#19260]]

Depends on D9520

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D9512
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 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.

8 participants