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

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:getblockfrompeer_param_names changing 2 files +4 −4
  1. luke-jr commented at 1:15 am on February 9, 2022: member

    #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 923312fbf6a89efde1739da0b7209694d4f892ba.

  2. RPC: Switch getblockfrompeer back to standard param names blockhash and nodeid
    This commit partially reverts 923312fbf6a89efde1739da0b7209694d4f892ba.
    f5e008774b
  3. DrahtBot added the label RPC/REST/ZMQ on Feb 9, 2022
  4. shaavan approved
  5. shaavan commented at 9:38 am on February 9, 2022: contributor

    ACK f5e008774b5d6070fc661f37b9368dc3729bfb67

    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?

  6. Sjors commented at 9:50 am on February 9, 2022: member

    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.

  7. in src/rpc/blockchain.cpp:788 in f5e008774b
    783@@ -784,8 +784,8 @@ static RPCHelpMan getblockfrompeer()
    784         "Subsequent calls for the same block and a new peer will cause the response from the previous peer to be ignored.\n"
    785         "\nReturns an empty JSON object if the request was successfully scheduled.",
    786         {
    787-            {"block_hash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash to try to fetch"},
    788-            {"peer_id", RPCArg::Type::NUM, RPCArg::Optional::NO, "The peer to fetch it from (see getpeerinfo for peer IDs)"},
    789+            {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The block hash to try to fetch"},
    790+            {"nodeid", RPCArg::Type::NUM, RPCArg::Optional::NO, "The peer to fetch it from (see getpeerinfo for node IDs)"},
    


    MarcoFalke commented at 10:00 am on February 9, 2022:

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

    0getpeerinfo ... Result:
    1[                                         (json array)
    2  {                                       (json object)
    3    "id" : n,                             (numeric) Peer index
    
  8. MarcoFalke commented at 10:02 am on February 9, 2022: member
    weak nack, but I don’t really care either way
  9. ajtowns commented at 1:15 pm on February 9, 2022: member

    Concept ACK

    nodeid is an existing param name for disconnectpeer.

  10. jonatack commented at 2:03 pm on February 9, 2022: member
    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 c26655ed3f102a 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.
  11. Sjors commented at 2:27 pm on February 9, 2022: member

    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.

  12. MarcoFalke commented at 4:14 pm on February 9, 2022: member
    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?
  13. luke-jr commented at 5:50 pm on February 9, 2022: member

    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…

  14. ajtowns commented at 8:16 am on March 10, 2022: member
    Is this worth keeping open if it’s not making it into 23.0?
  15. laanwj added this to the "Blockers" column in a project

  16. laanwj removed this from the "Blockers" column in a project

  17. laanwj added this to the milestone 23.0 on Mar 31, 2022
  18. laanwj added the label Needs backport (23.x) on Mar 31, 2022
  19. MarcoFalke commented at 12:04 pm on April 8, 2022: member

    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.

  20. MarcoFalke closed this on Apr 8, 2022

  21. MarcoFalke commented at 12:31 pm on April 8, 2022: member
    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 (review)
  22. fanquake referenced this in commit e0680bbce8 on Apr 8, 2022
  23. sidhujag referenced this in commit 38e8abff86 on Apr 8, 2022
  24. MarcoFalke removed the label Needs backport (23.x) on Apr 8, 2022
  25. DrahtBot locked this on Apr 8, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-23 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me