Skip to content

Fix field name styling in submitpackage RPC results - #31900

Closed
tnull wants to merge 2 commits into
bitcoin:masterfrom
tnull:2025-02-align-delimiter-in-package-msg
Closed

tnull wants to merge 2 commits into
bitcoin:masterfrom
tnull:2025-02-align-delimiter-in-package-msg

Conversation

@tnull

@tnull tnull commented Feb 18, 2025

Copy link
Copy Markdown

Previously, the submitpackage RPC call returned a response key named package_msg, which is inconsistent with the other field names that are using - as a delimiter. Here, we align the style of package-msg.

cc @glozow @instagibbs

@DrahtBot

DrahtBot commented Feb 18, 2025 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31900.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK stickies-v

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #31385 (package validation: relax the package-not-child-with-unconfirmed-parents rule by glozow)

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.

@glozow glozow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, though I've heard we don't like hyphens, so perhaps go in the other direction and change all the other ones to _?

@tnull

tnull commented Feb 18, 2025 •

Copy link
Copy Markdown
Author

lgtm, though I've heard we don't like hyphens, so perhaps go in the other direction and change all the other ones to _?

Hmm, sure, happy to change if that would be preferable, mostly went this way as I saw other examples using - (e.g., p2sh-segwit in decodescript result, bit125-replaceable in the wallet RPCs, etc), but I now realize there are also many (more?) that use _. This makes me wonder if we are really positive it's worth breaking the current API, if neither of the options (- or _) is consistently used across the RPC API? I guess in the submitpackage case it's a tad more awkward as both variants are used in a single RPC response?

@glozow

glozow commented Feb 18, 2025

Copy link
Copy Markdown
Contributor

I want to say this changed over time... I can't find the thread where I was convinced, but here's chat GPT's argument for why underscores are better than hyphens in JSON:

  1. Consistency with JavaScript & JSON standards – JSON keys are commonly accessed in JavaScript, and using hyphens (some-key) requires bracket notation (obj["some-key"]) instead of the simpler dot notation (obj.some_key).
  2. Better compatibility – Many programming languages (Python, JavaScript, etc.) use underscores for variable and property names, making underscore-separated keys more natural to work with.
  3. Avoids potential parsing issues – Some parsers and serialization libraries may misinterpret hyphens as minus signs, leading to unexpected issues."

fwiw, if we think of pre-29 as the last chance to be liberal with changing API, I do think unifying it within submitpackage makes sense (for context, this is a continuation of the convo from spesmilo/electrum-protocol#4 (comment)).

@stickies-v stickies-v left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The developer notes state:

Argument and field naming: please consider whether there is already a naming style or spelling convention in the API for the type of object in question (blockhash, for example), and if so, try to use that. If not, use snake case fee_delta (and not, e.g. feedelta or camel case feeDelta).

Rationale: Consistency with the existing interface.

So it seems like if any change is made, it should be package_msg, or update developer notes first. The JSON-RPC spec does not provide guidelines on using either or the other, and it doesn't seem to me like there is an industry standard either, so I don't see a particular reason to update the developer notes.

fwiw, if we think of pre-29 as the last chance to be liberal with changing API, I do think unifying it within submitpackage makes sense

I agree with that. Concept ACK.

Previously, the result of a `submitpackage` RPC call would include
fields with mixed styles (mixing dash-case and snake_case). Here, we
align them all to use snake_case, i.e., to use the `_` delimiter.
Previously, the result of a `testmempoolaccept` RPC call would include
fields with mixed styles (mixing dash-case and snake_case). Here, we
align them all to use snake_case, i.e., to use the `_` delimiter.
@tnull
tnull force-pushed the 2025-02-align-delimiter-in-package-msg branch from 52a24de to a85ea7d Compare February 19, 2025 13:28
@tnull tnull changed the title Fix delimeter in package-msg field of submitpackage RPC Fix field name styling in submitpackage RPC results Feb 19, 2025
@tnull

tnull commented Feb 19, 2025 •

Copy link
Copy Markdown
Author

Alright, I now updated this PR to adjust all submitpackage result field names that previously used dash-case. As it seemed a bit odd to have some of the same fields (effective-feerate, effective-includes) with different styling as part of testmempoolaccept, I now also added a commit aligning the fields there, too, but please let me know if I should simply drop that commit if we wouldn't want to break that RPC API as well.

fwiw, if we think of pre-29 as the last chance to be liberal with changing API, I do think unifying it within submitpackage makes sense (for context, this is a continuation of the convo from spesmilo/electrum-protocol#4 (comment)).

Alright, good to know. It might be noteworthy that there are other projects that directly forward Core's JSON (e.g. the Esplora implementations over at mempool/electrs#105 and Blockstream/electrs#119) that would also be affected by the API breakage (and for clients it might also be a bit annoying as they surely can't know with version of Core a particular Esplora server is running under the hood, but I guess they'd need to figure something out, or just use the newer version asap?). That said, I agree that if this should get fixed/aligned, now might be the last chance to do so (also given that said downstream projects haven't fully finished deploying submitpackage support yet).

@stickies-v

Copy link
Copy Markdown
Contributor

submitpackage is marked as experimental and unstable, so changing that is fine imo. That does not hold for testmempoolaccept, so if we make changes to fields you'll have to add a -deprecatedrpc option. I don't think breaking a stable API just for stylistic purposes is worth it, so I would postpone that until we need another breaking change.

Would be good to add release notes to document the submitpackage breaking changes.

Comment thread src/rpc/mempool.cpp
{RPCResult::Type::STR, "reject-reason", /*optional=*/true, "Rejection reason (only present when 'allowed' is false)"},
{RPCResult::Type::STR, "reject-details", /*optional=*/true, "Rejection details (only present when 'allowed' is false and rejection details exist)"},
{RPCResult::Type::STR, "reject_reason", /*optional=*/true, "Rejection reason (only present when 'allowed' is false)"},
{RPCResult::Type::STR, "reject_details", /*optional=*/true, "Rejection details (only present when 'allowed' is false and rejection details exist)"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

reject-details was only added in 221c789 (master), so changing it seems fine

@glozow

glozow commented Feb 19, 2025

Copy link
Copy Markdown
Contributor

Alright, good to know. It might be noteworthy that there are other projects that directly forward Core's JSON (e.g. the Esplora implementations over at mempool/electrs#105 and Blockstream/electrs#119) that would also be affected by the API breakage

Ah right, I forgot about that. And spesmilo/electrumx#288 and spesmilo/electrum-protocol#1. I think this would inconvenience a few people.

Ok... even though it's marked as experimental, I think it's too late to break submitpackage purely for style reasons. Fwiw I did think this was worthwhile before (and I pinged @tnull after seeing comment), but I'm leaning towards nack now. My apologies!

@tnull

tnull commented Feb 19, 2025

Copy link
Copy Markdown
Author

Ok... even though it's marked as experimental, I think it's too late to break submitpackage purely for style reasons. Fwiw I did think this was worthwhile before (and I pinged @tnull after seeing comment), but I'm leaning towards nack now. My apologies!

Alright, no worries! Going ahead and closing this.

@tnull tnull closed this Feb 19, 2025
@bitcoin bitcoin locked and limited conversation to collaborators Jul 30, 2026
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.

5 participants