-
Notifications
You must be signed in to change notification settings - Fork 36.9k
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
test: Wait for both veracks in add_p2p_connection #18247
Conversation
fac8203
to
fa58623
Compare
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.
Concept ACK with a question on implementation.
p2p_conn.wait_for_verack() | ||
# Force the node to fully process our verack as well | ||
p2p_conn.sync_with_ping() |
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.
It looks like this change would affect quite a few other functional tests that don't pass wait_for_verack=False
. Is it a good idea to change it here rather than in p2p_blocksonly?
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.
Yes, whenever we add a p2p connection in the tests we want the least amount of surprise and want to assume that the connection has been fully established when the function returns.
Only in adversarial tests do we need to make sure that the connection is not (or only partially) established. Do you see any other test that needs a partial connection?
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.
There are some tests that now have a redundant sync_with_ping()
immediately following an add_p2p_connection()
, e.g. in p2p_invalid_messages.py::143
and others that have a single operation between the two calls and which are probably being needlessly synced twice (or perhaps should not be synced until after the single operation), e.g. in 3 places in p2p_dos_header_tree.py
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 fine, at worst slows down the test by a few milliseconds.
There are some tests that now have a redundant sync_with_ping() immediately following an add_p2p_connection(), e.g. in p2p_invalid_messages.py::143
I fixed this instance in the latest commit, but couldn't find any other instances.
and others that have a single operation between the two calls and which are probably being needlessly synced twice (or perhaps should not be synced until after the single operation), e.g. in 3 places in p2p_dos_header_tree.py
Why are they needlessly being synced? First they need to wait until the connection is fully established, then they need to wait until the message they sent is fully processed. This is a common pattern in our tests, see send_and_ping
.
I went ahead and replaced the two-line calls there with the more widely used one-line send_and_ping
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.
Why are they needlessly being synced?
Unless I am confused, these cases seem to be synced one additional time after this change:
- Before: add connection / send / sync
- After: add connection including sync by default / send / sync
Help me understand if that's not the case?
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 fine, in this case the sync is redundant, but I can't see a way to distinguish the redundant case from the non-redundant one. Even if we could, the cost of a few milliseconds is probably not worth it to optimize this, right?
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.
Force pushed with additional doc to explain my reasoning
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 agree; thanks for the doc
Would be nice to move forward with this. I am seeing about one ci failure each day because of this bug. |
Also replace the two-line (send_message + sync_with_ping) with the one-line send_and_ping
fa5d339
to
faf1d04
Compare
ACK faf1d04 Verified that p2p_leaks and p2p_timeouts needed these changes and looked at other tests. |
…nection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that #18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
Summary: Partial backport of Core [[bitcoin/bitcoin#18247 | PR18247]] Depends on D6431 Test Plan: ninja check-all Reviewers: #bitcoin_abc, jasonbcox, deadalnix Reviewed By: #bitcoin_abc, jasonbcox, deadalnix Subscribers: deadalnix, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D6384
…connection Summary: Also replace the two-line (send_message + sync_with_ping) with the one-line send_and_ping bitcoin/bitcoin@faf1d04 --- Depends on D6384 Concludes backport of Core [[bitcoin/bitcoin#18247 | PR18247]] Test Plan: ./test/functional/test_runner.py Reviewers: #bitcoin_abc, deadalnix, jasonbcox Reviewed By: #bitcoin_abc, deadalnix, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D6432
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
…p2p_connection 4670006 test: remove redundant sync_with_ping after add_p2p_connection (Jon Atack) Pull request description: Now that bitcoin#18247 is merged, these calls are redundant. ACKs for top commit: vasild: utACK 4670006 Tree-SHA512: bdbfe8bcf9dbdde0a8115e3a62bfe359910798d7a3010d920ffca07049cb5f97bf8fb9b6f70079b0607105192b61a6d665774e59a2b678597b47ad6237595ad5
This fixes the race in p2p_blocksonly
E.g. https://travis-ci.org/MarcoFalke/bitcoin-core/jobs/657038844#L4500