Skip to content
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

scripted-diff: Replace strCommand with msg_type #18533

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Apr 5, 2020

Receiving a message is not a command, but simply a message of some type

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 5, 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.

@naumenkogs
Copy link
Member

Not sure how we go about refactoring like this, but I do like this change. ACK!

I was thinking maybe we should make a type stronger than a string since we're touching it, but I guess there's not much we can do here.

@maflcko
Copy link
Member Author

maflcko commented Apr 5, 2020

Not sure how we go about refactoring like this, but I do like this change. ACK!

For purely stylistic matters, I think the rule is to not change the style unless you touch that line for other reasons. However, in this case, I think it is a problem of code (self) documentation. A command and message type are two completely different things and should not be confused with each other.

I was thinking maybe we should make a type stronger than a string since we're touching it, but I guess there's not much we can do here.

Indeed, string is the best we can do here. On the wire it is a string and practically you'll always have to do string comparison. Even if it is to convert the string to an enum (#10145).

@promag
Copy link
Contributor

promag commented Apr 5, 2020

ACK, also update src/test/fuzz/process_message.cpp?

-BEGIN VERIFY SCRIPT-
sed -i 's/\<strCommand\>/msg_type/g' ./src/net_processing.cpp ./src/test/fuzz/process_message.cpp
-END VERIFY SCRIPT-
@maflcko
Copy link
Member Author

maflcko commented Apr 6, 2020

Addressed @promag's feedback

@promag
Copy link
Contributor

promag commented Apr 6, 2020

ACK 7777e36.

@naumenkogs
Copy link
Member

ACK 7777e36

@practicalswift
Copy link
Contributor

ACK 7777e36 -- I've always thought the strCommand name is confusing :)

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

ACK 7777e36

A command and message type are two completely different things and should not be confused with each other.

Concerning this point, a follow-up PR renaming also CNetMessage.m_command would make sense I guess?

@maflcko
Copy link
Member Author

maflcko commented Apr 6, 2020

Concerning this point, a follow-up PR renaming also CNetMessage.m_command would make sense I guess?

There is some active work going on in CNetMessage, so it can be done as part of one of those changes that touch that code anyway.

@theStack
Copy link
Contributor

theStack commented Apr 6, 2020

Another place where the "command" naming is still used is in the class CMessageHeader:

  • char pchCommand[COMMAND_SIZE];
  • std::string GetCommand() const;
  • .....

@maflcko
Copy link
Member Author

maflcko commented Apr 8, 2020

Did all of the replacements suggested by @theStack in one scripted diff

@maflcko
Copy link
Member Author

maflcko commented Apr 8, 2020

The full replacement commit was eeee135, but I've reverted this to the initial version, which was focussed on just net_processing and was less invasive and has 4 ACKs. Someone else can pick up the full replacement later.

@maflcko
Copy link
Member Author

maflcko commented Apr 8, 2020

I've also checked that on my system with clang and gcc on -O2 it produces the same binaries. So I will go ahead and merge this.

@maflcko maflcko merged commit 4c59236 into bitcoin:master Apr 8, 2020
@maflcko maflcko deleted the 2004-netMsgType branch April 8, 2020 16:15
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 13, 2020
7777e36 scripted-diff: Replace strCommand with msg_type (MarcoFalke)

Pull request description:

  Receiving a message is not a command, but simply a message of some type

ACKs for top commit:
  promag:
    ACK 7777e36.
  naumenkogs:
    ACK 7777e36
  practicalswift:
    ACK 7777e36 -- I've always thought the `strCommand` name is confusing :)
  theStack:
    ACK 7777e36

Tree-SHA512: 662bac579064c621191916274314b85111cfb4df488f00893ceb16def1c47af4b2a0f34cd7349722099b5a9d23160edb8eb999841f1d64af3e0da02e4870b4bf
maflcko pushed a commit that referenced this pull request Apr 19, 2020
9df32e8 scripted-diff: test: replace command with msgtype (Sebastian Falbesoner)

Pull request description:

  This is a follow-up PR to #18533, which changed the naming of `strCommand` to `msg_type` in the network processing code. The same approach is done here for the function test framework, to get rid of the wrong "command" terminology for network mesage types. (Commands are usually used in the CLI or RPC context, so using the same name in the network message context would only be confusing.)

  The commit was created through the following steps:
  1. search for all occurences of the string "command" within the folder `test/functional`
  ```git grep -i command test/functional > command_finds```
  2. manually sort out all false-positives, i.e. occurences of "command" which describe commands in the correct sense (mostly CLI or RPC related, also some with Socks5)
  3. put the remaining occurences into a scripted-diff (a quite simple one, actually) that renames "command" to "msgtype" in the concerned files.

  The name `msgtype` was intentionally chosen without the underscore `_` as classes beginning with `msg_` define concrete types of messages.

ACKs for top commit:
  MarcoFalke:
    ACK 9df32e8 . Makes sense that tests use the same naming as Bitcoin Core. See `NetMsgType` here: https://doxygen.bitcoincore.org/namespace_net_msg_type.html

