-
Notifications
You must be signed in to change notification settings - Fork 38.6k
test: Extends MEMPOOL msg functional test #28485
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
1e999b4 to
eb4b020
Compare
test/functional/p2p_filter.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why, given that this test uses immediate tx-relay. Shouldn't this check fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there hasn't been a SendMessages yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC send_and_ping should force a SendMessages now (on current master)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be missing the point here, but why should it fail? Even if send_and_ping forces SendMessages, aren't invs still delayed?
If the following is added at the end of the test, you can see how the transaction is served:
filter_peer.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=int(self.nodes[0].getmempoolentry(add_txid)["wtxid"], 16))]))
filter_peer.send_and_ping(msg_getdata([CInv(t=MSG_WTX, h=int(self.nodes[0].getmempoolentry(add_txid)["wtxid"], 16))]))
assert filter_peer.tx_received
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a import time;time.sleep(.1) after the wallet.send_to to observe that the test fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be using send_message instead so SendMessages is not forced, or just get rid of this third tx request?
FWIW, adding a sleep after send_message will make it fail too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests must pass in all environments. If you rely on a race condition for the test to pass, it will fail eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, my point was whether the last check was even worth it. I finally figured out what was going on (h/t to @glozow for being my rubber duckie):
It turns out m_last_inv_sequence is not updated every single time an INV is sent, but every single time an INV may be sent. As long as the node trickles for that peer, m_last_inv_sequence is increased, hence why the transaction was requestable even though no INV was being sent.
Therefore, by using sync_and_ping, which forces SendMessages, we can assert that the transaction is requestable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c9e31a4 should have fixed this
eb4b020 to
c9e31a4
Compare
c9e31a4 to
d10acba
Compare
glozow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK d10acba3d730397484f10ccb2f1116544161507d, with some nits
d10acba to
fb288f3
Compare
|
Addressed nits |
glozow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK fb288f331277536c8b528c0eae44d81617fcbee6, only diff is the 2 nits on logging
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fb288f331277536c8b528c0eae44d81617fcbee6
test/functional/p2p_filter.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (feel free to ignore): MiniWallet's send_to already returns both txid and wtxid, so one doesn't need the extra getmempoolentry RPC call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm taking this
fb288f3 to
3f2da64
Compare
|
Addressed comments. Should be re-review ready |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm ACK 3f2da64a45f79033c29d08ee24147ca124a26c22
test/functional/p2p_filter.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can remove this line, now that you use wait_for_tx ?
test/functional/p2p_filter.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Is this change from send_message(msg_mempool()) to send_and_ping(msg_mempool()) required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is. Did a bunch of testing locally and it may be a remnant of the old approach taken for this test, which does not longer apply.
I've reversed some of the calls to make the diff as minimal as possible
3f2da64 to
59e86af
Compare
|
lgtm ACK 59e86afbcdfb9dbf52a6580246233ee501c51475 |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 59e86afbcdfb9dbf52a6580246233ee501c51475
instagibbs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done much review of #27675 , but I can't make the test case fail sensibly by commenting out the mempool message, and by the reading of the code.
test/functional/p2p_filter.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I comment out these lines the test still passes. Seems wrong based on text below at https://github.com/bitcoin/bitcoin/pull/28485/files#diff-c5c320cd909288d7cf2d82632c6bafcb9085413bfddf5edf361f288dbd76e0cbR153 ?
Based on my look at the code, in SendMessages we set m_last_inv_sequence = m_mempool.GetSequence() immediately on connection, even if we had no INVs to send. This means new connections can ask for anything historical, regardless of mempool message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is related to this? #28485 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so we agree, which makes the test a bit odd imo. The MEMPOOL message being sent or not has no relation on whether we respond to that particular getdata from the peer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't think this is inherently wrong. The irrelevant transaction is requestable (independently of the mempool message) because it is in the mempool and would have been announced to the peer if it happened to be interested in it (which is not the case, based on the filter).
Sending the mempool message and checking is done to make sure only the relevant transaction is annonced. However, we are still able to request the irrelevant.
Currently, p2p_filter.py::test_msg_mempool is not testing much. This extends the tests so the interaction between sending MEMPOOL messages with a filter that does not include all transactions in the mempool reacts, plus how it interacts with INV messages
59e86af to
97c0dfa
Compare
|
ACK 97c0dfa tests line up with my understanding of the code |
theStack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-ACK 97c0dfa
Currently, p2p_filter.py::test_msg_mempool is not testing much. This extends the tests so the interaction between sending
MEMPOOLmessages with a filter that does not include all transactions in the mempool reacts, plus how it interacts withINVmessages, especially after the changes introduced by #27675