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

kernel: move RunCommandParseJSON to its own file #26196

Merged
merged 2 commits into from Oct 10, 2022

Conversation

theuni
Copy link
Member

@theuni theuni commented Sep 28, 2022

Because libbitcoinkernel does not include this new object, this has the side-effect of eliminating its unnecessary boost::process dependency.

This leaves libbitcoinkernel with 3 remaining boost dependencies:

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

Concept ACK

src/util/run_command.h Outdated Show resolved Hide resolved
@theuni
Copy link
Member Author

theuni commented Sep 28, 2022

boost::date_time for util/time.cpp, which I'll separate out next. Exactly like this PR.

@fanquake mentioned to me today that he has this done already in a local branch, so I'll leave that to him to PR it at some point.

@fanquake
Copy link
Member

Concept ACK

fanquake mentioned to me today that he has this done already in a local branch, so I'll leave that to him to PR it at some point.

See #26198.

boost::multi_index which I'm not sure about yet.

I have a larger Boost reduction branch, that builds on your signals2 implementation, that might a starting point for this.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 28, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22417 (util/system: Close non-std fds when execing slave processes by luke-jr)

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.

@hebasto
Copy link
Member

hebasto commented Sep 29, 2022

Concept ACK.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK fffbae5 - looks good. Could fixup the header comments if that's wanted. I'm optimistic that Boost Process will "go away" at some point. Removing it from the kernel is an improvement for now.

@theuni
Copy link
Member Author

theuni commented Oct 3, 2022

Force-pushed the requested copyright comment fixup, no other changes.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

re-ACK 98a8ad8

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK 98a8ad8

src/util/run_command.h Outdated Show resolved Hide resolved
src/util/run_command.cpp Outdated Show resolved Hide resolved
src/util/run_command.cpp Outdated Show resolved Hide resolved
@Sjors
Copy link
Member

Sjors commented Oct 4, 2022

ACK 98a8ad8. This certainly sounds like something that doesn't need to be in the kernel.

Given the name of the new file it would make sense to move runCommand over as well. As would moving the tests to their own file. But both can wait.

@theuni
Copy link
Member Author

theuni commented Oct 4, 2022

ACK 98a8ad8. This certainly sounds like something that doesn't need to be in the kernel.

Given the name of the new file it would make sense to move runCommand over as well. As would moving the tests to their own file. But both can wait.

I'd rather not, as we're really trying to separate out the nasty boost dependency here as opposed to the process launching functionality. If anything, I think it'd make more sense to just rename the function/file to be more specific as a follow-up.

Because libbitcoinkernel does not include this new object, this has the
side-effect of eliminating the unnecessary boost::process dependency.
@theuni
Copy link
Member Author

theuni commented Oct 4, 2022

Rearranged the headers as suggested by @hebasto. Would prefer to leave any other fixups to follow-up PRs.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

re-ACK 192325a - failing Windows CI can be ignored. Unrelated to this change.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

re-ACK 192325a

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 192325a, but I think you should consider moving the new file to libbitcoin_common.a instead of libbitcoin_util_a and src/common/ instead of src/util/.

Previously the difference between util and common was more nebulous, but now after talking to Carl and writing https://github.com/bitcoin/bitcoin/blob/master/doc/design/libraries.md, it seems like util can be the library for things included in the kernel which the kernel can depend on, and common can be the library for other code that needs to be shared internally, but should not be part of the kernel or shared externally.

@theuni
Copy link
Member Author

theuni commented Oct 4, 2022

I think you should consider moving the new file to libbitcoin_common.a instead of libbitcoin_util_a and src/common/ instead of src/util/.

I know I said above that I was going to leave this PR as-is, but this makes a lot of sense to me and it may as well be moved to a proper home from the start. So I've added a second commit to move this out of util and into common. Thanks @ryanofsky for the suggestion!

I do agree with @Sjors that maybe the file/function should be renamed and maybe some other functionality should be moved in, but I'd still prefer to discuss that in a follow-up PR as the primary goal here is getting a boost dep out of the kernel.

@theuni
Copy link
Member Author

theuni commented Oct 4, 2022

I believe c-i blew up here because libbitcoin_common.a currently does not get built with BOOST_CPPFLAGS but libbitcoin_util.a does. I'm going to push a test commit to reverse that because of the move here. Hopefully that works as opposed to having to keep it for both libs.

Edit: sigh, this is going to crash and burn because of interfaces/handler.cpp.

Quoting ryanofsky: "util can be the library for things included in the kernel
which the kernel can depend on, and common can be the library for other code
that needs to be shared internally, but should not be part of the kernel or
shared externally."
@theuni
Copy link
Member Author

theuni commented Oct 4, 2022

Mmm, that test-run really should have failed, but the compile failure is hidden because our boost header path is always implicitly included. Another instance of this: #26086 (comment)

I have now begrudgingly made $(BOOST_CPPFLAGS) available to both libs. We can get rid of it for utils when we decide on an approach for nuking boost::signals from there.

I suspect that @ryanofsky will be ok with this but @fanquake will consider it a regression. I'll let you two fight it out :). I'm fine with either:

  • adding the boost flags where needed (done in 2nd commit)
  • dropping the 2nd commit entirely for now

Edit: to be clear, util needs boost for interfaces/handler.cpp and common needs it for common/run_command.cpp.

@ryanofsky
Copy link
Contributor

ryanofsky commented Oct 5, 2022

Edit: to be clear, util needs boost for interfaces/handler.cpp and common needs it for common/run_command.cpp.

That's interesting. I would say interfaces/*.cpp files belong more naturally in libbitcoin_common_a than libbitcoin_util_a anyway, since they aren't general purpose utilities, just bits of common code shared by node/wallet/gui executables. Also they shouldn't be part of the kernel. Maybe it would be easy to build these files as part of the common library instead of util library here, or it could be done as a followup to fully drop the boost dependency from util.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Code review ACK 43b8777. Could consider squashing the two commits, so the code just moves once instead of twice.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK 43b8777

but the compile failure is hidden because our boost header path is always implicitly included. Another instance of this: #26086 (comment)

We'll follow up here (suggested change) very shortly.

I suspect that ryanofsky will be ok with this but fanquake will consider it a regression. I'll let you two fight it out :)

Happy to just move this forward. Things are going in the right direction.

or it could be done as a followup to fully drop the boost dependency from util.

I am happy to follow up with this.

@fanquake fanquake merged commit 866dd66 into bitcoin:master Oct 10, 2022
#include <config/bitcoin-config.h>
#endif

#include <common/run_command.h>
Copy link
Member

Choose a reason for hiding this comment

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

pico-nit: Shouldn't this be in the very first line after the comment?

Copy link
Member

Choose a reason for hiding this comment

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

I'll look at the follow up for moving more code, and could address as part of that.

@fanquake
Copy link
Member

I am happy to follow up with this.

This is now #26293.

We'll follow up here (suggested change) very shortly.

After a second look, the remaining change in that branch is (as self-described) a hack, and I somehow forgot I'd already removed BOOST_CPPFLAGS from the BITCOIN_INCLUDES, so less to actually follow up on here.

@bitcoin bitcoin locked and limited conversation to collaborators Oct 11, 2023
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.

None yet

7 participants