From beb8f0b8c7a47a1702f2a5a166af0b0720464ae3 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 09:31:31 +0800 Subject: [PATCH 01/22] create docker release action --- .github/workflows/docker.yml | 83 ++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..e9c961133 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,83 @@ +# Publishes the Docker image. + +name: docker + +on: + push: + tags: + - v* + +env: + IMAGE_NAME: ${{ github.repository_owner }}/nanoreth + CARGO_TERM_COLOR: always + DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/nanoreth + DOCKER_USERNAME: ${{ github.actor }} + +jobs: + build-rc: + if: contains(github.ref, '-rc') + name: build and push as release candidate + runs-on: ubuntu-24.04 + permissions: + packages: write + contents: read + strategy: + fail-fast: false + matrix: + build: + - name: "Build and push nanoreth image" + command: "make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push" + steps: + - uses: actions/checkout@v5 + - uses: rui314/setup-mold@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Install cross main + id: cross_main + run: | + cargo install cross --git https://github.com/cross-rs/cross + - name: Log in to Docker + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin + - name: Set up Docker builder + run: | + docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 + docker buildx create --use --name cross-builder + - name: Build and push ${{ matrix.build.name }} + run: ${{ matrix.build.command }} + + build: + if: ${{ !contains(github.ref, '-rc') }} + name: build and push as latest + runs-on: ubuntu-24.04 + permissions: + packages: write + contents: read + strategy: + fail-fast: false + matrix: + build: + - name: "Build and push nanoreth image" + command: "make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push-latest" + steps: + - uses: actions/checkout@v5 + - uses: rui314/setup-mold@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Install cross main + id: cross_main + run: | + cargo install cross --git https://github.com/cross-rs/cross + - name: Log in to Docker + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin + - name: Set up Docker builder + run: | + docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 + docker buildx create --use --name cross-builder + - name: Build and push ${{ matrix.build.name }} + run: ${{ matrix.build.command }} \ No newline at end of file From 03f86c3a8d2842a1e53b8153c292102f6ceca754 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 09:34:59 +0800 Subject: [PATCH 02/22] . --- .github/workflows/docker.yml | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e9c961133..f1db26730 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,42 +14,7 @@ env: DOCKER_USERNAME: ${{ github.actor }} jobs: - build-rc: - if: contains(github.ref, '-rc') - name: build and push as release candidate - runs-on: ubuntu-24.04 - permissions: - packages: write - contents: read - strategy: - fail-fast: false - matrix: - build: - - name: "Build and push nanoreth image" - command: "make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push" - steps: - - uses: actions/checkout@v5 - - uses: rui314/setup-mold@v1 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Install cross main - id: cross_main - run: | - cargo install cross --git https://github.com/cross-rs/cross - - name: Log in to Docker - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin - - name: Set up Docker builder - run: | - docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 - docker buildx create --use --name cross-builder - - name: Build and push ${{ matrix.build.name }} - run: ${{ matrix.build.command }} - build: - if: ${{ !contains(github.ref, '-rc') }} name: build and push as latest runs-on: ubuntu-24.04 permissions: From 166814b2be8964a8a9134542c85190b0f3eca862 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 09:41:17 +0800 Subject: [PATCH 03/22] . --- .github/workflows/docker.yml | 58 ++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f1db26730..72dc5a935 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,35 +14,29 @@ env: DOCKER_USERNAME: ${{ github.actor }} jobs: - build: - name: build and push as latest - runs-on: ubuntu-24.04 - permissions: - packages: write - contents: read - strategy: - fail-fast: false - matrix: - build: - - name: "Build and push nanoreth image" - command: "make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push-latest" - steps: - - uses: actions/checkout@v5 - - uses: rui314/setup-mold@v1 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - cache-on-failure: true - - name: Install cross main - id: cross_main - run: | - cargo install cross --git https://github.com/cross-rs/cross - - name: Log in to Docker - run: | - echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin - - name: Set up Docker builder - run: | - docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 - docker buildx create --use --name cross-builder - - name: Build and push ${{ matrix.build.name }} - run: ${{ matrix.build.command }} \ No newline at end of file + build: + name: build and push as latest + runs-on: ubuntu-24.04 + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v5 + - uses: rui314/setup-mold@v1 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Install cross main + id: cross_main + run: | + cargo install cross --git https://github.com/cross-rs/cross + - name: Log in to Docker + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin + - name: Set up Docker builder + run: | + docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 + docker buildx create --use --name cross-builder + - name: Build and push nanoreth image + run: make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push-latest \ No newline at end of file From d06e7ad7b0bb236b264c315e2afbedfcdde3a7ba Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 09:46:42 +0800 Subject: [PATCH 04/22] . --- Makefile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Makefile b/Makefile index e67aa711e..37ac8cae7 100644 --- a/Makefile +++ b/Makefile @@ -207,3 +207,56 @@ check-features: --package reth-primitives-traits \ --package reth-primitives \ --feature-powerset + + +##@ Docker + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --driver docker-container --name cross-builder` +.PHONY: docker-build-push +docker-build-push: ## Build and push a cross-arch Docker image tagged with the latest git tag. + $(call docker_build_push,$(GIT_TAG),$(GIT_TAG)) + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --driver docker-container --name cross-builder` +.PHONY: docker-build-push-git-sha +docker-build-push-git-sha: ## Build and push a cross-arch Docker image tagged with the latest git sha. + $(call docker_build_push,$(GIT_SHA),$(GIT_SHA)) + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --driver docker-container --name cross-builder` +.PHONY: docker-build-push-latest +docker-build-push-latest: ## Build and push a cross-arch Docker image tagged with the latest git tag and `latest`. + $(call docker_build_push,$(GIT_TAG),latest) + +# Note: This requires a buildx builder with emulation support. For example: +# +# `docker run --privileged --rm tonistiigi/binfmt --install amd64,arm64` +# `docker buildx create --use --name cross-builder` +.PHONY: docker-build-push-nightly +docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with the latest git tag with a `-nightly` suffix, and `latest-nightly`. + $(call docker_build_push,nightly,nightly) + +# Create a cross-arch Docker image with the given tags and push it +define docker_build_push + $(MAKE) build-x86_64-unknown-linux-gnu + mkdir -p $(BIN_DIR)/amd64 + cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/reth $(BIN_DIR)/amd64/reth + + $(MAKE) build-aarch64-unknown-linux-gnu + mkdir -p $(BIN_DIR)/arm64 + cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/reth $(BIN_DIR)/arm64/reth + + docker buildx build --file ./Dockerfile.cross . \ + --platform linux/amd64,linux/arm64 \ + --tag $(DOCKER_IMAGE_NAME):$(1) \ + --tag $(DOCKER_IMAGE_NAME):$(2) \ + --provenance=false \ + --push +endef From 5bdde7035117c9fbea1eeeae2a8816d59db61d65 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 09:54:59 +0800 Subject: [PATCH 05/22] . --- .github/workflows/docker.yml | 2 ++ Makefile | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 72dc5a935..a8507a732 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,6 +6,8 @@ on: push: tags: - v* + branches: + - "*" env: IMAGE_NAME: ${{ github.repository_owner }}/nanoreth diff --git a/Makefile b/Makefile index 37ac8cae7..068fb72c9 100644 --- a/Makefile +++ b/Makefile @@ -245,13 +245,13 @@ docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with # Create a cross-arch Docker image with the given tags and push it define docker_build_push - $(MAKE) build-x86_64-unknown-linux-gnu + $(MAKE) build mkdir -p $(BIN_DIR)/amd64 - cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/reth $(BIN_DIR)/amd64/reth + cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/reth-hl $(BIN_DIR)/amd64/reth-hl - $(MAKE) build-aarch64-unknown-linux-gnu + $(MAKE) build mkdir -p $(BIN_DIR)/arm64 - cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/reth $(BIN_DIR)/arm64/reth + cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/reth-hl $(BIN_DIR)/arm64/reth-hl docker buildx build --file ./Dockerfile.cross . \ --platform linux/amd64,linux/arm64 \ From c7ed9fc8f163052053fe28b9c186b22afc0e89f9 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:02:39 +0800 Subject: [PATCH 06/22] . --- Makefile | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 068fb72c9..943cc342e 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,31 @@ check-features: --package reth-primitives \ --feature-powerset +# The following commands use `cross` to build a cross-compile. +# +# These commands require that: +# +# - `cross` is installed (`cargo install cross`). +# - Docker is running. +# - The current user is in the `docker` group. +# +# The resulting binaries will be created in the `target/` directory. +# For aarch64, set the page size for jemalloc. +# When cross compiling, we must compile jemalloc with a large page size, +# otherwise it will use the current system's page size which may not work +# on other systems. JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to use 64-KiB +# pages. See: https://github.com/paradigmxyz/reth/issues/6742 +build-aarch64-unknown-linux-gnu: export JEMALLOC_SYS_WITH_LG_PAGE=16 + +# No jemalloc on Windows +build-x86_64-pc-windows-gnu: FEATURES := $(filter-out jemalloc jemalloc-prof,$(FEATURES)) + +# Note: The additional rustc compiler flags are for intrinsics needed by MDBX. +# See: https://github.com/cross-rs/cross/wiki/FAQ#undefined-reference-with-build-std +build-%: + RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \ + cross build --bin reth --target $* --features "$(FEATURES)" --profile "$(PROFILE)" ##@ Docker # Note: This requires a buildx builder with emulation support. For example: @@ -245,11 +269,11 @@ docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with # Create a cross-arch Docker image with the given tags and push it define docker_build_push - $(MAKE) build + $(MAKE) build-x86_64-unknown-linux-gnu mkdir -p $(BIN_DIR)/amd64 cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/reth-hl $(BIN_DIR)/amd64/reth-hl - $(MAKE) build + $(MAKE) build-aarch64-unknown-linux-gnu mkdir -p $(BIN_DIR)/arm64 cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/reth-hl $(BIN_DIR)/arm64/reth-hl From b352197e20e1715586b6a7fe6680c6f23b2073bf Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:06:43 +0800 Subject: [PATCH 07/22] . --- Dockerfile.cross | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Dockerfile.cross diff --git a/Dockerfile.cross b/Dockerfile.cross new file mode 100644 index 000000000..8fcaf5d7e --- /dev/null +++ b/Dockerfile.cross @@ -0,0 +1,15 @@ +# This image is meant to enable cross-architecture builds. +# It assumes the reth binary has already been compiled for `$TARGETPLATFORM` and is +# locatable in `./dist/bin/$TARGETARCH` +FROM --platform=$TARGETPLATFORM ubuntu:22.04 + +LABEL org.opencontainers.image.source=https://github.com/hl-archive-node/nanoreth +LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0" + +# Filled by docker buildx +ARG TARGETARCH + +COPY ./dist/bin/$TARGETARCH/reth-hl /usr/local/bin/reth-hl + +EXPOSE 9001 8545 8546 +ENTRYPOINT ["/usr/local/bin/reth"] \ No newline at end of file From 68bc908adb25ed430e6acfcb70b685c91fa4b99a Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:07:35 +0800 Subject: [PATCH 08/22] . --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 943cc342e..4cdcc402f 100644 --- a/Makefile +++ b/Makefile @@ -232,7 +232,7 @@ build-x86_64-pc-windows-gnu: FEATURES := $(filter-out jemalloc jemalloc-prof,$(F # See: https://github.com/cross-rs/cross/wiki/FAQ#undefined-reference-with-build-std build-%: RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \ - cross build --bin reth --target $* --features "$(FEATURES)" --profile "$(PROFILE)" + cross build --bin reth-hl --target $* --features "$(FEATURES)" --profile "$(PROFILE)" ##@ Docker # Note: This requires a buildx builder with emulation support. For example: From 6e0cdfcbc14775196bb6b5bc8d7c26467fb3f153 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:36:21 +0800 Subject: [PATCH 09/22] . --- Cross.toml | 38 ++++++++++++++++++++++++++++++++++++++ Makefile | 3 +++ 2 files changed, 41 insertions(+) create mode 100644 Cross.toml diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 000000000..5cf503bfa --- /dev/null +++ b/Cross.toml @@ -0,0 +1,38 @@ +[build] +pre-build = [ + # Use HTTPS for package sources + "apt-get update && apt-get install --assume-yes --no-install-recommends ca-certificates", + "find /etc/apt/ -type f \\( -name '*.list' -o -name '*.sources' \\) -exec sed -i 's|http://|https://|g' {} +", + + # Configure APT retries and timeouts to handle network issues + "echo 'Acquire::Retries \"3\";' > /etc/apt/apt.conf.d/80-retries", + "echo 'Acquire::http::Timeout \"60\";' >> /etc/apt/apt.conf.d/80-retries", + "echo 'Acquire::ftp::Timeout \"60\";' >> /etc/apt/apt.conf.d/80-retries", + + # rust-bindgen dependencies: llvm-dev libclang-dev (>= 10) clang (>= 10) + # See: https://github.com/cross-rs/cross/wiki/FAQ#using-clang--bindgen for + # recommended clang versions for the given cross and bindgen version. + "apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev libclang-dev clang", +] + +[target.x86_64-pc-windows-gnu] +# Why do we need a custom Dockerfile on Windows: +# 1. `reth-libmdbx` stopped working with MinGW 9.3 that cross image comes with. +# 2. To be able to update the version of MinGW, we need to also update the Ubuntu that the image is based on. +# +# Also see https://github.com/cross-rs/cross/issues/1667 +# Inspired by https://github.com/cross-rs/cross/blob/9e2298e17170655342d3248a9c8ac37ef92ba38f/docker/Dockerfile.x86_64-pc-windows-gnu#L51 +dockerfile = "./Dockerfile.x86_64-pc-windows-gnu" + +[target.riscv64gc-unknown-linux-gnu] +image = "ubuntu:24.04" +pre-build = [ + "apt update", + "apt install --yes gcc gcc-riscv64-linux-gnu libclang-dev make", +] +env.passthrough = [ + "CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc", +] + +[build.env] +passthrough = ["JEMALLOC_SYS_WITH_LG_PAGE"] \ No newline at end of file diff --git a/Makefile b/Makefile index 4cdcc402f..97eef6403 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,9 @@ PROFILE ?= release # Extra flags for Cargo CARGO_INSTALL_EXTRA_FLAGS ?= +# The docker image name +DOCKER_IMAGE_NAME ?= ghcr.io/hl-archive-node/nanoreth + ##@ Help .PHONY: help From 9a9118ecd8cbe3c0319deae5131b0815c2ff17f7 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:37:56 +0800 Subject: [PATCH 10/22] . --- Dockerfile.cross | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile.cross b/Dockerfile.cross index 8fcaf5d7e..d24942f55 100644 --- a/Dockerfile.cross +++ b/Dockerfile.cross @@ -6,6 +6,9 @@ FROM --platform=$TARGETPLATFORM ubuntu:22.04 LABEL org.opencontainers.image.source=https://github.com/hl-archive-node/nanoreth LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0" +# Install root certificates for aws sdk to work +RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates + # Filled by docker buildx ARG TARGETARCH From cb4359ec205640c6d4ffe4ee2c5f9b25020e680b Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:43:49 +0800 Subject: [PATCH 11/22] . --- Cross.toml | 7 +++++++ Makefile | 1 + 2 files changed, 8 insertions(+) diff --git a/Cross.toml b/Cross.toml index 5cf503bfa..b0a2ef2a0 100644 --- a/Cross.toml +++ b/Cross.toml @@ -15,6 +15,13 @@ pre-build = [ "apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev libclang-dev clang", ] +# Use specific Docker images for Linux targets to avoid GLIBC compatibility issues +[target.x86_64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5" + +[target.aarch64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5" + [target.x86_64-pc-windows-gnu] # Why do we need a custom Dockerfile on Windows: # 1. `reth-libmdbx` stopped working with MinGW 9.3 that cross image comes with. diff --git a/Makefile b/Makefile index 97eef6403..7919afb73 100644 --- a/Makefile +++ b/Makefile @@ -236,6 +236,7 @@ build-x86_64-pc-windows-gnu: FEATURES := $(filter-out jemalloc jemalloc-prof,$(F build-%: RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \ cross build --bin reth-hl --target $* --features "$(FEATURES)" --profile "$(PROFILE)" + ##@ Docker # Note: This requires a buildx builder with emulation support. For example: From 52b17dac1a0685a69a955bd70fb7cab0d89f497f Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:49:15 +0800 Subject: [PATCH 12/22] . --- .github/workflows/docker.yml | 2 +- Cross.toml | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a8507a732..3167812ab 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,7 +32,7 @@ jobs: - name: Install cross main id: cross_main run: | - cargo install cross --git https://github.com/cross-rs/cross + cargo install cross --git https://github.com/cross-rs/cross v0.2.5 - name: Log in to Docker run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin diff --git a/Cross.toml b/Cross.toml index b0a2ef2a0..5cf503bfa 100644 --- a/Cross.toml +++ b/Cross.toml @@ -15,13 +15,6 @@ pre-build = [ "apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev libclang-dev clang", ] -# Use specific Docker images for Linux targets to avoid GLIBC compatibility issues -[target.x86_64-unknown-linux-gnu] -image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5" - -[target.aarch64-unknown-linux-gnu] -image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5" - [target.x86_64-pc-windows-gnu] # Why do we need a custom Dockerfile on Windows: # 1. `reth-libmdbx` stopped working with MinGW 9.3 that cross image comes with. From c23b12ac0cdb034e4c0684b664a9f39f195616e1 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:50:01 +0800 Subject: [PATCH 13/22] . --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3167812ab..417c1bd65 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,7 +32,7 @@ jobs: - name: Install cross main id: cross_main run: | - cargo install cross --git https://github.com/cross-rs/cross v0.2.5 + cargo install cross --git https://github.com/cross-rs/cross --force v0.2.5 - name: Log in to Docker run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin From 6212b9dc9ef4fbc04f9666a142e53c6493cbeb10 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:51:37 +0800 Subject: [PATCH 14/22] . --- .github/workflows/docker.yml | 2 +- Cross.toml | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 417c1bd65..a8507a732 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,7 +32,7 @@ jobs: - name: Install cross main id: cross_main run: | - cargo install cross --git https://github.com/cross-rs/cross --force v0.2.5 + cargo install cross --git https://github.com/cross-rs/cross - name: Log in to Docker run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin diff --git a/Cross.toml b/Cross.toml index 5cf503bfa..5c94c650c 100644 --- a/Cross.toml +++ b/Cross.toml @@ -35,4 +35,12 @@ env.passthrough = [ ] [build.env] -passthrough = ["JEMALLOC_SYS_WITH_LG_PAGE"] \ No newline at end of file +passthrough = ["JEMALLOC_SYS_WITH_LG_PAGE"] + +# Use specific Docker images for Linux targets to avoid GLIBC compatibility issues +# TODO remove this when cross has more stable release +[target.x86_64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5" + +[target.aarch64-unknown-linux-gnu] +image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5" \ No newline at end of file From 88bdda8c9a458c732cdc7e52fdadd66de5367de0 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 10:55:21 +0800 Subject: [PATCH 15/22] . --- Cross.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cross.toml b/Cross.toml index 5c94c650c..db6597c56 100644 --- a/Cross.toml +++ b/Cross.toml @@ -2,7 +2,7 @@ pre-build = [ # Use HTTPS for package sources "apt-get update && apt-get install --assume-yes --no-install-recommends ca-certificates", - "find /etc/apt/ -type f \\( -name '*.list' -o -name '*.sources' \\) -exec sed -i 's|http://|https://|g' {} +", + # "find /etc/apt/ -type f \\( -name '*.list' -o -name '*.sources' \\) -exec sed -i 's|http://|https://|g' {} +", # Configure APT retries and timeouts to handle network issues "echo 'Acquire::Retries \"3\";' > /etc/apt/apt.conf.d/80-retries", From ca650a09e732b0340d0ea6638b625d5c7491bc53 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:02:14 +0800 Subject: [PATCH 16/22] . --- .github/workflows/docker.yml | 7 +----- Cross.toml | 46 ------------------------------------ Dockerfile.cross | 18 -------------- Makefile | 45 +++++++---------------------------- 4 files changed, 9 insertions(+), 107 deletions(-) delete mode 100644 Cross.toml delete mode 100644 Dockerfile.cross diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a8507a732..48552911b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,16 +29,11 @@ jobs: - uses: Swatinem/rust-cache@v2 with: cache-on-failure: true - - name: Install cross main - id: cross_main - run: | - cargo install cross --git https://github.com/cross-rs/cross - name: Log in to Docker run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username ${DOCKER_USERNAME} --password-stdin - name: Set up Docker builder run: | - docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64 - docker buildx create --use --name cross-builder + docker buildx create --use --name builder - name: Build and push nanoreth image run: make IMAGE_NAME=$IMAGE_NAME DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME PROFILE=maxperf docker-build-push-latest \ No newline at end of file diff --git a/Cross.toml b/Cross.toml deleted file mode 100644 index db6597c56..000000000 --- a/Cross.toml +++ /dev/null @@ -1,46 +0,0 @@ -[build] -pre-build = [ - # Use HTTPS for package sources - "apt-get update && apt-get install --assume-yes --no-install-recommends ca-certificates", - # "find /etc/apt/ -type f \\( -name '*.list' -o -name '*.sources' \\) -exec sed -i 's|http://|https://|g' {} +", - - # Configure APT retries and timeouts to handle network issues - "echo 'Acquire::Retries \"3\";' > /etc/apt/apt.conf.d/80-retries", - "echo 'Acquire::http::Timeout \"60\";' >> /etc/apt/apt.conf.d/80-retries", - "echo 'Acquire::ftp::Timeout \"60\";' >> /etc/apt/apt.conf.d/80-retries", - - # rust-bindgen dependencies: llvm-dev libclang-dev (>= 10) clang (>= 10) - # See: https://github.com/cross-rs/cross/wiki/FAQ#using-clang--bindgen for - # recommended clang versions for the given cross and bindgen version. - "apt-get update && apt-get install --assume-yes --no-install-recommends llvm-dev libclang-dev clang", -] - -[target.x86_64-pc-windows-gnu] -# Why do we need a custom Dockerfile on Windows: -# 1. `reth-libmdbx` stopped working with MinGW 9.3 that cross image comes with. -# 2. To be able to update the version of MinGW, we need to also update the Ubuntu that the image is based on. -# -# Also see https://github.com/cross-rs/cross/issues/1667 -# Inspired by https://github.com/cross-rs/cross/blob/9e2298e17170655342d3248a9c8ac37ef92ba38f/docker/Dockerfile.x86_64-pc-windows-gnu#L51 -dockerfile = "./Dockerfile.x86_64-pc-windows-gnu" - -[target.riscv64gc-unknown-linux-gnu] -image = "ubuntu:24.04" -pre-build = [ - "apt update", - "apt install --yes gcc gcc-riscv64-linux-gnu libclang-dev make", -] -env.passthrough = [ - "CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc", -] - -[build.env] -passthrough = ["JEMALLOC_SYS_WITH_LG_PAGE"] - -# Use specific Docker images for Linux targets to avoid GLIBC compatibility issues -# TODO remove this when cross has more stable release -[target.x86_64-unknown-linux-gnu] -image = "ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5" - -[target.aarch64-unknown-linux-gnu] -image = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5" \ No newline at end of file diff --git a/Dockerfile.cross b/Dockerfile.cross deleted file mode 100644 index d24942f55..000000000 --- a/Dockerfile.cross +++ /dev/null @@ -1,18 +0,0 @@ -# This image is meant to enable cross-architecture builds. -# It assumes the reth binary has already been compiled for `$TARGETPLATFORM` and is -# locatable in `./dist/bin/$TARGETARCH` -FROM --platform=$TARGETPLATFORM ubuntu:22.04 - -LABEL org.opencontainers.image.source=https://github.com/hl-archive-node/nanoreth -LABEL org.opencontainers.image.licenses="MIT OR Apache-2.0" - -# Install root certificates for aws sdk to work -RUN apt-get update && apt-get install -y ca-certificates && update-ca-certificates - -# Filled by docker buildx -ARG TARGETARCH - -COPY ./dist/bin/$TARGETARCH/reth-hl /usr/local/bin/reth-hl - -EXPOSE 9001 8545 8546 -ENTRYPOINT ["/usr/local/bin/reth"] \ No newline at end of file diff --git a/Makefile b/Makefile index 7919afb73..251397e19 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ # Modifed from reth Makefile .DEFAULT_GOAL := help +GIT_SHA ?= $(shell git rev-parse HEAD) +GIT_TAG ?= $(shell git describe --tags --abbrev=0) BIN_DIR = "dist/bin" # List of features to use when building. Can be overridden via the environment. @@ -211,32 +213,6 @@ check-features: --package reth-primitives \ --feature-powerset -# The following commands use `cross` to build a cross-compile. -# -# These commands require that: -# -# - `cross` is installed (`cargo install cross`). -# - Docker is running. -# - The current user is in the `docker` group. -# -# The resulting binaries will be created in the `target/` directory. - -# For aarch64, set the page size for jemalloc. -# When cross compiling, we must compile jemalloc with a large page size, -# otherwise it will use the current system's page size which may not work -# on other systems. JEMALLOC_SYS_WITH_LG_PAGE=16 tells jemalloc to use 64-KiB -# pages. See: https://github.com/paradigmxyz/reth/issues/6742 -build-aarch64-unknown-linux-gnu: export JEMALLOC_SYS_WITH_LG_PAGE=16 - -# No jemalloc on Windows -build-x86_64-pc-windows-gnu: FEATURES := $(filter-out jemalloc jemalloc-prof,$(FEATURES)) - -# Note: The additional rustc compiler flags are for intrinsics needed by MDBX. -# See: https://github.com/cross-rs/cross/wiki/FAQ#undefined-reference-with-build-std -build-%: - RUSTFLAGS="-C link-arg=-lgcc -Clink-arg=-static-libgcc" \ - cross build --bin reth-hl --target $* --features "$(FEATURES)" --profile "$(PROFILE)" - ##@ Docker # Note: This requires a buildx builder with emulation support. For example: @@ -271,20 +247,15 @@ docker-build-push-latest: ## Build and push a cross-arch Docker image tagged wit docker-build-push-nightly: ## Build and push cross-arch Docker image tagged with the latest git tag with a `-nightly` suffix, and `latest-nightly`. $(call docker_build_push,nightly,nightly) -# Create a cross-arch Docker image with the given tags and push it +# Create a Docker image using the main Dockerfile define docker_build_push - $(MAKE) build-x86_64-unknown-linux-gnu - mkdir -p $(BIN_DIR)/amd64 - cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/reth-hl $(BIN_DIR)/amd64/reth-hl - - $(MAKE) build-aarch64-unknown-linux-gnu - mkdir -p $(BIN_DIR)/arm64 - cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/reth-hl $(BIN_DIR)/arm64/reth-hl - - docker buildx build --file ./Dockerfile.cross . \ - --platform linux/amd64,linux/arm64 \ + docker buildx build --file ./Dockerfile . \ + --platform linux/amd64 \ --tag $(DOCKER_IMAGE_NAME):$(1) \ --tag $(DOCKER_IMAGE_NAME):$(2) \ + --build-arg BUILD_PROFILE=$(PROFILE) \ + --build-arg FEATURES=$(FEATURES) \ + --build-arg RUSTFLAGS=-C target-cpu=native \ --provenance=false \ --push endef From f05e6b6f6eef38def2e05c4432e3d44f3e11771c Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:05:59 +0800 Subject: [PATCH 17/22] . --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 251397e19..0a766b49c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ .DEFAULT_GOAL := help GIT_SHA ?= $(shell git rev-parse HEAD) -GIT_TAG ?= $(shell git describe --tags --abbrev=0) +GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "latest") BIN_DIR = "dist/bin" # List of features to use when building. Can be overridden via the environment. From 0328b040f7a3ee6fdb62df6c1ef59740a1d3266f Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:08:53 +0800 Subject: [PATCH 18/22] . --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0a766b49c..a05298ec1 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ .DEFAULT_GOAL := help GIT_SHA ?= $(shell git rev-parse HEAD) -GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "latest") +GIT_TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null) BIN_DIR = "dist/bin" # List of features to use when building. Can be overridden via the environment. @@ -253,9 +253,9 @@ define docker_build_push --platform linux/amd64 \ --tag $(DOCKER_IMAGE_NAME):$(1) \ --tag $(DOCKER_IMAGE_NAME):$(2) \ - --build-arg BUILD_PROFILE=$(PROFILE) \ - --build-arg FEATURES=$(FEATURES) \ - --build-arg RUSTFLAGS=-C target-cpu=native \ + --build-arg BUILD_PROFILE="$(PROFILE)" \ + --build-arg FEATURES="$(FEATURES)" \ + --build-arg RUSTFLAGS="-C target-cpu=native" \ --provenance=false \ --push endef From 4615ba53c4162c006577cf2652dd227be10cb1ea Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:12:57 +0800 Subject: [PATCH 19/22] . --- .github/workflows/docker.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 48552911b..f4c58b818 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,8 +6,6 @@ on: push: tags: - v* - branches: - - "*" env: IMAGE_NAME: ${{ github.repository_owner }}/nanoreth From 66dd70d2580b2673a2d67e1285a70c8fcf6e0a3f Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:14:16 +0800 Subject: [PATCH 20/22] . --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index a05298ec1..ebf9d110b 100644 --- a/Makefile +++ b/Makefile @@ -254,8 +254,6 @@ define docker_build_push --tag $(DOCKER_IMAGE_NAME):$(1) \ --tag $(DOCKER_IMAGE_NAME):$(2) \ --build-arg BUILD_PROFILE="$(PROFILE)" \ - --build-arg FEATURES="$(FEATURES)" \ - --build-arg RUSTFLAGS="-C target-cpu=native" \ --provenance=false \ --push endef From 0a4a0026db7c657c230cd8039012d1842afdd791 Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:20:00 +0800 Subject: [PATCH 21/22] . --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index ebf9d110b..a05298ec1 100644 --- a/Makefile +++ b/Makefile @@ -254,6 +254,8 @@ define docker_build_push --tag $(DOCKER_IMAGE_NAME):$(1) \ --tag $(DOCKER_IMAGE_NAME):$(2) \ --build-arg BUILD_PROFILE="$(PROFILE)" \ + --build-arg FEATURES="$(FEATURES)" \ + --build-arg RUSTFLAGS="-C target-cpu=native" \ --provenance=false \ --push endef From c32b83721289ffa8e2f24d72eae759b13c32d57a Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Sun, 31 Aug 2025 11:22:03 +0800 Subject: [PATCH 22/22] . --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a05298ec1..a02040c31 100644 --- a/Makefile +++ b/Makefile @@ -254,7 +254,7 @@ define docker_build_push --tag $(DOCKER_IMAGE_NAME):$(1) \ --tag $(DOCKER_IMAGE_NAME):$(2) \ --build-arg BUILD_PROFILE="$(PROFILE)" \ - --build-arg FEATURES="$(FEATURES)" \ + --build-arg FEATURES="jemalloc,asm-keccak" \ --build-arg RUSTFLAGS="-C target-cpu=native" \ --provenance=false \ --push