-
Notifications
You must be signed in to change notification settings - Fork 261
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
Parse params directly instead of through node (partial revert #10244) #35
Conversation
Concept ACK. The reasoning as explained in the commit message makes sense to me. Maybe a better PR title would be "Parse params directly instead of through node (partial revert #10244)". And then in the PR description: "In addition to spawning a new bitcoin-node process, we want bitcoin-gui to connect to an existing bitcoin-node proces. So for that reason it should be able to parse its own parameters, rather than rely on the node." |
return; | ||
} | ||
if (!m_node.softSetArg("-prune", prune_val)) { | ||
if (!gArgs.SoftSetArg("-prune", prune_val)) { |
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.
Can't this use this->node().context()->args
instead of the global, which should be gone hopefully 🔜 ?
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.
re: #35 (comment)
Can't this use
this->node().context()->args
instead of the global, which should be gone hopefully 🔜 ?
After bitcoin/bitcoin#10102, there is no NodeContext in the gui process. An ArgsManager reference could be passed to OptionsModel if desired, though.
I'll try to describe the desired behavior as I understand it. When a In variant (a) the In variant (b) the existing Did I understand the concept correct? How the possible conflicts between different process parsed arguments should be resolved? |
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.
Updated 5adf00e -> 49b993d (pr/ipc-guiarg.1
-> pr/ipc-guiarg.2
, compare) with test simplification suggested by Marco, and 3 more commits pulled from bitcoin/bitcoin#19461
re: Sjors #35 (comment)
Maybe a better PR title [...]
Thanks! Used your title and description.
re: hebasto #35 (comment)
I'll try to describe the desired behavior as I understand it. [...]
Yes that's a good description of bitcoin/bitcoin#19461.
How the possible conflicts between different process parsed arguments should be resolved?
This PR doesn't actually change how arguments are interpreted, it just allows them to be sent differently in bitcoin/bitcoin#19461. Like you described above, in that PR if the gui process spawns a new node process, it forwards the arguments and there are no conflicts. But as mentioned in the PR description for bitcoin/bitcoin#19461 "there are rough edges" in that PR and "if node command line options are passed to bitcoin-gui and bitcoin-gui connects to an exiting bitcoin-node process instead of spawning a new one, the node options will be silently ignored." More ideally, passing mismatched node options to bitcoin-gui would trigger errors or warnings. Adding this error checking could be a new commit in bitcoin/bitcoin#19461 or a followup PR.
return; | ||
} | ||
if (!m_node.softSetArg("-prune", prune_val)) { | ||
if (!gArgs.SoftSetArg("-prune", prune_val)) { |
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.
re: #35 (comment)
Can't this use
this->node().context()->args
instead of the global, which should be gone hopefully 🔜 ?
After bitcoin/bitcoin#10102, there is no NodeContext in the gui process. An ArgsManager reference could be passed to OptionsModel if desired, though.
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.
Not passing an |
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 49b993d, tested on Linux Mint 20 (x86_64, Qt 5.12.8).
49b993d
I think the m_shutdown
member should be dropped due to the following reasons:
- currently, the
SplashScreen::shutdown()
could be called only after entering to the main event loop, i.e., after the firstapp.exec()
call; therefore,SplashScreen::setNode()
will always see the initial value of them_shutdown
- if in the future more complicated behavior will be introduced,
SplashScreen::setNode()
andSplashScreen::shutdown()
are potentially data-racy, and them_shutdown
member could require be protected by a mutex
nano-nit: why not apply clang-format-diff.py
for each commit?
Thanks for reviewing! I looked into many things but wound up not making changes for reasons described below. re: #35 (comment)
I don't think this follows. It's ok for functions to have preconditions, and this is a pretty straightforward precondition to have for an accessor returning a reference.
We might just have a style disagreement here, but if there are specific changes you are looking for, maybe you could post them or describe them in more detail. I don't think we need to have pointers and null checks in places where the pointers can never be null. There's only one place in the PR that actually needs to check for a null node: the splash screen code handling the Q keypress needs to check if the node is connected before sending it a shutdown request. Everywhere else, references and not pointers are more appropriate and have been retained. re: #35 (review)
m_shutdown is needed so the splash screen can be shown instantly without waiting for anything and the Q key can function requesting a shutdown as soon as possible. Maybe this change could be moved to bitcoin/bitcoin#19461, but you could also say the same about all other changes in this PR. I hope the cleanups in this PR make sense by themselves, but the actual motivation for this PR is to enable bitcoin/bitcoin#19461.
A mutex would only be required if Qt signals are used incorrectly. GUI state should be accessed by one thread.
I read diffs to understand changes and having unrelated formatting changes mixed into commits makes this harder. |
I understand this motivation. But the splash screen is not derived from Line 604 in 49b993d
|
What is this comment referring to and what is it asking for? I think we both agree handling a null pointer in the splashscreen is not strictly needed here. It's needed to handle the delayed gui->node connection implemented in bitcoin/bitcoin#19461. The point of all the changes in this PR is to reduce size and complexity of bitcoin/bitcoin#19461. I think it makes sense to handle null node pointer in the splash screen here in this PR which is first introducing the pointer variable, even though the variable won't have a null value until bitcoin/bitcoin#19461. |
Concept ACK. |
Concept ACK |
@ryanofsky Mind rebasing? (no DrahtBot's notifications in this repo for now) |
49b993d
to
1a0875f
Compare
Rebased 49b993d -> 1a0875f ( |
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.
1a0875f
to
37b7eba
Compare
Rebased 1a0875f -> 37b7eba ( |
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.
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.
crACK 333507a 🦌
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
crACK 333507a1f3 🦌
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgqNQv7BdH9+5Rmi/cztRlIzz//JI94OOHZY3r2lQ6GovtiSTstsj4eeGarqfNL
v5JOwpXU5NXyJ62BevybdeOwukJTsycj+N8ozCs8HP8ts6H4ji+DA0jpEQA8HBH3
vuLwZI2cV4UrYSebBAJsQZxEpsHqX+eFEhgxUUoZypSgGNDt6A4SuXOKBeT5uU+v
aWjPs5sfsuCiFrMC7opq9/9rIzGNEAnf4zla748NLhbKof+W3HdH5+i1dPSf4tNl
pKdlnt0AoJfuRTlior37qPftEWazXypvupxRnMZ92YRRD+qVrgiTn6c2K6+SvH0G
IhY1//3dYqzPczpR8aAv9igOL1iN2svjrdxm8fPFIU5/feKi92al5RqeXFBUtGLs
ZzJ3XY3paOnMm0A1Zy790TXyOc07Trxu/c3Xe90vR6DKqUoqvKj/443uMLxlMZdj
OCEbjVJJ5jXCadwdQtQmA9uceNj22Hep9AfSdvExflPRq8gq7Q5PzdB5SaNh7VBE
rb2JCP5V
=OHa6
-----END PGP SIGNATURE-----
Timestamp of file with hash 726f1597cbef5b840b8b43b9a0c4aada8e06894a7a3803c798f9d71e3ef4d656 -
src/interfaces/node.h
Outdated
//! needs to be called after selectParams() because the settings file | ||
//! location is network-specific. | ||
virtual bool initSettings(std::string& error) = 0; | ||
|
||
//! Get the (assumed) blockchain size. | ||
virtual uint64_t getAssumedBlockchainSize() = 0; |
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.
in commit 427c8da
why is this not removed?
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.
src/qt/bitcoin.cpp
Outdated
@@ -457,11 +460,11 @@ int GuiMain(int argc, char* argv[]) | |||
|
|||
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these | |||
// Command-line options take precedence: | |||
node->setupServerArgs(); | |||
SetupServerArgs(*node->context()); |
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.
commit 427c8da: The documentation for context() says "Useful for testing". Did you mean to write node_context
instead?
SetupServerArgs(*node->context()); | |
SetupServerArgs(node_context); |
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.
re: https://github.com/bitcoin-core/gui/pull/35/files#r471397426
commit 427c8da: The documentation for context() says "Useful for testing". Did you mean to write
node_context
instead?
Changed, agree this is a little better. SetupServerArgs should really not be using NodeContext at all (argument is removed in bitcoin/bitcoin#10102), but for this PR which is not in the GUI repository, I wanted to avoid changing non-gui code.
333507a
to
3ae9b4a
Compare
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 review!
Updated 333507a -> 3ae9b4a (pr/ipc-guiarg.5
-> pr/ipc-guiarg.6
, compare) with suggestions
src/interfaces/node.h
Outdated
//! needs to be called after selectParams() because the settings file | ||
//! location is network-specific. | ||
virtual bool initSettings(std::string& error) = 0; | ||
|
||
//! Get the (assumed) blockchain size. | ||
virtual uint64_t getAssumedBlockchainSize() = 0; |
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.
src/qt/bitcoin.cpp
Outdated
@@ -457,11 +460,11 @@ int GuiMain(int argc, char* argv[]) | |||
|
|||
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these | |||
// Command-line options take precedence: | |||
node->setupServerArgs(); | |||
SetupServerArgs(*node->context()); |
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.
re: https://github.com/bitcoin-core/gui/pull/35/files#r471397426
commit 427c8da: The documentation for context() says "Useful for testing". Did you mean to write
node_context
instead?
Changed, agree this is a little better. SetupServerArgs should really not be using NodeContext at all (argument is removed in bitcoin/bitcoin#10102), but for this PR which is not in the GUI repository, I wanted to avoid changing non-gui code.
re-run ci |
Change gui code to use gArgs, Params() functions directly instead of going through interfaces::Node. Remotely accessing bitcoin-node ArgsManager from bitcoin-gui works fine in bitcoin/bitcoin#10102, when bitcoin-gui spawns a new bitcoin-node process and controls its startup, but for bitcoin-gui to support -ipcconnect option in bitcoin/bitcoin#19461 and connect to an existing bitcoin-node process, it needs ability to parse arguments itself before connecting out. This change also simplifies bitcoin/bitcoin#10102 a bit, by making the bitcoin-gui -> bitcoin-node startup sequence more similar to the bitcoin-node -> bitcoin-wallet startup sequence where the parent process parses arguments and passes them to the child process instead of the parent process using the child process to parse arguments.
Remove Node references no longer needed after previous commit
No change in behavior. Replacing references with pointers allows Node interface creation to be delayed until later during gui startup next commit to support implementing -ipcconnect option
This is needed to allow bitcoin-gui to connect to existing node process with -ipcconnect instead of spawning a new process. It's possible to spawn a new bitcoin-node process without knowing the current data dir or network, but connecting to an existing bitcoin-node requires knowing the datadir and network first.
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.
will re-review after rebase
|
||
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these | ||
// Command-line options take precedence: | ||
node->setupServerArgs(); | ||
SetupServerArgs(node_context); |
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: Could add an unused reference to the argsmanager that is supposed to be used by gui code (instead of the global).
Would either be const ArgsManager& args = *node_context.args
or = gArgs
?
Feel free to ingore.
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.
re: #35 (comment)
nit: Could add an unused reference to the argsmanager that is supposed to be used by gui code (instead of the global).
I started implementing this but stopped because there are a number of other uses of gArgs in this function that I thought it would be better not to change here to avoid increasing the size of the PR.
Bigger picture, gArgs is used pretty widely in many parts of qt code and I think that if it's going to be removed, it'd be best to do it in a focused PR updating all the references at the same time.
SetupUIArgs(gArgs); | ||
std::string error; | ||
if (!node->parseParameters(argc, argv, error)) { | ||
node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error)); | ||
if (!gArgs.ParseParameters(argc, argv, error)) { |
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: (if feedback is addressed)
Could use
if (!gArgs.ParseParameters(argc, argv, error)) { | |
if (!args.ParseParameters(argc, argv, error)) { |
here?
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 pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
3ae9b4a
to
519cae8
Compare
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 review
Rebased 3ae9b4a -> 519cae8 (pr/ipc-guiarg.6
-> pr/ipc-guiarg.7
, compare) due to conflict with bitcoin/bitcoin#19779
|
||
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these | ||
// Command-line options take precedence: | ||
node->setupServerArgs(); | ||
SetupServerArgs(node_context); |
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.
re: #35 (comment)
nit: Could add an unused reference to the argsmanager that is supposed to be used by gui code (instead of the global).
I started implementing this but stopped because there are a number of other uses of gArgs in this function that I thought it would be better not to change here to avoid increasing the size of the PR.
Bigger picture, gArgs is used pretty widely in many parts of qt code and I think that if it's going to be removed, it'd be best to do it in a focused PR updating all the references at the same time.
SetupUIArgs(gArgs); | ||
std::string error; | ||
if (!node->parseParameters(argc, argv, error)) { | ||
node->initError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error)); | ||
if (!gArgs.ParseParameters(argc, argv, error)) { |
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.
re-ACK 519cae8, only change is rebase and addressed nits of my previous review last week 🌄 Show signature and timestampSignature:
Timestamp of file with hash |
This PR is part of the process separation project.
This is a partial revert of bitcoin/bitcoin#10244. It changes gui code to go back to using gArgs and Params() functions directly instead of using interfaces::Node to handle arguments.
These changes were originally pushed as part of bitcoin/bitcoin#19461. Motivation is to support a new GUI process connecting to an already running node process. Details are explained in commit messages, but in addition to spawning a new bitcoin-node process, we want bitcoin-gui to connect to an existing bitcoin-node process. So for that reason it should be able to parse its own parameters, rather than rely on the node.