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

build: Add Rust to reprobuilds so we can bundle the cln-grpc plugin with it #5421

Merged
merged 6 commits into from
Jul 21, 2022

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Jul 13, 2022

Keeping my fingers crossed it just works out of the box :-)

There is a dummy version with CHANGELOG and tag v0.99.1 at cdecker@f9bcb25 which can be used to check everybody agrees on the hashes:

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

ACK 0c1d916

@cdecker
Copy link
Member Author

cdecker commented Jul 14, 2022

ACK 0c1d916

Where you able to reproducibly build the test release?

@vincenzopalazzo
Copy link
Collaborator

Where you able to reproducibly build the test release?

Damnt! i forgot to submit the new review! really? :/

Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Mh I just acked a couple hours ago when the build start on my normal computer before finish the space and abort the process in the middle.

From a clean cloud machine I have problems, so I will redo my review and adding the problem that I'm facing below.

In addition, I did not found the v0.99.1 tag in your repo and I just checkout the commit cdecker@f9bcb25

There is anythings that I'm doing wrong?

@@ -2,6 +2,8 @@ FROM bionic

ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV RUST_PROFILE=release
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mh! by following the what there is written in https://lightning.readthedocs.io/REPRODUCIBLE.html#builder-image-setup during the command exectution

sudo docker build -t cl-repro-bionic - < Dockerfile.bionic

i receive the following message

gitpod /workspace/tmp/lightning/contrib/reprobuild ((f9bcb2510...)) $ sudo docker build -t cl-repro-bionic - < Dockerfile.bionic
Sending build context to Docker daemon  3.584kB
Step 1/13 : FROM bionic
pull access denied for bionic, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

assuming that we need to update the build system? and you are not see this because you have the image already cloned?

Copy link
Member Author

Choose a reason for hiding this comment

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

You need to also build the base image, a couple of lines above: https://lightning.readthedocs.io/REPRODUCIBLE.html#base-image-creation

That will build the ubuntu bionic image for example using solely the installation medium contents (fetched from the web), and then we build on top of that known good state.

Copy link
Member Author

Choose a reason for hiding this comment

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

To get the tags you might have to git fetch --tags, but I thought it should work out of the box. If that doesn't work you can always git fetch cdecker refs/tags/v0.99.1:v0.99.1

Copy link
Collaborator

Choose a reason for hiding this comment

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

To get the tags you might have to git fetch --tags, but I thought it should work out of the box. If that doesn't work you can always git fetch cdecker refs/tags/v0.99.1:v0.99.1

Mh! I do not find any tag with this name on your repository https://github.com/cdecker/lightning/tags

Copy link
Member Author

@cdecker cdecker Jul 14, 2022

Choose a reason for hiding this comment

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

Oops, my bad:

git push origin --tags
Enumerating objects: 18, done.
Counting objects: 100% (18/18), done.
Delta compression using up to 8 threads
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 13.00 KiB | 1.18 MiB/s, done.
Total 18 (delta 0), reused 17 (delta 0)
To github.com:cdecker/lightning.git
 * [new tag]             v0.99.1 -> v0.99.1

Please ignore my comments above, I forgot to push the tag 🤦

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, no problem :)

In addition, when I ran the following command
➜ lightning git:(repobuild/v0.99.1) ✗ sudo docker run --rm -v $(pwd):/repo -ti cl-repro-bionic

I receive the following error at the end
cp: target '/repo/release/' is not a directory

and I also noted that the docs contain a path different from what you posted in the PR

In particular, you posted

release/clightning-v0.99.1-Ubuntu-18.04.tar.xz

The doc contains

/repo/release/clightning-v0.9.0rc1-Ubuntu-18.04.tar.xz

@niftynei
Copy link
Collaborator

Was not able to reproduce.

Checked out this branch. Ran

sudo docker build -t cl-repro-bionic - < contrib/reprobuild/Dockerfile.bionic
git co v0.99.1
sudo docker run --rm -v $(pwd):/repo -ti cl-repro-bionic

These are the shas it produces. The .zip is correct, the built binaries are wrong.

Do I need to do any configurations to get it to work? I tried reconfiguring with rust on and rebuilding but got the same result.

8c547e07e90ff70892c90c9c2722573b7aaf22298c7e58d1e8e1cfdcc8b5fcbe  clightning-v0.99.1-Ubuntu-18.04.tar.xz
b73b295a1ee6fb59a5d6e7a50ab4181caec86f51596031a764798807263d6e43  clightning-v0.99.1-Ubuntu-20.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  clightning-v0.99.1.zip

@cdecker
Copy link
Member Author

cdecker commented Jul 16, 2022

That is very interesting, retrying a couple of times I do get different results, and sometimes they even match your hashes:

