Compare commits
4 Commits
master
...
9c9b7680e4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c9b7680e4 | ||
|
|
d0b4fb1be6 | ||
|
|
67b9cde59e | ||
|
|
d49e9a5199 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -37,7 +37,3 @@ src/config.json
|
|||||||
Thumbs.db
|
Thumbs.db
|
||||||
*.swp
|
*.swp
|
||||||
*~
|
*~
|
||||||
release/
|
|
||||||
build-linux/
|
|
||||||
build-windows/
|
|
||||||
deps-windows/
|
|
||||||
|
|||||||
124
build.sh
124
build.sh
@@ -1,124 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# XMRig-HAC Release Build Script
|
|
||||||
# Usage: ./build.sh [--linux-release] [--win-release]
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
RELEASE_DIR="$ROOT_DIR/release"
|
|
||||||
VERSION=$(grep '#define APP_VERSION' "$ROOT_DIR/src/version.h" | sed 's/.*"\(.*\)"/\1/')
|
|
||||||
|
|
||||||
BUILD_LINUX=false
|
|
||||||
BUILD_WIN=false
|
|
||||||
|
|
||||||
for arg in "$@"; do
|
|
||||||
case "$arg" in
|
|
||||||
--linux-release) BUILD_LINUX=true ;;
|
|
||||||
--win-release) BUILD_WIN=true ;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 [--linux-release] [--win-release]"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! $BUILD_LINUX && ! $BUILD_WIN; then
|
|
||||||
echo "Usage: $0 [--linux-release] [--win-release]"
|
|
||||||
echo ""
|
|
||||||
echo "Flags:"
|
|
||||||
echo " --linux-release Build Linux x86_64 release"
|
|
||||||
echo " --win-release Build Windows x86_64 release (cross-compile with MinGW)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "=== XMRig-HAC Release Builder v${VERSION} ==="
|
|
||||||
mkdir -p "$RELEASE_DIR"
|
|
||||||
|
|
||||||
build_linux() {
|
|
||||||
echo ""
|
|
||||||
echo "========================================="
|
|
||||||
echo " Building Linux x86_64 Release"
|
|
||||||
echo "========================================="
|
|
||||||
|
|
||||||
local BUILD_DIR="$ROOT_DIR/build-linux"
|
|
||||||
local DEPS_DIR="$ROOT_DIR/scripts/deps"
|
|
||||||
|
|
||||||
# Build dependencies if needed
|
|
||||||
if [ ! -f "$DEPS_DIR/lib/libuv.a" ] || [ ! -f "$DEPS_DIR/lib/libssl.a" ] || [ ! -f "$DEPS_DIR/lib/libhwloc.a" ]; then
|
|
||||||
echo "--- Building Linux dependencies ---"
|
|
||||||
cd "$ROOT_DIR/scripts"
|
|
||||||
bash build_deps.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure and build
|
|
||||||
mkdir -p "$BUILD_DIR"
|
|
||||||
cd "$BUILD_DIR"
|
|
||||||
|
|
||||||
cmake "$ROOT_DIR" \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DBUILD_STATIC=ON \
|
|
||||||
-DWITH_OPENCL=OFF \
|
|
||||||
-DWITH_CUDA=OFF \
|
|
||||||
-DXMRIG_DEPS="$DEPS_DIR"
|
|
||||||
|
|
||||||
make -j"$(nproc)"
|
|
||||||
strip xmrig
|
|
||||||
|
|
||||||
# Package
|
|
||||||
local PKG_NAME="xmrig-hac-${VERSION}-linux-x64"
|
|
||||||
local PKG_DIR="$RELEASE_DIR/$PKG_NAME"
|
|
||||||
rm -rf "$PKG_DIR"
|
|
||||||
mkdir -p "$PKG_DIR"
|
|
||||||
|
|
||||||
cp "$BUILD_DIR/xmrig" "$PKG_DIR/"
|
|
||||||
cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json"
|
|
||||||
cp "$ROOT_DIR/README.md" "$PKG_DIR/"
|
|
||||||
|
|
||||||
cd "$RELEASE_DIR"
|
|
||||||
zip -r "${PKG_NAME}.zip" "$PKG_NAME"
|
|
||||||
rm -rf "$PKG_DIR"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Linux release: release/${PKG_NAME}.zip"
|
|
||||||
}
|
|
||||||
|
|
||||||
build_windows() {
|
|
||||||
echo ""
|
|
||||||
echo "========================================="
|
|
||||||
echo " Building Windows x86_64 Release"
|
|
||||||
echo "========================================="
|
|
||||||
|
|
||||||
# Delegate to the existing cross-compilation script
|
|
||||||
cd "$ROOT_DIR/scripts"
|
|
||||||
bash build_windows.sh
|
|
||||||
|
|
||||||
local BUILD_DIR="$ROOT_DIR/build-windows"
|
|
||||||
|
|
||||||
# Package
|
|
||||||
local PKG_NAME="xmrig-hac-${VERSION}-win-x64"
|
|
||||||
local PKG_DIR="$RELEASE_DIR/$PKG_NAME"
|
|
||||||
rm -rf "$PKG_DIR"
|
|
||||||
mkdir -p "$PKG_DIR"
|
|
||||||
|
|
||||||
cp "$BUILD_DIR/xmrig.exe" "$PKG_DIR/"
|
|
||||||
cp "$ROOT_DIR/bin/WinRing0/WinRing0x64.sys" "$PKG_DIR/"
|
|
||||||
cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json"
|
|
||||||
cp "$ROOT_DIR/README.md" "$PKG_DIR/"
|
|
||||||
|
|
||||||
cd "$RELEASE_DIR"
|
|
||||||
zip -r "${PKG_NAME}.zip" "$PKG_NAME"
|
|
||||||
rm -rf "$PKG_DIR"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Windows release: release/${PKG_NAME}.zip"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run selected builds
|
|
||||||
$BUILD_LINUX && build_linux
|
|
||||||
$BUILD_WIN && build_windows
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "========================================="
|
|
||||||
echo " Release artifacts in release/"
|
|
||||||
echo "========================================="
|
|
||||||
ls -lh "$RELEASE_DIR"/*.zip 2>/dev/null || true
|
|
||||||
@@ -61,14 +61,14 @@ if [ ! -f "$DEPS_DIR/lib/libuv.a" ]; then
|
|||||||
echo "=== Building libuv dependency ==="
|
echo "=== Building libuv dependency ==="
|
||||||
cd "$DEPS_DIR"
|
cd "$DEPS_DIR"
|
||||||
|
|
||||||
if [ ! -d "libuv-1.51.0" ]; then
|
if [ ! -d "libuv-v1.51.0" ]; then
|
||||||
if [ ! -f "libuv.tar.gz" ]; then
|
if [ ! -f "libuv.tar.gz" ]; then
|
||||||
curl -L -o libuv.tar.gz https://github.com/libuv/libuv/archive/refs/tags/v1.51.0.tar.gz
|
curl -L -o libuv.tar.gz https://github.com/libuv/libuv/archive/refs/tags/v1.51.0.tar.gz
|
||||||
fi
|
fi
|
||||||
tar -xzf libuv.tar.gz
|
tar -xzf libuv.tar.gz
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd libuv-1.51.0
|
cd libuv-v1.51.0
|
||||||
mkdir -p build && cd build
|
mkdir -p build && cd build
|
||||||
cmake .. \
|
cmake .. \
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$XMRIG_DIR/cmake/mingw-w64-toolchain.cmake" \
|
-DCMAKE_TOOLCHAIN_FILE="$XMRIG_DIR/cmake/mingw-w64-toolchain.cmake" \
|
||||||
|
|||||||
@@ -436,53 +436,6 @@ void xmrig::CpuWorker<N>::start()
|
|||||||
// Submit full 32-byte nonce + rx_hash as result
|
// Submit full 32-byte nonce + rx_hash as result
|
||||||
JobResults::submit(JobResult(job, current_solo_nonces + i * 32, m_hash + (i * 32)));
|
JobResults::submit(JobResult(job, current_solo_nonces + i * 32, m_hash + (i * 32)));
|
||||||
}
|
}
|
||||||
} else if (job.algorithm() == Algorithm::RX_HUSH && !m_job.isSoloMining()) {
|
|
||||||
// ── DRAGONX/HUSH pool mining: dual check ──
|
|
||||||
//
|
|
||||||
// DragonX uses dual PoW: the block hash is SHA256D(header + RandomX solution),
|
|
||||||
// NOT the RandomX hash itself. We must check SHA256D for EVERY hash to detect
|
|
||||||
// blocks, and also check the RandomX hash for share difficulty.
|
|
||||||
//
|
|
||||||
// Reconstruct the 140-byte header with the 4-byte nonce at offset 108.
|
|
||||||
// In pool mode, bytes 112-139 of nNonce are zero (only 4-byte nonce used).
|
|
||||||
uint8_t blob_for_header[140];
|
|
||||||
memcpy(blob_for_header, m_job.blob(), 108); // header base
|
|
||||||
memset(blob_for_header + 108, 0, 32); // clear 32-byte nonce field
|
|
||||||
memcpy(blob_for_header + 108, ¤t_job_nonces[i], 4); // 4-byte nonce at offset 108
|
|
||||||
|
|
||||||
bool submitted = false;
|
|
||||||
|
|
||||||
// Check SHA256D for block detection if pool sent block_target
|
|
||||||
if (job.hasBlockTarget()) {
|
|
||||||
alignas(8) uint8_t pow_hash[32];
|
|
||||||
dragonx_pow_hash(blob_for_header, m_hash + (i * 32), pow_hash);
|
|
||||||
|
|
||||||
// Compare pow_hash <= block_target (both in uint256 internal byte order)
|
|
||||||
// byte[31] is MSB (most significant in arith terms), compare from there down
|
|
||||||
bool isBlock = true;
|
|
||||||
for (int b = 31; b >= 0; --b) {
|
|
||||||
if (pow_hash[b] < job.blockTarget()[b]) {
|
|
||||||
break; // pow_hash < target → is a block
|
|
||||||
} else if (pow_hash[b] > job.blockTarget()[b]) {
|
|
||||||
isBlock = false;
|
|
||||||
break; // pow_hash > target → not a block
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isBlock) {
|
|
||||||
// SHA256D meets block target — submit immediately
|
|
||||||
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), nullptr);
|
|
||||||
submitted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Also check RandomX hash for normal share difficulty (if not already submitted)
|
|
||||||
if (!submitted) {
|
|
||||||
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
|
|
||||||
if (value < job.target()) {
|
|
||||||
JobResults::submit(job, current_job_nonces[i], m_hash + (i * 32), nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// ── Standard XMRig path (Monero, CryptoNight, etc.) ──
|
// ── Standard XMRig path (Monero, CryptoNight, etc.) ──
|
||||||
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
|
const uint64_t value = *reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24);
|
||||||
|
|||||||
@@ -418,7 +418,6 @@ bool xmrig::Client::parseJob(const rapidjson::Value ¶ms, int *code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
job.setSigKey(Json::getString(params, "sig_key"));
|
job.setSigKey(Json::getString(params, "sig_key"));
|
||||||
job.setBlockTarget(Json::getString(params, "block_target"));
|
|
||||||
|
|
||||||
m_job.setClientId(m_rpcId);
|
m_job.setClientId(m_rpcId);
|
||||||
|
|
||||||
|
|||||||
@@ -115,40 +115,6 @@ bool xmrig::Job::setSeedHash(const char *hash)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Job::setBlockTarget(const char *target)
|
|
||||||
{
|
|
||||||
if (!target) {
|
|
||||||
m_hasBlockTarget = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t len = strlen(target);
|
|
||||||
if (len != 64) { // 32 bytes = 64 hex chars
|
|
||||||
m_hasBlockTarget = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse 64-char hex string (display order) into uint256-compatible internal byte order.
|
|
||||||
// Display "00072f0f...000" → internal: data[31]=0x00, data[30]=0x07, data[29]=0x2f, ...
|
|
||||||
// This matches how Bitcoin/Zcash uint256 stores values (LSB at data[0], MSB at data[31]).
|
|
||||||
// Raw SHA256D output from OpenSSL also goes into uint256.data[] without reversal,
|
|
||||||
// so both hash and target are in the same internal byte order for comparison.
|
|
||||||
uint8_t tmp[32];
|
|
||||||
if (!Cvt::fromHex(tmp, sizeof(tmp), target, len)) {
|
|
||||||
m_hasBlockTarget = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reverse display order to internal byte order (LSB-first / little-endian uint256)
|
|
||||||
for (int i = 0; i < 32; ++i) {
|
|
||||||
m_blockTarget[i] = tmp[31 - i];
|
|
||||||
}
|
|
||||||
|
|
||||||
m_hasBlockTarget = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Job::setTarget(const char *target)
|
bool xmrig::Job::setTarget(const char *target)
|
||||||
{
|
{
|
||||||
static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t {
|
static auto parse = [](const char *target, size_t size, const Algorithm &algorithm) -> uint64_t {
|
||||||
@@ -331,9 +297,6 @@ void xmrig::Job::copy(const Job &other)
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
m_hasMinerSignature = other.m_hasMinerSignature;
|
m_hasMinerSignature = other.m_hasMinerSignature;
|
||||||
m_hasBlockTarget = other.m_hasBlockTarget;
|
|
||||||
m_isSoloMining = other.m_isSoloMining;
|
|
||||||
memcpy(m_blockTarget, other.m_blockTarget, sizeof(m_blockTarget));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -390,9 +353,6 @@ void xmrig::Job::move(Job &&other)
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
m_hasMinerSignature = other.m_hasMinerSignature;
|
m_hasMinerSignature = other.m_hasMinerSignature;
|
||||||
m_hasBlockTarget = other.m_hasBlockTarget;
|
|
||||||
m_isSoloMining = other.m_isSoloMining;
|
|
||||||
memcpy(m_blockTarget, other.m_blockTarget, sizeof(m_blockTarget));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -105,11 +105,6 @@ public:
|
|||||||
inline bool isSoloMining() const { return m_isSoloMining; }
|
inline bool isSoloMining() const { return m_isSoloMining; }
|
||||||
inline void setSoloMining(bool solo) { m_isSoloMining = solo; }
|
inline void setSoloMining(bool solo) { m_isSoloMining = solo; }
|
||||||
|
|
||||||
// DragonX block target for SHA256D PoW check (32 bytes, internal byte order)
|
|
||||||
inline bool hasBlockTarget() const { return m_hasBlockTarget; }
|
|
||||||
inline const uint8_t *blockTarget() const { return m_blockTarget; }
|
|
||||||
bool setBlockTarget(const char *target);
|
|
||||||
|
|
||||||
void setHushHeader(const uint8_t *header108);
|
void setHushHeader(const uint8_t *header108);
|
||||||
|
|
||||||
# ifdef XMRIG_PROXY_PROJECT
|
# ifdef XMRIG_PROXY_PROJECT
|
||||||
@@ -177,8 +172,6 @@ private:
|
|||||||
uint8_t m_blob[kMaxBlobSize]{ 0 };
|
uint8_t m_blob[kMaxBlobSize]{ 0 };
|
||||||
uint8_t m_index = 0;
|
uint8_t m_index = 0;
|
||||||
bool m_isSoloMining = false;
|
bool m_isSoloMining = false;
|
||||||
bool m_hasBlockTarget = false;
|
|
||||||
uint8_t m_blockTarget[32]{};
|
|
||||||
|
|
||||||
# ifdef XMRIG_PROXY_PROJECT
|
# ifdef XMRIG_PROXY_PROJECT
|
||||||
char m_rawBlob[kMaxBlobSize * 2 + 8]{};
|
char m_rawBlob[kMaxBlobSize * 2 + 8]{};
|
||||||
|
|||||||
Reference in New Issue
Block a user