Skip to content

Conversation

@glozow
Copy link
Member

@glozow glozow commented May 27, 2020

This PR adds a few tests that are bloomfilter-related, including behavior for when bloomfilters are turned off:

  1. Tests p2p message msg_mempool: a node that has peerbloomfilters enabled should send its mempool (disabled behavior already tested here).
  2. Tests that bloomfilter peers with fRelay=False in the version message should not receive any invs until they set the filter. The rest is the same as what’s already tested in p2p_filter.py.
  3. Tests that peers get disconnected if they send filterload or filteradd p2p messages to a node with bloom filters disabled.
  4. Refactor: renames p2p_mempool.py to p2p_nobloomfilter_messages.py.
  5. Fixes race conditions in p2p_filter.py

@DrahtBot
Copy link
Contributor

DrahtBot commented May 28, 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.

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Concept ACK. I think you can probably merge all the tests for bloom filters enabled and disabled into a single test file.

@glozow glozow force-pushed the test-bloomfilter branch from e692c3c to 9514423 Compare June 3, 2020 22:51
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.

Concept ACK

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

Looks good. A few comments inline.

@glozow glozow force-pushed the test-bloomfilter branch from 72672bc to f78730d Compare June 5, 2020 22:37
@maflcko
Copy link
Member

maflcko commented Jun 6, 2020

nit: commit f78730d582c605882e5a3bf554aefb1a92942b0e can be done as a scripted diff, but no big deal

@glozow glozow force-pushed the test-bloomfilter branch from f78730d to 1e64440 Compare June 7, 2020 16:28
@glozow
Copy link
Member Author

glozow commented Jun 7, 2020

Resolves #18473 . Ready for Review again!

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 1e64440490 looks like an improvement, but I have some nits to consider 🍬

Show signature and timestamp

Signature:

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

ACK 1e64440490 looks like an improvement, but I have some nits to consider 🍬
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiqqQv9HPT78+tE2ecU5neOV9/iItDomZZ3+dJ/+1clX3pZNzJ7k0Qh/Cr3DBU+
Eh4zIS0D1ooVyxknFMhGziukNAmlzYAFW1lSytCwEMCxZhJ4Nujlq3dp/aaQ5FoH
j1D2zvTe4QEKvysqTqHafJQ0iuxYoXzO2TXs5io6923GpxLHwndOiozkNUkLd9TA
2W2XwhO/k7Uu0r0SCBFmSyZmb93Jus8h118q0Dskg7uM8FBJ/FuPS6xvIUWpn21h
3etYU0+9E8ncRJ6SXTU4bKcPsHbJrpjo3hzGghhJLlz1+ywJzSiF2TVumFilgMyU
+MwS/Yvm+vwuTQwFOzIzAQfQYdm1Dh0JOcy52Uob1keytZV/K3opDS3MrlvlPxIC
4ZKMuT/JclX9UkKzIu/ppQ6O57PbhJAcZyXBs4JrQ896rLccsYSGO3K1jQgijrEA
lZQhSVPm2Y0/cHMrgr9/QcZKk+Ffyvz89HgThyrvmNJNdGCLhuPnoWlQMwjhpviq
akjJhYf+
=Pmtq
-----END PGP SIGNATURE-----

Timestamp of file with hash 88b89b80c24192ef59fea53c027a40ed6e6fe7c8d6795036ca7991f3fb4d7971 -

@glozow glozow force-pushed the test-bloomfilter branch 3 times, most recently from f709a14 to b758749 Compare June 10, 2020 03:24
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.

Concept ACK b758749173

glozow added 5 commits June 10, 2020 07:27
-msg_mempool is currently only tested with bloomfilter disabled
(node is disconnected) in p2p_mempool.py
-msg_mempool should get mempool txns in response when bloomfilter
is enabled
-edit test that doesn't test msg_mempool as intended
A node with fRelay=False should not receive any invs until filter is set using
filterload; all other behavior should be identical.
…nect

-A node with bloomfilters disabled should disconnect peers that send
msg_mempool, msg_filterload, or msg_filteradd.
-Renamed the test because it now has a wider scope and msg_mempool's
actual functionality makes more sense for p2p_filter.py.
-grab mininode_lock for every access to mininode attributes,
otherwise there are race conditions
-BEGIN VERIFY SCRIPT-
sed -i 's/FilterNode/P2PBloomFilter/g' test/functional/p2p_filter.py;
sed -i 's/filter_node/filter_peer/g' test/functional/p2p_filter.py;
-END VERIFY SCRIPT-
@glozow glozow force-pushed the test-bloomfilter branch from b758749 to dca7394 Compare June 10, 2020 15:41
@maflcko
Copy link
Member

