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

Vendor 0.21.2 #79

Merged
merged 5 commits into from
Jan 8, 2024
Merged

Vendor 0.21.2 #79

merged 5 commits into from
Jan 8, 2024

Conversation

tcharding
Copy link
Member

This is #77 without the version bump patch.

Upgrade to a new way of vendoring Core and vendor version 0.21.2 - note please this will be directly followed by an upgrade to 0.21-final. Done separately to proof out the workflow of such an upgrade.

@apoelstra
Copy link
Member

I'm gonna go ahead and review/ACK this although strictly speaking the intermediate commits don't compile. I think this crate has historically had a lot of vendoring-related grief and bisection is probably already pretty busted, and this puts us on the start to fixing that.

@tcharding
Copy link
Member Author

Yes, my bad I could have mentioned that - they explicitly do not compile, and I had exactly the same thoughts as you mention. It would be nice if we could start getting them all to compile from now. The do in secp so I think we should, I"ll try and keep that as a goal.

# not specified a revision, just copy the directory rather than using 'git clone'.
# This lets us use non-git repos or dirty source trees as secp sources.
if [ "$CORE_VENDOR_CP_NOT_CLONE" == "yes" ]; then
cp -r "$CORE_VENDOR_REPO" .
Copy link
Member

Choose a reason for hiding this comment

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

In b83e1de:

In the rust-secp version of this it's a cp "$VENDOR_REPO" "$DIR". Why did you change $DIR to .? It causes the following chmod to fail.

Copy link
Member Author

@tcharding tcharding Dec 19, 2023

Choose a reason for hiding this comment

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

At the time I couldn't work out a sane way to call the script, I was using

 CORE_VENDOR_CP_NOT_CLONE=yes CORE_VENDOR_REPO=/home/tobin/build/github.com/tcharding/bitcoin contrib/vendor-bitcoin-core.sh v0.21-final

