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

sigp/lcli container image only built for modern x86 CPUs #4370

Closed
dboreham opened this issue Jun 4, 2023 · 4 comments · Fixed by #5069
Closed

sigp/lcli container image only built for modern x86 CPUs #4370

dboreham opened this issue Jun 4, 2023 · 4 comments · Fixed by #5069
Labels
bug Something isn't working good first issue Good for newcomers infra-ci

Comments

@dboreham
Copy link

dboreham commented Jun 4, 2023

Description

The lcli binary shipped in the sigp/lcli container image is built to run on a CPU with extensions (probably AVX2?) that are not present on all x86 CPUs. The result is that when the tool is run on such a machine, it throws an illegal instruction exception.

Such CPUs are not particularly rare : we have encountered the issue both in GitHub runners and in VMs in our internal build infra.

Version

Tested this container image and also a local built from the current stable branch.

Present Behaviour

The lcli tool, when run with the insecure-validators subcommand, throws an illegal instruction exception on some CPUs.

e.g.:

$  ./lcli insecure-validators --count 4 --base-dir $(pwd) --node-count 4
Validator 1
Illegal instruction (core dumped)

Expected Behaviour

Should not throw illegal instruction exception.

Steps to resolve

The lcli container should be built with a portable compiler target, but it isn't.

@dboreham
Copy link
Author

dboreham commented Jun 4, 2023

It appears that although the Dockerfile has the arg PORTABLE which is set =true in the build script, PORTABLE doesn't actually do anything:

$ grep -R PORTABLE .
./.github/workflows/docker.yml:                      --build-arg PORTABLE=true \
./lcli/Dockerfile:ARG PORTABLE
./lcli/Dockerfile:ENV PORTABLE $PORTABLE

@dboreham
Copy link
Author

dboreham commented Jun 4, 2023

Related: #1395

@dboreham
Copy link
Author

dboreham commented Jun 4, 2023

This fixes it for me:

diff --git a/lcli/Dockerfile b/lcli/Dockerfile
index 98f33f215..485ebfd5b 100644
--- a/lcli/Dockerfile
+++ b/lcli/Dockerfile
@@ -6,7 +6,7 @@ RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-de
 COPY . lighthouse
 ARG PORTABLE
 ENV PORTABLE $PORTABLE
-RUN cd lighthouse && make install-lcli
+RUN if [ "$PORTABLE" = true ] ; then export FEATURES=portable; fi && cd lighthouse && make install-lcli

 FROM ubuntu:22.04
 RUN apt-get update && apt-get -y upgrade && apt-get clean && rm -rf /var/lib/apt/lists/*
$ ./lcli-fixed insecure-validators --count 4 --base-dir $(pwd) --node-count 4
Validator 1
WARN: Scrypt parameters are too weak (n: 2, p: 1, r: 8), we recommend (n: 262144, p: 1, r: 8)
Validator 2
WARN: Scrypt parameters are too weak (n: 2, p: 1, r: 8), we recommend (n: 262144, p: 1, r: 8)
Validator 3
WARN: Scrypt parameters are too weak (n: 2, p: 1, r: 8), we recommend (n: 262144, p: 1, r: 8)
Validator 4
WARN: Scrypt parameters are too weak (n: 2, p: 1, r: 8), we recommend (n: 262144, p: 1, r: 8)

@michaelsproul
Copy link
Member

Good catch, thanks

Would you mind opening a PR to fix it? My preffered fix would be to remove the PORTABLE arg and pass FEATURES through from the Dockerfile. The existing makefile will then use those features here:

lighthouse/Makefile

Lines 53 to 58 in c547a11

# Builds the lcli binary in release (optimized).
install-lcli:
cargo install --path lcli --force --locked \
--features "$(FEATURES)" \
--profile "$(PROFILE)" \
$(CARGO_INSTALL_EXTRA_FLAGS)

We should also update the Github action that builds the image so that it uses FEATURES=portable instead of PORTABLE=true:

build-docker-lcli:
runs-on: ubuntu-22.04
needs: [extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
steps:
- uses: actions/checkout@v3
- name: Dockerhub login
run: |
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
- name: Build lcli dockerfile (with push)
run: |
docker build \
--build-arg PORTABLE=true \
--tag ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX} \
--file ./lcli/Dockerfile .
docker push ${LCLI_IMAGE_NAME}:${VERSION}${VERSION_SUFFIX}

@michaelsproul michaelsproul added bug Something isn't working good first issue Good for newcomers infra-ci labels Jun 7, 2023
aBMania added a commit to aBMania/lighthouse that referenced this issue Jan 15, 2024
mergify bot pushed a commit that referenced this issue Jan 30, 2024
* Set lcli docker build to use portable feature (#4370)

* Merge remote-tracking branch 'origin/unstable' into unstable
danielrachi1 pushed a commit to danielrachi1/lighthouse that referenced this issue Feb 14, 2024
* Set lcli docker build to use portable feature (sigp#4370)

* Merge remote-tracking branch 'origin/unstable' into unstable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers infra-ci
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants