-
Notifications
You must be signed in to change notification settings - Fork 36.6k
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
rpc: query general daemon information via RPC #17958
Conversation
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.
Thank you for implementing this @brakmic, left a few comments!
obj.pushKV("startuptime", FormatISO8601DateTime(GetStartupTime())); | ||
return obj; | ||
|
||
} |
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.
Is it better to move this function to server.cpp
since that file contains the majority of control
commands, like getrpcinfo
and uptime
?
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 could move them there. Actually, I put them in misc.cpp because I wasn't sure where to put it best. Maybe we should wait for additional input from others before changing the current variant?
src/rpc/misc.cpp
Outdated
" \"useragent\":\"client name\", (string) Client name\n" | ||
" \"datadir\":\"datadir path\", (string) Data directory path\n" | ||
" \"blocksdir\":\"blocksdir path\", (string) Blocks directory path\n" | ||
" \"startuptime\":\"string\", (string) Startup time\n" |
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.
uptime
in server.cpp
returns type int64_t
. I think for consistency it would be better for startuptime
to return the same thing. The consumer of the timestamp can choose how to format 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.
Well, the GUI shows a properly formatted / localized time. Returning a numeric value would maybe collide with user expectations? Or we could simply return two values (raw number and localized one). In any case, this should not be a big problem. Let's wait for more input, shall we? :)
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.
-0.1 on adding this. I'm not sure what the use case is; there are already calls like bitcoin-cli -version
and bitcoin-cli -getinfo
, and unless I'm missing something the user knows any custom dir settings either from having set them in the .conf file or from passing them as startup option args. Perhaps as additions to -getinfo, if really desired? See also #17314.
Edit: I didn't understand the motivation on first review.
If there is any problem with this PR I will close it, no problem. I simply had some free time, so I thought, let's implement one of the requests that aren't that complex for me ;) |
I understand better now what the use case is after @msafi's explanation. |
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. |
Why isn't the BerkeleyDB version included? |
Because it wasn't asked for in the feature request. |
If we display the GUI stuff in text form we should display it all including the BDB version |
No problem, this can be included. However, first we should wait for more reviews. |
"""Check if 'getgeneralinfo' is callable.""" | ||
try_rpc(None, None, self.nodes[0].getgeneralinfo, None, None) | ||
"""Check if 'getgeneralinfo' is idempotent (multiple requests return same data).""" | ||
json1 = self.nodes[0].getgeneralinfo() |
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.
Why not put this into a tuple
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 don't understand the context. However, I am not that experienced in python so it could be that my code is not following best-practices.
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.
As a general thought, I'd humbly suggest spending time looking at existing tests here, reviewing, practising writing PRs without opening them, and polishing PRs more before adding them to the stack of open PRs to review. Maybe I'm doing this wrong, but I have dozens of finished commits that I've written locally without opening PRs to (a) to learn the codebase, and (b) to maintain a ratio of 5-15 PRs reviewed or issues tested per PR opened, as the number of open issues and PRs keeps growing and review/testing is where resources are needed.
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.
Well, the best way to learn something is by doing it. Reading docs is fine, sure, but in the end you have to "say something" so others can hear you (and give you a proper critique). Docs don't correct you if you get something wrong. Anyway, I think it's best to close this PR, just to make the PR-mountain a bit smaller. This RPC call isn't that important anyway, I think.
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 have a lot to learn but these two articles based on the past ten months might be helpful:
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.
@jonatack Is this PR really that bad? I spent a few weeks looking at the codebase and tests and I would have raised a similar PR.
Will read the articles, thanks!
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.
@jonatack Is this PR really that bad? I spent a few weeks looking at the codebase and tests and I would have raised a similar PR.
Well, we all do. I think the best way for you to answer your question is to review a few dozen of the open PRs. Here are the high-priority ones that really need review: https://github.com/bitcoin/bitcoin/projects/8
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.
How is this different from the existing RPCs uptime
and getnetworkinfo
?
@MarcoFalke But the following data is missing from
|
It is in
What would the use case be?
This should go in |
Why is it included in the GUI then? IMO everything which accessible through the GUI should be accessible through the RPC interface as well. Why even bother about a concept that is already implemented in some way? |
Sure, it's a large, legacy codebase and there are inconsistencies. Meanwhile, is a regression or CVE getting past review somewhere? WRT external wallets using the RPC interface, I agree more feedback on the use cases may be helpful. |
@MarcoFalke The use-case is to build a GUI that works fully through RPC. Jonas Schnelli said this:
I'm working on such a GUI. But regardless of what I'm working on, if there's a desire to rearchitect the Bitcoin Core GUI to work through RPC then we need to make changes like what's in this PR. Does this help explain the use case? The other case that can be made for this type of change is what @emilengler said: if you make some information available on the GUI, why not also make it available through RPC? |
General Concept ACK. I think it can be useful to get the If there is a use case for the BDB version info (is there?), it should (must?!) probably be under |
Because the BDB version is available on the GUI and it's easy to add, I think it should be included. I think it might help avoid subjectivity and decision fatigue if we were to establish some general criteria/guidelines for what is allowed to be added to RPC. |
The GUI isn't perfect and a pure 1:1 replication through the RPC API is maybe not the best approach. I would rather think about possible use cases why someone would want to know the Berkley-DB version (wallet file incompatibility?).
I guess the answer is: "it depends". IMO additional information through RPC should solve a real use case (which I can see for a remote RPC GUI for blocksdir/datadir/version-build-number). |
I agree. If I had to give a general guideline as an exercise, I'd say, in roughly decreasing order of priority: fixing bugs, improving security/test coverage, addressing real use cases, doing nothing or doing less/removing code, doing more/adding code. |
@msafi In my opinion, even though it may have happened in the past, the bar for adding a new RPC to New RPCs come with maintenance and and backwards-compatibility overheads, and once added, can be near impossible to modify/remove, which can hinder lower level, higher priority refactoring efforts. See the history of
As has already been mentioned, it doesn't make much sense for us to add any information to a new RPC that can already be derived from an existing one (or any other way), so if this is going to be added, lets make sure we're not duplicating anything. It's also been mentioned that some of the information might be better suited to an existing RPC, rather than adding a new one, I also agree with this. i.e the bdb version going in More generally, if you're interested in the modularization of Bitcoin Core (which is a step towards implementing alternative GUIs), and what work is being done on that front, I'd suggest looking at the Process Separation Project, if you haven't already; along with PRs like #10102. |
Agree with @fanquake. @msafi my suggestion is to keep working on the gui-over-rpc and skip this detail. With that you'll be in a better position to request these changes.
@emilengler it's a different case, the GUI is the node. |
The question was not what's the node. I was more referring to the way how the/a node can be accessed (RPC, GUI) |
Right, either you access a remote node or the local node. The existing GUI is to access the local node, and in that case makes sense to see the datadir. But for remote access, the datadir is not that relevant, or is it? |
I agree. That's how it should be. That's why I didn't want this feature request to be about my project because in that case it's not worth the overhead for Bitcoin Core. But my being the only one to request it doesn't mean I'm the only one wanting it. That's why I agree with the thinking that any information on the GUI should be available through RPC (with some caveats, like has been mentioned).
I wanted make a complete end-user release of Orange with just the node syncing feature. Then build incrementally. The Anyways, while I still think it would be useful to bring the RPC interface closer to the GUI, I understand the concerns around priority, urgency, and resources. So I'll accept whatever is decided here. With regard to my project, something will be figured out eventually... |
It is. The RPC interface is also used by the admins with bitcoin-cli who might wanna know where it is located |
Needs rebase |
Going to close this for now. Maybe we can revisit it in the future. |
Github-Pull: bitcoin#17958 Rebased-From: cdbd38d
This PR implements a new feature requested in #17952
A new call getgeneralinfo is now available for sending general daemon information back to clients. Currently, this data is only available via GUI (debug window / information tab).
The RPC execution looks like this:
bitcoin-cli -regtest getgeneralinfo
bitcoin-cli -regtest help getgeneralinfo
However, I am not sure if the current format in "startuptime" field is acceptable. Maybe there is a better function that should be used? Currently I am using the FormatISO8601DateTime function.
Test
A new functional test rpc_getgeneralinfo.py is available.
Regards,