From 2c79e6ba4ed8c0be35a547cc7c5991f2f1e22a58 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Mon, 13 Jan 2025 08:06:27 -0600 Subject: [PATCH] fix: fixes anvil-zksync failing on ubuntu-latest (#527) * fix: fix builds for releases * chore: bump base image * chore: update to 22:04 explicitly * chore: fix lint * chore: fix lint issue * fix lint errors --- .github/workflows/release.yml | 10 +++++++--- Cross.toml | 12 ++++++------ Makefile | 4 ++++ crates/core/src/fork.rs | 2 +- e2e-tests-rust/src/utils.rs | 3 +-- spec-tests/src/utils.rs | 3 +-- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7a55cbc..3f74d1e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,9 +41,9 @@ jobs: ] include: - arch: x86_64-unknown-linux-gnu - platform: ubuntu-20.04 + platform: ubuntu-24.04 - arch: aarch64-unknown-linux-gnu - platform: ubuntu-20.04 + platform: ubuntu-24.04 - arch: x86_64-apple-darwin platform: macos-latest - arch: aarch64-apple-darwin @@ -77,7 +77,11 @@ jobs: - name: Build anvil-zksync for ${{ matrix.arch }} run: | - make build-${{ matrix.arch }} + if [[ "${{ matrix.arch }}" == *"linux"* ]]; then + make build-static-${{ matrix.arch }} + else + make build-${{ matrix.arch }} + fi - name: Rename and move binary run: | diff --git a/Cross.toml b/Cross.toml index cb732fa5..93b229ef 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,14 +1,14 @@ -# Cross.toml - [target.x86_64-unknown-linux-gnu] +image = "ubuntu:24.04" pre-build = [ "export DEBIAN_FRONTEND=noninteractive", "export TZ=Etc/UTC", "dpkg --add-architecture $CROSS_DEB_ARCH", - "apt update -q && apt upgrade -yq && apt install --assume-yes --no-install-recommends libclang-10-dev clang-10 cmake build-essential pkg-config libssl-dev:$CROSS_DEB_ARCH libsasl2-dev llvm-dev gnutls-bin", - "apt install -y gcc-10 g++-10", - "update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10", - "update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10" + "apt update -q && apt upgrade -yq", + "apt install --assume-yes --no-install-recommends libclang-14-dev clang-14 cmake build-essential pkg-config libssl-dev:$CROSS_DEB_ARCH libsasl2-dev llvm-14-dev gnutls-bin", + "apt install -y gcc-11 g++-11", + "update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11", + "update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11" ] [target.aarch64-unknown-linux-gnu] diff --git a/Makefile b/Makefile index 40a11209..630f32d9 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,10 @@ run: all build-%: cross build --bin anvil-zksync --target $* --release +# Build the Rust project for a specific target (static build). +build-static-%: + RUSTFLAGS='-C target-feature=+crt-static' OPENSSL_STATIC=1 cross build --bin anvil-zksync --target $* --release + # Build the Rust documentation rust-doc: cargo doc --no-deps --open diff --git a/crates/core/src/fork.rs b/crates/core/src/fork.rs index 9f98be2d..83f9907e 100644 --- a/crates/core/src/fork.rs +++ b/crates/core/src/fork.rs @@ -552,7 +552,7 @@ impl ForkDetails { if !block_details .protocol_version - .map_or(false, supported_protocol_versions) + .is_some_and(supported_protocol_versions) { return Err(eyre!("This block is using the unsupported protocol version: {:?}. This binary supports versions {}.", block_details.protocol_version, diff --git a/e2e-tests-rust/src/utils.rs b/e2e-tests-rust/src/utils.rs index 64bf62e6..71de3b50 100644 --- a/e2e-tests-rust/src/utils.rs +++ b/e2e-tests-rust/src/utils.rs @@ -66,8 +66,7 @@ impl LockedPort { /// or is not needed anymore. impl Drop for LockedPort { fn drop(&mut self) { - self.lockfile - .unlock() + fs2::FileExt::unlock(&self.lockfile) .with_context(|| format!("failed to unlock lockfile for port={}", self.port)) .unwrap(); } diff --git a/spec-tests/src/utils.rs b/spec-tests/src/utils.rs index 8ba96c20..f5cadbc0 100644 --- a/spec-tests/src/utils.rs +++ b/spec-tests/src/utils.rs @@ -64,8 +64,7 @@ impl LockedPort { /// or is not needed anymore. impl Drop for LockedPort { fn drop(&mut self) { - self.lockfile - .unlock() + fs2::FileExt::unlock(&self.lockfile) .with_context(|| format!("failed to unlock lockfile for port={}", self.port)) .unwrap(); }