Skip to content

Conversation

pythcoiner
Copy link

@pythcoiner pythcoiner commented Jan 24, 2025

In MiniscriptDescriptor::ToStringHelper() only the StringType::Private variant of the type argument was handled. This PR implements serializing w/ all variants of StringType & add a functional test for the descriptor triggering the related issue.

Closes #31694: previously when calling listdescriptors RPC on a wallet containing a taproot descriptor w/ a (miniscript) taptree, origins of internal key & taptree were serialized w/ differents hardened derivation markers:

  • origin of the internal key were serialized w/ StringType::Normalized type (using h as marker)
  • origins of taptree keys were serialized w/ StringType::Private type (using ' as marker)

Note: Origins in segwit (wsh()) miniscript descriptors were also serialized w/ StringType::Private type (' marker) and are now serialized w/ StringType::Normalized type (h marker).

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 24, 2025

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/31734.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK 1440000bytes, brunoerg

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:

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.

@pythcoiner pythcoiner changed the title Miniscriptdescriptor to string Account for all StringType variants in Miniscriptdescriptor::ToString() Jan 24, 2025
@pythcoiner pythcoiner changed the title Account for all StringType variants in Miniscriptdescriptor::ToString() miniscript: ccount for all StringType variants in Miniscriptdescriptor::ToString() Jan 24, 2025
@pythcoiner pythcoiner changed the title miniscript: ccount for all StringType variants in Miniscriptdescriptor::ToString() miniscript: acount for all StringType variants in Miniscriptdescriptor::ToString() Jan 24, 2025
@pythcoiner pythcoiner force-pushed the miniscriptdescriptor_to_string branch from 2c70728 to 87be050 Compare January 24, 2025 16:58
@DrahtBot
Copy link
Contributor

🚧 At least one of the CI tasks failed.
Debug: https://github.com/bitcoin/bitcoin/runs/36134804974

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

@pythcoiner pythcoiner marked this pull request as draft January 25, 2025 00:38
@pythcoiner pythcoiner force-pushed the miniscriptdescriptor_to_string branch 2 times, most recently from 8ce78e5 to 0bc213d Compare January 25, 2025 01:18
@pythcoiner pythcoiner marked this pull request as ready for review January 25, 2025 02:04
Copy link
Contributor

@hodlinator hodlinator left a comment

Choose a reason for hiding this comment

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

Code review 0bc213d

Thanks for taking on this issue! Not very familiar with this area but maybe I can assist in refining the PR anyway. Seems directionally correct to use h consistently for hardened derivation paths unless backwards compatibility is requested.

PR title/summary

PR title typo

acount -> account

Summary

- In `MiniscriptDescriptor::ToStringHelper()` only `StringType::Private` variant of `type` argument was accounted. This PR implement serializing w/ all variants of `StringType` & add a functionnal test for the descriptor triggereing the related issue.
+ In `MiniscriptDescriptor::ToStringHelper()` only the `StringType::Private` variant of the `type` argument was handled. This PR implements serializing w/ all variants of `StringType` & add a functional test for the descriptor triggering the related issue.

Maybe the summary could also include a brief explanation of why this change ends up fixing the issue?

Commit order

The commit order is wrong for our CI setup, adding the test before the fix. Our CI expects each commit to succeed, so the test needs to be added last (reviewers can drop the other commit or run with binaries from master in order to trigger test failures).

@pythcoiner pythcoiner changed the title miniscript: acount for all StringType variants in Miniscriptdescriptor::ToString() miniscript: account for all StringType variants in Miniscriptdescriptor::ToString() Jan 29, 2025
@pythcoiner pythcoiner force-pushed the miniscriptdescriptor_to_string branch from 0bc213d to 498c47d Compare January 30, 2025 02:10
@pythcoiner
Copy link
Author

Thanks for the review @hodlinator! comments addressed & added more details to the summary

@1440000bytes

This comment was marked as abuse.

1 similar comment
@brunoerg
Copy link
Contributor

brunoerg commented Feb 3, 2025

Concept ACK

Copy link
Contributor

@hodlinator hodlinator left a comment

Choose a reason for hiding this comment

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

Code review 498c47d

Since last review

git range-diff master 0bc213d 498c47d

  • Reordered commits and avoid touching new test code in 2 commits. ✅
  • Forwards on cache argument from calling function, changed types and const. ✅
  • Improved PR title and summary. ✅

Concept

Before the PR, first key origin/derivation path in the descriptor undergoes ' -> h conversion, but the second one does not. There seems to be some code in descriptor.cpp that deliberately tries to preserve apostrophes. I'm unsure whether the change breaks any existing requirements. My instinct says software depending on Bitcoin Core should handle h in all cases. But there may be cases where changing the format leads to errors, worst case leading to users having problems recovering funds. If we go ahead with this PR, it should probably have release notes (example of PR with release notes).

Wallet and surrounding code is a beast that I don't have enough familiarity with to produce a Concept A-C-K at this point. Main code being changed seems to be from bfb0367 by @darosior and @sipa.

TODO

  • Lacking LIFETIMEBOUND (see inline comment).
  • nit: PR summary typos: "differents hardened derivation marker" -> "different hardened derivation markers"

@pythcoiner pythcoiner force-pushed the miniscriptdescriptor_to_string branch from 498c47d to a5c0516 Compare February 6, 2025 08:11
@pythcoiner pythcoiner force-pushed the miniscriptdescriptor_to_string branch from a5c0516 to 28a4fcb Compare February 7, 2025 09:13
@pythcoiner
Copy link
Author

tahnks for your time @hodlinator!

@fanquake
Copy link
Member

cc @darosior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent hardened derivation marker in listdescriptors output
6 participants