8000 Add rand-std feature by tcharding · Pull Request #1387 · rust-bitcoin/rust-bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add rand-std feature #1387

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

Merged
merged 2 commits into from
Dec 30, 2022
Merged

Conversation

tcharding
Copy link
Member
@tcharding tcharding commented Nov 14, 2022

This PR uncovered incorrect feature gating in secp256k1, fixed in rust-bitcoin/rust-secp256k1#519

Currently we enable "secp256k1/rand-std" in the "rand" feature, this is incorrect because it means "rand" implies "std" which it does not.

Add a "rand-std" feature that turns on "seck256k1/rand-std" and make the "rand" feature turn on "seck256k1/rand".

Fix: #1384

@@ -1686,7 +1685,6 @@ mod tests {
assert_eq!(psbt1, psbt2);
}

#[cfg(feature = "rand")]
fn gen_keys() -> (PrivateKey, PublicKey, Secp256k1<All>) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

WTF, this shouldn't work. I suspect we have something seriously wrong, maybe we're enabling rand-std via other means.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought the same but "rand-std" is enabled in the dev dependencies.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, maybe that's wrong because we can't properly check that the features work correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed! Thanks for prodding me to fix it correctly.

@tcharding tcharding force-pushed the 11-15-rand-std-feature branch from c51e02a to 71787e8 Compare November 16, 2022 21:17
@tcharding
Copy link
Member Author

Changes in force push:

  • Remove original first patch (which removed feature gating on "rand"), instead feature gate on "rand-std" as part of the patch that adds "rand-std" feature.
  • Do not use dev-dependency secp256k1 with "rand-std" enabled, instead correctly feature gate all unit test code.

@tcharding tcharding force-pushed the 11-15-rand-std-fea 8000 ture branch from 71787e8 to 1a0437d Compare November 16, 2022 21:24
@tcharding
Copy link
Member Author

Added missing feature guard to rustdoc example code.

@tcharding tcharding force-pushed the 11-15-rand-std-feature branch from 1a0437d to 8a15d22 Compare November 16, 2022 21:37
@tcharding
Copy link
Member Author

Fix even more mistakes with the original push :(

@tcharding tcharding force-pushed the 11-15-rand-std-feature branch 2 times, most recently from f132e12 to 6248a70 Compare November 16, 2022 23:08
@Kixunil
Copy link
Collaborator
Kixunil commented Nov 17, 2022

From a quick look it looks like the problem is in secp256k1 🤨

@tcharding
Copy link
Member Author

From a quick look it looks like the problem is in secp256k1 raised_eyebrow

Bother huh, I patched it just now.

@tcharding tcharding force-pushed the 11-15-rand-std-feature branch from 6248a70 to affd2ab Compare November 17, 2022 05:34
@tcharding
Copy link
Member Author

Put this on ice until the rand-std stuff in secp goes in and is released.

@tcharding tcharding marked this pull request as draft November 18, 2022 02:01
@tcharding
Copy link
Member Author

note to self: if #1416 merges update the doc to use rand-std in this PR.

@tcharding tcharding force-pushed the 11-15-rand-std-feature branch from affd2ab to 9fcc303 Compare December 5, 2022 22:49
@tcharding tcharding force-pushed the 11-15-rand-std-feature branch 2 times, most recently from acbf4ba to 2e156c1 Compare December 20, 2022 23:11
@Kixunil
Copy link
Collaborator
Kixunil commented Dec 22, 2022

#1493 is in.

Currently we enable "secp256k1/rand-std" in the "rand" feature, this is
incorrect because it means "rand" implies "std" which it does not.

Add a "rand-std" feature that turns on "seck256k1/rand-std" and make the
"rand" feature turn on "seck256k1/rand".
In order to get better test coverage we should not enable the secp26k1
feature "rand-std" in dev-dependencies but instead feature gate tests
that depend on this feature.
@tcharding tcharding force-pushed the 11-15-rand-std-feature branch from 2e156c1 8000 to 941083e Compare December 22, 2022 21:34
@Kixunil Kixunil added this to the 0.30.0 milestone Dec 22, 2022
@sanket1729
Copy link
Member

Do not use dev-dependency secp256k1 with "rand-std" enabled, instead correctly feature gate all unit test code.

Can you explain more about the benefits of this? To me, It feels like this only adds additional code while writing tests.

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 941083e

@Kixunil
Copy link
Collaborator
Kixunil commented Dec 23, 2022

Can you explain more about the benefits of this?

Unconditionally enabling it could cause us to miss features-related bugs.

@tcharding tcharding marked this pull request as ready for review December 23, 2022 21:17
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 941083e

@apoelstra apoelstra merged commit 3b11ff6 into rust-bitcoin:master Dec 30, 2022
@tcharding tcharding deleted the 11-15-rand-std-feature branch January 12, 2023 07:35
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.

"rand" feature implies "std"
4 participants
0