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

RPC: Switch getblockfrompeer back to standard param names blockhash and nodeid #24294

Closed
wants to merge 1 commit into from

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Feb 9, 2022

#23706 changed the param names to block_hash and peer_id, which in a vacuum seems fine.

But this new method is the only place we refer to them by these names. Many other places (including every RPC param) use blockhash already, and the one other RPC usage has nodeid (and there are no other cases where it is called a "peer ID").

For this reason, I think we should keep to the standard param names for now.

This commit partially reverts 923312f.

Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

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

ACK f5e0087

I agree with @luke-jr. I checked that throughout the src/rpc folder and src/rpc/wallet folder, wherever block_hash is used, it is used as a function variable and not as an RPC argument. For the RPC arguments, blockhash is used.
The same goes for peer_id. peer_id is used for function variable, and nodeid is used as RPC argument.

So I think it makes sense to keep RPC argument naming consistent with other RPC functions.

@Sjors, I would like to hear what you think about this?

@Sjors
Copy link
Member

Sjors commented Feb 9, 2022

No strong preference.

There's something to be said for moving towards more consistent argument naming whenever a new RPC method or argument is introduced.

However, it also seems unlikely that we'll change the argument names in ancient RPC calls like getblock, which means it may remain inconsistent for a long time.

blockhash and nodeid are easier to type, which is nice.

I don't remember if somebody suggested the rename, or if I did it to be consistent with variable names.

I'd also like to know @jnewbery, @MarcoFalke and @jonatack's take.

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.

weak nack, but I don't really care either way

{"block_hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash to try to fetch"},
{"peer_id", RPCArg::Type::NUM, RPCArg::Optional::NO, "The peer to fetch it from (see getpeerinfo for peer IDs)"},
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash to try to fetch"},
{"nodeid", RPCArg::Type::NUM, RPCArg::Optional::NO, "The peer to fetch it from (see getpeerinfo for node IDs)"},
Copy link
Member

Choose a reason for hiding this comment

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

I might be missing something, but the other, existing, RPC is called getpeerinfo and not getnodeinfo. Also, the result is called "peer index".

getpeerinfo ... Result:
[                                         (json array)
  {                                       (json object)
    "id" : n,                             (numeric) Peer index

@ajtowns
Copy link
Contributor

ajtowns commented Feb 9, 2022

Concept ACK

nodeid is an existing param name for disconnectpeer.

@jonatack
Copy link
Contributor

jonatack commented Feb 9, 2022

The word "peer" is used throughout the getblockfrompeer help, so if this is changed, the help ought to be updated to be consistent (as well as the RPC to "getblockfromnode"), as well as the developer notes' RPC interface guidelines, which since c26655e in 2017 state that snake case should be used for argument naming. ISTM that internal consistency within a call outweighs how legacy arguments are named in other calls; otherwise, the bar for applying the developer note guideline seems overly high. Also, "peer" is a more precise term, as a peer is a node that is not ours. Tend to NACK the current version of this pull for these reasons.

@Sjors
Copy link
Member

Sjors commented Feb 9, 2022

So we already have references to both "peer" (getpeerinfo, disconnectpeer command name) and "node" (disconnectpeer argument name) in existing RPC calls. I find "peer" more clear, so it makes sense to me to favor that in new methods.

So I'm inclined to NACK the nodeid part of this.

Also, "peer" is a more precise term, as a peer is a node that is not ours.

Also in the context of lightning, nodes have an identifier, which is the same wether or not you're connected to them. Bitcoin nodes don't have such an identity, but "node id" might still be confused to refer to such an identity.

@maflcko
Copy link
Member

maflcko commented Feb 9, 2022

At this point it might be a smaller diff (and better) to change the docs (not the args, though) to s/node/peer/g instead of a global s/peer/node/g?

@luke-jr
Copy link
Member Author

luke-jr commented Feb 9, 2022

Usage of "peer" doesn't necessarily contradict "nodeid" - clearly a peer can have a nodeid, and this concept is expressed in disconnectpeer.

That being said, I suppose with only one other method using nodeid, it wouldn't be too bad to silently deprecate it and change it to peer_id instead...

@ajtowns
Copy link
Contributor

ajtowns commented Mar 10, 2022

Is this worth keeping open if it's not making it into 23.0?

@laanwj laanwj added this to Blockers in High-priority for review Mar 31, 2022
@laanwj laanwj removed this from Blockers in High-priority for review Mar 31, 2022
@laanwj laanwj added this to the 23.0 milestone Mar 31, 2022
@maflcko
Copy link
Member

maflcko commented Apr 8, 2022

Closing for now, given that this appears to be controversial and doesn't justify holding back the 23.0 release process at this point.

If the changes here are a goal going forward, it would be better to bind the name to the type and introduce finer-grained RPC arg/result types. This way everything will be enforced by the compiler and we don't need to waste review on it.

@maflcko
Copy link
Member

maflcko commented Apr 8, 2022

Looks like this was partially picked up in #24806 again, but overall I think this is low-priority for this experimental RPC that should be used for testing only. Especially given the underdocumentation of it, see #24226 (comment)

fanquake added a commit that referenced this pull request Apr 8, 2022
…e blockhash

88917f9 RPC: Switch getblockfrompeer back to standard param name blockhash (Luke Dashjr)

Pull request description:

  This commit partially reverts 923312f.

  Portion of #24294.

ACKs for top commit:
  MarcoFalke:
    review ACK 88917f9
  ajtowns:
    ACK 88917f9
  jonatack:
    Review-and-grep-only ACK 88917f9

Tree-SHA512: e42497ea6162623e449c5e60b83a5abbef568f226edc022aa14bbc1f1921618255d593968cf43f7a6d2c0bfd84cdd4b05fbce5c724759b20035e6eead758d443
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Apr 8, 2022
…ram name blockhash

88917f9 RPC: Switch getblockfrompeer back to standard param name blockhash (Luke Dashjr)

Pull request description:

  This commit partially reverts 923312f.

  Portion of bitcoin#24294.

ACKs for top commit:
  MarcoFalke:
    review ACK 88917f9
  ajtowns:
    ACK 88917f9
  jonatack:
    Review-and-grep-only ACK 88917f9

Tree-SHA512: e42497ea6162623e449c5e60b83a5abbef568f226edc022aa14bbc1f1921618255d593968cf43f7a6d2c0bfd84cdd4b05fbce5c724759b20035e6eead758d443
@bitcoin bitcoin locked and limited conversation to collaborators Apr 8, 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

8 participants