But that results in bitcoin/bitcoin. How do you call it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you using CORE_VENDOR_REPO=/path/to/bitcoin/*

Copy link
Member

Choose a reason for hiding this comment

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

No, just CORE_VENDOR_REPO=/path/to/bitcoin. As in

CORE_VENDOR_CP_NOT_CLONE=yes \
CORE_VENDOR_GIT_ROOT=.. \
CORE_VENDOR_REPO=/nix/store/77qhrhjq230jh6zswzg2nfxirpw4zdd3-source \
CORE_VENDOR_DEPEND_DIR=./depend2/ \
./contrib/vendor-bitcoin-core.sh -f

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 not specifying CORE_VENDOR_DEPEND_DIR then it will default to depend/. And you'll get a directory depend/bitcoin as expected. I'm not sure how you would get bitcoin/bitcoin.

Copy link
Member Author

Choose a reason for hiding this comment

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

ooooo, TIL, if the destination directory exists already then the behaviour of cp is different to if it does not exist - I have never realized this, wow, mind blown. If the directory does not exist it is as you say, it creates the directory correctly, but if it exists then it gets copied into the existing one.

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 still don't know how this was happening though because we explicitly rm -rf $DIR right above. Anyways, onwards and upwards!

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 have never realized this, wow, mind blown

FWIW I always use rsync and never use cp -r, its still surprising that I did not know the nuances of cp.

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't be opposed to using rsync here, FWIW, though it would be an extra dependency I'd have to pull into my nix derivation and it's probably overkill here.

Agreed that cp is nuts :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I didn't mean to use it here, I just meant on my machine I never use cp for directories.

@tcharding
Copy link
Member Author

Force pushed the change discussed above, and tested with CORE_VENDOR_CP_NOT_CLONE=yes CORE_VENDOR_REPO=/home/tobin/build/github.com/tcharding/bitcoin contrib/vendor-bitcoin-core.sh v0.21.2

Thanks for you patience :)

shift
done

echo "Vendoring Bitcoin Core version: $CORE_VENDOR_VERSION"
Copy link
Member

Choose a reason for hiding this comment

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

In 902bc9c:

The rust-secp version of this allows you to leave the revision unset and just use whatever code is present in the directory you're copying. We should preserve this behavior.

Copy link
Member Author

@tcharding tcharding Dec 23, 2023

Choose a reason for hiding this comment

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

Cracking the whip on me, I was too lazy to parse out the version number using regex - I'll do it now :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, that wasn't so painful.


# Check out specified revision
pushd "$DIR" > /dev/null
git checkout "$CORE_VENDOR_VERSION"
Copy link
Member

Choose a reason for hiding this comment

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

In 902bc9c:

In particular, here you unconditionally do a git checkout. This will not work if you are copying a source tree that is not in git.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now mimic's the secp script.

Instead of using a subtree add a script to vendor Bitcoin Core. Based on
the one in `rust-secp256k1`.
Run the vendoring script:

   `./vendor-bitcoin-core.sh v0.21.2`
Fix the build after vendoring new version of Core.

Includes changes to the build script by Jake and update to the C++
toolchain suggested by Richard.

Co-developed-by: Jake Rawsthorne <jake@jakerawsthorne.co.uk>
Co-developed-by: Richard Ulrich <richard.ulrich@seba.swiss>
@tcharding
Copy link
Member Author

Now more like the secp script and includes -h option.

$ contrib/vendor-bitcoin-core.sh -h

Usage: script OPTIONS [bitcoin-core-version]

OPTIONS:

 -f    Vendor even if there are local changes to the rust-bitcoinconsensus git index
 -h    Print this help an exit

Example:

    vendor-bitcoin-core v0.21.2

@apoelstra
Copy link
Member

Awesome :) we are super close. The vendoring script works now, but when I check the vendored code against the source I see

diff -r depend/bitcoin/src/clientversion.cpp depend2/bitcoin/src/clientversion.cpp
28c28
< #define GIT_COMMIT_ID "12d7ec38e2c69539d6d9d7e99c4da8e41b7824d6"
---
> #define GIT_COMMIT_ID "af591f2068d0363c92d9756ca39c43db85e5804c"

These two commit IDs are the tip of this PR in this repo and the commit from Bitcoin Core that we're vendoring.

This is suuper weird. If you look at bitcoin/src/clientversion.cpp you will find neither line. Instead you will see

  //! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives. $Format:%n#define GIT_COMMIT_ID "%H"$

How does git do this and under what circumstances? I don't know. But I worry that it is putting our commit ID into this line rather than the Core commit ID. OTOH I don't think any of these constants are used by libbitcoinconsensus so maybe it doesn't matter..

Anyway I think I should just whitelist this specific file and forget about it. But let me know what you think.

@tcharding
Copy link
Member Author

tcharding commented Dec 27, 2023

But I worry that it is putting our commit ID into this line rather than the Core commit ID.

I don't really like the idea of having this change in there, could bite us down the track. A simple hack could be, at the end of the vendoring script, to just grep for GIT_COMMIT_ID and echo a message "manually remove the change to GIT_COMMIT_ID" - we could spit out the old/new lines and the file.

@tcharding
Copy link
Member Author

#define GIT_COMMIT_ID "12d7ec38e2c69539d6d9d7e99c4da8e41b7824d6"

I had a bit of a play and we are still doing something different, I don't get these lines in clientversion.cpp, and they don't exist on this branch?

I tried using clone (and last time I pushed I was using copy)?

@apoelstra
Copy link
Member

I think you need to use git archive or something to populate these lines. I am getting it by using Nix to source the git repo.

I think this is a non-issue because:

  • The offending line doesn't actually appear in the repo; it is already dependent on some git magic that users are unlikely to trigger.
  • The offending #define is not actually used in bitcoinconsensus anywhere.

@tcharding
Copy link
Member Author

Cool, so this is good to go in then, right?

@apoelstra
Copy link
Member

Yep. I'll tweak my scripts to ignore this line and ACK/merge it.

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 12d7ec3

@apoelstra apoelstra merged commit 875511c into rust-bitcoin:master Jan 8, 2024
9 checks passed
@tcharding tcharding deleted the vendor-0.21.2 branch January 9, 2024 02:30
@apoelstra apoelstra mentioned this pull request Feb 7, 2024
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.

2 participants