maflcko commented Jun 10, 2020

ACK dca7394 only changes is restoring accidentally deleted test 🍮

Show signature and timestamp

Signature:

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

ACK dca73941eb only changes is restoring accidentally deleted test 🍮
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUg6PAv/ROMdaabZoFQqsrL/+8J/dZZQXJsUGSiG2TpTQibWFyPSlvgYeDe5raf6
yTa139/BqIY8ZsoiMsW7dwHtx3sJQ4bEkL53nECP5OaFS3wdK+6DoddSW4n/Vdm0
F3/Wz01/x2tYg8hXP4jpoaBN1KcJpbDtrp+hk4UuOu2Yrwxm7sT1uJi8Gl5g8cRc
wKPFldxOR/NvB2WjDWGHwda3WSN9ylEa66XYjXCm3dVi0cL4rfsVy6pudL4yVmh8
suygyKj15vWTmJz4NRsWnTisIRBXcIen/gNvNKl8bEfNU1BUeThziey/6i/zszq6
DP51JOUSOGCEZqZsK6vcaflUz6GRIGkBQXQ/mC4DrtNJHakn0wSLZ+gO2UKuIKdU
r6NnqvNSrNFWkc2l1tfmxovGnkZQ2iwu98Mo/X8hs7SCshvcVsDLvhhDecxB61Z6
tsnwdSR8EBZrMkGWUYjzG6BAsnV/hQpLErFuthJTzEDdmyoO2eWAYk+R3+5Uszrl
euwfkY0A
=debF
-----END PGP SIGNATURE-----

Timestamp of file with hash 70bc0be0f61503b76003fe460f747227c9eb065aff2dd334d2640b7467d69650 -

@glozow
Copy link
Member Author

glozow commented Jun 10, 2020

Thanks for the thorough review @MarcoFalke 🙏 , greatly appreciated.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK dca7394 modulo a few nits if you retouch, happy to re-ACK if you take any of them but don't feel obliged to.

self.test_filter(filter_peer)
self.nodes[0].disconnect_p2ps()

self.log.info('Test BIP 37 for a node with fRelay = False')
Copy link
Member

Choose a reason for hiding this comment

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

497a619 perhaps put the BIP37 tests into their own function

Copy link
Member Author

Choose a reason for hiding this comment

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

They're mostly in their own function test_filter, so I left this one as is.

@maflcko
Copy link
Member

maflcko commented Jun 11, 2020

With two ACKs, this test change seems ready to merge. @gzhao408 Let me know if you want to address the feedback or want to leave it as is for now (for potential follow-ups) and have the pull request merged.

@glozow
Copy link
Member Author

glozow commented Jun 11, 2020

Thank you for the review @jonatack 🙏 !
I've made a followup #19252 for disconnect_p2ps to wait for disconnect to complete anyway, so I can easily incorporate the feedback there. @MarcoFalke green light to merge :) thanks

@maflcko maflcko merged commit b33136b into bitcoin:master Jun 11, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 11, 2020
… tests

dca7394 scripted-diff: rename node to peer for mininodes (gzhao408)
0474ea2 [test] fix race conditions and test in p2p_filter (gzhao408)
4ef80f0 [test] sending invalid msgs to node with bloomfilters=0 causes disconnect (gzhao408)
497a619 [test] add BIP 37 test for node with fRelay=false (gzhao408)
e8acc60 [test] add mempool msg test for node with bloomfilter enabled (gzhao408)

