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

Bumps rand to 0.6.X & associated updates #92

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

huitseeker
Copy link
Contributor

@huitseeker huitseeker changed the title Bumps rand to 0.6.3 & associated updates Bumps rand to 0.6.X & associated updates Jan 11, 2019
@real-or-random
Copy link
Collaborator

related: #80 (comment)
So, we could stop exporting rand. Not sure if it's a good idea.

@real-or-random
Copy link
Collaborator

... and depends on the outcome of rust-bitcoin/rust-bitcoin#206

@apoelstra
Copy link
Member

What would this increase the minimum rustc version to?

@real-or-random
Copy link
Collaborator

according to their README, "Since version 0.5, Rand requires Rustc version 1.22 or greater." So we can't do this if we stick to 1.20. rust-bitcoin/rust-bitcoin#210

@real-or-random
Copy link
Collaborator

So as rust-bitcoin requires 1.22 now, there is nothing that prevents us from taking this update.

Do we want to keep exporting rand? If we don't export, this will break downstream code but we'll break that code probably anyway due to update. It's just possible that we'll need to export it again in a few months when rand upgrades requires a newer Rust again...

@apoelstra
Copy link
Member

What do you mean "we'll need to export it again"? We should keep exporting rand so that users don't have to manually keep track of what version dependencies we're using and change boilerplate code in response to it.

@apoelstra
Copy link
Member

Also, importantly, if users want to use their own version of rand but are required to have access to rand 0.6 types for use with rust-secp, the only simple way to get it is if rust-secp re-exports it. Then they can use rand for their stuff and secp256k1::rand for our stuff.

@real-or-random
Copy link
Collaborator

Yes, so we should just keep it.

@huitseeker Thanks for your PR again! So this requires us to bump to to rust 1.22.0. Can you additionally

(or alternatively, make sure that we can make those changes
https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/ )

@huitseeker huitseeker force-pushed the rand-update branch 2 times, most recently from a5a102f to b917eda Compare January 30, 2019 23:53
@huitseeker
Copy link
Contributor Author

I could have sworn @sgeisler had diagnosed the Windows failure and merged this. Anyway, @real-or-random any thoughts on whether we should include the reversal of 9a4961c?)

@real-or-random
Copy link
Collaborator

I don't think that the changes to BadRng are necessary:

  • next_64 is fine but we could also just stick to next_u32.
  • There are helper functions provided to implement the other functions: https://docs.rs/rand_core/0.3.1/rand_core/impls/index.html. So we don't need our own implementation of fill_bytes and would not rely on transmute.
  • Also try_fill_bytes can just implemented using Ok(fill_bytes(...), which is also just a single line of code.

I mean in the end this is just a debugging Rng, so there is nothing wrong with changing it but I feel we should not use transmute unless we really need to.

For the Windows build: Yes, that's unfortunate, The reason is that the cc crate uses a function on Windows, which requires Rust 1.27. (https://doc.rust-lang.org/std/option/enum.Option.html#method.filter). So you're right, we shouldn't revert 9a4961c but instead change the comment in the Travis config to explain that cc is the reason for disabling Windows builds on 1.22, and note in the README that the restriction to 1.22 is only for the Linux target.

With those two points addresses, this is good to merge for me but I'd like to see an ACK from everybody due to the rust version bump, not only on Linux to 1.22 but in particular on Windows to at least 1.27 (maybe it's in fact even higher, who knows...). @TheBlueMatt? @apoelstra?

@real-or-random
Copy link
Collaborator

Ok what I'm saying is wrong. We're not bumping on Windows; I guess the build fails already now. But it still will be good to hear your thoughts.

@huitseeker
Copy link
Contributor Author

I'll make a few changes along the lines of your suggestions later today.

@huitseeker huitseeker force-pushed the rand-update branch 2 times, most recently from c51eb9e to 728aaf2 Compare February 11, 2019 00:02
@real-or-random
Copy link
Collaborator

Thanks for the updates! And sorry that I'm so slow at responding here.

Hm, to be honest, now that I see that we need another rand_core then (which is needed by rand anyway though) I'm not convinced anymore that what I suggested is the best approach. But before I ask you to do even more changes and create even more back and forth, I'll suggest waiting for @apoelstra and @TheBlueMatt's opinion on that issue and on the PR in general.

@huitseeker huitseeker force-pushed the rand-update branch 2 times, most recently from c6fcb4c to 87199ca Compare February 20, 2019 03:50
@huitseeker
Copy link
Contributor Author

huitseeker commented Feb 20, 2019

I'm happy with a 207acef like style where the relevant rand_core functions are pulled within the PR. Just let me know @apoelstra @TheBlueMatt (making a few fixes at the moment, test results are less bad than on master).

@huitseeker huitseeker force-pushed the rand-update branch 2 times, most recently from d2bd5e4 to c62b7f1 Compare February 20, 2019 04:35
README.md Outdated
@@ -20,5 +20,4 @@ Contributions to this library are welcome. A few guidelines:
* Any breaking changes must have an accompanied entry in CHANGELOG.md
* No new dependencies, please.
* No crypto should be implemented in Rust, with the possible exception of hash functions. Cryptographic contributions should be directed upstream to libsecp256k1.
* This library should always compile with any combination of features on **Rust 1.14**, which is the currently shipping compiler on Debian.

* This library should always compile with any combination of features on **Rust 1.22**, which is the currently shipping compiler on Debian.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should drop the reason; Debian actually ships 1.24 or 1.26 or something. Our reasoning for 1.22 is more complicated.

@apoelstra
Copy link
Member

concept ACK. I think we need an analagous PR for rust-bitcoin which is using rand 0.3 (lol!!) to update to 0.6 or maybe just drop it.

I'm a bit apprehensive about these new default functions...or rather, about the new functions that they call. I'm unsure whether the library will interact well with instances of these types which are all-bits-zero. I'm OK with this PR but it may be that a future PR removes these things because they can be used to trigger assertation failures or something.

@huitseeker
Copy link
Contributor Author

huitseeker commented Feb 20, 2019

@apoelstra

  • will drop min-rust-version reason as suggested in Bumps rand to 0.6.X & associated updates #92 (comment)
  • the new() functions are already public and untouched by this PR. The Default impl materializes the existence of this public no-argument constructor (and pleases clippy). Happy to tweak.

@huitseeker huitseeker force-pushed the rand-update branch 2 times, most recently from d493d9b to 495e0b3 Compare February 20, 2019 20:08
@huitseeker huitseeker force-pushed the rand-update branch 3 times, most recently from 86d3f16 to 495e0b3 Compare February 26, 2019 03:54
@apoelstra apoelstra merged commit 7234606 into rust-bitcoin:master Feb 26, 2019
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.

None yet

4 participants