Skip to content
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

DerivedDescriptor unfinished business #448

Merged

Conversation

LLFourn
Copy link
Contributor

@LLFourn LLFourn commented Jul 14, 2022

This PR further develops the idea introduced in #345. It has two commits both with relatively detailed commit messages that can be reviewed separately. In summary:

  1. Develop the DerivedDescriptorKey (a key that is guaranteed not to have wildcard in it) idea more by adding missing functionality and refining the API. In addition, I removed the error cases from ConversionError which seems to have been omitted from Define a new type for derived DescriptorPublicKeys #345.
  2. Since the introduction of DerivedDescriptorKey, the overlapping usage of the term "derive" has become quite confusing. In addition to the usual definition of "derive" we have also used it to mean "replace a wildcard with a particular derivation index". I deprecated and renamed everything that uses the latter definition.

LLFourn added 2 commits July 14, 2022 16:23
Earlier we introduced DerivedDescriptorKey (an descriptor whose
wildcards are known to have been replaced with derivation indexes) to
eliminate wildcard derivation errors. This commit attempts to realise the
full benefits of this idea. I tried to keep backwards compatibility.

The naming of things no longer follows the logic of code so I'm going to
fix that in a follow up.
The words "derive", "derived" and "derivable" were being used to
describe things that aren't stricly derivation. Derivation is the
process of taking cryptographic data and deterministically producing
something else given some inputs. This is how the term is used in bip32,
rust-bitcoin and more generally.

In rust-miniscript the term is also used to mean "replacing a wildcard
in a derivation path with a particular index". This can be quite
confusing. For example, `is_derivable` returns true when there is a
wildcard in the descriptor -- but it should return the opposite (given
the usual meaning)! You can't do a derivation because you don't know
the full derivation path yet (it's s got a wildcard in it). This commit
replaces all instances where "derive" is used in this way.
@LLFourn LLFourn force-pushed the derived_descriptor_unfinished_business branch from 875dbc1 to 2ad6555 Compare July 14, 2022 08:23
@apoelstra
Copy link
Member

This looks great! The renaming really helps make sense of these APIs. Is "definite" a standard term or did you make it up for this PR? TBH I'm not sure what the right way to say "non-wildcard" is.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 2ad6555

@tcharding
Copy link
Member

tcharding commented Jul 14, 2022

TBH I'm not sure what the right way to say "non-wildcard" is

Ha! I got confused as hell over the 'derive' usage and also came to this same conclusion, so I did a definition search just now on wildcard to try come up with some terms, could we use one of these?

  • specific / specified
  • known
  • concrete

(We have concrete already in policy so probably not good.)

Comment on lines +445 to +446
#[deprecated(note = "use at_derivation_index instead")]
/// Deprecated name of [`at_derivation_index`].
Copy link
Member

Choose a reason for hiding this comment

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

I quite like this idea of removing the original comment and replacing with "Deprecated name of ..", I'm going to use that myself in future.

nit: Can you put the attribute below the comment please if you rebase for any other reason.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

I'm not a fully qualified miniscript reviewer yet so just shallow review. Thanks man!

@@ -441,40 +428,50 @@ impl DescriptorPublicKey {
}
}

/// Whether or not the key has a wildcards
/// Whether or not the key has a wildcard
#[deprecated(note = "use has_wildcard instead")]
Copy link
Member

Choose a reason for hiding this comment

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

@apoelstra / @sanket1729 I wonder if we can come up with a way to remind ourselves to add the 'since' field to this (and to these attributes in general) when we do the release tracking issue that bumps the version. these 'deprecated' attributes are impossible to write correctly because the next release number is not known at time of writing.

Copy link
Member

Choose a reason for hiding this comment

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

maybe we could file an issue with clippy to lint this :) "deprecated without since" default warn

Copy link
Member

Choose a reason for hiding this comment

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

But we only want it right before doing release not all the time.

@LLFourn
Copy link
Contributor Author

LLFourn commented Jul 15, 2022

This looks great! The renaming really helps make sense of these APIs. Is "definite" a standard term or did you make it up for this PR? TBH I'm not sure what the right way to say "non-wildcard" is.

Not a standard term in anything surrounding Bitcoin. I borrowed it from linguistics which I think would describe a language feature like /* as introducing definiteness. /* allows you to talk about keys indefinitely. It works something like "a" does in English: I can say "I will take a car to the airport" without specifying precisely which car while still conveying useful information. It allows you to narrow things down without yet being definite.

To keep to this line of thinking has_wildcard could be is_indefinite but I thought it best not to go that far as when I suggested "definite" in #345 it got a mixed response.

TBH I'm not sure what the right way to say "non-wildcard" is

Ha! I got confused as hell over the 'derive' usage and also came to this same conclusion, so I did a definition search just now on wildcard to try come up with some terms, could we use one of these?

  • specific / specified
  • known
  • concrete

(We have concrete already in policy so probably not good.)

"concrete" refers to a descriptor that has already derived keys in comments and docs already too.
Even if you are not familiar with the linguistic concept, SpecificDescriptorKey and KnownDescrpitorKey don't seem significantly better than DefiniteDescriptorKey. I could live with WildcardFreeDescriptorKey since it is precise (and rhymes!).

@apoelstra
Copy link
Member

I can live with any of these (including Definite :)).

Sorry to stir up a bikeshedding discussion, especially when I have no strong preference, but I think it could be worthwhile.

@tcharding
Copy link
Member

I think you are right @LLFourn nothing else seems better than 'definite', FWIW +1 from me.

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK 2ad6555. Thanks for the clean changes.

@sanket1729 sanket1729 merged commit c7c39f1 into rust-bitcoin:master Jul 20, 2022
@LLFourn LLFourn deleted the derived_descriptor_unfinished_business branch September 19, 2022 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants