Fresh-syncing nodes rejected the on-chain min-diff block at the RANDOMX_VALIDATION activation height (2838976) because GetNextWorkRequired computed the expected nBits from the preceding normal-difficulty blocks, producing 469847994 instead of the on-chain 0x200f0f0f (HUSH_MINDIFF_NBITS). This caused all seed nodes to be banned with "Incorrect diffbits" and the node could never sync past that height. Two changes: 1. GetNextWorkRequired (pow.cpp): Return nProofOfWorkLimit at the exact RANDOMX_VALIDATION activation height, matching the on-chain diff reset. 2. ContextualCheckBlockHeader (main.cpp): Raise DragonX daaForkHeight to RANDOMX_VALIDATION + 62000, covering the window where nBits was never validated (diff reset at 2838976 through the attack at ~2879907). Tested by invalidating block 2838975 and reconsidering — node re-validated through the diff reset and attack window, syncing back to tip with zero bad-diffbits rejections. Bump version to 1.0.1.
208 lines
7.3 KiB
Bash
Executable File
208 lines
7.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright (c) 2016-2024 The Hush developers
|
|
# Copyright (c) 2024-2026 The DragonX developers
|
|
# Distributed under the GPLv3 software license, see the accompanying
|
|
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
|
|
set -eu -o pipefail
|
|
|
|
VERSION="1.0.1"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
RELEASE_DIR="$SCRIPT_DIR/release"
|
|
|
|
# Parse release flags
|
|
BUILD_LINUX_RELEASE=0
|
|
BUILD_WIN_RELEASE=0
|
|
BUILD_MAC_RELEASE=0
|
|
BUILD_LINUX_COMPAT=0
|
|
REMAINING_ARGS=()
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--linux-release)
|
|
BUILD_LINUX_RELEASE=1
|
|
;;
|
|
--linux-compat)
|
|
BUILD_LINUX_COMPAT=1
|
|
;;
|
|
--win-release)
|
|
BUILD_WIN_RELEASE=1
|
|
;;
|
|
--mac-release)
|
|
BUILD_MAC_RELEASE=1
|
|
;;
|
|
--all-release)
|
|
BUILD_LINUX_RELEASE=1
|
|
BUILD_WIN_RELEASE=1
|
|
BUILD_MAC_RELEASE=1
|
|
;;
|
|
*)
|
|
REMAINING_ARGS+=("$arg")
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Clean artifacts that may conflict between platform builds
|
|
clean_for_platform() {
|
|
local platform="$1"
|
|
echo "Cleaning build artifacts for $platform build..."
|
|
|
|
# Use make clean if Makefile exists (safer than manual deletion)
|
|
if [ -f src/Makefile ]; then
|
|
make -C src clean 2>/dev/null || true
|
|
fi
|
|
|
|
# Remove final binaries
|
|
if [ -d src ]; then
|
|
rm -f src/dragonxd src/dragonx-cli src/dragonx-tx 2>/dev/null || true
|
|
rm -f src/dragonxd.exe src/dragonx-cli.exe src/dragonx-tx.exe 2>/dev/null || true
|
|
rm -f src/hushd src/hush-cli src/hush-tx 2>/dev/null || true
|
|
rm -f src/hushd.exe src/hush-cli.exe src/hush-tx.exe 2>/dev/null || true
|
|
fi
|
|
|
|
# Clean RandomX build for cross-platform compatibility
|
|
rm -rf src/RandomX/build 2>/dev/null || true
|
|
|
|
# Clean cryptoconditions
|
|
rm -rf src/cc/*.o src/cc/*.a 2>/dev/null || true
|
|
|
|
# Clean config cache (forces reconfigure for cross-platform)
|
|
rm -f config.status config.log 2>/dev/null || true
|
|
|
|
echo "Clean complete for $platform"
|
|
}
|
|
|
|
# Package release for a platform
|
|
package_release() {
|
|
local platform="$1"
|
|
local release_subdir="$RELEASE_DIR/dragonx-$VERSION-$platform"
|
|
|
|
echo "Packaging release for $platform..."
|
|
mkdir -p "$release_subdir"
|
|
|
|
# Copy bootstrap script
|
|
cp "$SCRIPT_DIR/util/bootstrap-dragonx.sh" "$release_subdir/"
|
|
|
|
# Copy common files
|
|
cp "$SCRIPT_DIR/contrib/asmap/asmap.dat" "$release_subdir/" 2>/dev/null || true
|
|
cp "$SCRIPT_DIR/sapling-output.params" "$release_subdir/" 2>/dev/null || true
|
|
cp "$SCRIPT_DIR/sapling-spend.params" "$release_subdir/" 2>/dev/null || true
|
|
|
|
case "$platform" in
|
|
linux-amd64)
|
|
cp "$SCRIPT_DIR/src/dragonxd" "$release_subdir/"
|
|
cp "$SCRIPT_DIR/src/dragonx-cli" "$release_subdir/"
|
|
cp "$SCRIPT_DIR/src/dragonx-tx" "$release_subdir/"
|
|
strip "$release_subdir/dragonxd" "$release_subdir/dragonx-cli" "$release_subdir/dragonx-tx"
|
|
;;
|
|
win64)
|
|
cp "$SCRIPT_DIR/src/dragonxd.exe" "$release_subdir/"
|
|
cp "$SCRIPT_DIR/src/dragonx-cli.exe" "$release_subdir/"
|
|
cp "$SCRIPT_DIR/src/dragonx-tx.exe" "$release_subdir/"
|
|
x86_64-w64-mingw32-strip "$release_subdir/"*.exe 2>/dev/null || strip "$release_subdir/"*.exe 2>/dev/null || true
|
|
;;
|
|
macos)
|
|
cp "$SCRIPT_DIR/src/dragonxd" "$release_subdir/"
|
|
cp "$SCRIPT_DIR/src/dragonx-cli" "$release_subdir/"
|
|
cp "$SCRIPT_DIR/src/dragonx-tx" "$release_subdir/"
|
|
strip "$release_subdir/dragonxd" "$release_subdir/dragonx-cli" "$release_subdir/dragonx-tx" 2>/dev/null || true
|
|
;;
|
|
esac
|
|
|
|
echo "Release packaged: $release_subdir"
|
|
ls -la "$release_subdir"
|
|
}
|
|
|
|
# Handle release builds
|
|
if [ $BUILD_LINUX_COMPAT -eq 1 ] || [ $BUILD_LINUX_RELEASE -eq 1 ] || [ $BUILD_WIN_RELEASE -eq 1 ] || [ $BUILD_MAC_RELEASE -eq 1 ]; then
|
|
mkdir -p "$RELEASE_DIR"
|
|
|
|
if [ $BUILD_LINUX_COMPAT -eq 1 ]; then
|
|
echo "=== Building Linux compat release (Ubuntu 20.04 via Docker) ==="
|
|
if ! command -v docker &>/dev/null; then
|
|
echo "Error: docker is required for --linux-compat builds"
|
|
exit 1
|
|
fi
|
|
|
|
# Use sudo for docker if the user isn't in the docker group
|
|
DOCKER_CMD="docker"
|
|
if ! docker info &>/dev/null 2>&1; then
|
|
echo "Note: Using sudo for docker (add yourself to the docker group to avoid this)"
|
|
DOCKER_CMD="sudo docker"
|
|
fi
|
|
|
|
DOCKER_IMAGE="dragonx-compat-builder"
|
|
COMPAT_PLATFORM="linux-amd64-ubuntu2004"
|
|
COMPAT_RELEASE_DIR="$RELEASE_DIR/dragonx-$VERSION-$COMPAT_PLATFORM"
|
|
|
|
echo "Building Docker image (Ubuntu 20.04 base)..."
|
|
$DOCKER_CMD build -f Dockerfile.compat -t "$DOCKER_IMAGE" .
|
|
|
|
echo "Extracting binaries from Docker image..."
|
|
CONTAINER_ID=$($DOCKER_CMD create "$DOCKER_IMAGE")
|
|
mkdir -p "$COMPAT_RELEASE_DIR"
|
|
|
|
for bin in dragonxd dragonx-cli dragonx-tx; do
|
|
$DOCKER_CMD cp "$CONTAINER_ID:/build/src/$bin" "$COMPAT_RELEASE_DIR/$bin"
|
|
done
|
|
$DOCKER_CMD rm "$CONTAINER_ID" >/dev/null
|
|
|
|
# Fix ownership (docker cp creates root-owned files)
|
|
# Binaries are already stripped inside the Docker container
|
|
if [ "$(stat -c '%U' "$COMPAT_RELEASE_DIR/dragonxd")" = "root" ]; then
|
|
sudo chown "$(id -u):$(id -g)" "$COMPAT_RELEASE_DIR"/dragonx*
|
|
fi
|
|
|
|
# Copy common files
|
|
cp "$SCRIPT_DIR/util/bootstrap-dragonx.sh" "$COMPAT_RELEASE_DIR/"
|
|
cp "$SCRIPT_DIR/contrib/asmap/asmap.dat" "$COMPAT_RELEASE_DIR/" 2>/dev/null || true
|
|
cp "$SCRIPT_DIR/sapling-output.params" "$COMPAT_RELEASE_DIR/" 2>/dev/null || true
|
|
cp "$SCRIPT_DIR/sapling-spend.params" "$COMPAT_RELEASE_DIR/" 2>/dev/null || true
|
|
|
|
echo "Compat release packaged: $COMPAT_RELEASE_DIR"
|
|
ls -la "$COMPAT_RELEASE_DIR"
|
|
|
|
# Show glibc version requirement
|
|
echo ""
|
|
echo "Binary compatibility info:"
|
|
objdump -T "$COMPAT_RELEASE_DIR/dragonxd" | grep -oP 'GLIBC_\d+\.\d+' | sort -uV | tail -1 && echo "(max GLIBC version required)"
|
|
fi
|
|
|
|
if [ $BUILD_LINUX_RELEASE -eq 1 ]; then
|
|
echo "=== Building Linux release ==="
|
|
clean_for_platform linux
|
|
./util/build.sh --disable-tests "${REMAINING_ARGS[@]}"
|
|
package_release linux-amd64
|
|
fi
|
|
|
|
if [ $BUILD_WIN_RELEASE -eq 1 ]; then
|
|
echo "=== Building Windows release ==="
|
|
clean_for_platform windows
|
|
./util/build-win.sh --disable-tests "${REMAINING_ARGS[@]}"
|
|
package_release win64
|
|
fi
|
|
|
|
if [ $BUILD_MAC_RELEASE -eq 1 ]; then
|
|
echo "=== Building macOS release ==="
|
|
clean_for_platform macos
|
|
./util/build-mac.sh --disable-tests "${REMAINING_ARGS[@]}"
|
|
package_release macos
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Release builds complete ==="
|
|
ls -la "$RELEASE_DIR"/
|
|
exit 0
|
|
fi
|
|
|
|
# Standard build (auto-detect OS)
|
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
./util/build.sh --disable-tests "${REMAINING_ARGS[@]}"
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
./util/build-mac.sh --disable-tests "${REMAINING_ARGS[@]}"
|
|
elif [[ "$OSTYPE" == "msys"* ]]; then
|
|
./util/build-win.sh --disable-tests "${REMAINING_ARGS[@]}"
|
|
else
|
|
echo "Unable to detect your OS. What are you using?"
|
|
fi
|