Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7989d74fff |
File diff suppressed because one or more lines are too long
@@ -1,149 +0,0 @@
|
|||||||
# Multi-stage build for Gravity Reth (gravity-reth)
|
|
||||||
# Gravity Reth is a performance-optimized fork of Reth for Gravity L1
|
|
||||||
# Repository: https://github.com/Galxe/gravity-reth
|
|
||||||
|
|
||||||
ARG LLVM_IMAGE=snowstep/llvm
|
|
||||||
ARG LLVM_VERSION=debian-13-20251208082922
|
|
||||||
FROM ${LLVM_IMAGE}:${LLVM_VERSION} AS builder
|
|
||||||
|
|
||||||
# Install build dependencies and tools
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
build-essential \
|
|
||||||
curl \
|
|
||||||
git \
|
|
||||||
libssl-dev \
|
|
||||||
pkg-config \
|
|
||||||
wget \
|
|
||||||
ninja-build \
|
|
||||||
ccache \
|
|
||||||
autoconf \
|
|
||||||
automake \
|
|
||||||
libtool \
|
|
||||||
zlib1g-dev \
|
|
||||||
libclang-dev \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Set up clang as default C/C++ compiler
|
|
||||||
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
|
|
||||||
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
|
|
||||||
|
|
||||||
# Install Rust
|
|
||||||
ENV RUSTUP_HOME=/usr/local/rustup
|
|
||||||
ENV CARGO_HOME=/usr/local/cargo
|
|
||||||
ENV PATH=/usr/local/cargo/bin:$PATH
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
|
|
||||||
sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
|
|
||||||
|
|
||||||
# Install mold linker
|
|
||||||
RUN wget https://github.com/rui314/mold/releases/download/v2.40.4/mold-2.40.4-x86_64-linux.tar.gz && \
|
|
||||||
tar xf mold-2.40.4-x86_64-linux.tar.gz && \
|
|
||||||
cp mold-2.40.4-x86_64-linux/bin/mold /usr/local/bin/ && \
|
|
||||||
cp -r mold-2.40.4-x86_64-linux/lib/* /usr/local/lib/ && \
|
|
||||||
rm -rf mold-2.40.4-x86_64-linux*
|
|
||||||
|
|
||||||
# Install sccache for build caching
|
|
||||||
RUN wget https://github.com/mozilla/sccache/releases/download/v0.7.4/sccache-v0.7.4-x86_64-unknown-linux-musl.tar.gz && \
|
|
||||||
tar xf sccache-v0.7.4-x86_64-unknown-linux-musl.tar.gz && \
|
|
||||||
mv sccache-v0.7.4-x86_64-unknown-linux-musl/sccache /usr/local/bin/ && \
|
|
||||||
rm -rf sccache-v0.7.4-x86_64-unknown-linux-musl*
|
|
||||||
|
|
||||||
# Build arguments for customization
|
|
||||||
ARG ARCH_TARGET=native
|
|
||||||
ARG GRAVITY_RETH_VERSION=34078b9b69e75f2af1427f75c6ae8b07e28d5838
|
|
||||||
ARG GRAVITY_RETH_REPO=https://github.com/Galxe/gravity-reth
|
|
||||||
ARG PROFILE=maxperf
|
|
||||||
|
|
||||||
# Set up cargo for maximum performance with aggressive optimizations
|
|
||||||
RUN mkdir -p /root/.cargo && \
|
|
||||||
echo '[profile.maxperf]' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'inherits = "release"' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'lto = "fat"' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'codegen-units = 1' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'panic = "abort"' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'strip = true' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'opt-level = 3' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'overflow-checks = false' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'debug = false' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'debug-assertions = false' >> /root/.cargo/config.toml && \
|
|
||||||
echo '' >> /root/.cargo/config.toml && \
|
|
||||||
echo '[target.x86_64-unknown-linux-gnu]' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'linker = "/usr/local/bin/clang"' >> /root/.cargo/config.toml && \
|
|
||||||
echo 'rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold", "-C", "link-arg=-Wl,--as-needed"]' >> /root/.cargo/config.toml
|
|
||||||
|
|
||||||
# Clone and build gravity-reth
|
|
||||||
WORKDIR /build
|
|
||||||
RUN git clone $GRAVITY_RETH_REPO . && \
|
|
||||||
git checkout $GRAVITY_RETH_VERSION
|
|
||||||
|
|
||||||
# Set environment variables for optimization
|
|
||||||
ENV CC=clang
|
|
||||||
ENV CXX=clang++
|
|
||||||
ENV AR=llvm-ar
|
|
||||||
ENV RANLIB=llvm-ranlib
|
|
||||||
ENV LD=/usr/local/bin/mold
|
|
||||||
ENV SCCACHE_DIR=/tmp/sccache
|
|
||||||
ENV RUSTC_WRAPPER=/usr/local/bin/sccache
|
|
||||||
ENV LIBZ_SYS_STATIC=1
|
|
||||||
|
|
||||||
# Set C/C++ flags for dependencies
|
|
||||||
ENV CFLAGS_BASE="-O3 -fomit-frame-pointer -fno-semantic-interposition -funroll-loops"
|
|
||||||
ENV CXXFLAGS_BASE="-O3 -fomit-frame-pointer -fno-semantic-interposition -funroll-loops"
|
|
||||||
ENV LDFLAGS="-Wl,-O3 -Wl,--as-needed"
|
|
||||||
|
|
||||||
# Configure architecture-specific flags and build
|
|
||||||
# Gravity Reth build - optimized for Gravity L1 with AptosBFT consensus
|
|
||||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
||||||
--mount=type=cache,target=/usr/local/cargo/git \
|
|
||||||
--mount=type=cache,target=/build/target \
|
|
||||||
if [ "$ARCH_TARGET" = "native" ]; then \
|
|
||||||
RUSTFLAGS="-C target-cpu=native -C link-arg=-fuse-ld=/usr/local/bin/mold -C opt-level=3" \
|
|
||||||
CFLAGS="$CFLAGS_BASE -march=native" \
|
|
||||||
CXXFLAGS="$CXXFLAGS_BASE -march=native"; \
|
|
||||||
elif [ "$ARCH_TARGET" = "zen4" ]; then \
|
|
||||||
RUSTFLAGS="-C target-cpu=znver4 -C link-arg=-fuse-ld=/usr/local/bin/mold -C opt-level=3 -C llvm-args=-enable-machine-outliner" \
|
|
||||||
CFLAGS="$CFLAGS_BASE -march=znver4" \
|
|
||||||
CXXFLAGS="$CXXFLAGS_BASE -march=znver4"; \
|
|
||||||
elif [ "$ARCH_TARGET" = "zen5" ]; then \
|
|
||||||
RUSTFLAGS="-C target-cpu=znver5 -C link-arg=-fuse-ld=/usr/local/bin/mold -C opt-level=3 -C llvm-args=-enable-machine-outliner -C llvm-args=-enable-gvn-hoist -C llvm-args=-enable-dfa-jump-thread -C llvm-args=-slp-vectorize-hor-store" \
|
|
||||||
CFLAGS="$CFLAGS_BASE -march=znver5" \
|
|
||||||
CXXFLAGS="$CXXFLAGS_BASE -march=znver5"; \
|
|
||||||
else \
|
|
||||||
RUSTFLAGS="-C target-cpu=$ARCH_TARGET -C link-arg=-fuse-ld=/usr/local/bin/mold -C opt-level=3" \
|
|
||||||
CFLAGS="$CFLAGS_BASE -march=$ARCH_TARGET" \
|
|
||||||
CXXFLAGS="$CXXFLAGS_BASE -march=$ARCH_TARGET"; \
|
|
||||||
fi && \
|
|
||||||
export RUSTFLAGS CFLAGS CXXFLAGS && \
|
|
||||||
echo "Building Gravity Reth with RUSTFLAGS: $RUSTFLAGS" && \
|
|
||||||
cargo build --profile $PROFILE --locked --bin reth --features jemalloc,asm-keccak && \
|
|
||||||
cp target/$PROFILE/reth /usr/local/bin/gravity-reth
|
|
||||||
|
|
||||||
# Final stage - minimal runtime
|
|
||||||
FROM debian:trixie-slim
|
|
||||||
|
|
||||||
# Install runtime dependencies including jemalloc for better memory performance
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
ca-certificates \
|
|
||||||
libssl3 \
|
|
||||||
libjemalloc2 \
|
|
||||||
curl \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Copy the optimized binary
|
|
||||||
COPY --from=builder /usr/local/bin/gravity-reth /usr/local/bin/
|
|
||||||
|
|
||||||
# Create non-root user
|
|
||||||
RUN useradd -m -u 1000 -s /bin/bash gravity
|
|
||||||
|
|
||||||
# Set up data directory
|
|
||||||
RUN mkdir -p /root/.gravity/reth && \
|
|
||||||
chown -R gravity:gravity /root/.gravity
|
|
||||||
|
|
||||||
RUN echo '/usr/lib/x86_64-linux-gnu/libjemalloc.so.2' > /etc/ld.so.preload
|
|
||||||
|
|
||||||
ENV MALLOC_CONF="background_thread:true,metadata_thp:auto,dirty_decay_ms:30000,muzzy_decay_ms:30000"
|
|
||||||
|
|
||||||
USER gravity
|
|
||||||
|
|
||||||
EXPOSE 30303 30303/udp 9001 8545 8546 8551
|
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/gravity-reth"]
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
0:2a61c47583cc1edb9ec242d63647e0a0c74fdec6ece35cb033460f54cb0fca03
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
0:ed0edcd47c25c09e10aa51b79b9e9067b97b41d0a12cd63c04df2cca58f45b86
|
|
||||||
@@ -1 +1 @@
|
|||||||
{"database-type":"leveldb","log-level":"info","warp-api-enabled":true,"state-sync-enabled":true,"pruning-enabled":true,"eth-apis":["eth","eth-filter","net","admin","web3","internal-account","internal-blockchain","internal-debug","internal-eth","internal-personal","internal-transaction","internal-tx-pool","debug","debug-tracer","debug-file-tracer","debug-handler"]}
|
{"database-type":"leveldb","state-sync-enabled":true,"pruning-enabled":true,"commit-interval":4096,"api-max-duration":"30s","apis":["eth","eth-filter","net","web3","internal-account","internal-blockchain","internal-eth","internal-transaction","internal-tx-pool"]}
|
||||||
|
|||||||
Reference in New Issue
Block a user