8c547e07e90ff70892c90c9c2722573b7aaf22298c7e58d1e8e1cfdcc8b5fcbe  release/clightning-v0.99.1-Ubuntu-18.04.tar.xz
b73b295a1ee6fb59a5d6e7a50ab4181caec86f51596031a764798807263d6e43  release/clightning-v0.99.1-Ubuntu-20.04.tar.xz
bc4fe907b91cd9beb35d9bc5c08dde373ba12abedf457ef14d323b47ad0f983e  release/clightning-v0.99.1-Ubuntu-22.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  release/clightning-v0.99.1.zip
51aa5054a4eaa9324318ab26c871e2ac98ada1d5e4de86103c70510ffefc0abd  release-v1/clightning-v0.99.1-Ubuntu-18.04.tar.xz
5b564a1f0acfeecd20dc3db1210527a501237bfb15e33b995c4f168bd0c45363  release-v1/clightning-v0.99.1-Ubuntu-20.04.tar.xz
802441edbbfd1a8b88368598abc2ebd2044147d6b112cc2f9f65a1d31ef4eb2d  release-v1/clightning-v0.99.1-Ubuntu-22.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  release-v1/clightning-v0.99.1.zip
51aa5054a4eaa9324318ab26c871e2ac98ada1d5e4de86103c70510ffefc0abd  release-v2/clightning-v0.99.1-Ubuntu-18.04.tar.xz
5b564a1f0acfeecd20dc3db1210527a501237bfb15e33b995c4f168bd0c45363  release-v2/clightning-v0.99.1-Ubuntu-20.04.tar.xz
802441edbbfd1a8b88368598abc2ebd2044147d6b112cc2f9f65a1d31ef4eb2d  release-v2/clightning-v0.99.1-Ubuntu-22.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  release-v2/clightning-v0.99.1.zip

I'm wondering if it is because I had a dirty tree during the first runs. But we are cloning a clean repo as first step, then go through the tarball which matches, and build from there. I'll see if doing it from a clean tree works any more reliable.

@cdecker
Copy link
Member Author

cdecker commented Jul 17, 2022

Full sequence of steps:

git clone https://github.com/cdecker/lightning.git /tmp/reprobuild
cd /tmp/reprobuild
git checkout v0.99.1 # HEAD is now at f9bcb2510 v0.99.1
sudo docker run --rm -v $(pwd):/repo -ti cl-repro-bionic
sudo docker run --rm -v $(pwd):/repo -ti cl-repro-focal 
sudo docker run --rm -v $(pwd):/repo -ti cl-repro-jammy
sha256sum release/*
4a2673e57d7e2be17ddc1c5b0ea7397b3dc60b4e70a0c015fe92c3cdca81bd3f  release/clightning-v0.99.1-Ubuntu-18.04.tar.xz
82cbd1ad474f14e18b2ef47164f44f7d66b78bf154cea26fe8e656b62cce7796  release/clightning-v0.99.1-Ubuntu-20.04.tar.xz
9a009dbfd8c0074143fff7449689c1c8b0462a4a7476ad7597ae57ccee7413b2  release/clightning-v0.99.1-Ubuntu-22.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  release/clightning-v0.99.1.zip

@cdecker
Copy link
Member Author

cdecker commented Jul 17, 2022

Strange, would you mind sharing one of the ubuntu 20.04 or ubuntu 18.04 bundles? Maybe we can pin down where the diffs are.

@cdecker
Copy link
Member Author

cdecker commented Jul 17, 2022

Reran the reprobuilds on a new VM generating the builder images as per instructions, and I'm getting the following results:

4a2673e57d7e2be17ddc1c5b0ea7397b3dc60b4e70a0c015fe92c3cdca81bd3f  clightning-v0.99.1-Ubuntu-18.04.tar.xz
82cbd1ad474f14e18b2ef47164f44f7d66b78bf154cea26fe8e656b62cce7796  clightning-v0.99.1-Ubuntu-20.04.tar.xz
9a009dbfd8c0074143fff7449689c1c8b0462a4a7476ad7597ae57ccee7413b2  clightning-v0.99.1-Ubuntu-22.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  clightning-v0.99.1.zip

Matching my previous results, so I'm pretty convinced now that this is the right result.

@vincenzopalazzo
Copy link
Collaborator

30a4479b298a6e6856c8f112835eb2439d83f96112ef332dbeed786546753564  clightning-v0.99.1-Ubuntu-18.04.tar.xz
2b7fb73c4a7cf241bd2f3f33e52acd0817f1485ac9ff61c808bf6bb6ca116680  clightning-v0.99.1-Ubuntu-20.04.tar.xz
4c08e78bc8a1b35572625f166a01ea1507c8651f32489ea1bd35b1336c69d05b  clightning-v0.99.1-Ubuntu-22.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  clightning-v0.99.1.zip

These are mine, look different.

Do you need any particular data to debug it?

@cdecker
Copy link
Member Author

cdecker commented Jul 21, 2022

Ok, this is getting very strange. I took over @vincenzopalazzo's VM, trying to replicate exactly where the difference was, and I thought I had it (the builder docker image not being built with the v0.99.1 version of the Dockerfile), but it spits out different results. Then I tried to go through each step individually on both my machine and the VM, and they produce the same binaries, but different from any of the prior runs.

I'm starting to believe this is something like a date thing, that is reproducible as long as the builds are close enough together, but not if done too much time apart. For reference here are the steps I used on a completely clean VM (or after deleting all the docker images that are used in the build):

cd /tmp
git clone https://github.com/cdecker/lightning.git repo
cd /tmp/repo
git describe
# v0.11.0.1-239-gf67ab2a86
git checkout v0.99.1
# ...
# HEAD is now at f9bcb2510 v0.99.1
mkdir release  # Directory where artifacts will land

# Build the focal base image from installation medium
sudo docker run --rm -v $(pwd):/build ubuntu:22.04 \
     bash -c "apt-get update && apt-get install -y debootstrap && debootstrap focal /build/focal"
sudo tar -C focal -c . | sudo docker import - focal

# Build the builder image
sudo docker build -t cl-repro-focal - < contrib/reprobuild/Dockerfile.focal

sudo docker run --rm -v $(pwd):/repo -ti cl-repro-focal

This resulted in the following hashes on both machines:

a4453d510323dc0a0b423bbab18eacb260072b5c43fcdcc8572f056fe636222c  clightning-v0.99.1-Ubuntu-20.04.tar.xz
8ac5e53a6ec9b62afbf898ec089e7d9bfe5608010047029d3345081d419118db  clightning-v0.99.1.zip

I will look into where the differences are as soon as I wrap my head around the diffoscope output.

@cdecker
Copy link
Member Author

cdecker commented Jul 21, 2022

Ok, new attempt. I think I found the mismatch: dependencies updating under our feet.

So now we commit the Cargo.lock file which should ensure that we always pull exactly the same dependency versions, whereas without it was pulling in the latest compatible one, as determined by our version restrictions. So far I have reproduced these hashes on 3 machines (laptop + 2 VMs). Hopefully we can get this resolved with this.

🚧 Please notice that the v0.99.1 has been updated and may need to be pulled again: git fetch origin --tags -f (where origin is my fork at https://github.com/cdecker/lightning.git). 🚧

777f2c32bc0193d2a019a794937ea944a603279f6fdd38ce6665eafe377d4b9e  clightning-v0.99.1-Ubuntu-18.04.tar.xz
5eaf5ba337366d53d869c6122fd363e506caa63846a3e791161de9fd19fe0090  clightning-v0.99.1-Ubuntu-20.04.tar.xz
5f256cc3d3ab38592f7fc37143390431616e4f3a85ac838452419c3797706967  clightning-v0.99.1-Ubuntu-22.04.tar.xz
61e2e96aa08372cf3f6d2fab73a4acfa7c1bd6866ac9f57c9c8dabe1fcd1ebeb  clightning-v0.99.1.zip

Changelog-Added: build: Reproducible builds now include rust binaries such as the `cln-grpc` plugin
We also had to switch around the directories, so now the instructions
assume you're in the repo root directory
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

I'm starting the procedure in a clean and update tag, but in the meanwhile I added a small comment before I will forget it :)

@@ -146,6 +148,8 @@ repository (remember to checkout the tag you are trying to build):

```bash
sudo docker run --rm -v $(pwd):/repo -ti cl-repro-bionic
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe this is a change that need to be done inside the docker container, but during the the process that start in this line I need to ran mkdir release and rerun the process again.

Maybe can be done inside the docker container or at least documented it?

@vincenzopalazzo
Copy link
Collaborator

vincenzopalazzo commented Jul 21, 2022

Ok, this is my result!

777f2c32bc0193d2a019a794937ea944a603279f6fdd38ce6665eafe377d4b9e  clightning-v0.99.1-Ubuntu-18.04.tar.xz
5eaf5ba337366d53d869c6122fd363e506caa63846a3e791161de9fd19fe0090  clightning-v0.99.1-Ubuntu-20.04.tar.xz
5f256cc3d3ab38592f7fc37143390431616e4f3a85ac838452419c3797706967  clightning-v0.99.1-Ubuntu-22.04.tar.xz
61e2e96aa08372cf3f6d2fab73a4acfa7c1bd6866ac9f57c9c8dabe1fcd1ebeb  clightning-v0.99.1.zip

Let's rerun this tomorrow, and let's see what happens!

@niftynei
Copy link
Collaborator

ACK 6725d02

@niftynei niftynei merged commit b3fde87 into ElementsProject:master Jul 21, 2022
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.

3 participants