Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste |
10f69e5 to
270ecac
Compare
There was a problem hiding this comment.
Concept ACK
One thing I could not settle by reading. The test asserts the discriminator's literals rather than the two relations behind them.
Inserting an argument before verbosity in getblock leaves parameterIndex 1 addressing the new argument, and swapping the verbosity 2 and 3 arms points value 2 at the arm with prevout. rpc_openrpc.py passes on both builds, and none of the three new CHECK_NONFATALs looks at either relation. Worth pinning them?
Comparing getblock["params"][discriminator["parameterIndex"]]["name"] to discriminator["parameter"], and asserting the two object arms differ in prevout in the order values claims, fails on both and passes on this head.
| UniValue vals{UniValue::VARR}; | ||
| vals.push_backV(discriminator->values); | ||
| disc_meta.pushKV("values", std::move(vals)); | ||
| result_schema.pushKV("x-bitcoin-discriminatedResult", std::move(disc_meta)); |
There was a problem hiding this comment.
The schema field in OpenRPCDocResult already explains x-bitcoin-unit to whoever reads the help. Worth a line for x-bitcoin-discriminatedResult too? The parameter-side schema field next to it has the same gap for x-bitcoin-default-hint, if you would rather cover both at once.
nit: the other x-bitcoin- keys in the document are all lowercase and hyphenated, so x-bitcoin-discriminated-result would match.
Good catch, thanks! I've updated the tests according to your suggestion |
270ecac to
213b2ed
Compare
213b2ed to
3b02b9b
Compare
|
Rebased off master |
OpenRPC documents `getblock` as a four-way `oneOf` on `verbosity`, but
nothing in the schema maps `verbosity` values onto those branches.
Add optional `RPCResultDiscriminator` on `RPCResults`, emit it as
`x-bitcoin-discriminated-result`, and stamp `getblock` so `verbosity`
selects the existing oneOf arms via {0, 1, 2, 3} in that order.
No runtime behavior change.
Parameter schemas may include `x-bitcoin-default-hint` when the default cannot be expressed as a JSON value. Multi-result schemas may include `x-bitcoin-discriminated-result` naming the request parameter or parameters that select among the top-level oneOf branches.
3b02b9b to
85f2993
Compare
willcl-ark
left a comment
There was a problem hiding this comment.
ACK 85f2993
RPCResultDiscriminator seems like a fair concept to use here.
I tried to think of other ways to implement, such as attaching each verbosity value directly to its RPCResult arm, which would remove the parallel ordering between values and oneOf, but it would be overkill for the one current use IMO.
Same, I find it a bit ugly that we can't discriminate all results. The reason is due to legacy code such as: Which leads to issues such as #18476. I don't think this will be fixed any time soon, or ever, so maybe a dedicated I am asking because clients would either care to have all of them discriminated, or none? What is so special about Also, while reviewing I found a likely unrelated bug: "mempool chunks" is not a discriminator, but should be the description of the array? |
This sounds reasonable. I can work on this once I get some more time, or happy to review a PR by someone else.
I had planned to go one by one for the RPCs that are selected by a request parameter.
Good catch. I will open a PR for a fix, unless someone else does before me. |
@nervana21 do you still plan on opening this? |
Yes, PR opened. Thanks for the reminder |
Maybe turn into draft for now? |
Done! |
0b17fa0 rpc: fix getmempoolfeeratediagram result description (nervana21) Pull request description: In #36175, maflcko [found](#36175 (comment)) that `"mempool chunks"` was incorrectly rendered as a result branch label. Fix it to annotate the array instead. <details> <summary><code>help getmempoolfeeratediagram</code> diff</summary> ```diff -Result (mempool chunks): -[ (json array) +Result: +[ (json array) mempool chunks { (json object) "weight" : n, (numeric) cumulative sigops-adjusted weight "fee" : n (numeric) cumulative fee }, ... ] ``` </details> ACKs for top commit: maflcko: lgtm ACK 0b17fa0 Tree-SHA512: 7dba3fb9f9b493a9e5f6192456b83bd872e312f70aeb2cc06ee737e4fbb194480aa387391482ea7dda8b283c930873f043cfde7d9665944907af6c84e490d87e
…iption 0b17fa0 rpc: fix getmempoolfeeratediagram result description (nervana21) Pull request description: In bitcoin#36175, maflcko [found](bitcoin#36175 (comment)) that `"mempool chunks"` was incorrectly rendered as a result branch label. Fix it to annotate the array instead. <details> <summary><code>help getmempoolfeeratediagram</code> diff</summary> ```diff -Result (mempool chunks): -[ (json array) +Result: +[ (json array) mempool chunks { (json object) "weight" : n, (numeric) cumulative sigops-adjusted weight "fee" : n (numeric) cumulative fee }, ... ] ``` </details> ACKs for top commit: maflcko: lgtm ACK 0b17fa0 Tree-SHA512: 7dba3fb9f9b493a9e5f6192456b83bd872e312f70aeb2cc06ee737e4fbb194480aa387391482ea7dda8b283c930873f043cfde7d9665944907af6c84e490d87e Cherry-picked-from: bitcoin/bitcoin@1ea904d

OpenRPC documents
getblockas a four-wayoneOfonverbosity, but the dump does not say which integer selects which arm. Therefore, clients that expose a type or method per verbosity (e.g. corepc, btcd) have to hardcode that map.This patch adds optional
RPCResultDiscriminatormetadata, emits it asx-bitcoin-discriminated-result, and stampsgetblock.getblockrequest handling and returned block data are unchanged. Now,help getblocknotes that verbosity 2 and 3 cannot be told apart by validating a response alone.Also updates
getopenrpcinfoschema text to documentx-bitcoin-discriminated-resultandx-bitcoin-default-hint.The change to the schema's format is:
x-bitcoin-discriminated-resultongetblockgetblockdescription notes verbosity 2 and 3 overlapschema text for
x-bitcoin-default-hintandx-bitcoin-discriminated-resultOther results can also use the same discriminator pattern.