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

Fix typo in deprecated type #2693

Merged
merged 1 commit into from May 1, 2024

Conversation

matthiasdebernardini
Copy link
Contributor

@matthiasdebernardini matthiasdebernardini commented Apr 17, 2024

In #2258 we attempted to add back in deprecated BIP-32 types - but we spelled the identifier incorrectly. The patch was then backported to the 0.31.x branch in December but was only just noticed now.

Fix typo in deprecated type from Extendend -> Extended.

@github-actions github-actions bot added the C-bitcoin PRs modifying the bitcoin crate label Apr 17, 2024
@coveralls
Copy link

coveralls commented Apr 17, 2024

Pull Request Test Coverage Report for Build 8904697452

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 83.131%

Totals Coverage Status
Change from base Build 8904174578: 0.0%
Covered Lines: 19195
Relevant Lines: 23090

💛 - Coveralls

@@ -31,11 +31,11 @@ const VERSION_BYTES_TESTNETS_PRIVATE: [u8; 4] = [0x04, 0x35, 0x83, 0x94];

/// The old name for xpub, extended public key.
#[deprecated(since = "0.31.0", note = "use xpub instead")]
pub type ExtendendPubKey = Xpub;
pub type ExtendedPubKey = Xpub;
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, we should just delete this code. The type was named ExtendedPubKey in 0.30 and we removed ExtendedPubKey completely in 0.31 by accidentally mis-spelling it.

Copy link
Contributor

@storopoli storopoli Apr 17, 2024

Choose a reason for hiding this comment

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

Yes, I also agree. Note that with the CI testing, it took a long time for someone to find this typo.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed :(. We messed up the deprecation cycle here. Frustrating that nobody noticed until now -- it would have made the 0.30 to 0.31 transition much easier.

Maybe this PR should instead be a backport to the 0.31 branch.

Also the deprecation method should say Xpub instead of xpub, which will make it clear that there's an actual type called Xpub.

Copy link
Member

Choose a reason for hiding this comment

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

Note that with the CI testing, it took a long time for someone to find this typo.

I'm not sure that tests would have caught it. Tobin and I updated a bunch of crates from 0.30 to 0.31, and I recall seeing that ExtendedPubKey no longer compiled and thinking "hmm don't I remember us doing a deprecation here?" and then deciding that there must've been some reason we didn't.

Copy link
Member

Choose a reason for hiding this comment

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

@tcharding @apoelstra the deprecation warning does not show up unless you explicitly wrap the create a new type. Simply pub type A = B does an alias and would not show warning when user uses type A.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should do as you suggested once in the past @apoelstra and during RC testing I should do each upgrade as two separate patches, the first being required changes and the second fixing all the lints (deprecation). That way we may notice if something is in the first patch that shouldn't have been.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, though if Sanket is correct, we won't actually get a deprecation warning in this case :(.

Copy link
Member

Choose a reason for hiding this comment

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

I swapped Xpriv for ExtendendPrivKey on master (with the spelling mistake) and got a warning

cargo run --example taproot-psbt --features=rand-std,bitcoinconsensus
warning: /home/tobin/build/github.com/tcharding/rust-bitcoin/master/bitcoin/Cargo.toml: version requirement `0.105.0+25.1` for dependency `bitcoinconsensus` includes semver metadata which will be ignored, removing the metadata is recommended to avoid confusion
   Compiling bitcoin v0.32.0-rc1 (/home/tobin/build/github.com/tcharding/rust-bitcoin/master/bitcoin)
warning: use of deprecated type alias `bitcoin::bip32::ExtendendPrivKey`: use xpriv instead
  --> bitcoin/examples/taproot-psbt.rs:81:77
   |
81 | use bitcoin::bip32::{ChildNumber, DerivationPath, Fingerprint, Xpriv, Xpub, ExtendendPrivKey};
   |                                                                             ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

warning: use of deprecated type alias `bitcoin::bip32::ExtendendPrivKey`: use xpriv instead
   --> bitcoin/examples/taproot-psbt.rs:117:9
    |
117 |         ExtendendPrivKey::from_str(BENEFACTOR_XPRIV_STR)?,
    |         ^^^^^^^^^^^^^^^^

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for checking. For some reason, I recall this not working.

Copy link
Member

Choose a reason for hiding this comment

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

No sweat, there are various deprecation things that definitely do not work as they appear, I can not remember which ones work and which don't either.

@tcharding
Copy link
Member

Maybe this PR should instead be a backport to the 0.31 branch.

Agreed, added label - I'll handle the backport.

@tcharding tcharding added the port-0.31.x Needs porting to 0.31.x branch label Apr 17, 2024
@tcharding tcharding changed the title fixed typo Fix typo in deprecated type Apr 17, 2024
@tcharding
Copy link
Member

Hi @matthiasdebernardini, thanks for noticing our fail, and thanks for fixing it! This patch will need to be backported to the 0.31.x branch, I took the liberty to improve the PR title and description - could you improve the commit with something similar please then I'll backport the patch exactly as it is merged into master.

Thanks again!

bitcoin/src/bip32.rs Outdated Show resolved Hide resolved
bitcoin/src/bip32.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK 6f0c5c1

@tcharding
Copy link
Member

Can you squash down to a single commit please.

@matthiasdebernardini
Copy link
Contributor Author

Let me know if there is anything else @tcharding !

@tcharding
Copy link
Member

Need to fix the commit message please.

@matthiasdebernardini
Copy link
Contributor Author

Got it! Should be good now.

@tcharding
Copy link
Member

Still needs a brief message followed by the body. You can see this blog for how to write a commit message: https://chris.beams.io/posts/git-commit/

In PR rust-bitcoin#2258, deprecated BIP-32 types were re-added but contained a typo in the identifier: "Extendend" instead of "Extended". This commit fixes that typo.

The incorrect patch was backported to the 0.31.x branch in December but only noticed recently.
@matthiasdebernardini
Copy link
Contributor Author

Thank you for your guidance, I think this commit message is good now. Let me know otherwise.

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.

ACK 12411fc

@tcharding
Copy link
Member

Thanks for sticking with it! Grumpy old devs like me like commit messages to be limited to 72 characters wide ... but I let this one through :)

Thanks for the contribution man! Sorry to be such a fussy reviewer.

Copy link
Contributor

@storopoli storopoli left a comment

Choose a reason for hiding this comment

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

ACK 12411fc

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 12411fc

@apoelstra apoelstra merged commit ad212da into rust-bitcoin:master May 1, 2024
21 checks passed
@matthiasdebernardini
Copy link
Contributor Author

@tcharding I think that's a positive - I look forward to learning more and making better contributions in the future. Thanks again!

@tcharding
Copy link
Member

Awesome, glad to have your contributions! We have a ton of work that needs doing, some easy so not so much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bitcoin PRs modifying the bitcoin crate port-0.31.x Needs porting to 0.31.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants