-
Notifications
You must be signed in to change notification settings - Fork 38.8k
test: Remove confusing mininode terminology #19760
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
|
I think instead of |
Thanks Marco. Should be fixed now. |
31244d0 to
a4a2f78
Compare
|
concept ACK! I still have to stop and think to distinguish testnode from mininode. I was skeptical about the rename to p2p, but looking at the code has convinced me it makes sense. |
|
Concept ACK On behalf of future generations of Bitcoin Core contributors: thank you! :) |
|
Concept ACK! Thank you for the PR, @jnewbery. As a newcomer, I have started to think about mininode as "mocknode" and testnode as just "node". Since the entire network is peer-to-peer anyway, would it be valuable to avoid using that to mean mock? |
Yes indeed. A
In the abstract, it doesn't make sense to talk about a |
|
Concept ACK |
|
I'm not sure if this makes things less confusing: In a test where our node has, in current terminology, one connection to a mininode and one to another bitcoind instance, it would in future terminology have one Since I am used to thinking of a mininode as an object first, it would help me if someone could explain where exactly the confusion with |
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.
Concept ACK
(very big Concept ACK)
I added a few suggestions because I, too, have opinions for making the test framework clearer 😅 .
- There's almost always a better option than the test_framework.util
wait_until, which does not grab the lock automatically, and doesn't have any context from the TestFramework instance. - The TestNode
p2pproperty can be misleading, especially in situations where there are multiple p2p_conns connected. It's very possible to be referring to the wrong connection when usingnode.p2p. Generally I think it's always better to either use the connection returned byadd_p2p_connectionor index into thep2pslist.
|
(Edited for some inaccuracies pointed out by sipa)
Calling it MockNode would be even more confusing I think, because that sounds so similar to TestNode, and we often "mock" things (e.g. time) so that we can manipulate them in the functional tests. I'd even be ok with renaming TestNode to MockNode. I can't really think of anything that mininodes do other than send/receive p2p messages. I think of mininodes as fake peers (but only when connected, as jnewbery said above) that we have full control over, and can use to elicit some behavior from the TestNode(s). |
|
I don't have a strong opinion either way on the renaming, but wanted to respond to this::
To me, that's exactly what makes something a node: whether or not it interacts with other nodes via the P2P protocol, making it a node of the P2P network graph. Here we just have a very minimal node that doesn't do anything more than that. |
|
@sipa so "peer" == "node"? |
|
A peer is a node that's not yourself (and you're communicating with). |
This comment pinpoints one source of my confusion: Overall, I understand the distinction now and don't have a strong opinion either way. Just my 2c as a rookie. |
I think this is done in #19752.
I have no problem with that happening, but it should be in a different PR. |
a4a2f78 to
b1d9900
Compare
|
My PR description has made this conversation a bit more abstract than it needs to be. To recenter on the changes this PR is making:
That's all that this PR does. Rebased on master. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
-BEGIN VERIFY SCRIPT- sed -i 's/mininode_lock/p2p_lock/g' $(git grep -l "mininode_lock") -END VERIFY SCRIPT-
-BEGIN VERIFY SCRIPT- sed -i 's/\.mininode/\.p2p/g' $(git grep -l "mininode") git mv test/functional/test_framework/mininode.py test/functional/test_framework/p2p.py -END VERIFY SCRIPT-
b1d9900 to
bf0720c
Compare
|
rebased |
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 bf0720c
|
changes look good, but I think there are two more uses of the word "mininode" in comments that would be nice to update
|
bf0720c to
d5800da
Compare
Thanks! Not sure how I missed those. I've now removed them. |
|
ACK d5800da |
kallewoof
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.
Big concept ACK -- the mininode stuff really confused me when I first started using the test framework.
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.
Code review ACK (sans scripted diff stuff; I did review the diff-scripts but did not verify that the actual changes matched up)
A sorting nit, just for you John.
| assert_greater_than_or_equal, | ||
| assert_raises, | ||
| assert_raises_rpc_error, | ||
| assert_is_hex_string, |
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 < r
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 d5800da 🚞 Show signature and timestampSignature: Timestamp of file with hash |
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.
left some nits.
@jnewbery let me know if you want this merged or want to address the nits
I think this is rfm
| from test_framework.blocktools import create_block, create_coinbase | ||
| from test_framework.messages import msg_block | ||
| from test_framework.mininode import P2PInterface, mininode_lock | ||
| from test_framework.p2p import p2p_lock, P2PInterface |
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.
| This python code was modified from ArtForz' public domain half-a-node, as | ||
| found in the mini-node branch of http://github.com/jgarzik/pynode. | ||
| The P2PInterface objects interact with the bitcoind nodes under test using the |
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.
| The P2PInterface objects interact with the bitcoind nodes under test using the | |
| The P2PInterface classes interact with the ____ nodes under test using the |
I think this should say "classes" instead. Also, I am not sure about bitcoind, since it is also possible to run the tests against the gui. Though using PACKAGE_NAME here might be a bit too abstract?
If you think it's rfm, let's merge it now. I can fix the style comments in a follow-up. |
d5800da [test] Remove final references to mininode (John Newbery) 5e8df33 test: resort imports (John Newbery) 85165d4 scripted-diff: Rename mininode to p2p (John Newbery) 9e2897d scripted-diff: Rename mininode_lock to p2p_lock (John Newbery) Pull request description: New contributors are often confused by the terminology in the test framework, and what the difference between a _node_ and a _peer_ is. To summarize: - a 'node' is a bitcoind instance. This is the thing whose behavior is being tested. Each bitcoind node is managed by a python `TestNode` object which is used to start/stop the node, manage the node's data directory, read state about the node (eg process status, log file), and interact with the node over different interfaces. - one of the interfaces that we can use to interact with the node is the p2p interface. Each connection to a node using this interface is managed by a python `P2PInterface` or derived object (which is owned by the `TestNode` object). We can open zero, one or many p2p connections to each bitcoind node. The node sees these connections as 'peers'. For historic reasons, the word 'mininode' has been used to refer to those p2p interface objects that we use to connect to the bitcoind node (the code was originally taken from the 'mini-node' branch of https://github.com/jgarzik/pynode/tree/mini-node). However that name has proved to be confusing for new contributors, so rename the remaining references. ACKs for top commit: amitiuttarwar: ACK d5800da MarcoFalke: ACK d5800da 🚞 Tree-SHA512: 2c46c2ac3c4278b6e3c647cfd8108428a41e80788fc4f0e386e5b0c47675bc687d94779496c09a3e5ea1319617295be10c422adeeff2d2bd68378e00e0eeb5de
Summary: PR description: > New contributors are often confused by the terminology in the test framework, and what the difference between a node and a peer is. To summarize: > - a 'node' is a bitcoind instance. This is the thing whose behavior is being tested. Each bitcoind node is managed by a python TestNode object which is used to start/stop the node, manage the node's data directory, read state about the node (eg process status, log file), and interact with the node over different interfaces. > - one of the interfaces that we can use to interact with the node is the p2p interface. Each connection to a node using this interface is managed by a python P2PInterface or derived object (which is owned by the TestNode object). We can open zero, one or many p2p connections to each bitcoind node. The node sees these connections as 'peers'. > > For historic reasons, the word 'mininode' has been used to refer to those p2p interface objects that we use to connect to the bitcoind node (the code was originally taken from the 'mini-node' branch of https://github.com/jgarzik/pynode/tree/mini-node). However that name has proved to be confusing for new contributors, so rename the remaining references. > ``` > -BEGIN VERIFY SCRIPT- > sed -i 's/mininode_lock/p2p_lock/g' $(git grep -l "mininode_lock") > -END VERIFY SCRIPT- > ``` This is a partial backport of [[bitcoin/bitcoin#19760 | core#19760]] [1/4] bitcoin/bitcoin@85165d4 Backport note: I did not cherry-pick the commit, I ran the `sed` script. The only deviations from the script are style changes from the linter. Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9572
Summary: This is a partial backport of [[bitcoin/bitcoin#19760 | core#19760]] [3/4] bitcoin/bitcoin@5e8df33 Some changes are debatable (e.g. `assert_is_hex_string` > `assert_is_hash_string`), but I think it is best to deviate as little as possible from the Core code for such minor points of detail. Depends on D9573 Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9574
Summary: This concludes backport of [[bitcoin/bitcoin#19760 | core#19760]] [4/4] bitcoin/bitcoin@d5800da There is a minor change to a comment that is missing in `p2p_permissions.py` because of a new test that is not yet backported. Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Differential Revision: https://reviews.bitcoinabc.org/D9575


New contributors are often confused by the terminology in the test framework, and what the difference between a node and a peer is. To summarize:
TestNodeobject which is used to start/stop the node, manage the node's data directory, read state about the node (eg process status, log file), and interact with the node over different interfaces.P2PInterfaceor derived object (which is owned by theTestNodeobject). We can open zero, one or many p2p connections to each bitcoind node. The node sees these connections as 'peers'.For historic reasons, the word 'mininode' has been used to refer to those p2p interface objects that we use to connect to the bitcoind node (the code was originally taken from the 'mini-node' branch of https://github.com/jgarzik/pynode/tree/mini-node). However that name has proved to be confusing for new contributors, so rename the remaining references.