-
Notifications
You must be signed in to change notification settings - Fork 37k
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
doc: add guidance for RPC to developer notes #30142
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30142. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
|
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
doc/developer-notes.md
Outdated
@@ -1449,6 +1449,16 @@ A few guidelines for introducing and reviewing new RPC interfaces: | |||
- *Rationale*: JSON strings are Unicode strings, not byte strings, and | |||
RFC8259 requires JSON to be encoded as UTF-8. | |||
|
|||
- When choosing data types for RPC JSON, prefer data types that are flexible to expansion without change of data type. For example, `{"result":{"warnings":[]}}` rather than `{"result":{"warnings":""}}`, which allows for multiple warnings to be included as array elements. |
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: this sentence might be better structured starting with a verb:
Prefer to choose RPC JSON data types that are flexible to expansion without change of data type.
ACK 61853a2. |
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.
Concept ACK
doc/developer-notes.md
Outdated
@@ -1449,6 +1449,12 @@ A few guidelines for introducing and reviewing new RPC interfaces: | |||
- *Rationale*: JSON strings are Unicode strings, not byte strings, and | |||
RFC8259 requires JSON to be encoded as UTF-8. | |||
|
|||
A few guidelines for modifying and reviewing existing RPC interfaces: | |||
|
|||
- Implement an associated `-deprecatedrpc=` option to retain previous RPC behavior when modifying the structure of RPC interface JSON. This includes, but is not limited to, changes such as: data types changes (e.g. from `{"result":{"warnings":""}}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Include detailed instructions on feature deprecation and re-enabling previous behavior in release notes. |
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.
Perhaps useful to elaborate a bit more on distinguishing between backwards compatible/incompatible behaviour?
- Implement an associated `-deprecatedrpc=` option to retain previous RPC behavior when modifying the structure of RPC interface JSON. This includes, but is not limited to, changes such as: data types changes (e.g. from `{"result":{"warnings":""}}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Include detailed instructions on feature deprecation and re-enabling previous behavior in release notes. | |
- Implement an associated `-deprecatedrpc=` option to retain previous RPC behavior when modifying the structure of RPC interface JSON in a backwards-incompatible manner. This includes, but is not limited to, changes such as: data types changes (e.g. from `{"result":{"warnings":""}}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Include detailed instructions on feature deprecation and re-enabling previous behavior in release notes. Adding fields is generally considered backwards compatible. |
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.
Oh would also add that deprecated behaviour should be documented in the RPC docs, such as e.g. in
Lines 663 to 664 in 0ca1d1b
RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} : | |
RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)", |
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.
Yes, we've also traditionally mentioned these in all-caps in the RPC helps, i.e.
RPCResult{RPCResult::Type::STR, "warnings", "(DEPRECATED) network and blockchain warnings, if any...)"} :
Perhaps for this case an example on its own line would 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.
Thanks. Mentioned that adding a key to an object is considered backward compatible. Also added an example from RPC code with DEPRECATED
.
doc/developer-notes.md
Outdated
@@ -1449,6 +1449,12 @@ A few guidelines for introducing and reviewing new RPC interfaces: | |||
- *Rationale*: JSON strings are Unicode strings, not byte strings, and | |||
RFC8259 requires JSON to be encoded as UTF-8. | |||
|
|||
A few guidelines for modifying and reviewing existing RPC interfaces: | |||
|
|||
- Implement an associated `-deprecatedrpc=` option to retain previous RPC behavior when modifying the structure of RPC interface JSON. This includes, but is not limited to, changes such as: data types changes (e.g. from `{"result":{"warnings":""}}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Include detailed instructions on feature deprecation and re-enabling previous behavior in release notes. |
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.
Include detailed instructions on feature deprecation and re-enabling previous behavior in release notes.
Release notes should refer to the RPC help for details instead of substituting for full documentation. Example: "Please refer to the RPC help of getbalances
for details."
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.
Implement an associated
-deprecatedrpc=
option to retain previous RPC behavior when modifying the structure of RPC interface JSON in a backwards-incompatible manner.
Suggest to lead with what would require this, use simpler language, and mention the period:
"If an RPC will be changed in a backward-incompatible way, add an associated -deprecatedrpc=
option to retain previous RPC behavior during the deprecation period."
This includes, but is not limited to, ...
(Is this long sentence and its examples and legalese all necessary? Don't hesitate to shorten where possible.)
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. Specified that the release note should refer to RPC help, and led with is being changed in a backwards-incompatible way
b5f62f3
to
7b55357
Compare
doc/developer-notes.md
Outdated
@@ -1460,6 +1460,22 @@ A few guidelines for introducing and reviewing new RPC interfaces: | |||
- *Rationale*: JSON strings are Unicode strings, not byte strings, and | |||
RFC8259 requires JSON to be encoded as UTF-8. | |||
|
|||
A few guidelines for modifying and reviewing existing RPC interfaces: | |||
|
|||
- If an RPC is being changed in a backward-incompatible way, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data types changes (e.g. from `{"result":{"warnings":""}}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Adding a key to an object is generally considered backwards compatible. A release note should be included that refers to RPC help for details of feature deprecation and re-enabling previous behavior. Example RPC help: |
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.
Could drop the redundant/repeated "result" everywhere?
- If an RPC is being changed in a backward-incompatible way, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data types changes (e.g. from `{"result":{"warnings":""}}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Adding a key to an object is generally considered backwards compatible. A release note should be included that refers to RPC help for details of feature deprecation and re-enabling previous behavior. Example RPC help: | |
- If an RPC is being changed in a backward-incompatible way, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data types changes (e.g. from `{"warnings":""}` to `{"result":{"warnings":[]}}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"result":{"warning":""}}` to `{"result":{"warnings":""}}`). Adding a key to an object is generally considered backwards compatible. A release note should be included that refers to RPC help for details of feature deprecation and re-enabling previous behavior. Example RPC help: |
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.
Good point. Implemented.
7b55357
to
0e7926e
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.
No opinion about the content, reviewed only grammatically
doc/developer-notes.md
Outdated
A few guidelines for modifying and reviewing existing RPC interfaces: | ||
|
||
- If an RPC is being changed in a backward-incompatible way, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data types changes (e.g. from `{"warnings":""}` to `{"warnings":[]}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"warning":""}` to `{"warnings":""}`). Adding a key to an object is generally considered backwards compatible. A release note should be included that refers to RPC help for details of feature deprecation and re-enabling previous behavior. Example RPC help: | ||
```c++ |
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.
Would it make sense to refer to the code instead, to avoid duplication and maintenance burden?
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. Replaced with a permalink for it
bitcoin/src/rpc/blockchain.cpp
Lines 1316 to 1323 in 94f0adc
(IsDeprecatedRPCEnabled("warnings") ? | |
RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} : | |
RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)", | |
{ | |
{RPCResult::Type::STR, "", "warning"}, | |
} | |
} | |
), |
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.
No opinion about the content, reviewed only grammatically
0e7926e
to
40ac07e
Compare
utACK 40ac07e |
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 40ac07e
Good addition!
doc/developer-notes.md
Outdated
@@ -1460,6 +1460,12 @@ A few guidelines for introducing and reviewing new RPC interfaces: | |||
- *Rationale*: JSON strings are Unicode strings, not byte strings, and | |||
RFC8259 requires JSON to be encoded as UTF-8. | |||
|
|||
A few guidelines for modifying and reviewing existing RPC interfaces: |
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: Below doesn't talk about reviewing afaict
A few guidelines for modifying and reviewing existing RPC interfaces: | |
A few guidelines for modifying existing RPC interfaces: |
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.
True, though i suppose the same guidelines for modifying RPC interfaces can be used to review the changes by seeing if the changes follow the guidelines, without mentioning review explicitly.
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. 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.
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 40ac07e
doc/developer-notes.md
Outdated
@@ -1460,6 +1460,12 @@ A few guidelines for introducing and reviewing new RPC interfaces: | |||
- *Rationale*: JSON strings are Unicode strings, not byte strings, and | |||
RFC8259 requires JSON to be encoded as UTF-8. | |||
|
|||
A few guidelines for modifying and reviewing existing RPC interfaces: | |||
|
|||
- If an RPC is being changed in a backward-incompatible way, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data type changes (e.g. from `{"warnings":""}` to `{"warnings":[]}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"warning":""}` to `{"warnings":""}`). Adding a key to an object is generally considered backward compatible. A release note should be included that refers to RPC help for details of feature deprecation and re-enabling previous behavior. [Example RPC help](https://github.com/bitcoin/bitcoin/blob/94f0adcc31d2d263a03e46192922e3a7672e39d9/src/rpc/blockchain.cpp#L1316-L1323). |
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.
- If an RPC is being changed in a backward-incompatible way, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data type changes (e.g. from `{"warnings":""}` to `{"warnings":[]}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"warning":""}` to `{"warnings":""}`). Adding a key to an object is generally considered backward compatible. A release note should be included that refers to RPC help for details of feature deprecation and re-enabling previous behavior. [Example RPC help](https://github.com/bitcoin/bitcoin/blob/94f0adcc31d2d263a03e46192922e3a7672e39d9/src/rpc/blockchain.cpp#L1316-L1323). | |
- It's preferable to avoid changing an RPC in a backward-incompatible manner, but in that case, add an associated `-deprecatedrpc=` option to retain previous RPC behavior during the deprecation period. Backward-incompatible changes include: data type changes (e.g. from `{"warnings":""}` to `{"warnings":[]}`, changing a value from a string to a number, etc.), logical meaning changes of a value, or key name changes (e.g. `{"warning":""}` to `{"warnings":""}`). Adding a key to an object is generally considered backward-compatible. Include a release note that refers the user to the RPC help for details of feature deprecation and re-enabling previous behavior. [Example RPC help](https://github.com/bitcoin/bitcoin/blob/94f0adcc/src/rpc/blockchain.cpp#L1316-L1323). |
(I don't think the link is the best example, but in any case the URL can be shorter for people who read these notes in their text editor instead of online.)
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. 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.
Related to #30142 (comment) - it's more uniform now
Adds deprecatedrpc guidance statement to the RPC interface guidelines section.
40ac07e
to
c6eca6f
Compare
ACK c6eca6f |
ACK c6eca6f |
lgtm ACK c6eca6f |
ACK c6eca6f |
(Meta: the current GitHub safetyism and friction is annoying, when all you want to do is ACK 😄) "This issue is highly active. Reconsider commenting unless you have read all the comments and have something to add." "Your link may be misinterpreted by GitHub." |
Adds guidance statements to the RPC interface section of the developer notes with examples of when to implement
-deprecatedrpc=
.Wanted to increase awareness of preferred RPC implementation approaches for newer contributors.
This implements some of what's discussed in #29912 (comment)
Opinions may differ, so please don't be shy. We want to make RPC as solid/safe as possible.
Examples of discussions where guidelines/context might have added value:
#30212 (comment)
#29845 (comment)
#30381 (review)
#29954 (comment)
#30410 (review)
#30713
#30381
#29060 (review)