-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Rename message_command variables in src/net* and src/rpc/net.cpp #24141
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
Concept ACK. Making rename commits a "scripted-diff" will simplify reviewing a lot. |
Link to documentation how to use |
I ran this script against your PR - https://raw.githubusercontent.com/shaavan/bitcoin/dd720d20d994bcac9974ca12db849baaff5adabe/24141-scripted-diff.sh
|
Concept ACK |
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.
Approach ACK
src/net.cpp
Outdated
@@ -102,7 +102,7 @@ enum BindFlags { | |||
// The sleep time needs to be small to avoid new sockets stalling | |||
static const uint64_t SELECT_TIMEOUT_MILLISECONDS = 50; | |||
|
|||
const std::string NET_MESSAGE_COMMAND_OTHER = "*other*"; | |||
const std::string NET_MESSAGE_OTHER = "*other*"; |
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.
Shouldn't NET_MESSAGE_COMMAND_OTHER
be renamed to NET_MESSAGE_TYPE_OTHER
?
After some consideration - I generally agree with @w0xlt - the values held in the string are defined in Line 64 in 9ec3991
& Line 12 in 9ec3991
The |
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. |
e80330b
to
8f31aad
Compare
Updated from e80330b to 8f31aad (pr24141.01 -> pr24141.02) Changes:
Thanks, @prusnak and @hebasto, for the scripted-diff example and documentation. And thanks, @RandyMacmillian, for the script message, which I have used as an inspiration for the commit 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.
ACK 8f31aad
Lint is failing because the changed comments do not match the pattern of the sed command.
Change the comments in another commit and this CI error will be fixed.
@w0xlt - Interesting nuance to scripted diffs - thanks for the insight. 😄 - basically each change needs its own commit in incremental steps. |
Nice catch, @w0xlt! I reckoned the comment change is relatively small and wouldn't require a separate commit. But let's keep the lint intact. Let me update the PR with separating comment changes in a new commit. |
8f31aad
to
d077901
Compare
Updated from 8f31aad to d077901 (pr24141.02 -> pr24141.03) Changes:
|
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 d077901
Does each commit compile on its own? |
d077901
to
ec50abf
Compare
Updated from d077901 to ec50abf (pr24141.03 -> pr24141.04) Changes:
Thanks, @MarcoFalke, for catching it. |
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
Some more candidates for the second commit:
diff --git a/src/net.cpp b/src/net.cpp
index f3ae11ce1..04d9b318d 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -748,7 +748,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
// decompose a single CNetMessage from the TransportDeserializer
CNetMessage msg(std::move(vRecv));
- // store command string, time, and sizes
+ // store message type string, time, and sizes
msg.m_type = hdr.GetCommand();
msg.m_time = time;
msg.m_message_size = hdr.nMessageSize;
@@ -759,7 +759,7 @@ CNetMessage V1TransportDeserializer::GetMessage(const std::chrono::microseconds
// We just received a message off the wire, harvest entropy from the time (and the message checksum)
RandAddEvent(ReadLE32(hash.begin()));
- // Check checksum and header command string
+ // Check checksum and header message type string
if (memcmp(hash.begin(), hdr.pchChecksum, CMessageHeader::CHECKSUM_SIZE) != 0) {
LogPrint(BCLog::NET, "Header error: Wrong checksum (%s, %u bytes), expected %s was %s, peer=%d\n",
SanitizeString(msg.m_type), msg.m_message_size,
diff --git a/src/net.h b/src/net.h
index b1a19bcc4..62d23f6c4 100644
--- a/src/net.h
+++ b/src/net.h
@@ -298,7 +298,7 @@ public:
/** The TransportDeserializer takes care of holding and deserializing the
* network receive buffer. It can deserialize the network buffer into a
- * transport protocol agnostic CNetMessage (command & payload)
+ * transport protocol agnostic CNetMessage (message type & payload)
*/
class TransportDeserializer {
public:
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index cc23876af..3bcf2d1b1 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -4078,8 +4078,8 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
return;
}
- // Ignore unknown commands for extensibility
- LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(msg_type), pfrom.GetId());
+ // Ignore unknown messages types for extensibility
+ LogPrint(BCLog::NET, "Unknown message type \"%s\" from peer=%d\n", SanitizeString(msg_type), pfrom.GetId());
return;
}
(Though changing a log message is not a refactor strictly speaking, so not sure if it's appropriate in this PR.)
Updated from ec50abf to 15eb7b9 (pr24141.04 → pr24141.05, diff) Addressed @theStack comments. Included the suggestions suggested by @theStack here. About the Log message:
But I think changing the log message would be essential to make it consistent with the other changes done in this PR. So I would require other reviewers’ suggestions on this matter, on whether it is better to edit the log message or not. |
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 15eb7b9
About the Log message: I thought about adding it in the 2nd commit, but then I inclined against it for the following reason:
- This will not strictly be a refactoring change
- This changes a file (net_processing.cpp) untouched in this PR.
But I think changing the log message would be essential to make it consistent with the other changes done in this PR. So I would require other reviewers’ suggestions on this matter, on whether it is better to edit the log message or not.
Probably it could be done with another follow-up (final) PR which replaces the remaining occurences of the "message command" terminology in src/protocol.{h,cpp} and src/net_processing.cpp?
Not sure about the scripted diff. It seems a bit bloated and throws errors (https://cirrus-ci.com/task/6681881558122496?logs=lint#L842). Try something like:
|
Concept ACK |
Are you still working on this? #24141 (comment) |
-BEGIN VERIFY SCRIPT- s1() { sed -i "s/$1/$2/g" $(git grep -l "$1" ./); } s1 'NET_MESSAGE_COMMAND_OTHER' 'NET_MESSAGE_TYPE_OTHER' s1 'mapMsgCmdSize' 'mapMsgTypeSize' s1 'mapRecvBytesPerMsgCmd' 'mapRecvBytesPerMsgType' s1 'mapSendBytesPerMsgCmd' 'mapSendBytesPerMsgType' s1 'recvPerMsgCmd' 'recvPerMsgType' s1 'sendPerMsgCmd' 'sendPerMsgType' -END VERIFY SCRIPT-
Updated from pr24141.05 → pr24141.06 Changes:
Thanks, @MarcoFalke, for the script suggestion. Using your suggested script, I resolved the The current and the last version of the PR are identical (see the diff), except for the script used to create those changes, so I think it should be easy to review this update. |
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
src/net.h
Outdated
extern const std::string NET_MESSAGE_COMMAND_OTHER; | ||
typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes | ||
extern const std::string NET_MESSAGE_TYPE_OTHER; | ||
typedef std::map<std::string, uint64_t> mapMsgTypeSize; //message, total bytes |
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: Second commit s/message/message type/
. Or:
typedef std::map<std::string, uint64_t> mapMsgTypeSize; //message, total bytes | |
using mapMsgTypeSize = std::map</* msg type */ std::string, /* total bytes */ uint64_t>; |
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.
Thanks, @MarcoFalke, for taking another look. As per your suggestion, I was able to identify one more place in the second commit where your suggestion could be implemented.
- // to prevent a memory DOS, only allow valid commands
+ // to prevent a memory DOS, only allow valid messages
But I opted against changing the above from messages
to message types
, as that would have decreased the sentence's logical soundness IMO.
Updated from pr24141.06 → pr24141.07 Addressed @MarcoFalke suggestion. Changes:
|
src/net.cpp
Outdated
// Store received bytes per message command | ||
// to prevent a memory DOS, only allow valid commands | ||
// Store received bytes per message type | ||
// to prevent a memory DOS, only allow valid messages |
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 should say "known message types"?
For example, a reject
message might be valid according to BIP 61, but the type is unknown to this version of Bitcoin Core.
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.
Thanks for seeing it. I think you are right. Using "known message types" would be a better wording for this sentence.
Let me address it by updating the second commit.
Approach ACK |
…files Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Update from pr24141.07 → pr24141.08, diff Addressed suggestion by @MarcoFalke Changes:
|
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.
review ACK e71c51b 💥
Show signature
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK e71c51b27d420fbd6cc0a36f62e63e190e13473a 💥
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhJ/Qv+KgTz8htAqBuJ6FnTHQdjyLswJvYHXukDceneF5E72Gifx7MaJw439PKt
MjVpE6s1VCZIliOhSojkNrINaL07pLQu+MoDNSkdOHexfm6xlsDg29nBdba0ocLq
meTNnDW+f+uUibpz+6NxY7Fur8YIpyz+Ney8X0EkOa73F01Dcy9rjAzRZRjCI/gk
X9i7kWzByG7uTzAAvuNxV+F1Kg1qVX2GgMOtxmYj+qpbx2kVCd7YA2pUjYbLeuPL
9/SWmNdYnjFPznUUhby0HcSY0wwZ5urKIhWPgVeXpQgnQJu4WCNYum+ckBIThhor
uS1IkAtylgZfwcEU4m8unW4dUoQkeCFyN8xVSsQztL1TinM3CmzKnsgZq1LkU2El
i1HTy5qxZCybGh2y3R/bUuygFelDw9PZY2Qm/AtvCaf1rsowGAG6Xq0gAsKwON9V
co1M/Qgh9fbizx5PJx3uIWRM3SwD0QEojRkLSikmnwdrc08OA2Eo3zN9kNzfpDaS
CfbI81Qr
=u23E
-----END PGP SIGNATURE-----
… src/rpc/net.cpp e71c51b refactor: rename command -> message type in comments in the src/net* files (Shashwat) 2b09593 scripted-diff: Rename message command to message type (Shashwat) Pull request description: This PR is a follow-up to bitcoin#24078. > a message is not a command, but simply a message of some type The first commit covers the message_command variable name and comments not addressed in the original PR in `src/net*` files. The second commit goes beyond the original `src/net*` limit of bitcoin#24078 and does similar changes in the `src/rpc/net.cpp` file. ACKs for top commit: MarcoFalke: review ACK e71c51b 💥 Tree-SHA512: 24015d132c00f15239e5d3dc7aedae904ae3103a90920bb09e984ff57723402763f697d886322f78e42a0cb46808cb6bc9d4905561dc6ddee9961168f8324b05
This PR is a follow-up to #24078.
The first commit covers the message_command variable name and comments not addressed in the original PR in
src/net*
files.The second commit goes beyond the original
src/net*
limit of #24078 and does similar changes in thesrc/rpc/net.cpp
file.