Skip to content

test: Remove unused classes from p2p_leak.py - #19727

Merged
fanquake merged 3 commits into
bitcoin:masterfrom
dhruv:test-p2p-leak
Aug 20, 2020
Merged

fanquake merged 3 commits into
bitcoin:masterfrom
dhruv:test-p2p-leak

Conversation

@dhruv

@dhruv dhruv commented Aug 15, 2020 •

Copy link
Copy Markdown
Contributor

@fanquake fanquake added the Tests label Aug 15, 2020
@adamjonas

Copy link
Copy Markdown
Contributor

@dhruv welcome! Looks like a great first contribution.

Ran tests and everything LGTM, but @jnewbery is probably the guy who you'd want to take a look at this since it was his suggestion.

@jnewbery

Copy link
Copy Markdown
Contributor

Concept ACK. Thanks @dhruv . I'll review soon.

@dhruv

dhruv commented Aug 16, 2020

Copy link
Copy Markdown
Contributor Author

@dhruv welcome! Looks like a great first contribution.

Thank you for the warm welcome and review, @adamjonas. I am excited to be here.

@glozow glozow left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept ACK! Welcome Dhruv :D

I was heavy-handed with the nits because I wanted to give as much feedback as possible (please forgive me). Mostly, I think you should have a clear distinction between nodes and mininodes in your naming and comments.

bitcoind nodes (i.e. TestNodes) = I would call them "nodes"
Mininodes = not bitcoind nodes, they just implement the P2P interface. So I'd prefer to call them "peers"

Also left a few food-for-thought questions about synchronization.

Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
@promag

promag commented Aug 17, 2020

Copy link
Copy Markdown
Contributor

Peers = not bitcoind nodes, but "mininodes" that just implement the P2P interface

A node is a peer, a peer can be a node, a peer is not a beer 🍻

@glozow

glozow commented Aug 17, 2020

Copy link
Copy Markdown
Contributor

A node is a peer, a peer can be a node

Oops ya that looks wrong out of context. I meant we shouldn't call mininodes nodes, and "peer" is what I recommend as a better name. I edited my comment thank you @promag 🥂

@jnewbery jnewbery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good @dhruv . Thanks for your contribution! I've left a couple of comments inline.

You should also make a couple of small changes to the commit logs. The summary line should be in the indicative mood (ie "remove CNodeNoVersionMisbehaving" instead of "removing CNodeNoVersionMisbehaving"), and all lines should be wrapped at 80 chars (see https://chris.beams.io/posts/git-commit/ for some tips on writing commit logs).

Comment thread test/functional/p2p_leak.py Resolved
Comment thread test/functional/p2p_leak.py Resolved
@dhruv dhruv changed the title test: Removing unused classes from p2p_leak.py test: Remove unused classes from p2p_leak.py Aug 17, 2020
@dhruv

dhruv commented Aug 17, 2020

Copy link
Copy Markdown
Contributor Author

@jnewbery Comments addressed. I also increased a wait_until timeout in this commit to address this. Please let me know if there is a better way.

@dhruv

dhruv commented Aug 17, 2020

Copy link
Copy Markdown
Contributor Author

The test is now failing on a different architecture but passing on the one it failed at the last time (before raising the timeout) which I think confirms that it's a Travis CI timeout issue. However, I feel uncertain that just continuing to raise the timeout to reduce test fragility is the path forward. I'm looking for guidance from more experienced contributors.

@amitiuttarwar amitiuttarwar left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

concept ACK! welcome! 🎈

  • I've figured out the root cause of the sporadic test failure. in order to suggest a fix I want to better understand the intention of the wait_until...bytesrecv_per_msg assertion.

I'm also hoping to help you figure out the root cause of the failure yourself. Two big hints from my debugging process:

  • Running it locally on repeat & seeing that even if I decrease the timeout to 0.1, I wasn't able to get (even a sporadic) failure.
  • Reading the failure logs on Travis, and seeing that the node received all the ping messages, disconnected the peer, and then later is failing the bytesrecv_per_msg condition. Why could that be?

Incase you haven't seen it, ./combine_logs is a very helpful tool for introspecting on what's going on during tests. You could try comparing the logs from the failure to the logs you see in your ordinary success cases.

other meta notes:

  • no need to refer to review comments in your commit messages. the context is best left for github convo & the commit messages focused on the code changes :) its fine for the message to just be 1 line when the commit seems self explanatory.

  • I think two of these commits (removing C prefix & distinguishing nodes from peers) can probably be done via a scripted diff.

Comment thread test/functional/p2p_leak.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a reason this is a wait_until? won't this peer start with ever_connected as false & here we want to check that it is still false?

@dhruv dhruv Aug 18, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The peer does start with ever_connected set to False. Then, if I understand things correctly, when the tcp connection is established, mininode.py::P2PConnection::connection_made() will invoke p2p_leak.py::LazyPeer::on_open() which will set no_version_disconnect_peer.ever_connected to True. So I think this wait_until is waiting for the transport connection to be established prior to generating a block below. This way it can verify that the peers do not receive leaked information despite an established tcp connection, and not because of connection problems.

Am I missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh I'm sorry, I mixed up true and false 😅
yes this makes sense- we want to check that ever_connected has been switched to true, and allow some buffer time for that to occur.

Comment thread test/functional/p2p_leak.py Resolved
@dhruv

dhruv commented Aug 18, 2020

Copy link
Copy Markdown
Contributor Author

Thanks for the great review, @amitiuttarwar. I appreciate you taking the time to teach me with hints rather than giving out the answer. I've removed the assertion and made the changes to the commit messages. I had some trouble running test/lint/commit-script-check.sh locally so I am going to look more into that in the morning.

@dhruv
dhruv force-pushed the test-p2p-leak branch 3 times, most recently from b84919a to 54ebddd Compare August 18, 2020 06:38
@practicalswift

Copy link
Copy Markdown
Contributor

Concept ACK

Warm welcome as a contributor @dhruv! Hope to see more contributions from you in the future :)

@jnewbery jnewbery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. One comment inline.

I think the last two commits can be squashed. No need to rename classes in one commit and then rename them again in a subsequent commit!

Comment thread test/functional/p2p_leak.py Resolved
@dhruv

dhruv commented Aug 18, 2020

Copy link
Copy Markdown
Contributor Author

@jnewbery commits squashed

@jnewbery jnewbery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Final code looks good, but something's gone askew with the commits. See comment inline.

When you squash or fixup commits, there's no need to rebase on the lastest master. That makes things a bit more difficult for reviewers, because they can't easily compare what's changed.

Comment thread test/functional/p2p_leak.py Resolved
dhruv added 2 commits August 18, 2020 13:06
It's also clearer to have `no_version_disconnect_node` send a message
other than version or verack in order to reach the peer discouragement
threshold.
…_leak.py

Also, remove "C" prefix from class names to match new style
@jnewbery

Copy link
Copy Markdown
Contributor

tested ACK ed5cd12

@amitiuttarwar

Copy link
Copy Markdown
Contributor

utACK ed5cd12

@fanquake
fanquake merged commit 70d7ddb into bitcoin:master Aug 20, 2020
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 15, 2021
Summary:
> test: remove `CNodeNoVersionMisbehavior` from p2p_leak.py
>
> It's also clearer to have `no_version_disconnect_node` send a message
> other than version or verack in order to reach the peer discouragement
> threshold.

> test: remove `CNodeNoVersionIdle` from p2p_leak.py

> test: Distinguish between nodes(bitcoind) and peers(mininodes) in p2p_leak.py
>
> Also, remove "C" prefix from class names to match new style

This is a backport of [[bitcoin/bitcoin#19727 | core#19727]]

Test Plan: `ninja check-functional`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

8 participants