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

Update what deps to pin #1977

Merged
merged 2 commits into from Aug 10, 2023
Merged

Conversation

yancyribbens
Copy link
Contributor

Update the deps to pin so that they match contrib/test.sh: https://github.com/rust-bitcoin/rust-bitcoin/blob/master/bitcoin/contrib/test.sh#L27

cargo update -p serde --precise 1.0.156
cargo update -p half --precise 1.7.1
Copy link
Member

Choose a reason for hiding this comment

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

We still pin half in the fuzz tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake on my part for not confirming ahead of time, but I'm not sure why these deps need to be pinned. @apoelstra mentioned they where out of sync now with contrib/test.sh #1969.

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 it's probably fine not to mention half since downstream users won't need to pin it.

Re "not sure why", try compiling with 1.48.0 without the pin, and see what happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested building rust-bitcoin as well as a downstream crate that depends on rust-bitcoin without the pinning and both built without a problem using cargo +1.48 build. To build rust-bitcoin, I had to copy Cargo-recent.lock -> Cargo.lock. I tested the builds inside a clean bsd jail to be sure there wasn't any cargo cache or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also note the downstream crate is pointing at the master branch on git that I tested.

Copy link
Member

Choose a reason for hiding this comment

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

If you are using Cargo-recent.lock then you're not testing the pins.

For my part I can't build with 1.48.0 with the current set of pins, because proc-macros2 doesn't build with the latest MSRV. When I add that pin, I then can't build because of some incompatibility with hashes macros.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After a clean install the pins in ./bitcoin/contrib/test.sh without changing Cargo.lock:

cargo update -p serde_json --precise 1.0.99
cargo update -p serde --precise 1.0.156

however this does not build for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you are using Cargo-recent.lock then you're not testing the pins.

If that's the case, then do the pins actually need to be run in ./bitcoin/contrib/test.sh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested taking the pins out of test.sh and the test suits passes.

apoelstra
apoelstra previously approved these changes Aug 7, 2023
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 634f873

@apoelstra
Copy link
Member

apoelstra commented Aug 7, 2023

Ok, the following series of actions doesn't work:

cargo +1.48.0 update
#cargo +1.48.0 build ## will fail, needs serde pins

# serde pins copied from contrib/test.sh
cargo update -p serde_json --precise 1.0.99
cargo update -p serde --precise 1.0.156
#cargo +1.48.0 build ## will fail, needs proc-macro2 pin

cargo update -p quote --precise 1.0.30 # needed to pin proc-macro2
cargo update -p proc-macro2 --precise 1.0.63
#cargo +1.48.0 build ## will fail, gives me macro errors

# Tell cargo to actually build the code in the repo, don't download other random code and build that instead.
# This is so surprising and weird that it probably should get a CVE..
cargo +1.48.0 update -p bitcoin:0.30.1 --precise 0.30.0

cargo +1.48.0 build # Ok now this will build.

# Let's try with all features now..
#cargo +1.48.0 build --all-features --all-targets ## will fail, needs serde_test pin

cargo update -p serde_test --precise 1.0.175
cargo +1.48.0 build --all-features --all-targets ## Ok, good now

While the macro errors appear to originate inside the repo, they don't occur when I use Cargo-recent.lock. Investigating further..

Edit: Ok, the issue seems to be that after running cargo update, it starts trying to build a random cached version of rust-bitcoin with the version of bitcoin_hashes from the repo, which is clearly a cargo bug.

Edit 2: Got it working. Updated code. I think that @yancyribbons is right that the half pin isn't needed.v

@tcharding
Copy link
Member

tcharding commented Aug 7, 2023

Tell cargo to actually build the code in the repo, don't download other random code and build that instead.
This is so surprising and weird that it probably should get a CVE..
cargo +1.48.0 update -p bitcoin:0.30.1 --precise 0.30.0

Holy Moly, I did not get this step any time I tried to workout the pins.

@tcharding
Copy link
Member

tcharding commented Aug 8, 2023

Confirming sequence of command posted above. So the readme needs to be something like:

# To build without running tests, pin these four:
cargo update -p serde_json --precise 1.0.99
cargo update -p serde --precise 1.0.156
cargo update -p quote --precise 1.0.30
cargo update -p proc-macro2 --precise 1.0.63

# To build and run tests, also pin:
cargo update -p serde_test --precise 1.0.175

@yancyribbens
Copy link
Contributor Author

Both cargo build and cargo test worked for me with the four pins:

cargo update -p serde_json --precise 1.0.99
cargo update -p serde --precise 1.0.156
cargo update -p quote --precise 1.0.30
cargo update -p proc-macro2 --precise 1.0.63

I didn't need to run the following to run test:

cargo update -p serde_test --precise 1.0.175

note I tested this on a clean install.

@yancyribbens
Copy link
Contributor Author

The README has been updated to include the four pins.

@apoelstra
Copy link
Member

This PR now has a stray "add max standard tx weight to transaction" commit in it which does not match any other PR.

@yancyribbens
Copy link
Contributor Author

@apoelstra thanks. Rebase gone bad I guess :)

@apoelstra
Copy link
Member

Looks good! As a separate PR we should add a test that directly tries to use the latest deps from cargo (and that will require the pins).

tcharding
tcharding previously approved these changes Aug 8, 2023
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 8ac3eb2

apoelstra
apoelstra previously approved these changes Aug 8, 2023
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 8ac3eb2

@tcharding
Copy link
Member

Strange that you didn't need to pin serde_test, I rechecked on my system and this script does not run if I comment out the serde_test pin

#!/bin/sh

rm Cargo.lock
cargo +1.48.0 update
#cargo +1.48.0 build ## will fail, needs serde pins

# serde pins copied from contrib/test.sh
cargo update -p serde_json --precise 1.0.99
cargo update -p serde --precise 1.0.156
#cargo +1.48.0 build ## will fail, needs proc-macro2 pin

cargo update -p quote --precise 1.0.30 # needed to pin proc-macro2
cargo update -p proc-macro2 --precise 1.0.63
#cargo +1.48.0 build ## will fail, gives me macro errors

cargo +1.48.0 update -p bitcoin:0.30.1 --precise 0.30.0
# cargo +1.48.0 build ## will fail, needs serde_test pin

cargo update -p serde_test --precise 1.0.175

cargo +1.48.0 test

@apoelstra
Copy link
Member

@tcharding oh, oops. So, CI currently does not test pinning at all, because it exclusively tests with the fixed lockfiles. I think we do need the serde_test pin.

@tcharding
Copy link
Member

So, CI currently does not test pinning at all

Yeah, sadly I can feel a multi hour bash hacking session coming on ...

@sanket1729
Copy link
Member

The following works for rust-minsicript
https://github.com/rust-bitcoin/rust-miniscript/blob/d1c61e49316f00835dea13a7ec81eb85f13e3742/contrib/test.sh#L24-L31

Note that not all of these would be required as rust-miniscript also has a dev dependency on bitcoind crate.

@yancyribbens
Copy link
Contributor Author

Strange that you didn't need to pin serde_test, I rechecked on my system and this script does not run if I comment out the serde_test pin

Oops yeah you're right, serde_test pin is required. I think maybe I accidently ran cargo test without adding 1.48 yesterday.

@yancyribbens
Copy link
Contributor Author

Added cargo update -p serde_test --precise 1.0.175 to the README.md

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 443a4c5

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 443a4c5

@apoelstra apoelstra merged commit b60c192 into rust-bitcoin:master Aug 10, 2023
29 checks passed
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