-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Move message processing to new 'procmsg' module. #4646
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
Compiles and passes tests. Could use some refinement.
Code was left indented for diff-reading purposes in previous commit.
Updated such that each message is a method. It is recommended to review each commit rather than the sum of all commits, as this patch series follows the "equivalent transformation" method of refactoring code into a more useful form. This should be suitable for updating to use signals or similar (possibly moving back outside of the class if necessary). |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4646_aa9ad2895e32dcaedba5e1511f5edead4664c029/ for binaries and test log. |
Oh, yes, please! |
Idea ACK, but this code is pretty much in flux still (askfor/headersfirst/sendmessages/...); I'd propose to delay this until close to the next major release. |
After headersfirst has been merged, can we reopen this? |
No objection against just moving things like this, but things like #4831 conflict probably with less, and actually go further, as it actually splits processing up completely, rather than just moving it as a whole. |
Things like ping/pong handling and alert handling can probably be split off in a way similar to #4831. |
@@ -17,6 +17,7 @@ | |||
#include "txmempool.h" | |||
#include "ui_interface.h" | |||
#include "util.h" | |||
#include "procmsg.h" |
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: Alphabetical ordering.
Suggestion: Why not let the clang-script fix coding style for this? |
I really like how jgarzik@78edf5c (Split up P2P message processing into MessageEngine methods) improves the readability of the p2p messages. |
I felt that this was a good step towards the direction we want to go longer term, which is registering processing methods (signals/hooks), so that the message processing implementation is more de-coupled from network message dispatch. It sounded like @sipa did not like this as an intermediate step, though. |
I would absolutely be in favor of this as intermediate step if not for the review overhead and the fact that it will break existing pull requests that already go further. Afterwards I think we can definitely do this for the non-trivial pieces after the trivial ones have been moved out. |
Needs rebase... |
Closing. I still think this is worth merging and @jtimon seems to agree. However it has not gained sufficient momentum to get merged for whatever reason. As usual, it is easy to re-open a PR if this turns out to be in error, ACKs suddenly appear, etc. Applying the "close old PRs, easy to reopen" pattern. This code movement change is too large to continue rebasing if it is not getting merged. |
I really think this kind of PR opens the door to many modularity improvements. And I understand that code movements are a burden to reviewers because they need to keep up to date with them after they're merged. This is a very big move on main.cpp that everybody is touching. I really think we should break both EvalScript and ProcessMessage with an identical-build single commit. With an identical build you don't even need any tested ACK, utACKS should be enough. |
@jtimon I agree. It is however difficult to produce identical hashes due to minor compiler build differences such as the ones that sipa mentions. You could probably perform some #include tricks to accomplish the first file movement step with equivalent hashes, if you keep ProcessMessage() intact. Once the individual code blocks move to their own functions/methods, the hashes will unavoidably differ. A line-by-line source code comparison tool would be better than a hash check. |
I have nothing against changes like this, except I think that:
1) The resulting temporary state is worse than the start due to circular
dependencies (you don't claim it is, but:)
2) It does not help anything towards achieving the IMHO correct solution,
which is separate handler modules, like @laanwj's inv/ask transaction
handling. In fact, it interferes with it.
I would like to see moving bits of processing out to well-encapsulated
handler modules, and would have expected such changes to have happened by
now.
|
I was talking about doing the equivalent to that commit without moving anything first.
Shouldn't
We already have that with git. And by not correcting the indentation at first, the commit can be very readable (specially if the new class is not introduced). But the identical hash eliminates the need for testing, which is nice. @sipa would you oppose to just doing the function separation in main.cpp ? That wouldn't create any circular dependencies and I believe it would help with the later modularization that you want (apart from making ProcessMessage much, much, much more readable [I don't use eclipse anymore but I believe some checkstyle plugins can segfault just by trying to analyze this function {if you first disable the typical "too long function" check, obviously}</bad joke>]). |
I'm talking about something along this lines: bitcoin:master...jtimon:process-message-0.12.99 EDIT: |
No problem with splitting up processing.
|
@sipa Great, I will eventually open what I started there then, although I believe it would be good to make more things like #6163 first, so that we don't have to work more later (having to add more parameters to the new functions). Thoughts on the identical build? Could d8e5ff4 theoretically produce an identical build? Is it worth it (given that you need a previous commit at least for the return trues)? |
I think that for refactors like this, you shouldn't aim for identical builds. The only way to achieve that is by forcing the compiler to inline things, which for such large blocks of code is probably a bad idea. |
Thanks, @sipa that's useful. But I don't see why inlining all those new static functions is a bad idea. First, it is no worse than what we currently have, and second, the inline can be removed in a fixup! commit (to be squashed together after "testing", just like the preparation commit). In any case, maybe is still not worth it, but what about doing something similar in consensus code, more concretely in EvalScript? To remind you, #5153 was considered too risky (#5153 (comment)). |
@jtimon I mean forcing the compiler to inline things - just putting the 'inline' keyword may not be enough for that (it may need compiler flags, for example), and even then, the order in the binary may end up being different. Just saying that IMHO that's not a good use of your time, but if you think you can make the build identical, so much the better. I'm much less concerned about changes here than in script evaluation, as getting some state/variables/processing wrong in message handling should result in immediate failure (some messages not being processed), in script evaluation it could lead to very subtle differences. |
Basically the inlining doesn't produce any value. It doesn't generate identical hashes. Might as well make them separate functions/methods. |
Thank you very much both of you: this is very helpful. But, as said, I would like to see more of those |
Compiles and passes tests. Could use some refinement.