Pull request description:

  This PR adds a few tests that are bloomfilter-related, including behavior for when bloomfilters are turned _off_:
  1. Tests p2p message `msg_mempool`: a node that has `peerbloomfilters` enabled should send its mempool (disabled behavior already tested [here](https://github.com/bitcoin/bitcoin/blob/master/test/functional/p2p_mempool.py)).
  2. Tests that bloomfilter peers with [`fRelay=False`](https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki#extensions-to-existing-messages) in the `version` message should not receive any invs until they set the filter. The rest is the same as what’s already tested in `p2p_filter.py`.
  3. Tests that peers get disconnected if they send `filterload` or `filteradd` p2p messages to a node with bloom filters disabled.
  4. Refactor: renames p2p_mempool.py to p2p_nobloomfilter_messages.py.
  5. Fixes race conditions in p2p_filter.py

ACKs for top commit:
  MarcoFalke:
    ACK dca7394 only changes is restoring accidentally deleted test 🍮
  jonatack:
    ACK dca7394 modulo a few nits if you retouch, happy to re-ACK if you take any of them but don't feel obliged to.

Tree-SHA512: 442aeab0755cb8b830251ea170d1d5e6da8ac9029b3276d407a20ee3d588cc61b77b8842368de18c244056316b8c63b911776d6e106bc7c023439ab915b27ad3
maflcko pushed a commit that referenced this pull request Jun 17, 2020
…ter test followups

9a40cfc [refactor] use waiting inside disconnect_p2ps (gzhao408)
aeb9fb4 [test] wait for disconnect_p2ps to be reflected in getpeerinfo (gzhao408)
e81942d [test] logging and style followups for bloomfilter tests (gzhao408)

Pull request description:

  Followup to #19083 which adds bloomfilter-related tests.

  1. Make test_node `disconnect_p2ps` wait until disconnection is complete to avoid race conditions (and not place the burden on tests) from MarcoFalke's [comment](#19083 (comment)). And clean up any redundant `wait_until`s in the functional tests.
  2. Clean up style + logging in p2p_filter.py and p2p_nobloomfilter_messages.py and jonatack's other [comments](#19083 (review))

ACKs for top commit:
  jonatack:
    Code review ACK 9a40cfc from re-reviewing the diff and `git range-diff 5cafb46 8386ad5 9a40cfc`
  MarcoFalke:
    ACK 9a40cfc 🐂

Tree-SHA512: 2e14b1c12fc08a355bd5ccad7a2a734a4ccda4bc7dc7bac171cb57359819fc1599d764290729af74832fac3e2be258c5d406c701e78ab6d7262835859b9a7d87
@glozow glozow deleted the test-bloomfilter branch July 25, 2020 14:47
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2021
Summary:
dca73941eb0f0a4c9b68efed3870b536f7dd6cfe scripted-diff: rename node to peer for mininodes (gzhao408)
0474ea25afc65546cbfe5f822c0212bf3e211023 [test] fix race conditions and test in p2p_filter (gzhao408)
4ef80f0827392a1310ca5a29cc1f8f5ca5d16f95 [test] sending invalid msgs to node with bloomfilters=0 causes disconnect (gzhao408)
497a619386008dfaec0db15ecaebcdfaf75f5011 [test] add BIP 37 test for node with fRelay=false (gzhao408)
e8acc6015695c8439fc971a12709468995b96dcf [test] add mempool msg test for node with bloomfilter enabled (gzhao408)

Pull request description:

  This PR adds a few tests that are bloomfilter-related, including behavior for when bloomfilters are turned _off_:
  1. Tests p2p message `msg_mempool`: a node that has `peerbloomfilters` enabled should send its mempool (disabled behavior already tested [here](https://github.com/bitcoin/bitcoin/blob/master/test/functional/p2p_mempool.py)).
  2. Tests that bloomfilter peers with [`fRelay=False`](https://github.com/bitcoin/bips/blob/master/bip-0037.mediawiki#extensions-to-existing-messages) in the `version` message should not receive any invs until they set the filter. The rest is the same as what’s already tested in `p2p_filter.py`.
  3. Tests that peers get disconnected if they send `filterload` or `filteradd` p2p messages to a node with bloom filters disabled.
  4. Refactor: renames p2p_mempool.py to p2p_nobloomfilter_messages.py.
  5. Fixes race conditions in p2p_filter.py

---

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

Test Plan:
  ninja all
  ./test/test_runner.py p2p_filter p2p_nobloomfilter_messages

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D9511
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request May 13, 2021
…filter test followups

Summary:
9a40cfc558b3f7fa4fff1270f969582af17479a5 [refactor] use waiting inside disconnect_p2ps (gzhao408)
aeb9fb414e2d000830287d9dd3fed7fc2eb570d2 [test] wait for disconnect_p2ps to be reflected in getpeerinfo (gzhao408)
e81942d2e1288367e8da94adb2b2a88be99e4751 [test] logging and style followups for bloomfilter tests (gzhao408)

Pull request description:

  Followup to #19083 which adds bloomfilter-related tests.

  1. Make test_node `disconnect_p2ps` wait until disconnection is complete to avoid race conditions (and not place the burden on tests) from MarcoFalke's [comment](bitcoin/bitcoin#19083 (comment)). And clean up any redundant `wait_until`s in the functional tests.
  2. Clean up style + logging in p2p_filter.py and p2p_nobloomfilter_messages.py and jonatack's other [comments](bitcoin/bitcoin#19083 (review))

---

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

Depends on D9512

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D9513
@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.

5 participants