Tree-SHA512: cd0ee08a382910b7f10ce583acdaf4f8a39f9ba4a22434a914415727eedd98bac538de9bf6633574d5eb86f62558bc8dcb638a3289d99b04f8481f34e7a9a0c7
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 20, 2020
…e (naming)

9df32e8 scripted-diff: test: replace command with msgtype (Sebastian Falbesoner)

Pull request description:

  This is a follow-up PR to bitcoin#18533, which changed the naming of `strCommand` to `msg_type` in the network processing code. The same approach is done here for the function test framework, to get rid of the wrong "command" terminology for network mesage types. (Commands are usually used in the CLI or RPC context, so using the same name in the network message context would only be confusing.)

  The commit was created through the following steps:
  1. search for all occurences of the string "command" within the folder `test/functional`
  ```git grep -i command test/functional > command_finds```
  2. manually sort out all false-positives, i.e. occurences of "command" which describe commands in the correct sense (mostly CLI or RPC related, also some with Socks5)
  3. put the remaining occurences into a scripted-diff (a quite simple one, actually) that renames "command" to "msgtype" in the concerned files.

  The name `msgtype` was intentionally chosen without the underscore `_` as classes beginning with `msg_` define concrete types of messages.

ACKs for top commit:
  MarcoFalke:
    ACK 9df32e8 . Makes sense that tests use the same naming as Bitcoin Core. See `NetMsgType` here: https://doxygen.bitcoincore.org/namespace_net_msg_type.html

Tree-SHA512: cd0ee08a382910b7f10ce583acdaf4f8a39f9ba4a22434a914415727eedd98bac538de9bf6633574d5eb86f62558bc8dcb638a3289d99b04f8481f34e7a9a0c7
maflcko pushed a commit that referenced this pull request Jun 19, 2020
…alizedNetMsg

51e9393 refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg (Sebastian Falbesoner)

Pull request description:

  Follow-up PR for #18533 -- another small step towards getting rid of the confusing "command" terminology. Also see PR #18610 which tackled the functional tests.

ACKs for top commit:
  MarcoFalke:
    ACK 51e9393

Tree-SHA512: bb6f05a7be6823d5c4eab1d05b31fee944e700946827ad9425d59a3957fd879776c88c606319cbe9832d9451b275baedf913b71429ea3e01e4e82bf2d419e819
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 7, 2020
…d CSerializedNetMsg

51e9393 refactor: s/command/msg_type/ in CNetMsgMaker and CSerializedNetMsg (Sebastian Falbesoner)

Pull request description:

  Follow-up PR for bitcoin#18533 -- another small step towards getting rid of the confusing "command" terminology. Also see PR bitcoin#18610 which tackled the functional tests.

ACKs for top commit:
  MarcoFalke:
    ACK 51e9393

Tree-SHA512: bb6f05a7be6823d5c4eab1d05b31fee944e700946827ad9425d59a3957fd879776c88c606319cbe9832d9451b275baedf913b71429ea3e01e4e82bf2d419e819
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 19, 2020
Summary:
```
-BEGIN VERIFY SCRIPT-
sed -i 's/\<strCommand\>/msg_type/g' ./src/net_processing.cpp
./src/test/fuzz/process_message.cpp
-END VERIFY SCRIPT-
```

Backport of core [[bitcoin/bitcoin#18533 | PR18533]].

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D8460
maflcko pushed a commit to bitcoin-core/gui that referenced this pull request Jan 24, 2022
…mand with CNetMessage::m_type

224d878 net, refactor: Drop tautological local variables (Hennadii Stepanov)
3073a99 scripted-diff: Rename CNetMessage::m_command with CNetMessage::m_type (Hennadii Stepanov)

Pull request description:

  bitcoin/bitcoin#18533 (comment):
  > a message is not a command, but simply a message of some type

  Continuation of bitcoin/bitcoin#18533 and bitcoin/bitcoin#18937.

ACKs for top commit:
  theStack:
    Concept and code-review ACK 224d878
  shaavan:
    Code Review ACK 224d878
  w0xlt:
    crACK 224d878

Tree-SHA512: 898cafb44708dae1413fcc1533d809d75878891354f1b5edaaec1287f4921c31adc9330f4d42d82544a39689886bc17fee71ea587f9199fd5cc849d376f82176
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jan 28, 2022
…h CNetMessage::m_type

224d878 net, refactor: Drop tautological local variables (Hennadii Stepanov)
3073a99 scripted-diff: Rename CNetMessage::m_command with CNetMessage::m_type (Hennadii Stepanov)

Pull request description:

  bitcoin#18533 (comment):
  > a message is not a command, but simply a message of some type

  Continuation of bitcoin#18533 and bitcoin#18937.

ACKs for top commit:
  theStack:
    Concept and code-review ACK 224d878
  shaavan:
    Code Review ACK 224d878
  w0xlt:
    crACK 224d878

Tree-SHA512: 898cafb44708dae1413fcc1533d809d75878891354f1b5edaaec1287f4921c31adc9330f4d42d82544a39689886bc17fee71ea587f9199fd5cc849d376f82176
@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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants