Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ca1beeb73 | |||
| 85750521bb | |||
| 0255b801e5 | |||
| fa53bdea55 | |||
| e1acf7b786 | |||
| 54e0d3f3eb | |||
| eaee503d05 | |||
| 35f97b999c | |||
| 44ea8e4557 | |||
| f3d97dc3d6 | |||
| a32b4a6336 | |||
| 34f21e6236 | |||
| 964e4a6163 | |||
| f1b2c3c51f | |||
| b05361653e | |||
| 0019d9ff0d | |||
| 941e5114d8 | |||
| bec1a56f7d | |||
| dcfc64da42 | |||
| 9fee040ce0 | |||
| ca39b36337 | |||
| 7923f84233 | |||
| 7667f9d21e | |||
| 0741ad1c07 | |||
| f05ce6f697 | |||
| 23d3a24bc4 | |||
| 2cc5ba2fb9 | |||
| 93e3c07a18 | |||
| 7f0be0bcf5 | |||
| f8310f27b8 | |||
| 160ebd4289 | |||
| 6d6c12c1e8 | |||
| cf1c88b907 | |||
| 6449a78863 | |||
| d966088470 | |||
| 5faec12678 | |||
| 1bcddc8329 | |||
| 0905b23123 | |||
| 64914566c0 | |||
| ab80f55698 | |||
| 31860f2e65 | |||
| 6e7311a83c | |||
| e0a6daa5c7 | |||
| 313fb64b41 | |||
| 096e2e086b |
+37
-132
@@ -36,7 +36,7 @@ jobs:
|
||||
apk add git cmake gcc g++ make linux-headers xz
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -104,7 +104,7 @@ jobs:
|
||||
file p2pool
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-alpine-static-${{ matrix.config.arch }}
|
||||
path: build/p2pool
|
||||
@@ -132,7 +132,7 @@ jobs:
|
||||
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev xz-utils ${{ matrix.config.c }} ${{ matrix.config.cpp }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -165,7 +165,7 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-${{ matrix.config.os }}-${{ matrix.config.c }}
|
||||
path: build/p2pool
|
||||
@@ -189,7 +189,7 @@ jobs:
|
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -204,7 +204,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -244,7 +244,7 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-ubuntu-static-libs
|
||||
path: build/p2pool
|
||||
@@ -266,7 +266,7 @@ jobs:
|
||||
sudo apt install -y git build-essential cmake xz-utils
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -281,7 +281,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -321,106 +321,11 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-${{ matrix.config.os }}-aarch64
|
||||
path: build/p2pool
|
||||
|
||||
build-ubuntu-riscv64:
|
||||
|
||||
timeout-minutes: 60
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
config:
|
||||
- {os: ubuntu-22.04, flags: "-fuse-linker-plugin -ffunction-sections"}
|
||||
|
||||
steps:
|
||||
- name: Setup Alpine Linux
|
||||
uses: jirutka/setup-alpine@v1
|
||||
with:
|
||||
arch: riscv64
|
||||
branch: latest-stable
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y git build-essential cmake gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu xz-utils
|
||||
sudo cp /usr/riscv64-linux-gnu/lib/* /home/runner/rootfs/alpine-latest-riscv64/lib
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build libcurl
|
||||
run: |
|
||||
cd external/src/curl
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS="-Os -flto=auto ${{ matrix.config.flags }}" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libuv
|
||||
run: |
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
run: |
|
||||
cd external/src/libzmq
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='-Os -flto=auto ${{ matrix.config.flags }}' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build p2pool
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DSTATIC_LIBS=ON -DARCH_ID=riscv64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc) p2pool
|
||||
|
||||
- name: Run self-test
|
||||
shell: alpine.sh {0}
|
||||
run: build/p2pool --test
|
||||
|
||||
- name: Build RandomX tests
|
||||
run: |
|
||||
cd build
|
||||
make -j$(nproc) randomx-tests
|
||||
|
||||
- name: Run RandomX tests
|
||||
shell: alpine.sh {0}
|
||||
run: build/external/src/RandomX/randomx-tests
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd tests
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/riscv64_toolchain.cmake -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DSTATIC_LIBS=ON -DARCH_ID=riscv64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc) p2pool_tests
|
||||
|
||||
- name: Prepare test data
|
||||
run: |
|
||||
cd tests/build
|
||||
unxz *.xz
|
||||
|
||||
- name: Run tests
|
||||
shell: alpine.sh {0}
|
||||
run: |
|
||||
cd tests/build
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: p2pool-${{ matrix.config.os }}-riscv64
|
||||
path: build/p2pool
|
||||
|
||||
build-windows-msys2:
|
||||
|
||||
timeout-minutes: 60
|
||||
@@ -438,7 +343,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -463,7 +368,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_C_FLAGS='-Os ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_C_FLAGS='-Os ${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -503,7 +408,7 @@ jobs:
|
||||
./p2pool_tests.exe
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-msys2-${{ matrix.config.c }}.exe
|
||||
path: build/p2pool.exe
|
||||
@@ -524,7 +429,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -575,7 +480,7 @@ jobs:
|
||||
p2pool_tests.exe
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-vs-${{ matrix.config.os }}-randomx-${{ matrix.config.rx }}-upnp-${{ matrix.config.upnp }}-grpc-${{ matrix.config.grpc }}-tls-${{ matrix.config.tls }}.exe
|
||||
path: build/Release/p2pool.exe
|
||||
@@ -583,18 +488,18 @@ jobs:
|
||||
build-macos:
|
||||
|
||||
timeout-minutes: 90
|
||||
runs-on: macos-15-intel
|
||||
runs-on: macos-26-intel
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build libcurl
|
||||
run: |
|
||||
cd external/src/curl
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
make -j4
|
||||
|
||||
- name: Build libuv
|
||||
@@ -602,7 +507,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j4
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -610,14 +515,14 @@ jobs:
|
||||
cd external/src/libzmq
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_CXX_FLAGS='-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_CXX_FLAGS='-Os -flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF
|
||||
make -j4
|
||||
|
||||
- name: Build p2pool
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_CXX_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_ASM_FLAGS='-target x86_64-apple-macos10.13' -DSTATIC_LIBS=ON
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_CXX_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_ASM_FLAGS='-target x86_64-apple-macos10.13' -DSTATIC_LIBS=ON
|
||||
make -j4 p2pool
|
||||
|
||||
- name: Run RandomX tests
|
||||
@@ -632,7 +537,7 @@ jobs:
|
||||
cd tests
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_CXX_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_ASM_FLAGS='-target x86_64-apple-macos10.13' -DSTATIC_LIBS=ON
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_CXX_FLAGS='-flto -target x86_64-apple-macos10.13 -Wno-overriding-t-option' -DCMAKE_ASM_FLAGS='-target x86_64-apple-macos10.13' -DSTATIC_LIBS=ON
|
||||
make -j4 p2pool_tests
|
||||
|
||||
- name: Run tests
|
||||
@@ -642,7 +547,7 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-macos
|
||||
path: build/p2pool
|
||||
@@ -650,18 +555,18 @@ jobs:
|
||||
build-macos-aarch64:
|
||||
|
||||
timeout-minutes: 30
|
||||
runs-on: macos-15
|
||||
runs-on: macos-26
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build libcurl
|
||||
run: |
|
||||
cd external/src/curl
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-Os -target arm64-apple-macos-11" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-Os -target arm64-apple-macos-11" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
make -j3
|
||||
|
||||
- name: Build libuv
|
||||
@@ -669,7 +574,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -target arm64-apple-macos-11' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -target arm64-apple-macos-11' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j3
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -677,14 +582,14 @@ jobs:
|
||||
cd external/src/libzmq
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -target arm64-apple-macos-11' -DCMAKE_CXX_FLAGS='-Os -target arm64-apple-macos-11' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='-Os -target arm64-apple-macos-11' -DCMAKE_CXX_FLAGS='-Os -target arm64-apple-macos-11' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF
|
||||
make -j3
|
||||
|
||||
- name: Build p2pool
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-target arm64-apple-macos-11" -DCMAKE_CXX_FLAGS="-target arm64-apple-macos-11" -DSTATIC_LIBS=ON -DWITH_LTO=OFF -DARCH_ID=aarch64
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-target arm64-apple-macos-11" -DCMAKE_CXX_FLAGS="-target arm64-apple-macos-11" -DSTATIC_LIBS=ON -DWITH_LTO=OFF -DARCH_ID=aarch64
|
||||
make -j3 p2pool
|
||||
|
||||
- name: Run RandomX tests
|
||||
@@ -699,7 +604,7 @@ jobs:
|
||||
cd tests
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-target arm64-apple-macos-11" -DCMAKE_CXX_FLAGS="-target arm64-apple-macos-11" -DSTATIC_LIBS=ON -DWITH_LTO=OFF -DARCH_ID=aarch64
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="-target arm64-apple-macos-11" -DCMAKE_CXX_FLAGS="-target arm64-apple-macos-11" -DSTATIC_LIBS=ON -DWITH_LTO=OFF -DARCH_ID=aarch64
|
||||
make -j3 p2pool_tests
|
||||
|
||||
- name: Run tests
|
||||
@@ -709,7 +614,7 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-macos-aarch64
|
||||
path: build/p2pool
|
||||
@@ -729,7 +634,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -755,7 +660,7 @@ jobs:
|
||||
cd ../libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='-Os -flto' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j4
|
||||
cd ../../libzmq
|
||||
mkdir build
|
||||
@@ -779,7 +684,7 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-${{ matrix.os.name }}-${{ matrix.os.version }}
|
||||
path: build/p2pool
|
||||
@@ -799,7 +704,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -830,7 +735,7 @@ jobs:
|
||||
./p2pool_tests
|
||||
|
||||
- name: Archive binary
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-${{ matrix.os.name }}-${{ matrix.os.version }}
|
||||
path: build/p2pool
|
||||
|
||||
@@ -19,12 +19,12 @@ jobs:
|
||||
run: |
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 21
|
||||
sudo apt-get install -y clang-tidy-21
|
||||
clang-tidy-21 --verify-config
|
||||
sudo ./llvm.sh 22
|
||||
sudo apt-get install -y clang-tidy-22
|
||||
clang-tidy-22 --verify-config
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -32,9 +32,9 @@ jobs:
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DDEV_CLANG_TIDY=ON -DSTATIC_LIBS=ON -DWITH_INDEXED_HASHES=ON -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22 -DDEV_CLANG_TIDY=ON -DSTATIC_LIBS=ON -DWITH_INDEXED_HASHES=ON -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
|
||||
- name: Run clang-tidy
|
||||
run: |
|
||||
cd src
|
||||
clang-tidy-21 *.cpp -p ../build -checks=bugprone-*,clang-analyzer-*,llvm-*,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-cstyle-cast,cppcoreguidelines-rvalue-reference-param-not-moved,hicpp-use-emplace,hicpp-use-override,-bugprone-easily-swappable-parameters,-bugprone-empty-catch,-llvm-include-order -warnings-as-errors=* -header-filter=^[^\./]
|
||||
clang-tidy-22 *.cpp -p ../build -checks=bugprone-*,clang-analyzer-*,llvm-*,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-cstyle-cast,cppcoreguidelines-rvalue-reference-param-not-moved,hicpp-use-emplace,hicpp-use-override,-bugprone-easily-swappable-parameters,-bugprone-empty-catch,-llvm-include-order,-bugprone-random-generator-seed,-llvm-use-ranges,-bugprone-throwing-static-initialization -warnings-as-errors=* -header-filter=^[^\./]
|
||||
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
sudo apt update && sudo apt install git build-essential cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ jobs:
|
||||
run: |
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 21 all
|
||||
sudo ./llvm.sh 22 all
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
cd tests
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DDEV_DEBUG=ON -DWITH_INDEXED_HASHES=ON -DWITH_COVERAGE=ON -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DDEV_DEBUG=ON -DWITH_INDEXED_HASHES=ON -DWITH_COVERAGE=ON -DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc) p2pool_tests
|
||||
|
||||
- name: Run tests
|
||||
@@ -50,12 +50,12 @@ jobs:
|
||||
- name: Merge profile data
|
||||
run: |
|
||||
cd tests/build
|
||||
llvm-profdata-21 merge -sparse ./p2pool_tests.profraw -o ./p2pool_tests.profdata
|
||||
llvm-profdata-22 merge -sparse ./p2pool_tests.profraw -o ./p2pool_tests.profdata
|
||||
|
||||
- name: Export profile data
|
||||
run: |
|
||||
cd tests/build
|
||||
llvm-cov-21 export ./p2pool_tests -format=lcov -instr-profile=./p2pool_tests.profdata > coverage.info
|
||||
llvm-cov-22 export ./p2pool_tests -format=lcov -instr-profile=./p2pool_tests.profdata > coverage.info
|
||||
|
||||
- name: Run genhtml
|
||||
run: |
|
||||
@@ -63,7 +63,7 @@ jobs:
|
||||
genhtml --demangle-cpp -o coverage coverage.info
|
||||
|
||||
- name: Checkout GitHub Pages repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
repository: SChernykh/SChernykh.github.io
|
||||
token: ${{ secrets.PAGES_DEPLOY_TOKEN }}
|
||||
@@ -85,7 +85,7 @@ jobs:
|
||||
|
||||
- name: Archive coverage data
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool-coverage
|
||||
path: tests/build/coverage
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -48,14 +48,14 @@ jobs:
|
||||
|
||||
- name: Archive full error list
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: errors_full-linux
|
||||
path: cppcheck/errors_full.txt
|
||||
|
||||
- name: Archive checkers report
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: checkers_report-linux
|
||||
path: cppcheck/checkers_report.txt
|
||||
@@ -67,7 +67,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -96,14 +96,14 @@ jobs:
|
||||
|
||||
- name: Archive full error list
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: errors_full-windows
|
||||
path: cppcheck/errors_full.txt
|
||||
|
||||
- name: Archive checkers report
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: checkers_report-windows
|
||||
path: cppcheck/checkers_report.txt
|
||||
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -58,13 +58,13 @@ jobs:
|
||||
|
||||
# Upload SARIF file to GitHub Code Scanning Alerts
|
||||
- name: Upload SARIF to GitHub
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
uses: github/codeql-action/upload-sarif@v4
|
||||
with:
|
||||
sarif_file: ${{ steps.run-analysis.outputs.sarif }}
|
||||
|
||||
# Upload SARIF file as an Artifact to download and view
|
||||
- name: Upload SARIF as an Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: sarif-file
|
||||
path: ${{ steps.run-analysis.outputs.sarif }}
|
||||
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
XZ_OPT=-e9 tar --exclude=".git" --exclude="build" -f build/p2pool_source.tar.xz -c ../p2pool --xz
|
||||
|
||||
- name: Archive source code
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_source.tar.xz
|
||||
path: build/p2pool_source.tar.xz
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
sudo apt install -y git build-essential cmake gcc-12 g++-12
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_C_FLAGS='-fsanitize=thread -Og -fno-omit-frame-pointer -g' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_C_FLAGS='-fsanitize=thread -Og -fno-omit-frame-pointer -g' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -82,7 +82,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_ubuntu_data_tsan
|
||||
path: |
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
|
||||
sync-test-ubuntu-msan:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-22.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
@@ -103,14 +103,14 @@ jobs:
|
||||
run: |
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 21 all
|
||||
sudo ./llvm.sh 22 all
|
||||
|
||||
- name: Build libcxx_msan
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/llvm/llvm-project -b release/21.x
|
||||
git clone --depth=1 https://github.com/llvm/llvm-project -b release/22.x
|
||||
cd llvm-project
|
||||
mkdir build
|
||||
cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DLLVM_USE_SANITIZER=MemoryWithOrigins -DLIBCXXABI_USE_LLVM_UNWINDER=OFF
|
||||
cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" -DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22 -DLLVM_USE_SANITIZER=MemoryWithOrigins -DLIBCXXABI_USE_LLVM_UNWINDER=OFF
|
||||
ninja -C build cxx cxxabi
|
||||
cd build
|
||||
mkdir /tmp/libcxx_msan
|
||||
@@ -118,14 +118,14 @@ jobs:
|
||||
cp -r lib /tmp/libcxx_msan
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build libcurl
|
||||
run: |
|
||||
cd external/src/curl
|
||||
cmake . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-21 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -O0 -fno-omit-frame-pointer -g3' -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
cmake . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-22 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -O0 -fno-omit-frame-pointer -g3' -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libuv
|
||||
@@ -133,7 +133,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-21 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -O0 -fno-omit-frame-pointer -g3' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-22 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -O0 -fno-omit-frame-pointer -g3' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -141,14 +141,14 @@ jobs:
|
||||
cd external/src/libzmq
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -O0 -fno-omit-frame-pointer -g3' -DCMAKE_CXX_FLAGS='-nostdinc++ -nostdlib++ -fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -isystem /tmp/libcxx_msan/include/c++/v1 -O0 -fno-omit-frame-pointer -g3' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -O0 -fno-omit-frame-pointer -g3' -DCMAKE_CXX_FLAGS='-nostdinc++ -nostdlib++ -fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -isystem /tmp/libcxx_msan/include/c++/v1 -O0 -fno-omit-frame-pointer -g3' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc)
|
||||
|
||||
- name: Build p2pool
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -fno-omit-frame-pointer' -DCMAKE_CXX_FLAGS='-nostdinc++ -nostdlib++ -fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -isystem /tmp/libcxx_msan/include/c++/v1 -L/tmp/libcxx_msan/lib -Wl,-rpath /tmp/libcxx_msan/lib -lc++ -lc++abi -Wno-unused-command-line-argument -fuse-ld=lld-21 -fno-omit-frame-pointer' -DDEV_TEST_SYNC=ON -DDEV_WITH_MSAN=ON -DWITH_LTO=OFF -DSTATIC_LIBS=ON -DWITH_INDEXED_HASHES=ON -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22 -DCMAKE_C_FLAGS='-fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -fno-omit-frame-pointer' -DCMAKE_CXX_FLAGS='-nostdinc++ -nostdlib++ -fsanitize=memory -fsanitize-recover -fsanitize-memory-track-origins -isystem /tmp/libcxx_msan/include/c++/v1 -L/tmp/libcxx_msan/lib -Wl,-rpath /tmp/libcxx_msan/lib -lc++ -lc++abi -Wno-unused-command-line-argument -fuse-ld=lld-22 -fno-omit-frame-pointer' -DDEV_TEST_SYNC=ON -DDEV_WITH_MSAN=ON -DWITH_LTO=OFF -DSTATIC_LIBS=ON -DWITH_INDEXED_HASHES=ON -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc) p2pool
|
||||
|
||||
- name: Run p2pool
|
||||
@@ -173,7 +173,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_ubuntu_data_msan
|
||||
path: |
|
||||
@@ -193,7 +193,7 @@ jobs:
|
||||
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev gcc-12 g++-12
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -226,7 +226,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_ubuntu_data_ubsan
|
||||
path: |
|
||||
@@ -246,7 +246,7 @@ jobs:
|
||||
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev gcc-12 g++-12
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -279,7 +279,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_ubuntu_data_asan
|
||||
path: |
|
||||
@@ -301,10 +301,10 @@ jobs:
|
||||
run: |
|
||||
wget https://apt.llvm.org/llvm.sh
|
||||
chmod +x llvm.sh
|
||||
sudo ./llvm.sh 21 all
|
||||
sudo ./llvm.sh 22 all
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -312,7 +312,7 @@ jobs:
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DDEV_TEST_SYNC=ON -DDEV_DEBUG=ON -DDEV_WITH_TYSAN=ON -DWITH_LTO=OFF -DWITH_INDEXED_HASHES=ON -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-22 -DCMAKE_CXX_COMPILER=clang++-22 -DDEV_TEST_SYNC=ON -DDEV_DEBUG=ON -DDEV_WITH_TYSAN=ON -DWITH_LTO=OFF -DWITH_INDEXED_HASHES=ON -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
|
||||
make -j$(nproc) p2pool
|
||||
|
||||
- name: Run p2pool
|
||||
@@ -337,7 +337,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_ubuntu_data_tysan
|
||||
path: |
|
||||
@@ -352,19 +352,19 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
config:
|
||||
- {os: macos-15-intel, flags: ""}
|
||||
- {os: macos-15, flags: "-target arm64-apple-macos-11"}
|
||||
- {os: macos-26-intel, flags: ""}
|
||||
- {os: macos-26, flags: "-target arm64-apple-macos-11"}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Build libcurl
|
||||
run: |
|
||||
cd external/src/curl
|
||||
cmake . -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="${{ matrix.config.flags }}" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
cmake . -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS="${{ matrix.config.flags }}" -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF -DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON -DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF -DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF -DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON -DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON -DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON -DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON -DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON -DCURL_DISABLE_SOCKETPAIR=ON -DCURL_DISABLE_VERBOSE_STRINGS=ON -DCURL_DISABLE_WEBSOCKETS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF -DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF -DENABLE_UNIX_SOCKETS=OFF -DCURL_DISABLE_TESTS=ON -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include
|
||||
make -j4
|
||||
|
||||
- name: Build libuv
|
||||
@@ -372,7 +372,7 @@ jobs:
|
||||
cd external/src/libuv
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF -DENABLE_CLANG_TIDY=OFF
|
||||
make -j4
|
||||
|
||||
- name: Build libzmq
|
||||
@@ -380,14 +380,14 @@ jobs:
|
||||
cd external/src/libzmq
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF
|
||||
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF -DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF
|
||||
make -j4
|
||||
|
||||
- name: Build p2pool
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@18)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@18)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@18)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@18)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DWITH_LTO=OFF -DSTATIC_LIBS=ON -DDEV_TEST_SYNC=ON -DDEV_DEBUG=ON -DWITH_INDEXED_HASHES=ON
|
||||
cmake .. -DCMAKE_C_COMPILER="$(brew --prefix llvm@20)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@20)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@20)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@20)/bin/llvm-ranlib" -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DWITH_LTO=OFF -DSTATIC_LIBS=ON -DDEV_TEST_SYNC=ON -DDEV_DEBUG=ON -DWITH_INDEXED_HASHES=ON
|
||||
make -j4 p2pool
|
||||
|
||||
- name: Run p2pool
|
||||
@@ -411,7 +411,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_${{ matrix.config.os }}_data
|
||||
path: |
|
||||
@@ -425,7 +425,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -457,7 +457,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_windows_data_debug_asan
|
||||
path: |
|
||||
@@ -471,7 +471,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -502,7 +502,7 @@ jobs:
|
||||
|
||||
- name: Archive p2pool.log
|
||||
if: '!cancelled()'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: p2pool_windows_data_leaks
|
||||
path: |
|
||||
|
||||
@@ -131,6 +131,7 @@ set(HEADERS
|
||||
src/uv_util.h
|
||||
src/wallet.h
|
||||
src/zmq_reader.h
|
||||
src/i2p.h
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
@@ -164,6 +165,7 @@ set(SOURCES
|
||||
src/util.cpp
|
||||
src/wallet.cpp
|
||||
src/zmq_reader.cpp
|
||||
src/i2p.cpp
|
||||
)
|
||||
|
||||
if (AMD64)
|
||||
|
||||
@@ -66,7 +66,7 @@ Here's the comparison table of the different ways of mining. While pool mining i
|
||||
* Advanced mempool picking algorithm, it creates blocks with better reward than what monerod solo mining does
|
||||
* Password protected private pools
|
||||
* Highly reliable configurations are supported (multiple P2Pool nodes mining to the same wallet, each P2Pool node can use multiple Monero nodes and switch on the fly if an issue is detected)
|
||||
* Mining through [TOR](docs/TOR.MD) is fully supported
|
||||
* Mining through [TOR](docs/TOR.MD) and [I2P](docs/I2P.MD) are fully supported
|
||||
|
||||
## How payouts work in P2Pool
|
||||
|
||||
@@ -96,19 +96,16 @@ In order to continue mining on P2Pool, you must update both Monero and P2Pool so
|
||||
### General Considerations
|
||||
|
||||
- In order to mine on P2Pool, a synced Monero node using monerod v0.18.0.0 or newer is required. If you don't currently have one, you can download the [official Monero binaries](https://www.getmonero.org/downloads/), start `monerod` on your PC and wait until it's fully synced. Advanced Monero node setup instructions are [here](https://sethforprivacy.com/guides/run-a-monero-node-advanced/).
|
||||
- It is highly recommended that you create a separate restricted user account (in your OS) for mining. While P2Pool has been battle-tested for a long time now, any software may have unknown bugs/vulnerabilities.
|
||||
- It is highly recommended that you create a separate restricted user account (in your OS) for mining. While P2Pool has been battle-tested for a long time now, any software may have unknown bugs/vulnerabilities.
|
||||
- You can mine to a primary wallet address (the one starting with `4`) for mining. If you want to mine to a subaddress, you will need to provide both the main address (starting with 4) and the subaddress (starting with 8) using `--wallet` and `--subaddress` command line parameters.
|
||||
- You can add the `--mini` or `--nano` parameter to your P2Pool command to connect to the respective sidechain.
|
||||
> [!NOTE]
|
||||
>
|
||||
> You cannot use both `--mini` and `--nano` together
|
||||
>
|
||||
> Using `--mini` will change the p2p port to 37888.
|
||||
>
|
||||
> Using `--nano` will change the p2p port to 37890.
|
||||
> [!NOTE]
|
||||
> You cannot use both `--mini` and `--nano` together<br>
|
||||
> Using `--mini` will change the p2p port to 37888.<br>
|
||||
> Using `--nano` will change the p2p port to 37890.<br>
|
||||
- Check that ports 18080 (Monero p2p port) and 37889/37888/37890 (P2Pool default/mini/nano p2p port) are open in your firewall to ensure better connectivity. If you're mining from a computer behind NAT (like a router) you could consider forwarding the ports to your local machine.
|
||||
- You can connect multiple miners to the same P2Pool node. The more the better!
|
||||
- The steps below assume that you run everything on the same machine. If it's not the case, change `127.0.0.1` to appropriate IP addresses for your setup.
|
||||
- The steps below assume that you run everything on the same machine. If it's not the case, change `127.0.0.1` to appropriate IP addresses for your setup.
|
||||
- It is highly recommended to create a new mainnet wallet for P2Pool mining because **wallet addresses are public on P2Pool**.
|
||||
|
||||
**Wallet software compatible with P2Pool payouts**
|
||||
@@ -117,7 +114,6 @@ In order to continue mining on P2Pool, you must update both Monero and P2Pool so
|
||||
- [Cake Wallet v4.4.5 and newer](https://cakewallet.com/)
|
||||
- [Monero.com by Cake Wallet](https://monero.com/)
|
||||
- [Feather Wallet v2.1.0 and newer](https://featherwallet.org/)
|
||||
- [MyMonero](https://mymonero.com/)
|
||||
|
||||
### GUI for P2Pool
|
||||
|
||||
@@ -129,7 +125,7 @@ Merge mining is available in P2Pool since the fork that happened on October 12th
|
||||
|
||||
Blockchains that will support [Merge mining RPC API](https://github.com/SChernykh/p2pool/blob/master/docs/MERGE_MINING.MD#proposed-rpc-api):
|
||||
- [Townforge](https://townforge.net/) supports it in their [tmp-mm branch](https://git.townforge.net/townforge/townforge/src/branch/tmp-mm) (not released yet)
|
||||
- [DarkFi](https://dark.fi/) is going to support it, but it's [not ready yet](https://github.com/darkrenaissance/darkfi/issues/244)
|
||||
- [DarkFi](https://dark.fi/) supports it in their [testnet](https://dark.fi/book/testnet/merge-mining.html)
|
||||
```
|
||||
p2pool.exe --wallet YOUR_MONERO_WALLET_ADDRESS --merge-mine IP:port YOUR_WALLET_ADDRESS_ON_ANOTHER_BLOCKCHAIN
|
||||
```
|
||||
@@ -161,15 +157,15 @@ Note that Tari will be mined in solo mode (only full Tari blocks can be mined fo
|
||||
1. Download the latest P2Pool binaries [here](https://github.com/SChernykh/p2pool/releases/latest).
|
||||
- Alternatively, grab the latest source code for P2Pool and [build it](#build-instructions).
|
||||
2. Download the latest XMRig (linux-static-x64) binary [here](https://github.com/xmrig/xmrig/releases/latest).
|
||||
3. Prepare enough huge pages (each of monerod/P2Pool/XMRig needs them):
|
||||
3. Prepare enough huge pages (each of monerod/P2Pool/XMRig needs them):
|
||||
```
|
||||
sudo sysctl vm.nr_hugepages=3072
|
||||
```
|
||||
4. Check that ports 18080 (Monero p2p port) and 37889/37888/37890 (P2Pool default/mini/nano p2p port) are open in your local firewall to ensure better connectivity.
|
||||
5. Start `monerod` with the following command/options:
|
||||
4. Check that ports 18080 (Monero p2p port) and 37889/37888/37890 (P2Pool default/mini/nano p2p port) are open in your local firewall to ensure better connectivity.
|
||||
5. Start `monerod` with the following command/options:
|
||||
```
|
||||
./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
|
||||
```
|
||||
```
|
||||
**Note:**
|
||||
The `--zmq-pub` option is required for P2Pool to work properly.
|
||||
|
||||
@@ -191,16 +187,16 @@ The `--zmq-pub` option is required for P2Pool to work properly.
|
||||
```
|
||||
./xmrig -o 127.0.0.1:3333
|
||||
```
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
```
|
||||
./xmrig -u x+10000 -o 127.0.0.1:3333
|
||||
```
|
||||
9. XMRig should connect and start mining!
|
||||
|
||||
**Additional Information:**
|
||||
**Additional Information:**
|
||||
- For a more in-depth beginner friendly walk-through with the option of using Docker, please see SethForPrivacy's guide at: https://sethforprivacy.com/guides/run-a-p2pool-node/
|
||||
- You can check the p2pool.log for any warnings or errors using the following command:
|
||||
- You can check the p2pool.log for any warnings or errors using the following command:
|
||||
```
|
||||
grep -E 'WARNING|ERROR' p2pool.log
|
||||
```
|
||||
@@ -217,7 +213,7 @@ nocreate
|
||||
}
|
||||
```
|
||||
|
||||
### Windows
|
||||
### Windows
|
||||
|
||||
**Note:** *Windows SmartScreen may block incoming connections by files that are "Downloaded from the Internet". You can allow 'p2pool.exe' and 'monerod.exe' by double-clicking them, clicking "More Info", then click "Run Anyway" and then closing them immediately so you can run them from the command line. Advanced users can use the PowerShell cmdlet `Unblock-File` to remove this flag.*
|
||||
|
||||
@@ -225,8 +221,8 @@ nocreate
|
||||
- Alternatively, grab the latest source code for P2Pool and [build it](#build-instructions).
|
||||
2. Download the latest XMRig binary [here](https://github.com/xmrig/xmrig/releases/latest).
|
||||
3. Expand the P2Pool binaries into an appropriate location (`%USERPROFILE%/bin` or `C:/bin/` are good options)
|
||||
4. Expand XMRig binary into an appropriate location (the same folder as P2Pool is fine).
|
||||
5. Prepare huge pages to work properly (each of monerod/P2Pool/XMRig needs them):
|
||||
4. Expand XMRig binary into an appropriate location (the same folder as P2Pool is fine).
|
||||
5. Prepare huge pages to work properly (each of monerod/P2Pool/XMRig needs them):
|
||||
- On Windows 10 or above, run XMRig at least once as Administrator (right-click Run As Administrator)
|
||||
- On earlier versions of Windows, you'll need to run XMRig as Administrator at least once per login.
|
||||
6. Create "Monero" folder inside extracted P2Pool folder and copy Monero binaries there.
|
||||
@@ -234,7 +230,7 @@ nocreate
|
||||
|
||||
**Note:** *When running the below commands, Windows Firewall may prompt to allow connections, click "Allow" if prompted.*
|
||||
|
||||
8. Start `monerod` with the following command/options:
|
||||
8. Start `monerod` with the following command/options:
|
||||
```
|
||||
.\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
|
||||
```
|
||||
@@ -258,8 +254,8 @@ The `--zmq-pub` option is required for P2Pool to work properly.
|
||||
```
|
||||
.\xmrig.exe -o 127.0.0.1:3333
|
||||
```
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
```
|
||||
xmrig.exe -u x+10000 -o 127.0.0.1:3333
|
||||
```
|
||||
@@ -303,7 +299,7 @@ pacman -S p2pool
|
||||
|
||||
### [Nix/NixOS](https://nixos.org)
|
||||
|
||||
This is a flake only project. So you have to use [nixUnstable with nix flakes](https://nixos.wiki/wiki/Flakes) to build or install P2Pool.
|
||||
This is a flake only project. So you have to use [nixUnstable with nix flakes](https://nixos.wiki/wiki/Flakes) to build or install P2Pool.
|
||||
The commands below use the new flake specific reference-format, so be sure to also set `ca-references` in `--experimental-features`.
|
||||
|
||||
Because this project has submodules which are not fixed in _nixUnstable_ yet you have to use the `nix/master` branch:
|
||||
@@ -334,7 +330,7 @@ cmake .. -G "Visual Studio 16 2019"
|
||||
```
|
||||
then open generated build\p2pool.sln in Visual Studio and build it there
|
||||
|
||||
Alternatively, you can select "Clone a repository" within the GUI, then select "Build" from the menu.
|
||||
Alternatively, you can select "Clone a repository" within the GUI, then select "Build" from the menu.
|
||||
|
||||
### macOS
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
--no-autodiff Disable automatic difficulty adjustment for miners connected to stratum (WARNING: incompatible with Nicehash and MRR)
|
||||
--rpc-login Specify username[:password] required for Monero RPC server
|
||||
--socks5 Specify IP:port of a SOCKS5 proxy to use for outgoing connections
|
||||
--socks5-proxy-type The type of SOCKS5 proxy. Can be one of the following values: auto, plain, tor. Default is auto (auto-detect by the port number)
|
||||
--no-dns Disable DNS queries, use only IP addresses to connect to peers (seed node DNS will be unavailable too)
|
||||
--p2p-external-port Port number that your router uses for mapping to your local p2p port. Use it if you are behind a NAT and still want to accept incoming connections
|
||||
--no-upnp Disable UPnP port forwarding
|
||||
@@ -40,6 +41,8 @@
|
||||
--tls-cert-key file Load TLS certificate private key from "file" in the PEM format
|
||||
--rpc-ssl Enable SSL on RPC connections to the Monero node
|
||||
--rpc-ssl-fingerprint base64-encoded fingerprint of the Monero node's certificate (optional, use it for certificate pinning)
|
||||
--stratum-proxy-protocol Enable HAProxy PROXY protocol v2 for incoming Stratum connections (use with HAProxy send-proxy-v2)
|
||||
--p2p-proxy-protocol Enable HAProxy PROXY protocol v2 for incoming P2P connections (use with HAProxy send-proxy-v2)
|
||||
--no-stratum-http Disable HTTP on Stratum ports
|
||||
--full-validation Enables full share validation / increases CPU usage
|
||||
--onion-address Tell other peers to use this .onion address to connect to this node through TOR
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
## Running P2Pool with I2P
|
||||
|
||||
P2Pool has several command-line options that should be used for I2P setup:
|
||||
|
||||
- `--socks5 IP:port` to specify your I2P SOCKS proxy address (usually `127.0.0.1:4447` if you are using i2pd or followed the guide below)
|
||||
- `--socks5-proxy-type i2p` to specify the type of SOCKS5 proxy being used
|
||||
- `--no-dns` to disable all DNS queries and prevent DNS leaks. P2Pool only ever makes DNS requests to get a list of seed nodes, to resolve your Monero node's domain (if it's not set as an IP address), and to resolve manually added peers
|
||||
- `--no-upnp` to disable UPnP requests (they are sent to your router, so use this option if you are not on your home network)
|
||||
- `--i2p-address` your hidden service's `.b32.i2p` address (without port number). This address will be broadcast to other peers when you mine a share in P2Pool. This is to prevent address spamming - you have to mine a real share to be able to broadcast your I2P address.
|
||||
- **Attention: this also links the I2P address with the Monero wallet you use for mining. Create a new I2P address when mining through I2P, don't use your existing addresses to avoid metadata leaks.**
|
||||
- `--no-clearnet-p2p` to never connect to clearnet P2Pool nodes.
|
||||
|
||||
## Setting up I2P tunnels for P2Pool (i2pd on Linux)
|
||||
|
||||
Follow [these instructions](https://docs.i2pd.website/en/latest/user-guide/install/) to install i2pd on your system.
|
||||
First, ensure the SOCKS proxy tunnel is enabled (as it should be by default). See [here](https://docs.i2pd.website/en/latest/user-guide/configuration/) for more information.
|
||||
|
||||
You will need to modify some lines in the `tunnels.conf` file, usually located in `/var/lib/i2pd/tunnels.conf` on Linux.
|
||||
Add a server tunnel to allow inbound connections from peers:
|
||||
```ini
|
||||
[p2pool]
|
||||
type = server
|
||||
host = 127.0.0.1
|
||||
port = 28723
|
||||
keys = p2pool.dat
|
||||
```
|
||||
This will create a hidden service key in `/var/lib/i2pd/p2pool.dat`; you may want to back this up.
|
||||
Please note that you **must** use the port number shown above in order for other peers to be able to find you.
|
||||
|
||||
Restart i2pd:
|
||||
```bash
|
||||
sudo systemctl restart i2pd.service
|
||||
```
|
||||
|
||||
Get the hostname of your hidden service:
|
||||
```bash
|
||||
curl -s http://127.0.0.1:7070/?page=i2p_tunnels | grep -Eo "[a-zA-Z0-9./?=_%:-]*" | grep "28723"
|
||||
```
|
||||
|
||||
The resulting `.b32.i2p` address should then be used for the `--i2p-address` command-line parameter.
|
||||
|
||||
## Command line example
|
||||
```bash
|
||||
./p2pool --host MONERO_NODE_IP --wallet YOUR_WALLET --socks5 127.0.0.1:4447 --socks5-proxy-type i2p --no-dns --no-upnp --i2p-address YOUR_I2P_ADDRESS
|
||||
```
|
||||
+2
-1
@@ -3,6 +3,7 @@
|
||||
P2Pool has several command-line options that should be used for TOR setup:
|
||||
|
||||
- `--socks5 IP:port` to specify your TOR proxy address (usually `127.0.0.1:9050` if you installed TOR on the same PC)
|
||||
- `--socks5-proxy-type tor` to specify the type of SOCKS5 proxy being used
|
||||
- `--no-dns` to disable all DNS queries and prevent DNS leaks. P2Pool only ever makes DNS requests to get a list of seed nodes, to resolve your Monero node's domain (if it's not set as an IP address), and to resolve manually added peers
|
||||
- `--no-upnp` to disable UPnP requests (they are sent to your router, so use this option if you are not on your home network)
|
||||
- `--onion-address` your hidden service's address (without port number). This address will be broadcast to other peers when you mine a share in P2Pool. This is to prevent address spamming - you have to mine a real share to be able to broadcast your TOR address.
|
||||
@@ -27,5 +28,5 @@ P2Pool has several command-line options that should be used for TOR setup:
|
||||
|
||||
## Command line example
|
||||
```
|
||||
./p2pool --host MONERO_NODE_IP --wallet YOUR_WALLET --socks5 127.0.0.1:9050 --no-dns --no-upnp --onion-address ADDRESS_FROM_HOSTNAME_FILE
|
||||
./p2pool --host MONERO_NODE_IP --wallet YOUR_WALLET --socks5 127.0.0.1:9050 --socks5-proxy-type tor --no-dns --no-upnp --onion-address ADDRESS_FROM_HOSTNAME_FILE
|
||||
```
|
||||
|
||||
@@ -239,7 +239,6 @@ Wallets with confirmed P2Pool support<br>
|
||||
<li><a href="https://play.google.com/store/apps/details?id=com.m2049r.xmrwallet" target="_blank">Monerujo v3.0.2 "Fluorine Fermi"</a> and newer
|
||||
<li><a href="https://play.google.com/store/apps/details?id=com.cakewallet.cake_wallet" target="_blank">Cake Wallet v4.4.5</a> and newer
|
||||
<li><a href="https://featherwallet.org/" target="_blank">Feather Wallet v2.1.0</a> and newer
|
||||
<li><a href="https://mymonero.com/" target="_blank">MyMonero</a>
|
||||
</ul>
|
||||
It's highly recommended to create a new wallet for mining because wallet addresses are public on p2pool. You can mine to a primary wallet address (the one starting with `4`) for mining. If you want to mine to a subaddress, you will need to provide both the main address (starting with 4) and the subaddress (starting with 8) using "--wallet" and "--subaddress" command line parameters.
|
||||
</details>
|
||||
@@ -315,4 +314,4 @@ Donate to support the project:<br><span style="font-size:0.9rem;color:#b0b0b0;">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -239,7 +239,6 @@ Wallets with confirmed P2Pool support<br>
|
||||
<li><a href="https://play.google.com/store/apps/details?id=com.m2049r.xmrwallet" target="_blank">Monerujo v3.0.2 "Fluorine Fermi"</a> and newer
|
||||
<li><a href="https://play.google.com/store/apps/details?id=com.cakewallet.cake_wallet" target="_blank">Cake Wallet v4.4.5</a> and newer
|
||||
<li><a href="https://featherwallet.org/" target="_blank">Feather Wallet v2.1.0</a> and newer
|
||||
<li><a href="https://mymonero.com/" target="_blank">MyMonero</a>
|
||||
</ul>
|
||||
It's highly recommended to create a new wallet for mining because wallet addresses are public on p2pool. You can mine to a primary wallet address (the one starting with `4`) for mining. If you want to mine to a subaddress, you will need to provide both the main address (starting with 4) and the subaddress (starting with 8) using "--wallet" and "--subaddress" command line parameters.
|
||||
</details>
|
||||
@@ -315,4 +314,4 @@ Donate to support the project:<br><span style="font-size:0.9rem;color:#b0b0b0;">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -242,7 +242,6 @@ Wallets with confirmed P2Pool support<br>
|
||||
<li><a href="https://play.google.com/store/apps/details?id=com.m2049r.xmrwallet" target="_blank">Monerujo v3.0.2 "Fluorine Fermi"</a> and newer
|
||||
<li><a href="https://play.google.com/store/apps/details?id=com.cakewallet.cake_wallet" target="_blank">Cake Wallet v4.4.5</a> and newer
|
||||
<li><a href="https://featherwallet.org/" target="_blank">Feather Wallet v2.1.0</a> and newer
|
||||
<li><a href="https://mymonero.com/" target="_blank">MyMonero</a>
|
||||
</ul>
|
||||
It's highly recommended to create a new wallet for mining because wallet addresses are public on p2pool. You can mine to a primary wallet address (the one starting with `4`) for mining. If you want to mine to a subaddress, you will need to provide both the main address (starting with 4) and the subaddress (starting with 8) using "--wallet" and "--subaddress" command line parameters.
|
||||
</details>
|
||||
@@ -318,4 +317,4 @@ Donate to support the project:<br><span style="font-size:0.9rem;color:#b0b0b0;">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Vendored
+1
-1
Submodule external/src/RandomX updated: d341d6a61c...1343007c61
Vendored
+1
-1
Submodule external/src/cppzmq updated: 57cc98f8fc...072ed2683f
Vendored
+1
-1
Submodule external/src/curl updated: efe7a9f403...ebc5cb09a8
Vendored
+1
-1
Submodule external/src/grpc updated: b40fe4ffc4...42d5fab67b
Vendored
+1
-1
Submodule external/src/libuv updated: 012b1e9698...593eea1554
Vendored
+1
-1
Submodule external/src/libzmq updated: 1fce1ef005...22e433f95f
Vendored
+1
-1
Submodule external/src/miniupnp updated: 88a1515ea8...8503437d35
@@ -1,5 +1,5 @@
|
||||
diff --git a/crypto/rand/windows.cc b/crypto/rand/windows.cc
|
||||
index 6a93a2d84..f75112b4f 100644
|
||||
index ebd0d4afd..65e877f0e 100644
|
||||
--- a/crypto/rand/windows.cc
|
||||
+++ b/crypto/rand/windows.cc
|
||||
@@ -24,6 +24,7 @@
|
||||
@@ -8,11 +8,11 @@ index 6a93a2d84..f75112b4f 100644
|
||||
#include <windows.h>
|
||||
+#include <wincrypt.h>
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
|
||||
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
@@ -57,16 +58,39 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
||||
using namespace bssl;
|
||||
|
||||
@@ -59,16 +60,39 @@ void bssl::CRYPTO_sysrand(uint8_t *out, size_t requested) {
|
||||
// See: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
|
||||
typedef BOOL (WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData);
|
||||
typedef BOOL(WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData);
|
||||
static ProcessPrngFunction g_processprng_fn = nullptr;
|
||||
+static HCRYPTPROV g_hCryptProv = 0;
|
||||
+
|
||||
@@ -21,7 +21,7 @@ index 6a93a2d84..f75112b4f 100644
|
||||
+ return CryptGenRandom(g_hCryptProv, cbData, pbData);
|
||||
+}
|
||||
|
||||
static void init_processprng(void) {
|
||||
static void init_processprng() {
|
||||
HMODULE hmod = LoadLibraryW(L"bcryptprimitives");
|
||||
- if (hmod == nullptr) {
|
||||
- abort();
|
||||
@@ -54,4 +54,4 @@ index 6a93a2d84..f75112b4f 100644
|
||||
+ abort();
|
||||
}
|
||||
|
||||
void CRYPTO_init_sysrand(void) {
|
||||
void bssl::CRYPTO_init_sysrand() {
|
||||
|
||||
@@ -3,27 +3,27 @@ set -e
|
||||
|
||||
# Software versions to install
|
||||
|
||||
_7ZIP_VERSION=2501
|
||||
BINUTILS_VERSION=2_45_1
|
||||
_7ZIP_VERSION=2600
|
||||
BINUTILS_VERSION=2_46
|
||||
CLANG_VERSION=21.1.8
|
||||
CMAKE_VERSION=4.2.1
|
||||
CMAKE_VERSION=4.3.1
|
||||
FREEBSD_VERSION=12.4
|
||||
GCC_VERSION=15.2.0
|
||||
GLIBC_VERSION=2.42
|
||||
LINUX_HEADERS_VERSION=6.18.1
|
||||
GLIBC_VERSION=2.43
|
||||
LINUX_HEADERS_VERSION=6.19.12
|
||||
MACOSX_SDK_VERSION=26.1
|
||||
OSXCROSS_VERSION=2bc739ebe45db5d72e176d2a4e1c7dd95464e8e2
|
||||
MAKE_VERSION=4.4.1
|
||||
MINGW_VERSION=13.0.0
|
||||
XZ_VERSION=5.8.2
|
||||
MINGW_VERSION=14.0.0
|
||||
XZ_VERSION=5.8.3
|
||||
TAR_VERSION=1.35
|
||||
|
||||
_7ZIP_SHA256="4ca3b7c6f2f67866b92622818b58233dc70367be2f36b498eb0bdeaaa44b53f4"
|
||||
CMAKE_SHA256="c059bff1e97a2b6b5b0c0872263627486345ad0ed083298cb21cff2eda883980"
|
||||
_7ZIP_SHA256="c74dc4a48492cde43f5fec10d53fb2a66f520e4a62a69d630c44cb22c477edc6"
|
||||
CMAKE_SHA256="208d76804009cbe8ec9aea0aa052c857c6e59bd289b43b9941c99324dc78b1d8"
|
||||
FREEBSD_AARCH64_SHA256="6c401819bfb93e810c9f9aa670a1e4685f924df5e7e0c9c6397dd6c16c954fa2"
|
||||
FREEBSD_X86_64_SHA256="581c7edacfd2fca2bdf5791f667402d22fccd8a5e184635e0cac075564d57aa8"
|
||||
GLIBC_SHA256="d1775e32e4628e64ef930f435b67bb63af7599acb6be2b335b9f19f16509f17f"
|
||||
HEADERS_SHA256="d0a78bf3f0d12aaa10af3b5adcaed5bc767b5b78705e5ef885d5e930b72e25d5"
|
||||
GLIBC_SHA256="d9c86c6b5dbddb43a3e08270c5844fc5177d19442cf5b8df4be7c07cd5fa3831"
|
||||
HEADERS_SHA256="ce5c4f1205f9729286b569b037649591555f31ca1e03cc504bd3b70b8e58a8d5"
|
||||
MACOSX_SDK_SHA256="beee7212d265a6d2867d0236cc069314b38d5fb3486a6515734e76fa210c784c"
|
||||
MAKE_SHA256="dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"
|
||||
TAR_SHA256="4d62ff37342ec7aed748535323930c7cf94acf71c3591882b26a7ea50f3edc16"
|
||||
@@ -33,7 +33,7 @@ echo "Install prerequisites"
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update && apt-get upgrade -yq --no-install-recommends
|
||||
apt-get install -yq --no-install-recommends ca-certificates curl bzip2 flex texinfo bison ninja-build python3 file rsync xz-utils gawk gettext patch git gcc g++
|
||||
apt-get install -yq --no-install-recommends ca-certificates curl bzip2 flex texinfo bison ninja-build python3 python3-yaml file rsync xz-utils gawk gettext patch git gcc g++
|
||||
|
||||
echo "Cloning the P2Pool repository in background"
|
||||
|
||||
@@ -227,7 +227,7 @@ cd /root
|
||||
|
||||
tar xvf $CMAKE_FILE
|
||||
cp $CMAKE_NAME/bin/* /usr/local/bin
|
||||
cp -r $CMAKE_NAME/share/cmake-4.2 /usr/local/share
|
||||
cp -r $CMAKE_NAME/share/cmake-4.3 /usr/local/share
|
||||
|
||||
echo "Install clang"
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+16
-8
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Portions Copyright (c) 2012-2013 The Cryptonote developers
|
||||
* Portions Copyright (c) 2014-2021 The Monero Project
|
||||
* Portions Copyright (c) 2021 XMRig <https://github.com/xmrig>
|
||||
@@ -213,7 +213,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
|
||||
|
||||
// Block template construction is relatively slow, but it's better to keep the lock the whole time
|
||||
// instead of using temporary variables and making a quick swap in the end
|
||||
//
|
||||
//
|
||||
// All readers will line up for the new template instead of using the outdated template
|
||||
WriteLock lock(m_lock);
|
||||
|
||||
@@ -617,7 +617,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
|
||||
m_poolBlockTemplate->m_auxNonce = data.aux_nonce;
|
||||
|
||||
m_poolBlockTemplate->m_mergeMiningExtra.clear();
|
||||
|
||||
|
||||
for (const AuxChainData& c : data.aux_chains) {
|
||||
std::vector<uint8_t> v;
|
||||
v.reserve(HASH_SIZE + 16);
|
||||
@@ -644,6 +644,13 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
|
||||
m_poolBlockTemplate->m_mergeMiningExtra.emplace(keccak_onion_address_v3, std::vector(buf, buf + sizeof(buf)));
|
||||
}
|
||||
|
||||
if (!params.m_i2pDestinationHash.empty()) {
|
||||
uint8_t buf[HASH_SIZE + 2] = {};
|
||||
memcpy(buf, params.m_i2pDestinationHash.h, HASH_SIZE);
|
||||
|
||||
m_poolBlockTemplate->m_mergeMiningExtra.emplace(keccak_i2p_b32_address, std::vector(buf, buf + sizeof(buf)));
|
||||
}
|
||||
|
||||
init_merge_mining_merkle_proof();
|
||||
|
||||
const std::vector<uint8_t> sidechain_data = m_poolBlockTemplate->serialize_sidechain_data();
|
||||
@@ -752,7 +759,7 @@ void BlockTemplate::fill_optimal_knapsack(const MinerData& data, uint64_t base_r
|
||||
{
|
||||
// Find the maximum possible fee for every weight value and remember which tx leads to this fee/weight
|
||||
// Run time is O(N*W) where N is the number of transactions and W is the maximum block weight
|
||||
//
|
||||
//
|
||||
// Actual run time is 0.02-0.05 seconds on real full blocks
|
||||
// It's too slow and uses too much memory to be practical
|
||||
|
||||
@@ -975,7 +982,7 @@ int BlockTemplate::create_miner_tx(const MinerData& data, const std::vector<Mine
|
||||
LOGINFO(4, "increased EXTRA_NONCE from " << EXTRA_NONCE_SIZE << " to " << corrected_extra_nonce_size << " bytes to maintain miner tx weight");
|
||||
}
|
||||
writeVarint(corrected_extra_nonce_size, m_minerTxExtra);
|
||||
|
||||
|
||||
uint64_t extraNonceOffsetInMinerTx = m_minerTxExtra.size();
|
||||
m_minerTxExtra.insert(m_minerTxExtra.end(), corrected_extra_nonce_size, 0);
|
||||
|
||||
@@ -1406,7 +1413,7 @@ bool BlockTemplate::get_aux_proof(const uint32_t template_id, uint32_t extra_non
|
||||
uint32_t path2 = 0;
|
||||
|
||||
const bool result2 = get_merkle_proof(tree, h, proof2, path2);
|
||||
|
||||
|
||||
if ((result2 != result) || (proof2 != proof) || (path2 != path)) {
|
||||
LOGERR(1, "get_aux_proof: merkle_hash_with_proof and get_merkle_proof returned different results. Fix the code!");
|
||||
}
|
||||
@@ -1553,7 +1560,8 @@ void BlockTemplate::init_merge_mining_merkle_proof()
|
||||
}
|
||||
|
||||
root_hash root;
|
||||
if (!merkle_hash_with_proof(hashes, aux_slot, m_poolBlockTemplate->m_merkleProof, m_poolBlockTemplate->m_merkleProofPath, root)) {
|
||||
uint32_t merkle_proof_path;
|
||||
if (!merkle_hash_with_proof(hashes, aux_slot, m_poolBlockTemplate->m_merkleProof, merkle_proof_path, root)) {
|
||||
LOGERR(1, "init_merge_mining_merkle_proof: merkle_hash_with_proof failed. Fix the code!");
|
||||
return;
|
||||
}
|
||||
@@ -1570,7 +1578,7 @@ void BlockTemplate::init_merge_mining_merkle_proof()
|
||||
return;
|
||||
}
|
||||
|
||||
if ((proof != m_poolBlockTemplate->m_merkleProof) || (path != m_poolBlockTemplate->m_merkleProofPath)) {
|
||||
if ((proof != m_poolBlockTemplate->m_merkleProof) || (path != merkle_proof_path)) {
|
||||
LOGERR(1, "init_merge_mining_merkle_proof: merkle_hash_with_proof and get_merkle_proof returned different results. Fix the code!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+17
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -172,6 +172,22 @@ struct alignas(uint64_t) hash
|
||||
}
|
||||
}
|
||||
|
||||
explicit constexpr hash(const char (&s)[HASH_SIZE * 2 + 1]) : h{} {
|
||||
for (size_t i = 0; i < HASH_SIZE * 2; ++i) {
|
||||
char c = s[i];
|
||||
|
||||
if ('0' <= c && c <= '9') {
|
||||
c -= '0';
|
||||
} else if ('a' <= c && c <= 'f') {
|
||||
c = (c - 'a') + 10;
|
||||
} else if ('A' <= c && c <= 'F') {
|
||||
c = (c - 'A') + 10;
|
||||
}
|
||||
|
||||
h[i / 2] = (h[i / 2] << 4) | static_cast<uint8_t>(c);
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE bool operator<(const hash& other) const
|
||||
{
|
||||
const uint64_t* a = u64();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021 hyc <https://github.com/hyc>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -35,7 +35,7 @@ static constexpr int DEFAULT_BACKLOG = 1;
|
||||
namespace p2pool {
|
||||
|
||||
ConsoleCommands::ConsoleCommands(p2pool* pool)
|
||||
: TCPServer(DEFAULT_BACKLOG, ConsoleClient::allocate, std::string())
|
||||
: TCPServer(DEFAULT_BACKLOG, ConsoleClient::allocate, std::string(), Params::ProxyType::INVALID)
|
||||
, m_pool(pool)
|
||||
, m_tty{}
|
||||
, m_stdin_pipe{}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2026 jpk68
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "i2p.h"
|
||||
|
||||
LOG_CATEGORY(I2P)
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
hash from_i2p_b32(const std::string& address)
|
||||
{
|
||||
if ((address.length() < 8) || (address.find(".b32.i2p") != address.length() - 8)) {
|
||||
LOGWARN(3, "Invalid I2P address \"" << address << "\": doesn't end with \".b32.i2p\"");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (address.length() != 60) {
|
||||
LOGWARN(3, "Invalid I2P address \"" << address << "\": expected length 60, got " << address.length());
|
||||
return {};
|
||||
}
|
||||
|
||||
const hash result = from_i2p_b32_const(address.c_str());
|
||||
|
||||
if (result.empty()) {
|
||||
LOGWARN(3, "Invalid I2P address \"" << address << "\": has invalid character(s)");
|
||||
return {};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_i2p_b32(const hash& dest_hash)
|
||||
{
|
||||
uint8_t buf[HASH_SIZE + 1];
|
||||
memcpy(buf, dest_hash.h, HASH_SIZE);
|
||||
buf[HASH_SIZE] = 0;
|
||||
|
||||
std::string result;
|
||||
result.reserve(60);
|
||||
|
||||
uint64_t data = 0;
|
||||
uint64_t bit_size = 0;
|
||||
|
||||
for (size_t i = 0; i < HASH_SIZE + 1; ++i) {
|
||||
data = (data << 8) | buf[i];
|
||||
bit_size += 8;
|
||||
|
||||
while (bit_size >= 5) {
|
||||
bit_size -= 5;
|
||||
result += base32_alphabet[(data >> bit_size) & 31];
|
||||
}
|
||||
}
|
||||
|
||||
result.append(".b32.i2p");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2026 jpk68
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include <string>
|
||||
#include <uv.h>
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
static FORCEINLINE constexpr hash from_i2p_b32_const(const char* dest_hash)
|
||||
{
|
||||
uint8_t buf[HASH_SIZE + 4] = {};
|
||||
uint8_t* p = buf;
|
||||
|
||||
uint64_t data = 0;
|
||||
uint64_t bit_size = 0;
|
||||
|
||||
for (size_t i = 0; i < 52; ++i) {
|
||||
const char c = dest_hash[i];
|
||||
uint64_t digit = 0;
|
||||
|
||||
if ('a' <= c && c <= 'z') {
|
||||
digit = static_cast<uint64_t>(c - 'a');
|
||||
}
|
||||
else if ('A' <= c && c <= 'Z') {
|
||||
digit = static_cast<uint64_t>(c - 'A');
|
||||
}
|
||||
else if ('2' <= c && c <= '7') {
|
||||
digit = static_cast<uint64_t>(c - '2') + 26;
|
||||
}
|
||||
else {
|
||||
return {};
|
||||
}
|
||||
|
||||
data = (data << 5) | digit;
|
||||
bit_size += 5;
|
||||
|
||||
while (bit_size >= 8) {
|
||||
bit_size -= 8;
|
||||
*(p++) = static_cast<uint8_t>(data >> bit_size);
|
||||
}
|
||||
}
|
||||
|
||||
hash result;
|
||||
|
||||
for (size_t i = 0; i < HASH_SIZE; ++i) {
|
||||
result.h[i] = buf[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
hash from_i2p_b32(const std::string& address);
|
||||
std::string to_i2p_b32(const hash& dest_hash);
|
||||
|
||||
} // namespace p2pool
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,14 +25,14 @@ namespace ConstexprKeccak
|
||||
template<int ROUNDS>
|
||||
static FORCEINLINE constexpr void keccakf(std::array<uint64_t, 25>& st)
|
||||
{
|
||||
constexpr uint64_t round_constants[24] =
|
||||
constexpr uint64_t round_constants[24] =
|
||||
{
|
||||
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
|
||||
0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
|
||||
0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
|
||||
0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
|
||||
0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
|
||||
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
|
||||
0x8000000000008080, 0x0000000080000001, 0x8000000080008008
|
||||
};
|
||||
@@ -107,6 +107,7 @@ static constexpr hash keccak(const char (&input)[len])
|
||||
constexpr hash keccak_0x00 = keccak("\0");
|
||||
constexpr hash keccak_subaddress_viewpub = keccak("subaddress_viewpub");
|
||||
constexpr hash keccak_onion_address_v3 = keccak("onion_address_v3");
|
||||
constexpr hash keccak_i2p_b32_address = keccak("i2p_b32_address");
|
||||
|
||||
static_assert(keccak_0x00.u64<0>() == 0x14281E7A9E7836BCULL, "constexpr keccak code check failed");
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+11
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -89,6 +89,7 @@ void p2pool_usage()
|
||||
"--no-autodiff Disable automatic difficulty adjustment for miners connected to stratum (WARNING: incompatible with Nicehash and MRR)\n"
|
||||
"--rpc-login Specify username[:password] required for Monero RPC server\n"
|
||||
"--socks5 Specify IP:port of a SOCKS5 proxy to use for outgoing connections\n"
|
||||
"--socks5-proxy-type The type of SOCKS5 proxy. Can be one of the following values: auto, plain, tor, i2p. Default is auto (auto-detected by the port number)\n"
|
||||
"--no-dns Disable DNS queries, use only IP addresses to connect to peers (seed node DNS will be unavailable too)\n"
|
||||
"--p2p-external-port Port number that your router uses for mapping to your local p2p port. Use it if you are behind a NAT and still want to accept incoming connections\n"
|
||||
#ifdef WITH_UPNP
|
||||
@@ -104,9 +105,12 @@ void p2pool_usage()
|
||||
"--rpc-ssl Enable SSL on RPC connections to the Monero node\n"
|
||||
"--rpc-ssl-fingerprint base64-encoded fingerprint of the Monero node's certificate (optional, use it for certificate pinning)\n"
|
||||
#endif
|
||||
"--stratum-proxy-protocol Enable HAProxy PROXY protocol v2 for incoming Stratum connections (use with HAProxy send-proxy-v2)\n"
|
||||
"--p2p-proxy-protocol Enable HAProxy PROXY protocol v2 for incoming P2P connections (use with HAProxy send-proxy-v2)\n"
|
||||
"--no-stratum-http Disable HTTP on Stratum ports\n"
|
||||
"--full-validation Enables full share validation / increases CPU usage\n"
|
||||
"--onion-address Tell other peers to use this .onion address to connect to this node through TOR\n"
|
||||
"--i2p-address Tell other peers to use this .b32.i2p address to connect to this node through I2P\n"
|
||||
"--no-clearnet-p2p Forces P2P server to listen on 127.0.0.1 and to not connect to clearnet IPs\n"
|
||||
"--params-file File name to load parameters from. It can't be used together with any other command line parameters\n"
|
||||
"--help Show this help message\n\n"
|
||||
@@ -343,7 +347,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
grpc_init();
|
||||
if (params.grpc_needed()) {
|
||||
grpc_init();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_TLS
|
||||
@@ -362,7 +368,9 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
grpc_shutdown();
|
||||
if (params.grpc_needed()) {
|
||||
grpc_shutdown();
|
||||
}
|
||||
#endif
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+264
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,10 +23,19 @@
|
||||
#include "merge_mining_client_tari.h"
|
||||
#endif
|
||||
|
||||
LOG_CATEGORY(MergeMiningClient)
|
||||
#include "p2pool.h"
|
||||
#include "params.h"
|
||||
#include "pool_block.h"
|
||||
#include "keccak_constexpr.h"
|
||||
#include "side_chain.h"
|
||||
#include "merkle.h"
|
||||
|
||||
static thread_local const char* log_category_prefix = "MergeMiningClient ";
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
static constexpr hash Tari_ChainID{ "01f0cf665bd4cd31cbb2b2470236389c483522b350335e10a4a5dca34cb85990" };
|
||||
|
||||
IMergeMiningClient* IMergeMiningClient::create(p2pool* pool, const std::string& host, const std::string& wallet) noexcept
|
||||
{
|
||||
try {
|
||||
@@ -43,4 +52,257 @@ IMergeMiningClient* IMergeMiningClient::create(p2pool* pool, const std::string&
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MergeMiningClientShared::MergeMiningClientShared(p2pool* pool, const std::string& wallet)
|
||||
: m_chainParamsLock{}
|
||||
, m_chainParams{}
|
||||
, m_chainParamsTimestamp(0)
|
||||
, m_auxWallet(wallet)
|
||||
, m_pool(pool)
|
||||
, m_previousAuxHashes{}
|
||||
, m_previousAuxHashesIndex(0)
|
||||
, m_previousAuxHashesFoundIndex(std::numeric_limits<uint32_t>::max())
|
||||
{
|
||||
uv_rwlock_init_checked(&m_chainParamsLock);
|
||||
}
|
||||
|
||||
MergeMiningClientShared::~MergeMiningClientShared()
|
||||
{
|
||||
uv_rwlock_destroy(&m_chainParamsLock);
|
||||
}
|
||||
|
||||
void MergeMiningClientShared::on_external_block(const PoolBlock& block)
|
||||
{
|
||||
#ifdef WITH_MERGE_MINING_DONATION
|
||||
// The rest of the code is needed only when this node is sending donation messages
|
||||
if (m_pool->params().m_authorKeyFile.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* old_log_category_prefix = log_category_prefix;
|
||||
log_category_prefix = get_log_category();
|
||||
ON_SCOPE_LEAVE([old_log_category_prefix]() { log_category_prefix = old_log_category_prefix; });
|
||||
|
||||
// Sanity check
|
||||
if (block.m_transactions.empty() || block.m_hashingBlob.empty() || (block.m_hashingBlob.size() > 128)) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - " << block.m_transactions.size() << " transactions, hashing blob size = " << block.m_hashingBlob.size());
|
||||
return;
|
||||
}
|
||||
|
||||
ChainParameters chain_params;
|
||||
hash previous_aux_hashes[NUM_PREVIOUS_HASHES];
|
||||
{
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
|
||||
chain_params = m_chainParams;
|
||||
std::copy(m_previousAuxHashes, m_previousAuxHashes + NUM_PREVIOUS_HASHES, previous_aux_hashes);
|
||||
}
|
||||
|
||||
// Don't continue if our aux chain is not there
|
||||
if (block.m_mergeMiningExtra.find(chain_params.aux_id) == block.m_mergeMiningExtra.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// All aux chains in this block + the P2Pool sidechain
|
||||
std::vector<hash> aux_ids;
|
||||
|
||||
// All aux chains in this block
|
||||
std::vector<AuxChainData> aux_chains;
|
||||
|
||||
aux_ids.reserve(block.m_mergeMiningExtra.size() + 1);
|
||||
aux_chains.reserve(block.m_mergeMiningExtra.size() + 1);
|
||||
|
||||
uint64_t mm_extra_size = 0;
|
||||
|
||||
for (const auto& i : block.m_mergeMiningExtra) {
|
||||
// Filter aux chain data only
|
||||
if ((i.first == keccak_subaddress_viewpub) || (i.first == keccak_onion_address_v3) || (i.first == keccak_i2p_b32_address)) {
|
||||
continue;
|
||||
}
|
||||
++mm_extra_size;
|
||||
|
||||
hash data;
|
||||
difficulty_type diff;
|
||||
{
|
||||
const std::vector<uint8_t>& v = i.second;
|
||||
|
||||
if (v.size() < HASH_SIZE) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - invalid merge mining extra data " << '1');
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t* p = v.data();
|
||||
const uint8_t* e = v.data() + v.size();
|
||||
|
||||
memcpy(data.h, p, HASH_SIZE);
|
||||
p += HASH_SIZE;
|
||||
|
||||
p = readVarint(p, e, diff.lo);
|
||||
if (!p) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - invalid merge mining extra data " << '2');
|
||||
diff.lo = 0;
|
||||
}
|
||||
else {
|
||||
p = readVarint(p, e, diff.hi);
|
||||
if (!p) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - invalid merge mining extra data " << '3');
|
||||
diff.hi = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If it's our aux chain, check that it's the same job and that there is enough PoW
|
||||
if (i.first == chain_params.aux_id) {
|
||||
const bool different_hash = (data != chain_params.aux_hash);
|
||||
|
||||
if (different_hash || (diff != chain_params.aux_diff)) {
|
||||
uint32_t index = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
if (different_hash) {
|
||||
for (uint32_t k = 0; k < NUM_PREVIOUS_HASHES; ++k) {
|
||||
if (previous_aux_hashes[k] == data) {
|
||||
index = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_previousAuxHashesFoundIndex = index;
|
||||
|
||||
if (different_hash && (index == std::numeric_limits<uint32_t>::max())) {
|
||||
LOGINFO(4, "External aux job solution found, but it's for another miner");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGINFO(4, "External aux job solution found, but it's stale");
|
||||
chain_params.aux_hash = data;
|
||||
chain_params.aux_diff = diff;
|
||||
}
|
||||
else {
|
||||
m_previousAuxHashesFoundIndex = std::numeric_limits<uint32_t>::max();
|
||||
}
|
||||
|
||||
if (!diff.check_pow(block.m_powHash)) {
|
||||
#ifndef P2POOL_LOG_DISABLE
|
||||
const char* name = ((chain_params.aux_id == Tari_ChainID) ? "Tari" : "aux");
|
||||
#endif
|
||||
LOGINFO(4, "External aux job solution found, but it doesn't have enough PoW (block diff = " << block.m_difficulty << ", " << name << " diff = " << diff << ')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aux_ids.emplace_back(i.first);
|
||||
aux_chains.emplace_back(i.first, data, diff);
|
||||
}
|
||||
|
||||
aux_ids.emplace_back(m_pool->side_chain().consensus_hash());
|
||||
|
||||
LOGINFO(0, log::LightGreen() << "External aux job solution found. Processing it!");
|
||||
|
||||
// coinbase_merkle_proof
|
||||
root_hash root;
|
||||
std::vector<hash> proof;
|
||||
uint32_t path;
|
||||
|
||||
#ifdef WITH_INDEXED_HASHES
|
||||
std::vector<hash> transactions;
|
||||
transactions.reserve(block.m_transactions.size());
|
||||
|
||||
for (const auto& h : block.m_transactions) {
|
||||
transactions.emplace_back(h);
|
||||
}
|
||||
#else
|
||||
const std::vector<hash>& transactions = block.m_transactions;
|
||||
#endif
|
||||
|
||||
if (!merkle_hash_with_proof(transactions, 0, proof, path, root)) {
|
||||
LOGWARN(3, "on_external_block: merkle_hash_with_proof failed for coinbase transaction");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!verify_merkle_proof(transactions[0], proof, path, root)) {
|
||||
LOGWARN(3, "on_external_block: verify_merkle_proof failed for coinbase transaction");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> coinbase_merkle_proof;
|
||||
coinbase_merkle_proof.reserve(proof.size() * HASH_SIZE);
|
||||
|
||||
for (const hash& h : proof) {
|
||||
coinbase_merkle_proof.insert(coinbase_merkle_proof.end(), h.h, h.h + HASH_SIZE);
|
||||
}
|
||||
|
||||
// hashing_blob
|
||||
|
||||
uint8_t hashing_blob[128] = {};
|
||||
memcpy(hashing_blob, block.m_hashingBlob.data(), block.m_hashingBlob.size());
|
||||
|
||||
// nonce_offset and blob
|
||||
|
||||
size_t header_size = 0;
|
||||
const std::vector<uint8_t> blob = block.serialize_mainchain_data(&header_size);
|
||||
|
||||
if (header_size <= NONCE_SIZE) {
|
||||
LOGWARN(3, "on_external_block: invalid header_size");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t nonce_offset = static_cast<uint32_t>(header_size - NONCE_SIZE);
|
||||
|
||||
// aux_merkle_proof, aux_merkle_proof_path
|
||||
|
||||
std::vector<hash> aux_merkle_proof;
|
||||
uint32_t aux_merkle_proof_path = 0;
|
||||
|
||||
const hash sidechain_id = block.m_sidechainId;
|
||||
const uint32_t n_aux_chains = static_cast<uint32_t>(mm_extra_size + 1);
|
||||
|
||||
std::vector<hash> hashes(n_aux_chains);
|
||||
|
||||
uint32_t aux_nonce;
|
||||
if (!find_aux_nonce(aux_ids, aux_nonce, 1000)) {
|
||||
LOGWARN(3, "on_external_block: failed to find aux_nonce");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const AuxChainData& aux_data : aux_chains) {
|
||||
const uint32_t aux_slot = get_aux_slot(aux_data.unique_id, aux_nonce, n_aux_chains);
|
||||
|
||||
if (!hashes[aux_slot].empty()) {
|
||||
LOGWARN(3, "on_external_block: found an incorrect aux_nonce " << '1');
|
||||
return;
|
||||
}
|
||||
|
||||
hashes[aux_slot] = aux_data.data;
|
||||
}
|
||||
|
||||
const uint32_t aux_slot = get_aux_slot(m_pool->side_chain().consensus_hash(), aux_nonce, n_aux_chains);
|
||||
|
||||
if (!hashes[aux_slot].empty()) {
|
||||
LOGWARN(3, "on_external_block: found an incorrect aux_nonce " << '2');
|
||||
return;
|
||||
}
|
||||
|
||||
hashes[aux_slot] = sidechain_id;
|
||||
|
||||
if (!merkle_hash_with_proof(hashes, chain_params.aux_hash, aux_merkle_proof, aux_merkle_proof_path, root)) {
|
||||
LOGWARN(3, "on_external_block: merkle_hash_with_proof failed for the aux hash");
|
||||
return;
|
||||
}
|
||||
|
||||
if (root != block.m_merkleRoot) {
|
||||
LOGWARN(3, "on_external_block: merkle root didn't match");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!verify_merkle_proof(chain_params.aux_hash, aux_merkle_proof, aux_merkle_proof_path, root)) {
|
||||
LOGWARN(3, "on_external_block: verify_merkle_proof failed for the aux hash");
|
||||
return;
|
||||
}
|
||||
|
||||
submit_solution(coinbase_merkle_proof, hashing_blob, nonce_offset, block.m_seed, blob, aux_merkle_proof, aux_merkle_proof_path);
|
||||
#else // WITH_MERGE_MINING_DONATION
|
||||
(void)block;
|
||||
#endif // WITH_MERGE_MINING_DONATION
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "uv_util.h"
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
class p2pool;
|
||||
@@ -53,4 +55,34 @@ public:
|
||||
virtual void api_status(log::Stream&) const = 0;
|
||||
};
|
||||
|
||||
class MergeMiningClientShared : public IMergeMiningClient, public nocopy_nomove
|
||||
{
|
||||
public:
|
||||
MergeMiningClientShared(p2pool* pool, const std::string& wallet);
|
||||
~MergeMiningClientShared() override;
|
||||
|
||||
void on_external_block(const PoolBlock& block) override;
|
||||
|
||||
virtual const char* get_log_category() const = 0;
|
||||
|
||||
protected:
|
||||
mutable uv_rwlock_t m_chainParamsLock;
|
||||
ChainParameters m_chainParams;
|
||||
|
||||
uint64_t m_chainParamsTimestamp;
|
||||
|
||||
std::string m_auxWallet;
|
||||
|
||||
p2pool* m_pool;
|
||||
|
||||
enum {
|
||||
NUM_PREVIOUS_HASHES = 8,
|
||||
};
|
||||
|
||||
hash m_previousAuxHashes[NUM_PREVIOUS_HASHES];
|
||||
uint32_t m_previousAuxHashesIndex;
|
||||
|
||||
std::atomic<uint32_t> m_previousAuxHashesFoundIndex;
|
||||
};
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,12 +29,9 @@ LOG_CATEGORY(MergeMiningClientJSON_RPC)
|
||||
namespace p2pool {
|
||||
|
||||
MergeMiningClientJSON_RPC::MergeMiningClientJSON_RPC(p2pool* pool, const std::string& host, const std::string& wallet)
|
||||
: m_host(host)
|
||||
: MergeMiningClientShared(pool, wallet)
|
||||
, m_host(host)
|
||||
, m_port(80)
|
||||
, m_chainParamsTimestamp(0)
|
||||
, m_auxWallet(wallet)
|
||||
, m_ping(0.0)
|
||||
, m_pool(pool)
|
||||
, m_loop{}
|
||||
, m_loopThread{}
|
||||
, m_timer{}
|
||||
@@ -44,6 +41,13 @@ MergeMiningClientJSON_RPC::MergeMiningClientJSON_RPC(p2pool* pool, const std::st
|
||||
const size_t k = host.find_last_of(':');
|
||||
if (k != std::string::npos) {
|
||||
m_host = host.substr(0, k);
|
||||
|
||||
// Handle IPv6 addresses
|
||||
if ((m_host.length() > 2) && (m_host.find_first_of(':') != std::string::npos) && (m_host.front() == '[') && (m_host.back() == ']')) {
|
||||
m_host.erase(m_host.begin());
|
||||
m_host.pop_back();
|
||||
}
|
||||
|
||||
m_port = static_cast<int32_t>(std::stol(host.substr(k + 1), nullptr, 10));
|
||||
}
|
||||
|
||||
@@ -77,8 +81,6 @@ MergeMiningClientJSON_RPC::MergeMiningClientJSON_RPC(p2pool* pool, const std::st
|
||||
}
|
||||
m_timer.data = this;
|
||||
|
||||
uv_rwlock_init_checked(&m_lock);
|
||||
|
||||
err = uv_thread_create(&m_loopThread, loop, this);
|
||||
if (err) {
|
||||
LOGERR(1, "failed to start event loop thread, error " << uv_err_name(err));
|
||||
@@ -94,8 +96,6 @@ MergeMiningClientJSON_RPC::~MergeMiningClientJSON_RPC()
|
||||
uv_async_send(&m_shutdownAsync);
|
||||
uv_thread_join(&m_loopThread);
|
||||
|
||||
uv_rwlock_destroy(&m_lock);
|
||||
|
||||
LOGINFO(1, "stopped");
|
||||
}
|
||||
|
||||
@@ -115,15 +115,14 @@ void MergeMiningClientJSON_RPC::merge_mining_get_chain_id()
|
||||
|
||||
JSONRPCRequest::call(m_host, m_port, req, std::string(), m_pool->params().m_socks5Proxy, false, std::string(),
|
||||
[this](const char* data, size_t size, double ping) {
|
||||
WriteLock lock(m_lock);
|
||||
WriteLock lock(m_chainParamsLock);
|
||||
|
||||
if (parse_merge_mining_get_chain_id(data, size)) {
|
||||
if (ping > 0.0) {
|
||||
m_ping = ping;
|
||||
}
|
||||
|
||||
LOGINFO(1, m_host << ':' << m_port << " uses chain_id " << log::LightCyan() << m_chainParams.aux_id);
|
||||
LOGINFO(1, m_host << ':' << m_port << " ping is " << m_ping << " ms");
|
||||
|
||||
if (ping > 0.0) {
|
||||
LOGINFO(1, m_host << ':' << m_port << " ping is " << ping << " ms");
|
||||
}
|
||||
|
||||
// Chain ID received successfully, we can start polling for new mining jobs now
|
||||
const int err = uv_timer_start(&m_timer, on_timer, 0, 500);
|
||||
@@ -191,7 +190,7 @@ void MergeMiningClientJSON_RPC::merge_mining_get_aux_block(uint64_t height, cons
|
||||
|
||||
hash aux_hash;
|
||||
{
|
||||
ReadLock lock(m_lock);
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
aux_hash = m_chainParams.aux_hash;
|
||||
}
|
||||
|
||||
@@ -207,14 +206,29 @@ void MergeMiningClientJSON_RPC::merge_mining_get_aux_block(uint64_t height, cons
|
||||
bool changed = false;
|
||||
hash chain_id;
|
||||
|
||||
hash prev_aux_hash;
|
||||
std::vector<uint8_t> prev_aux_blob;
|
||||
{
|
||||
WriteLock lock(m_lock);
|
||||
WriteLock lock(m_chainParamsLock);
|
||||
|
||||
prev_aux_hash = m_chainParams.aux_hash;
|
||||
prev_aux_blob = m_chainParams.aux_blob;
|
||||
|
||||
if (parse_merge_mining_get_aux_block(data, size, changed)) {
|
||||
chain_id = m_chainParams.aux_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed && !chain_id.empty()) {
|
||||
{
|
||||
WriteLock lock(m_chainParamsLock);
|
||||
|
||||
const uint32_t index = (m_previousAuxHashesIndex++) % NUM_PREVIOUS_HASHES;
|
||||
|
||||
m_previousAuxHashes[index] = prev_aux_hash;
|
||||
m_previousAuxBlobs[index] = prev_aux_blob;
|
||||
}
|
||||
|
||||
m_pool->update_aux_data(chain_id);
|
||||
}
|
||||
},
|
||||
@@ -293,14 +307,19 @@ bool MergeMiningClientJSON_RPC::parse_merge_mining_get_aux_block(const char* dat
|
||||
|
||||
void MergeMiningClientJSON_RPC::submit_solution(const std::vector<uint8_t>& /*coinbase_merkle_proof*/, const uint8_t (&/*hashing_blob*/)[128], size_t /*nonce_offset*/, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof, uint32_t merkle_proof_path)
|
||||
{
|
||||
ReadLock lock(m_lock);
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
|
||||
std::vector<char> buf((m_chainParams.aux_blob.size() + HASH_SIZE + blob.size()) * 2 + merkle_proof.size() * (HASH_SIZE * 2 + 3) + 256);
|
||||
const uint32_t index = m_previousAuxHashesFoundIndex.exchange(std::numeric_limits<uint32_t>::max());
|
||||
|
||||
const std::vector<uint8_t>& aux_blob = (index < NUM_PREVIOUS_HASHES) ? m_previousAuxBlobs[index] : m_chainParams.aux_blob;
|
||||
const hash& aux_hash = (index < NUM_PREVIOUS_HASHES) ? m_previousAuxHashes[index] : m_chainParams.aux_hash;
|
||||
|
||||
std::vector<char> buf((aux_blob.size() + HASH_SIZE + blob.size()) * 2 + merkle_proof.size() * (HASH_SIZE * 2 + 3) + 256);
|
||||
log::Stream s(buf.data(), buf.size());
|
||||
|
||||
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"merge_mining_submit_solution\",\"params\":{"
|
||||
<< "\"aux_blob\":\"" << log::hex_buf(m_chainParams.aux_blob.data(), m_chainParams.aux_blob.size()) << '"'
|
||||
<< ",\"aux_hash\":\"" << m_chainParams.aux_hash << '"'
|
||||
<< "\"aux_blob\":\"" << log::hex_buf(aux_blob.data(), aux_blob.size()) << '"'
|
||||
<< ",\"aux_hash\":\"" << aux_hash << '"'
|
||||
<< ",\"blob\":\"" << log::hex_buf(blob.data(), blob.size()) << '"'
|
||||
<< ",\"merkle_proof\":[";
|
||||
|
||||
@@ -329,7 +348,7 @@ void MergeMiningClientJSON_RPC::submit_solution(const std::vector<uint8_t>& /*co
|
||||
|
||||
void MergeMiningClientJSON_RPC::print_status() const
|
||||
{
|
||||
ReadLock lock(m_lock);
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
|
||||
LOGINFO(0, "status" <<
|
||||
"\nHost = " << m_host << ':' << m_port <<
|
||||
@@ -340,7 +359,7 @@ void MergeMiningClientJSON_RPC::print_status() const
|
||||
|
||||
void MergeMiningClientJSON_RPC::api_status(log::Stream& s) const
|
||||
{
|
||||
ReadLock lock(m_lock);
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
|
||||
s << '{'
|
||||
<< "\"api\":\"JSON RPC\","
|
||||
@@ -356,7 +375,7 @@ bool MergeMiningClientJSON_RPC::get_params(ChainParameters& out_params) const
|
||||
{
|
||||
const uint64_t t = seconds_since_epoch();
|
||||
|
||||
ReadLock lock(m_lock);
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
|
||||
if (m_chainParams.aux_id.empty() || m_chainParams.aux_diff.empty()) {
|
||||
return false;
|
||||
@@ -448,4 +467,9 @@ void MergeMiningClientJSON_RPC::on_shutdown()
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_timer), nullptr);
|
||||
}
|
||||
|
||||
const char* MergeMiningClientJSON_RPC::get_log_category() const
|
||||
{
|
||||
return log_category_prefix;
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,19 +24,20 @@ namespace p2pool {
|
||||
class p2pool;
|
||||
struct PoolBlock;
|
||||
|
||||
class MergeMiningClientJSON_RPC : public IMergeMiningClient
|
||||
class MergeMiningClientJSON_RPC : public MergeMiningClientShared
|
||||
{
|
||||
public:
|
||||
MergeMiningClientJSON_RPC(p2pool* pool, const std::string& host, const std::string& wallet);
|
||||
~MergeMiningClientJSON_RPC() override;
|
||||
|
||||
bool get_params(ChainParameters& out_params) const override;
|
||||
void on_external_block(const PoolBlock& /*block*/) override {}
|
||||
void submit_solution(const std::vector<uint8_t>& coinbase_merkle_proof, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof, uint32_t merkle_proof_path) override;
|
||||
|
||||
void print_status() const override;
|
||||
void api_status(log::Stream&) const override;
|
||||
|
||||
const char* get_log_category() const override;
|
||||
|
||||
private:
|
||||
static void loop(void* data);
|
||||
|
||||
@@ -51,20 +52,11 @@ private:
|
||||
|
||||
bool parse_merge_mining_submit_solution(const char* data, size_t size) const;
|
||||
|
||||
std::vector<uint8_t> m_previousAuxBlobs[NUM_PREVIOUS_HASHES];
|
||||
|
||||
std::string m_host;
|
||||
int32_t m_port;
|
||||
|
||||
mutable uv_rwlock_t m_lock;
|
||||
ChainParameters m_chainParams;
|
||||
|
||||
uint64_t m_chainParamsTimestamp;
|
||||
|
||||
std::string m_auxWallet;
|
||||
|
||||
double m_ping;
|
||||
|
||||
p2pool* m_pool;
|
||||
|
||||
uv_loop_t m_loop;
|
||||
uv_thread_t m_loopThread;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -34,15 +34,9 @@ using namespace tari::rpc;
|
||||
namespace p2pool {
|
||||
|
||||
MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, const std::string& wallet)
|
||||
: m_chainParams{}
|
||||
, m_chainParamsTimestamp(0)
|
||||
, m_previousAuxHashes{}
|
||||
, m_previousAuxHashesIndex(0)
|
||||
, m_previousAuxHashesFoundIndex(std::numeric_limits<uint32_t>::max())
|
||||
, m_auxWallet(wallet)
|
||||
, m_pool(pool)
|
||||
: MergeMiningClientShared(pool, wallet)
|
||||
, m_tariJobParams{}
|
||||
, m_server(new TariServer(pool->params().m_socks5Proxy))
|
||||
, m_server(new TariServer(pool->params().m_socks5Proxy, pool->params().m_socks5ProxyType))
|
||||
, m_hostStr(host)
|
||||
, m_workerStop(0)
|
||||
, m_pushBlockStop(0)
|
||||
@@ -78,8 +72,6 @@ MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, con
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
uv_rwlock_init_checked(&m_chainParamsLock);
|
||||
|
||||
if (!m_server->start()) {
|
||||
throw std::exception();
|
||||
}
|
||||
@@ -89,7 +81,7 @@ MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, con
|
||||
s << "127.0.0.1:" << m_server->external_listen_port();
|
||||
|
||||
m_channelArgs.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 1000);
|
||||
|
||||
|
||||
m_channelArgs.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 1000);
|
||||
m_channelArgs.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 10000);
|
||||
|
||||
@@ -102,15 +94,15 @@ MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, con
|
||||
uv_mutex_init_checked(&m_workerLock);
|
||||
uv_cond_init_checked(&m_workerCond);
|
||||
|
||||
uv_mutex_init_checked(&m_pushBlockLock);
|
||||
uv_cond_init_checked(&m_pushBlockCond);
|
||||
|
||||
int err = uv_thread_create(&m_worker, run_wrapper, this);
|
||||
if (err) {
|
||||
LOGERR(1, "failed to start worker thread, error " << uv_err_name(err));
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
uv_mutex_init_checked(&m_pushBlockLock);
|
||||
uv_cond_init_checked(&m_pushBlockCond);
|
||||
|
||||
std::ifstream f("tari_nodes.txt");
|
||||
|
||||
if (f.is_open()) {
|
||||
@@ -170,8 +162,6 @@ MergeMiningClientTari::~MergeMiningClientTari()
|
||||
m_TariNode.reset();
|
||||
m_channel.reset();
|
||||
|
||||
uv_rwlock_destroy(&m_chainParamsLock);
|
||||
|
||||
uv_mutex_destroy(&m_workerLock);
|
||||
uv_cond_destroy(&m_workerCond);
|
||||
|
||||
@@ -207,230 +197,6 @@ bool MergeMiningClientTari::get_params(ChainParameters& out_params) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void MergeMiningClientTari::on_external_block(const PoolBlock& block)
|
||||
{
|
||||
#ifdef WITH_MERGE_MINING_DONATION
|
||||
// The rest of the code is needed only when this node is sending donation messages
|
||||
if (m_pool->params().m_authorKeyFile.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if (block.m_transactions.empty() || block.m_hashingBlob.empty() || (block.m_hashingBlob.size() > 128)) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - " << block.m_transactions.size() << " transactions, hashing blob size = " << block.m_hashingBlob.size());
|
||||
return;
|
||||
}
|
||||
|
||||
ChainParameters chain_params;
|
||||
uint64_t previous_aux_hashes[NUM_PREVIOUS_HASHES];
|
||||
{
|
||||
ReadLock lock(m_chainParamsLock);
|
||||
|
||||
chain_params = m_chainParams;
|
||||
memcpy(previous_aux_hashes, m_previousAuxHashes, sizeof(m_previousAuxHashes));
|
||||
}
|
||||
|
||||
// Don't continue if our aux chain is not there
|
||||
if (block.m_mergeMiningExtra.find(chain_params.aux_id) == block.m_mergeMiningExtra.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// All aux chains in this block + the P2Pool sidechain
|
||||
std::vector<hash> aux_ids;
|
||||
|
||||
// All aux chains in this block
|
||||
std::vector<AuxChainData> aux_chains;
|
||||
|
||||
aux_ids.reserve(block.m_mergeMiningExtra.size() + 1);
|
||||
aux_chains.reserve(block.m_mergeMiningExtra.size() + 1);
|
||||
|
||||
uint64_t mm_extra_size = 0;
|
||||
|
||||
for (const auto& i : block.m_mergeMiningExtra) {
|
||||
// Filter aux chain data only
|
||||
if ((i.first == keccak_subaddress_viewpub) || (i.first == keccak_onion_address_v3)) {
|
||||
continue;
|
||||
}
|
||||
++mm_extra_size;
|
||||
|
||||
hash data;
|
||||
difficulty_type diff;
|
||||
{
|
||||
const std::vector<uint8_t>& v = i.second;
|
||||
|
||||
const uint8_t* p = v.data();
|
||||
const uint8_t* e = v.data() + v.size();
|
||||
|
||||
if (p + HASH_SIZE > e) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - invalid merge mining extra data " << '1');
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(data.h, p, HASH_SIZE);
|
||||
p += HASH_SIZE;
|
||||
|
||||
p = readVarint(p, e, diff.lo);
|
||||
if (!p) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - invalid merge mining extra data " << '2');
|
||||
diff.lo = 0;
|
||||
}
|
||||
else {
|
||||
p = readVarint(p, e, diff.hi);
|
||||
if (!p) {
|
||||
LOGWARN(3, "on_external_block: sanity check failed - invalid merge mining extra data " << '3');
|
||||
diff.hi = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If it's our aux chain, check that it's the same job and that there is enough PoW
|
||||
if (i.first == chain_params.aux_id) {
|
||||
if ((data != chain_params.aux_hash) || (diff != chain_params.aux_diff)) {
|
||||
uint32_t index = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
for (uint32_t k = 0; k < NUM_PREVIOUS_HASHES; ++k) {
|
||||
if (previous_aux_hashes[k] == *data.u64()) {
|
||||
index = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_previousAuxHashesFoundIndex = index;
|
||||
|
||||
if (index == std::numeric_limits<uint32_t>::max()) {
|
||||
LOGINFO(4, "External aux job solution found, but it's for another miner");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGINFO(4, "External aux job solution found, but it's stale");
|
||||
chain_params.aux_hash = data;
|
||||
chain_params.aux_diff = diff;
|
||||
}
|
||||
else {
|
||||
m_previousAuxHashesFoundIndex = std::numeric_limits<uint32_t>::max();
|
||||
}
|
||||
|
||||
if (!diff.check_pow(block.m_powHash)) {
|
||||
LOGINFO(4, "External aux job solution found, but it doesn't have enough PoW (block diff = " << block.m_difficulty << ", Tari diff = " << diff << ')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aux_ids.emplace_back(i.first);
|
||||
aux_chains.emplace_back(i.first, data, diff);
|
||||
}
|
||||
|
||||
aux_ids.emplace_back(m_pool->side_chain().consensus_hash());
|
||||
|
||||
LOGINFO(0, log::LightGreen() << "External aux job solution found. Processing it!");
|
||||
|
||||
// coinbase_merkle_proof
|
||||
root_hash root;
|
||||
std::vector<hash> proof;
|
||||
uint32_t path;
|
||||
|
||||
#ifdef WITH_INDEXED_HASHES
|
||||
std::vector<hash> transactions;
|
||||
transactions.reserve(block.m_transactions.size());
|
||||
|
||||
for (const auto& h : block.m_transactions) {
|
||||
transactions.emplace_back(h);
|
||||
}
|
||||
#else
|
||||
const std::vector<hash>& transactions = block.m_transactions;
|
||||
#endif
|
||||
|
||||
if (!merkle_hash_with_proof(transactions, 0, proof, path, root)) {
|
||||
LOGWARN(3, "on_external_block: merkle_hash_with_proof failed for coinbase transaction");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!verify_merkle_proof(transactions[0], proof, path, root)) {
|
||||
LOGWARN(3, "on_external_block: verify_merkle_proof failed for coinbase transaction");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> coinbase_merkle_proof;
|
||||
coinbase_merkle_proof.reserve(proof.size() * HASH_SIZE);
|
||||
|
||||
for (const hash& h : proof) {
|
||||
coinbase_merkle_proof.insert(coinbase_merkle_proof.end(), h.h, h.h + HASH_SIZE);
|
||||
}
|
||||
|
||||
// hashing_blob
|
||||
|
||||
uint8_t hashing_blob[128] = {};
|
||||
memcpy(hashing_blob, block.m_hashingBlob.data(), block.m_hashingBlob.size());
|
||||
|
||||
// nonce_offset and blob
|
||||
|
||||
size_t header_size = 0;
|
||||
const std::vector<uint8_t> blob = block.serialize_mainchain_data(&header_size);
|
||||
|
||||
if (header_size <= NONCE_SIZE) {
|
||||
LOGWARN(3, "on_external_block: invalid header_size");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t nonce_offset = static_cast<uint32_t>(header_size - NONCE_SIZE);
|
||||
|
||||
// aux_merkle_proof, aux_merkle_proof_path
|
||||
|
||||
std::vector<hash> aux_merkle_proof;
|
||||
uint32_t aux_merkle_proof_path = 0;
|
||||
|
||||
const hash sidechain_id = block.m_sidechainId;
|
||||
const uint32_t n_aux_chains = static_cast<uint32_t>(mm_extra_size + 1);
|
||||
|
||||
std::vector<hash> hashes(n_aux_chains);
|
||||
|
||||
uint32_t aux_nonce;
|
||||
if (!find_aux_nonce(aux_ids, aux_nonce, 1000)) {
|
||||
LOGWARN(3, "on_external_block: failed to find aux_nonce");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const AuxChainData& aux_data : aux_chains) {
|
||||
const uint32_t aux_slot = get_aux_slot(aux_data.unique_id, aux_nonce, n_aux_chains);
|
||||
|
||||
if (!hashes[aux_slot].empty()) {
|
||||
LOGWARN(3, "on_external_block: found an incorrect aux_nonce " << '1');
|
||||
return;
|
||||
}
|
||||
|
||||
hashes[aux_slot] = aux_data.data;
|
||||
}
|
||||
|
||||
const uint32_t aux_slot = get_aux_slot(m_pool->side_chain().consensus_hash(), aux_nonce, n_aux_chains);
|
||||
|
||||
if (!hashes[aux_slot].empty()) {
|
||||
LOGWARN(3, "on_external_block: found an incorrect aux_nonce " << '2');
|
||||
return;
|
||||
}
|
||||
|
||||
hashes[aux_slot] = sidechain_id;
|
||||
|
||||
if (!merkle_hash_with_proof(hashes, chain_params.aux_hash, aux_merkle_proof, aux_merkle_proof_path, root)) {
|
||||
LOGWARN(3, "on_external_block: merkle_hash_with_proof failed for the aux hash");
|
||||
return;
|
||||
}
|
||||
|
||||
if (root != block.m_merkleRoot) {
|
||||
LOGWARN(3, "on_external_block: merkle root didn't match");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!verify_merkle_proof(chain_params.aux_hash, aux_merkle_proof, aux_merkle_proof_path, root)) {
|
||||
LOGWARN(3, "on_external_block: verify_merkle_proof failed for the aux hash");
|
||||
return;
|
||||
}
|
||||
|
||||
submit_solution(coinbase_merkle_proof, hashing_blob, nonce_offset, block.m_seed, blob, aux_merkle_proof, aux_merkle_proof_path);
|
||||
#else // WITH_MERGE_MINING_DONATION
|
||||
(void) block;
|
||||
#endif // WITH_MERGE_MINING_DONATION
|
||||
}
|
||||
|
||||
void MergeMiningClientTari::submit_solution(const std::vector<uint8_t>& coinbase_merkle_proof, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof, uint32_t merkle_proof_path)
|
||||
{
|
||||
Block block;
|
||||
@@ -820,7 +586,7 @@ void MergeMiningClientTari::run()
|
||||
|
||||
const uint32_t index = (m_previousAuxHashesIndex++) % NUM_PREVIOUS_HASHES;
|
||||
|
||||
m_previousAuxHashes[index] = *m_chainParams.aux_hash.u64();
|
||||
m_previousAuxHashes[index] = m_chainParams.aux_hash;
|
||||
m_previousTariBlocks[index] = std::move(m_tariBlock);
|
||||
|
||||
std::copy(mm_hash.begin(), mm_hash.end(), m_chainParams.aux_hash.h);
|
||||
@@ -863,8 +629,8 @@ void MergeMiningClientTari::run()
|
||||
// TariServer and TariClient are simply a proxy from a localhost TCP port to the external Tari node
|
||||
// This is needed for SOCKS5 proxy support (gRPC library doesn't support it natively)
|
||||
|
||||
MergeMiningClientTari::TariServer::TariServer(const std::string& socks5Proxy)
|
||||
: TCPServer(1, MergeMiningClientTari::TariClient::allocate, socks5Proxy)
|
||||
MergeMiningClientTari::TariServer::TariServer(const std::string& socks5Proxy, Params::ProxyType socks5ProxyType)
|
||||
: TCPServer(1, MergeMiningClientTari::TariClient::allocate, socks5Proxy, socks5ProxyType)
|
||||
, m_TariNodeIsV6(false)
|
||||
, m_TariNodeHost()
|
||||
, m_TariNodePort(0)
|
||||
@@ -1085,6 +851,8 @@ void MergeMiningClientTari::push_blocks_to(const std::string& node_address)
|
||||
LOGINFO(4, node_address << " is at block height " << tip_info.metadata().best_block_height());
|
||||
}
|
||||
|
||||
std::string prev_header_hash;
|
||||
|
||||
while (!m_pushBlockStop) {
|
||||
Block block;
|
||||
{
|
||||
@@ -1099,6 +867,13 @@ void MergeMiningClientTari::push_blocks_to(const std::string& node_address)
|
||||
}
|
||||
|
||||
const std::string& h = block.header().hash();
|
||||
|
||||
// Don't push the same block twice
|
||||
if (h == prev_header_hash) {
|
||||
continue;
|
||||
}
|
||||
prev_header_hash = h;
|
||||
|
||||
LOGINFO(4, "Pushing block " << log::hex_buf(h.data(), h.size()) << " to " << node_address);
|
||||
|
||||
grpc::ClientContext ctx;
|
||||
@@ -1119,4 +894,9 @@ void MergeMiningClientTari::push_blocks_to(const std::string& node_address)
|
||||
}
|
||||
}
|
||||
|
||||
const char* MergeMiningClientTari::get_log_category() const
|
||||
{
|
||||
return log_category_prefix;
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,7 +25,7 @@ namespace p2pool {
|
||||
class p2pool;
|
||||
struct PoolBlock;
|
||||
|
||||
class MergeMiningClientTari : public IMergeMiningClient, public nocopy_nomove
|
||||
class MergeMiningClientTari : public MergeMiningClientShared
|
||||
{
|
||||
public:
|
||||
MergeMiningClientTari(p2pool* pool, std::string host, const std::string& wallet);
|
||||
@@ -34,33 +34,18 @@ public:
|
||||
static constexpr char TARI_PREFIX[] = "tari://";
|
||||
|
||||
bool get_params(ChainParameters& out_params) const override;
|
||||
void on_external_block(const PoolBlock& block) override;
|
||||
void submit_solution(const std::vector<uint8_t>& coinbase_merkle_proof, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof, uint32_t merkle_proof_path) override;
|
||||
|
||||
void print_status() const override;
|
||||
void api_status(log::Stream&) const override;
|
||||
|
||||
const char* get_log_category() const override;
|
||||
|
||||
private:
|
||||
mutable uv_rwlock_t m_chainParamsLock;
|
||||
ChainParameters m_chainParams;
|
||||
|
||||
uint64_t m_chainParamsTimestamp;
|
||||
|
||||
enum {
|
||||
NUM_PREVIOUS_HASHES = 8,
|
||||
};
|
||||
|
||||
uint64_t m_previousAuxHashes[NUM_PREVIOUS_HASHES];
|
||||
tari::rpc::Block m_previousTariBlocks[NUM_PREVIOUS_HASHES];
|
||||
uint32_t m_previousAuxHashesIndex;
|
||||
|
||||
std::atomic<uint32_t> m_previousAuxHashesFoundIndex;
|
||||
|
||||
tari::rpc::Block m_tariBlock;
|
||||
|
||||
std::string m_auxWallet;
|
||||
p2pool* m_pool;
|
||||
|
||||
struct TariJobParams
|
||||
{
|
||||
uint64_t height;
|
||||
@@ -83,7 +68,7 @@ private:
|
||||
|
||||
struct TariServer : public TCPServer
|
||||
{
|
||||
explicit TariServer(const std::string& socks5Proxy);
|
||||
TariServer(const std::string& socks5Proxy, Params::ProxyType socks5ProxyType);
|
||||
~TariServer() {}
|
||||
|
||||
[[nodiscard]] bool start();
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+147
-24
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "rapidjson_wrapper.h"
|
||||
#include "merge_mining_client.h"
|
||||
#include "sha256.h"
|
||||
#include "i2p.h"
|
||||
|
||||
#ifdef WITH_TLS
|
||||
#include <openssl/curve25519.h>
|
||||
@@ -48,6 +49,7 @@ LOG_CATEGORY(P2PServer)
|
||||
|
||||
static constexpr char saved_peer_list_file_name[] = "p2pool_peers.txt";
|
||||
static constexpr char saved_onion_peer_list_file_name[] = "p2pool_onion_peers.txt";
|
||||
static constexpr char saved_i2p_peer_list_file_name[] = "p2pool_i2p_peers.txt";
|
||||
static const char* seed_nodes[] = { "seeds.p2pool.io", "main.p2poolpeers.net", "" };
|
||||
static const char* seed_nodes_mini[] = { "seeds-mini.p2pool.io", "mini.p2poolpeers.net", "" };
|
||||
static const char* seed_nodes_nano[] = { "seeds-nano.p2pool.io", "nano.p2poolpeers.net", ""};
|
||||
@@ -63,8 +65,12 @@ static constexpr hash seed_onion_nodes[] = {
|
||||
from_onion_v3_const("p2pseedtwyepi4crkf4akceen4twejcptnsbm6gjmzdfgxua57hiijid.onion")
|
||||
};
|
||||
|
||||
static constexpr hash seed_i2p_nodes[] = {
|
||||
from_i2p_b32_const("h6jrh53yvlvzqqyy7abzjp2t4kidtheee7e7nfbynecroc7yvbjq.b32.i2p")
|
||||
};
|
||||
|
||||
P2PServer::P2PServer(p2pool* pool)
|
||||
: TCPServer(DEFAULT_BACKLOG, P2PClient::allocate, pool->params().m_socks5Proxy)
|
||||
: TCPServer(DEFAULT_BACKLOG, P2PClient::allocate, pool->params().m_socks5Proxy, pool->params().m_socks5ProxyType, pool->params().m_p2pProxyProtocol)
|
||||
, m_pool(pool)
|
||||
, m_cache(pool->params().m_blockCache ? new BlockCache(pool->params()) : nullptr)
|
||||
, m_cacheLoaded(false)
|
||||
@@ -79,6 +85,8 @@ P2PServer::P2PServer(p2pool* pool)
|
||||
, m_seenGoodPeers(false)
|
||||
, m_peerListLastSaved(0)
|
||||
, m_numOnionConnections(0)
|
||||
, m_numI2PConnections(0)
|
||||
, m_isI2P(pool->params().m_socks5ProxyType == Params::ProxyType::I2P)
|
||||
, m_lookForMissingBlocks(true)
|
||||
, m_fastestPeer(nullptr)
|
||||
, m_newP2PoolVersionDetected(false)
|
||||
@@ -93,8 +101,10 @@ P2PServer::P2PServer(p2pool* pool)
|
||||
// Diffuse the initial state in case it has low quality
|
||||
m_rng.discard(10000);
|
||||
|
||||
m_peerId = m_rng();
|
||||
m_peerId_TOR = m_rng();
|
||||
// Make sure peer IDs are not 0
|
||||
do { m_peerId = m_rng(); } while (!m_peerId);
|
||||
do { m_peerId_TOR = m_rng(); } while (!m_peerId_TOR);
|
||||
do { m_peerId_I2P = m_rng(); } while (!m_peerId_I2P);
|
||||
|
||||
const Params& params = pool->params();
|
||||
|
||||
@@ -426,14 +436,16 @@ void P2PServer::update_peer_connections()
|
||||
|
||||
uint32_t num_outgoing = m_numConnections - m_numIncomingConnections;
|
||||
|
||||
// Try to have at least N/2 outgoing onion connections
|
||||
if (!m_socks5Proxy.empty()) {
|
||||
// Try to have at least N/2 (or N if clearnet P2P is disabled) outgoing onion connections
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == Params::ProxyType::TOR)) {
|
||||
std::vector<hash> pubkeys = m_pool->side_chain().seen_onion_pubkeys();
|
||||
|
||||
// Add seed nodes
|
||||
pubkeys.insert(pubkeys.end(), seed_onion_nodes, seed_onion_nodes + array_size(seed_onion_nodes));
|
||||
|
||||
for (uint32_t i = m_numOnionConnections, n = N / 2; (i < n) && !pubkeys.empty();) {
|
||||
const uint32_t n = m_pool->params().m_noClearnetP2P ? N : (N / 2);
|
||||
|
||||
for (uint32_t i = m_numOnionConnections; (i < n) && !pubkeys.empty();) {
|
||||
const uint64_t k = get_random64() % pubkeys.size();
|
||||
const std::string addr = to_onion_v3(pubkeys[k]);
|
||||
|
||||
@@ -457,6 +469,39 @@ void P2PServer::update_peer_connections()
|
||||
}
|
||||
}
|
||||
|
||||
// Try to have at least N/2 (or N if clearnet P2P is disabled) outgoing I2P connections
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == Params::ProxyType::I2P)) {
|
||||
std::vector<hash> dest_hashes = m_pool->side_chain().seen_i2p_dest_hashes();
|
||||
|
||||
// Add seed nodes
|
||||
dest_hashes.insert(dest_hashes.end(), seed_i2p_nodes, seed_i2p_nodes + array_size(seed_i2p_nodes));
|
||||
|
||||
const uint32_t n = m_pool->params().m_noClearnetP2P ? N : (N / 2);
|
||||
|
||||
for (uint32_t i = m_numI2PConnections; (i < n) && !dest_hashes.empty();) {
|
||||
const uint64_t k = get_random64() % dest_hashes.size();
|
||||
const std::string addr = to_i2p_b32(dest_hashes[k]);
|
||||
|
||||
int port = DEFAULT_P2P_PORT_I2P;
|
||||
|
||||
for (const hash& seed_i2p : seed_i2p_nodes) {
|
||||
if (dest_hashes[k] == seed_i2p) {
|
||||
const SideChain& s = m_pool->side_chain();
|
||||
port = s.is_mini() ? DEFAULT_P2P_PORT_MINI : (s.is_nano() ? DEFAULT_P2P_PORT_NANO : DEFAULT_P2P_PORT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((connected_clients_domain.find(addr) == connected_clients_domain.end()) && connect_to_peer(addr, port)) {
|
||||
++i;
|
||||
++num_outgoing;
|
||||
}
|
||||
|
||||
dest_hashes[k] = dest_hashes.back();
|
||||
dest_hashes.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// Try to have at least N outgoing connections (N defaults to 10, can be set via --out-peers command line parameter)
|
||||
if (!m_pool->params().m_noClearnetP2P) {
|
||||
while ((num_outgoing < N) && !peer_list.empty()) {
|
||||
@@ -629,6 +674,28 @@ void P2PServer::save_peer_list()
|
||||
}
|
||||
}
|
||||
|
||||
if (s.i2p_dest_hashes_count() > 0) {
|
||||
const std::string i2p_path = params.m_dataDir + saved_i2p_peer_list_file_name;
|
||||
|
||||
f.open(i2p_path, std::ios::binary);
|
||||
|
||||
if (!f.is_open()) {
|
||||
LOGERR(1, "failed to save I2P peer list " << i2p_path << ": error " << errno);
|
||||
}
|
||||
else {
|
||||
const std::vector<hash> dest_hashes = s.seen_i2p_dest_hashes();
|
||||
|
||||
for (const hash& h : dest_hashes) {
|
||||
f << to_i2p_b32(h) << '\n';
|
||||
}
|
||||
|
||||
f.flush();
|
||||
f.close();
|
||||
|
||||
LOGINFO(5, "I2P peer list saved (" << dest_hashes.size() << " peers)");
|
||||
}
|
||||
}
|
||||
|
||||
m_peerListLastSaved = seconds_since_epoch();
|
||||
}
|
||||
|
||||
@@ -727,8 +794,27 @@ void P2PServer::load_peer_list()
|
||||
}
|
||||
|
||||
// Finally load peers from p2pool_peers.txt and p2pool_onion_peers.txt
|
||||
for (size_t i = 0, n = (m_socks5Proxy.empty() ? 1 : 2); i < n; ++i) {
|
||||
const std::string path = m_pool->params().m_dataDir + (i ? saved_onion_peer_list_file_name : saved_peer_list_file_name);
|
||||
std::vector<std::string> paths;
|
||||
paths.resize(Params::ProxyType::MAX);
|
||||
|
||||
const Params& params = m_pool->params();
|
||||
|
||||
paths[Params::ProxyType::PLAIN] = params.m_dataDir + saved_peer_list_file_name;
|
||||
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == Params::ProxyType::TOR)) {
|
||||
paths[Params::ProxyType::TOR] = params.m_dataDir + saved_onion_peer_list_file_name;
|
||||
}
|
||||
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == Params::ProxyType::I2P)) {
|
||||
paths[Params::ProxyType::I2P] = params.m_dataDir + saved_i2p_peer_list_file_name;
|
||||
}
|
||||
|
||||
for (int i = Params::ProxyType::PLAIN; i < Params::ProxyType::MAX; ++i) {
|
||||
const std::string& path = paths[i];
|
||||
|
||||
if (path.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::ifstream f(path);
|
||||
|
||||
@@ -740,12 +826,18 @@ void P2PServer::load_peer_list()
|
||||
std::getline(f, address);
|
||||
|
||||
if (!address.empty()) {
|
||||
if (i > 0) {
|
||||
if (i == Params::ProxyType::TOR) {
|
||||
const hash h = from_onion_v3(address);
|
||||
if (!h.empty()) {
|
||||
pubkeys.emplace_back(h);
|
||||
}
|
||||
}
|
||||
else if (i == Params::ProxyType::I2P) {
|
||||
const hash h = from_i2p_b32(address);
|
||||
if (!h.empty()) {
|
||||
pubkeys.emplace_back(h);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!saved_list.empty()) {
|
||||
saved_list += ',';
|
||||
@@ -756,9 +848,12 @@ void P2PServer::load_peer_list()
|
||||
}
|
||||
f.close();
|
||||
|
||||
if (i > 0) {
|
||||
if (i == Params::ProxyType::TOR) {
|
||||
s.add_onion_pubkeys(pubkeys);
|
||||
}
|
||||
else if (i == Params::ProxyType::I2P) {
|
||||
s.add_i2p_dest_hashes(pubkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1199,13 +1294,17 @@ uint64_t P2PServer::get_random64()
|
||||
void P2PServer::print_status()
|
||||
{
|
||||
const uint64_t onion_list_size = m_pool->side_chain().onion_pubkeys_count();
|
||||
const uint64_t i2p_list_size = m_pool->side_chain().i2p_dest_hashes_count();
|
||||
|
||||
MutexLock lock(m_peerListLock);
|
||||
|
||||
LOGINFO(0, "status" <<
|
||||
"\nConnections = " << m_numConnections.load() << " (" << m_numIncomingConnections.load() << " incoming, " << m_numOnionConnections.load() << " onion)"
|
||||
"\nConnections = " << m_numConnections.load() <<
|
||||
" (" << m_numIncomingConnections.load() <<
|
||||
" incoming, " << m_numOnionConnections.load() << " onion, " << m_numI2PConnections.load() << " I2P)" <<
|
||||
"\nPeer list size = " << m_peerList.size() <<
|
||||
"\nOnion list size = " << onion_list_size <<
|
||||
"\nI2P list size = " << i2p_list_size <<
|
||||
"\nUptime = " << log::Duration(seconds_since_epoch() - m_pool->start_time())
|
||||
);
|
||||
}
|
||||
@@ -1896,7 +1995,11 @@ void P2PServer::P2PClient::reset()
|
||||
server->m_fastestPeer = nullptr;
|
||||
}
|
||||
if ((m_addressType == AddressType::DomainName) && m_connectedTime) {
|
||||
--server->m_numOnionConnections;
|
||||
if (server->m_isI2P == true) {
|
||||
--server->m_numI2PConnections;
|
||||
} else {
|
||||
--server->m_numOnionConnections;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1956,7 +2059,11 @@ bool P2PServer::P2PClient::on_connect()
|
||||
}
|
||||
|
||||
if (m_addressType == AddressType::DomainName) {
|
||||
++server->m_numOnionConnections;
|
||||
if (server->m_isI2P == true) {
|
||||
++server->m_numI2PConnections;
|
||||
} else {
|
||||
++server->m_numOnionConnections;
|
||||
}
|
||||
}
|
||||
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
@@ -1999,7 +2106,7 @@ bool P2PServer::P2PClient::on_read(const char* data, uint32_t size)
|
||||
const MessageId id = static_cast<MessageId>(buf[0]);
|
||||
|
||||
// Peer must complete the handshake challenge before sending any other messages
|
||||
if (!m_handshakeComplete && (id != m_expectedMessage)) {
|
||||
if ((!m_handshakeComplete || m_handshakeInvalid) && (id != m_expectedMessage)) {
|
||||
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " didn't send handshake messages first");
|
||||
ban(DEFAULT_BAN_TIME);
|
||||
server->remove_peer_from_list(this);
|
||||
@@ -2293,7 +2400,18 @@ bool P2PServer::P2PClient::send_handshake_challenge()
|
||||
k >>= 8;
|
||||
}
|
||||
|
||||
k = owner->get_peerId((m_addressType == AddressType::DomainName) && (strstr(m_addrString, ".onion:")));
|
||||
bool is_tor = false;
|
||||
|
||||
if ((m_addressType == AddressType::DomainName) && (strstr(m_addrString, ".onion:"))) {
|
||||
// We're connecting to an .onion address
|
||||
is_tor = true;
|
||||
}
|
||||
else if (!owner->m_pool->params().m_onionPubkey.empty() && m_isIncoming && (m_addressType != AddressType::DomainName) && m_addr.is_localhost()) {
|
||||
// We published our .onion address, and it's an incoming connection on localhost interface, so it's likely an incoming tor connection
|
||||
is_tor = true;
|
||||
}
|
||||
|
||||
k = owner->get_peerId(is_tor, owner->m_isI2P);
|
||||
memcpy(p, &k, sizeof(uint64_t));
|
||||
p += sizeof(uint64_t);
|
||||
|
||||
@@ -2486,7 +2604,7 @@ bool P2PServer::P2PClient::on_handshake_challenge(const uint8_t* buf)
|
||||
uint64_t peer_id;
|
||||
memcpy(&peer_id, buf + CHALLENGE_SIZE, sizeof(uint64_t));
|
||||
|
||||
if ((peer_id == server->get_peerId(false)) || (peer_id == server->get_peerId(true))) {
|
||||
if ((peer_id == server->m_peerId) || (peer_id == server->m_peerId_TOR) || (peer_id == server->m_peerId_I2P)) {
|
||||
LOGWARN(5, "tried to connect to self at " << static_cast<const char*>(m_addrString));
|
||||
return false;
|
||||
}
|
||||
@@ -2584,7 +2702,7 @@ bool P2PServer::P2PClient::on_listen_port(const uint8_t* buf)
|
||||
int32_t port;
|
||||
memcpy(&port, buf, sizeof(port));
|
||||
|
||||
if ((port < 0) || (port >= 65536)) {
|
||||
if ((port <= 0) || (port >= 65536)) {
|
||||
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " sent an invalid listen port number");
|
||||
return false;
|
||||
}
|
||||
@@ -3028,7 +3146,7 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
|
||||
const time_t cur_time = time(nullptr);
|
||||
|
||||
// Layout of the message:
|
||||
//
|
||||
//
|
||||
// 32 bytes | Secondary public key
|
||||
// 8 bytes | Secondary public key's expiration timestamp
|
||||
// 64 bytes | Master key signature signing the above 40 bytes
|
||||
@@ -3047,11 +3165,11 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
|
||||
}
|
||||
|
||||
// Layout of the data:
|
||||
//
|
||||
//
|
||||
// 8 bytes | timestamp
|
||||
//
|
||||
//
|
||||
// Next come one or multiple data entries:
|
||||
//
|
||||
//
|
||||
// 32 bytes | aux_id
|
||||
// 32 bytes | aux_hash
|
||||
// 16 bytes | aux_diff
|
||||
@@ -3098,6 +3216,11 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
|
||||
p += sizeof(int64_t);
|
||||
|
||||
// Ignore outdated messages
|
||||
if (data_timestamp > std::numeric_limits<int64_t>::max() - AUX_JOB_TIMEOUT) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an invalid AUX_JOB_DONATION message (timestamp = " << data_timestamp << ')');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cur_time >= data_timestamp + AUX_JOB_TIMEOUT) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an outdated AUX_JOB_DONATION message (" << cur_time << " >= " << data_timestamp << " + " << static_cast<int>(AUX_JOB_TIMEOUT) << ')');
|
||||
return true;
|
||||
@@ -3105,7 +3228,7 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
|
||||
|
||||
if ((data_end - p) % DATA_ENTRY_SIZE) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " sent an invalid AUX_JOB_DONATION message (" << (data_end - p) << " is not a multiple of " << DATA_ENTRY_SIZE << ')');
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
hash digest;
|
||||
@@ -3247,7 +3370,7 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_
|
||||
|
||||
std::vector<uint8_t> blob;
|
||||
blob.reserve(data.header_size + HASH_SIZE + 2);
|
||||
|
||||
|
||||
blob.insert(blob.end(), buf, buf + data.header_size);
|
||||
blob.insert(blob.end(), root.h, root.h + HASH_SIZE);
|
||||
writeVarint(num_transactions + 1, blob);
|
||||
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -37,6 +37,7 @@ static constexpr int DEFAULT_P2P_PORT_MINI = 37888;
|
||||
static constexpr int DEFAULT_P2P_PORT_NANO = 37890;
|
||||
|
||||
static constexpr int DEFAULT_P2P_PORT_ONION = 28722;
|
||||
static constexpr int DEFAULT_P2P_PORT_I2P = 28723;
|
||||
|
||||
static constexpr uint32_t PROTOCOL_VERSION_1_0 = 0x00010000UL;
|
||||
static constexpr uint32_t PROTOCOL_VERSION_1_1 = 0x00010001UL;
|
||||
@@ -95,9 +96,9 @@ public:
|
||||
// Both peers send handshake challenge immediately after a connection is established
|
||||
// Both peers must have the same consensus ID for handshake to succeed
|
||||
// Consensus ID is never sent over the network
|
||||
//
|
||||
//
|
||||
// Handshake sequence:
|
||||
//
|
||||
//
|
||||
// - Both peers send 8-byte random challenges (and 8 bytes of peer ID) to each other
|
||||
// - Each peer receives 8-byte challenge, chooses 8-byte random SALT and calculates H = KECCAK(CHALLENGE|CONSENSUS_ID|SALT)
|
||||
// - Both peers send their H and SALT, calculate H of the other peer and check if it matches with what other peer calculated
|
||||
@@ -191,7 +192,7 @@ public:
|
||||
|
||||
void broadcast(const PoolBlock& block, const PoolBlock* parent);
|
||||
[[nodiscard]] uint64_t get_random64();
|
||||
[[nodiscard]] uint64_t get_peerId(bool is_tor) const { return is_tor ? m_peerId_TOR : m_peerId; }
|
||||
[[nodiscard]] uint64_t get_peerId(bool is_tor, bool is_i2p) const { return is_tor ? m_peerId_TOR : (is_i2p ? m_peerId_I2P : m_peerId); }
|
||||
|
||||
void print_status() override;
|
||||
void show_peers_async();
|
||||
@@ -271,6 +272,7 @@ private:
|
||||
|
||||
uint64_t m_peerId;
|
||||
uint64_t m_peerId_TOR;
|
||||
uint64_t m_peerId_I2P;
|
||||
|
||||
mutable uv_mutex_t m_peerListLock;
|
||||
|
||||
@@ -291,6 +293,8 @@ private:
|
||||
std::atomic<uint64_t> m_peerListLastSaved;
|
||||
|
||||
std::atomic<uint32_t> m_numOnionConnections;
|
||||
std::atomic<uint32_t> m_numI2PConnections;
|
||||
bool m_isI2P;
|
||||
|
||||
uv_mutex_t m_broadcastLock;
|
||||
uv_async_t m_broadcastAsync;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+358
-264
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -19,8 +19,14 @@
|
||||
#include "params.h"
|
||||
#include "stratum_server.h"
|
||||
#include "p2p_server.h"
|
||||
#include "i2p.h"
|
||||
#include <fstream>
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
#include "merge_mining_client.h"
|
||||
#include "merge_mining_client_tari.h"
|
||||
#endif
|
||||
|
||||
LOG_CATEGORY(Params)
|
||||
|
||||
void p2pool_usage();
|
||||
@@ -32,275 +38,13 @@ static constexpr uint64_t MAX_STRATUM_BAN_TIME = (UINT64_C(1) << 34) - 1;
|
||||
|
||||
Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
{
|
||||
auto has1 = [](const auto& v) { return (v.size() > 1) && !v[1].empty();};
|
||||
auto has2 = [](const auto& v) { return (v.size() > 2) && !v[2].empty();};
|
||||
|
||||
for (const auto& arg : args) {
|
||||
// Ignore empty parameters
|
||||
if (arg.empty() || arg[0].empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
|
||||
if ((arg[0] == "host") && has1(arg)) {
|
||||
const char* address = arg[1].c_str();
|
||||
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
m_hosts.back().m_address = address;
|
||||
}
|
||||
else {
|
||||
const Host& h = m_hosts.back();
|
||||
m_hosts.emplace_back(address, h.m_rpcPort, h.m_zmqPort, "");
|
||||
}
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "rpc-port") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "zmq-port") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_zmqPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "light-mode") {
|
||||
m_lightMode = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "wallet") && has1(arg)) {
|
||||
const char* s = arg[1].c_str();
|
||||
|
||||
if (!m_mainWallet.decode(s)) {
|
||||
LOGERR(1, "Wallet " << s << " failed to decode");
|
||||
}
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "subaddress") && has1(arg)) {
|
||||
const char* s = arg[1].c_str();
|
||||
|
||||
if (!m_subaddress.decode(s)) {
|
||||
LOGERR(1, "Subaddress " << s << " failed to decode");
|
||||
}
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "stratum") && has1(arg)) {
|
||||
m_stratumAddresses = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "stratum-ban-time") && has1(arg)) {
|
||||
m_stratumBanTime = strtoull(arg[1].c_str(), nullptr, 10);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "p2p") && has1(arg)) {
|
||||
m_p2pAddresses = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "addpeers") && has1(arg)) {
|
||||
m_p2pPeerList = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "loglevel") && has1(arg)) {
|
||||
const int level = std::min(std::max<int>(static_cast<int>(strtol(arg[1].c_str(), nullptr, 10)), 0), log::MAX_GLOBAL_LOG_LEVEL);
|
||||
log::GLOBAL_LOG_LEVEL = level;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "data-dir") && has1(arg)) {
|
||||
m_dataDir = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "log-file") && has1(arg)) {
|
||||
m_logFilePath = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "sidechain-config") && has1(arg)) {
|
||||
m_sidechainConfig = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "data-api") && has1(arg)) {
|
||||
m_apiPath = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "local-api") || (arg[0] == "stratum-api")) {
|
||||
m_localStats = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-cache") {
|
||||
m_blockCache = false;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-color") {
|
||||
log::CONSOLE_COLORS = false;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_RANDOMX
|
||||
if (arg[0] == "no-randomx") {
|
||||
m_disableRandomX = true;
|
||||
ok = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (((arg[0] == "out-peers") || (arg[0] == "outpeers")) && has1(arg)) {
|
||||
m_maxOutgoingPeers = std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 10UL), 450UL);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (((arg[0] == "in-peers") || (arg[0] == "inpeers")) && has1(arg)) {
|
||||
m_maxIncomingPeers = std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 10UL), 450UL);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "start-mining") && has1(arg)) {
|
||||
m_minerThreads = std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 64UL);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "mini") {
|
||||
m_mini = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "nano") {
|
||||
m_nano = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-autodiff") {
|
||||
m_autoDiff = false;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "rpc-login") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcLogin = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_TLS
|
||||
if (arg[0] == "rpc-ssl") {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcSSL = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "rpc-ssl-fingerprint") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcSSL_Fingerprint = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((arg[0] == "socks5") && has1(arg)) {
|
||||
m_socks5Proxy = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-dns") {
|
||||
m_dns = false;
|
||||
disable_resolve_host = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "p2p-external-port") && has1(arg)) {
|
||||
m_p2pExternalPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_UPNP
|
||||
if ((arg[0] == "no-upnp") || (arg[0] == "no-igd")) {
|
||||
m_upnp = false;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "upnp-stratum") {
|
||||
m_upnpStratum = true;
|
||||
ok = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((arg[0] == "merge-mine") && has1(arg) && has2(arg)) {
|
||||
m_mergeMiningHosts.emplace_back(arg[1], arg[2]);
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_TLS
|
||||
if ((arg[0] == "tls-cert") && has1(arg)) {
|
||||
m_tlsCert = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "tls-cert-key") && has1(arg)) {
|
||||
m_tlsCertKey = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg[0] == "no-stratum-http") {
|
||||
m_enableStratumHTTP = false;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
#ifdef WITH_MERGE_MINING_DONATION
|
||||
if ((arg[0] == "adkf") && has1(arg)) {
|
||||
m_authorKeyFile = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg[0] == "full-validation") {
|
||||
m_enableFullValidation = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "onion-address") && has1(arg)) {
|
||||
m_onionAddress = arg[1];
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-clearnet-p2p") {
|
||||
m_noClearnetP2P = true;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
if (!process_arg(arg)) {
|
||||
fprintf(stderr, "Unknown or invalid command line parameter \"%s\"\n\n", arg[0].c_str());
|
||||
p2pool_usage();
|
||||
throw std::exception();
|
||||
@@ -316,6 +60,15 @@ Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_i2pAddress.empty()) {
|
||||
m_i2pDestinationHash = from_i2p_b32(m_i2pAddress);
|
||||
|
||||
if (m_i2pDestinationHash.empty()) {
|
||||
LOGERR(1, "Failed to parse \"" << m_i2pAddress << '"');
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
|
||||
auto invalid_host = [](const Host& h)
|
||||
{
|
||||
if (!h.valid()) {
|
||||
@@ -421,6 +174,328 @@ Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
else {
|
||||
fixup_path(m_dataDir);
|
||||
}
|
||||
|
||||
// Detect the proxy type
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == ProxyType::AUTO)) {
|
||||
m_socks5ProxyType = ProxyType::INVALID;
|
||||
|
||||
const size_t k = m_socks5Proxy.find_last_of(':');
|
||||
|
||||
if ((k != std::string::npos) && (k < m_socks5Proxy.length() - 1)) {
|
||||
const unsigned long port = strtoul(m_socks5Proxy.substr(k + 1).c_str(), nullptr, 10);
|
||||
|
||||
if ((port > 0) && (port < 65536)) {
|
||||
switch (port) {
|
||||
case 9050:
|
||||
m_socks5ProxyType = ProxyType::TOR;
|
||||
break;
|
||||
|
||||
case 4447:
|
||||
m_socks5ProxyType = ProxyType::I2P;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_socks5ProxyType = ProxyType::PLAIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Params::process_arg(const std::vector<std::string>& arg)
|
||||
{
|
||||
if ((arg[0] == "host") && has1(arg)) {
|
||||
const std::string& address = arg[1];
|
||||
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
m_hosts.back().m_address = address;
|
||||
}
|
||||
else {
|
||||
const Host& h = m_hosts.back();
|
||||
|
||||
int32_t rpc_port = h.m_rpcPort;
|
||||
int32_t zmq_port = h.m_zmqPort;
|
||||
|
||||
// Better not to use "h" here because emplace_back can reallocate
|
||||
m_hosts.emplace_back(address, rpc_port, zmq_port, std::string());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "rpc-port") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "zmq-port") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_zmqPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "light-mode") {
|
||||
m_lightMode = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "wallet") && has1(arg)) {
|
||||
const char* s = arg[1].c_str();
|
||||
|
||||
if (!m_mainWallet.decode(s)) {
|
||||
LOGERR(1, "Wallet " << s << " failed to decode");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "subaddress") && has1(arg)) {
|
||||
const char* s = arg[1].c_str();
|
||||
|
||||
if (!m_subaddress.decode(s)) {
|
||||
LOGERR(1, "Subaddress " << s << " failed to decode");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "stratum") && has1(arg)) {
|
||||
m_stratumAddresses = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "stratum-ban-time") && has1(arg)) {
|
||||
m_stratumBanTime = strtoull(arg[1].c_str(), nullptr, 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "p2p") && has1(arg)) {
|
||||
m_p2pAddresses = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "addpeers") && has1(arg)) {
|
||||
m_p2pPeerList = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "loglevel") && has1(arg)) {
|
||||
const int level = std::min(std::max<int>(static_cast<int>(strtol(arg[1].c_str(), nullptr, 10)), 0), log::MAX_GLOBAL_LOG_LEVEL);
|
||||
log::GLOBAL_LOG_LEVEL = level;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "data-dir") && has1(arg)) {
|
||||
m_dataDir = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "log-file") && has1(arg)) {
|
||||
m_logFilePath = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "sidechain-config") && has1(arg)) {
|
||||
m_sidechainConfig = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "data-api") && has1(arg)) {
|
||||
m_apiPath = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "local-api") || (arg[0] == "stratum-api")) {
|
||||
m_localStats = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-cache") {
|
||||
m_blockCache = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-color") {
|
||||
log::CONSOLE_COLORS = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_RANDOMX
|
||||
if (arg[0] == "no-randomx") {
|
||||
m_disableRandomX = true;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (((arg[0] == "out-peers") || (arg[0] == "outpeers")) && has1(arg)) {
|
||||
m_maxOutgoingPeers = std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 10UL), 450UL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (((arg[0] == "in-peers") || (arg[0] == "inpeers")) && has1(arg)) {
|
||||
m_maxIncomingPeers = std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 10UL), 450UL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "start-mining") && has1(arg)) {
|
||||
m_minerThreads = std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 64UL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "mini") {
|
||||
m_mini = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "nano") {
|
||||
m_nano = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-autodiff") {
|
||||
m_autoDiff = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "rpc-login") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcLogin = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_TLS
|
||||
if (arg[0] == "rpc-ssl") {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcSSL = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "rpc-ssl-fingerprint") && has1(arg)) {
|
||||
if (m_hosts.empty()) {
|
||||
m_hosts.emplace_back();
|
||||
}
|
||||
|
||||
m_hosts.back().m_rpcSSL_Fingerprint = arg[1];
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((arg[0] == "socks5") && has1(arg)) {
|
||||
m_socks5Proxy = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "socks5-proxy-type") && has1(arg)) {
|
||||
const std::string s = tolower(arg[1]);
|
||||
|
||||
m_socks5ProxyType = ProxyType::INVALID;
|
||||
|
||||
if (s == "auto") m_socks5ProxyType = ProxyType::AUTO;
|
||||
if (s == "plain") m_socks5ProxyType = ProxyType::PLAIN;
|
||||
if (s == "tor") m_socks5ProxyType = ProxyType::TOR;
|
||||
if (s == "i2p") m_socks5ProxyType = ProxyType::I2P;
|
||||
|
||||
return m_socks5ProxyType != ProxyType::INVALID;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-dns") {
|
||||
m_dns = false;
|
||||
disable_resolve_host = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "p2p-external-port") && has1(arg)) {
|
||||
m_p2pExternalPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_UPNP
|
||||
if ((arg[0] == "no-upnp") || (arg[0] == "no-igd")) {
|
||||
m_upnp = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "upnp-stratum") {
|
||||
m_upnpStratum = true;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((arg[0] == "merge-mine") && has1(arg) && has2(arg)) {
|
||||
m_mergeMiningHosts.emplace_back(arg[1], arg[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_TLS
|
||||
if ((arg[0] == "tls-cert") && has1(arg)) {
|
||||
m_tlsCert = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "tls-cert-key") && has1(arg)) {
|
||||
m_tlsCertKey = arg[1];
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg[0] == "no-stratum-http") {
|
||||
m_enableStratumHTTP = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_MERGE_MINING_DONATION
|
||||
if ((arg[0] == "adkf") && has1(arg)) {
|
||||
m_authorKeyFile = arg[1];
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg[0] == "full-validation") {
|
||||
m_enableFullValidation = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "onion-address") && has1(arg)) {
|
||||
m_onionAddress = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "i2p-address") && has1(arg)) {
|
||||
m_i2pAddress = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-clearnet-p2p") {
|
||||
m_noClearnetP2P = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "stratum-proxy-protocol") {
|
||||
m_stratumProxyProtocol = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "p2p-proxy-protocol") {
|
||||
m_p2pProxyProtocol = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Params::valid() const
|
||||
@@ -473,9 +548,28 @@ bool Params::valid() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_socks5ProxyType == ProxyType::INVALID) {
|
||||
LOGERR(1, "Invalid SOCKS5 proxy type. Check the --socks5 and --socks5-proxy-type parameters.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
bool Params::grpc_needed() const
|
||||
{
|
||||
for (const MergeMiningHost& h : m_mergeMiningHosts) {
|
||||
if (h.m_host.find(MergeMiningClientTari::TARI_PREFIX) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool Params::Host::init_display_name(const Params& p)
|
||||
{
|
||||
m_displayName = m_address;
|
||||
|
||||
+34
-5
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,13 +31,17 @@ struct Params
|
||||
|
||||
explicit Params(const std::vector<std::vector<std::string>>& args);
|
||||
|
||||
bool valid() const;
|
||||
[[nodiscard]] bool valid() const;
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
[[nodiscard]] bool grpc_needed() const;
|
||||
#endif
|
||||
|
||||
struct Host
|
||||
{
|
||||
Host() : m_address("127.0.0.1"), m_rpcPort(18081), m_zmqPort(18083), m_rpcSSL(false) {}
|
||||
|
||||
Host(const char* address, int32_t rpcPort, int32_t zmqPort, const char* rpcLogin)
|
||||
Host(const std::string& address, int32_t rpcPort, int32_t zmqPort, const std::string& rpcLogin)
|
||||
: m_address(address)
|
||||
, m_rpcPort(rpcPort)
|
||||
, m_zmqPort(zmqPort)
|
||||
@@ -45,9 +49,9 @@ struct Params
|
||||
, m_rpcSSL(false)
|
||||
{}
|
||||
|
||||
bool valid() const { return !m_address.empty() && m_rpcPort && m_zmqPort && (m_rpcPort != m_zmqPort); }
|
||||
[[nodiscard]] bool valid() const { return !m_address.empty() && m_rpcPort && m_zmqPort && (m_rpcPort != m_zmqPort); }
|
||||
|
||||
bool init_display_name(const Params& p);
|
||||
[[nodiscard]] bool init_display_name(const Params& p);
|
||||
|
||||
std::string m_address;
|
||||
int32_t m_rpcPort;
|
||||
@@ -104,7 +108,18 @@ struct Params
|
||||
bool m_mini = false;
|
||||
bool m_nano = false;
|
||||
bool m_autoDiff = true;
|
||||
|
||||
std::string m_socks5Proxy;
|
||||
|
||||
enum ProxyType {
|
||||
INVALID = -1,
|
||||
AUTO = 0,
|
||||
PLAIN = 1,
|
||||
TOR = 2,
|
||||
I2P = 3,
|
||||
MAX = 4,
|
||||
} m_socks5ProxyType = ProxyType::AUTO;
|
||||
|
||||
bool m_dns = true;
|
||||
int32_t m_p2pExternalPort = 0;
|
||||
#ifdef WITH_UPNP
|
||||
@@ -134,7 +149,21 @@ struct Params
|
||||
|
||||
std::string m_onionAddress;
|
||||
hash m_onionPubkey;
|
||||
|
||||
// Hidden service address provided by the user
|
||||
std::string m_i2pAddress;
|
||||
// Raw hash of the destination info; decoded Base32 address with suffix removed
|
||||
hash m_i2pDestinationHash;
|
||||
|
||||
bool m_noClearnetP2P = false;
|
||||
bool m_stratumProxyProtocol = false;
|
||||
bool m_p2pProxyProtocol = false;
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool process_arg(const std::vector<std::string>& arg);
|
||||
|
||||
[[nodiscard]] static bool has1(const std::vector<std::string>& arg) { return (arg.size() > 1) && !arg[1].empty();}
|
||||
[[nodiscard]] static bool has2(const std::vector<std::string>& arg) { return (arg.size() > 2) && !arg[2].empty();}
|
||||
};
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
+2
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -51,7 +51,6 @@ PoolBlock::PoolBlock()
|
||||
, m_difficulty{}
|
||||
, m_cumulativeDifficulty{}
|
||||
, m_merkleProof{}
|
||||
, m_merkleProofPath(0)
|
||||
, m_mergeMiningExtra{}
|
||||
, m_sidechainExtraBuf{}
|
||||
, m_sidechainId{}
|
||||
@@ -108,7 +107,6 @@ PoolBlock& PoolBlock::operator=(const PoolBlock& b)
|
||||
m_difficulty = b.m_difficulty;
|
||||
m_cumulativeDifficulty = b.m_cumulativeDifficulty;
|
||||
m_merkleProof = b.m_merkleProof;
|
||||
m_merkleProofPath = b.m_merkleProofPath;
|
||||
m_mergeMiningExtra = b.m_mergeMiningExtra;
|
||||
memcpy(m_sidechainExtraBuf, b.m_sidechainExtraBuf, sizeof(m_sidechainExtraBuf));
|
||||
m_sidechainId = b.m_sidechainId;
|
||||
@@ -200,7 +198,7 @@ std::vector<uint8_t> PoolBlock::serialize_mainchain_data(size_t* header_size, si
|
||||
}
|
||||
|
||||
*(p++) = TX_EXTRA_NONCE;
|
||||
*(p++) = static_cast<uint8_t>(extra_nonce_size);
|
||||
writeVarint(extra_nonce_size, [&p](uint8_t value) { *(p++) = value; });
|
||||
|
||||
if (!extra_nonce) {
|
||||
extra_nonce = &m_extraNonce;
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -62,6 +62,9 @@ static constexpr difficulty_type MAX_CUMULATIVE_DIFFICULTY{ 13019633956666736640
|
||||
// 1000 years at 1 block/second. It should be enough for any normal use.
|
||||
static constexpr uint64_t MAX_SIDECHAIN_HEIGHT = 31556952000ULL;
|
||||
|
||||
// Taken from Monero's cryptonote_config.h
|
||||
static constexpr uint64_t CRYPTONOTE_MAX_BLOCK_NUMBER = 500000000ULL;
|
||||
|
||||
// Limited by the format of the Merkle tree parameters in tx_extra
|
||||
static constexpr uint64_t MERGE_MINING_MAX_CHAINS = 256;
|
||||
static constexpr uint64_t LOG2_MERGE_MINING_MAX_CHAINS = 8;
|
||||
@@ -140,7 +143,6 @@ struct PoolBlock
|
||||
|
||||
// Merkle proof for merge mining
|
||||
std::vector<hash> m_merkleProof;
|
||||
uint32_t m_merkleProofPath;
|
||||
|
||||
// Merge mining extra data
|
||||
//
|
||||
|
||||
+17
-10
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -79,11 +79,13 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
||||
|
||||
uint64_t unlock_height;
|
||||
READ_VARINT(unlock_height);
|
||||
if (unlock_height > CRYPTONOTE_MAX_BLOCK_NUMBER) return __LINE__;
|
||||
|
||||
EXPECT_BYTE(1);
|
||||
EXPECT_BYTE(TXIN_GEN);
|
||||
|
||||
READ_VARINT(m_txinGenHeight);
|
||||
if (m_txinGenHeight > CRYPTONOTE_MAX_BLOCK_NUMBER) return __LINE__;
|
||||
if (m_majorVersion != sidechain.network_major_version(m_txinGenHeight)) return __LINE__;
|
||||
if (unlock_height != m_txinGenHeight + MINER_REWARD_UNLOCK_TIME) return __LINE__;
|
||||
|
||||
@@ -99,8 +101,8 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
||||
if (num_outputs > 0) {
|
||||
// Outputs are in the buffer, just read them
|
||||
// Each output is at least 34 bytes, exit early if there's not enough data left
|
||||
// 1 byte for reward, 1 byte for tx_type, 32 bytes for eph_pub_key
|
||||
constexpr uint64_t MIN_OUTPUT_SIZE = 34;
|
||||
// 1 byte for reward, 1 byte for tx_type, 32 bytes for eph_pub_key, 1 byte for view_tag
|
||||
constexpr uint64_t MIN_OUTPUT_SIZE = 35;
|
||||
|
||||
if (num_outputs > std::numeric_limits<uint64_t>::max() / MIN_OUTPUT_SIZE) return __LINE__;
|
||||
if (static_cast<uint64_t>(data_end - data) < num_outputs * MIN_OUTPUT_SIZE) return __LINE__;
|
||||
@@ -123,6 +125,8 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
||||
}
|
||||
|
||||
t.m_reward = reward;
|
||||
|
||||
if (total_reward + reward < total_reward) return __LINE__;
|
||||
total_reward += reward;
|
||||
|
||||
EXPECT_BYTE(TXOUT_TO_TAGGED_KEY);
|
||||
@@ -269,6 +273,12 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
||||
const int transactions_blob_size = static_cast<int>(num_transactions) * HASH_SIZE;
|
||||
const int transactions_blob_size_diff = transactions_blob_size - transactions_actual_blob_size;
|
||||
|
||||
const int data_size = static_cast<int>((data_end - data_begin) + outputs_blob_size_diff + transactions_blob_size_diff);
|
||||
|
||||
if (data_size > static_cast<int>(MAX_BLOCK_SIZE)) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
#if POOL_BLOCK_DEBUG
|
||||
m_mainChainDataDebug.reserve((data - data_begin) + outputs_blob_size_diff + transactions_blob_size_diff);
|
||||
m_mainChainDataDebug.assign(data_begin, data_begin + outputs_offset);
|
||||
@@ -413,9 +423,11 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
||||
if (static_cast<uint64_t>(data_end - data) < n) return __LINE__;
|
||||
|
||||
std::vector<uint8_t> t;
|
||||
t.resize(n);
|
||||
|
||||
READ_BUF(t.data(), n);
|
||||
if (n > 0) {
|
||||
t.resize(n);
|
||||
READ_BUF(t.data(), n);
|
||||
}
|
||||
|
||||
m_mergeMiningExtra.emplace(chain_id, std::move(t));
|
||||
}
|
||||
@@ -449,11 +461,6 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
||||
|
||||
hash check;
|
||||
const std::vector<uint8_t>& consensus_id = sidechain.consensus_id();
|
||||
const int data_size = static_cast<int>((data_end - data_begin) + outputs_blob_size_diff + transactions_blob_size_diff);
|
||||
|
||||
if (data_size > static_cast<int>(MAX_BLOCK_SIZE)) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
keccak_custom(
|
||||
[nonce_offset, extra_nonce_offset, mm_root_hash_offset, data_begin, data_size, &consensus_id, &outputs_blob, outputs_blob_size_diff, outputs_offset, outputs_blob_size, transactions_blob, transactions_blob_size_diff, transactions_offset, transactions_blob_size](int offset) -> uint8_t
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && defined(__cppcheck__)
|
||||
// cppcheck chokes on rapidjson headers in Windows
|
||||
#else
|
||||
|
||||
+43
-3
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -702,6 +702,13 @@ bool SideChain::add_block(const PoolBlock& block)
|
||||
m_seenOnionPubkeys[h] = new_block->m_localTimestamp;
|
||||
}
|
||||
|
||||
auto it2 = new_block->m_mergeMiningExtra.find(keccak_i2p_b32_address);
|
||||
if ((it2 != new_block->m_mergeMiningExtra.end()) && (it2->second.size() >= HASH_SIZE)) {
|
||||
hash h;
|
||||
memcpy(h.h, it2->second.data(), HASH_SIZE);
|
||||
m_seenI2PDestHashes[h] = new_block->m_localTimestamp;
|
||||
}
|
||||
|
||||
prune_seen_data();
|
||||
}
|
||||
|
||||
@@ -1156,7 +1163,7 @@ void SideChain::prune_seen_data()
|
||||
{
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
// Every 5 minutes, delete wallets that weren't seen for more than 72 hours and onion pubkeys that weren't seen for more than 12 hours
|
||||
// Every 5 minutes, delete wallets that haven't been seen for more than 72 hours and onion/I2P identifiers that haven't been seen for more than 12 hours
|
||||
if (m_seenWalletsLastPruneTime + 5ul * 60ul <= cur_time) {
|
||||
auto prune = [cur_time](auto& data, uint64_t timeout) {
|
||||
for (auto it = data.begin(); it != data.end();) {
|
||||
@@ -1173,6 +1180,7 @@ void SideChain::prune_seen_data()
|
||||
|
||||
prune(m_seenWallets, 72 * hour);
|
||||
prune(m_seenOnionPubkeys, 12 * hour);
|
||||
prune(m_seenI2PDestHashes, 12 * hour);
|
||||
|
||||
m_seenWalletsLastPruneTime = cur_time;
|
||||
}
|
||||
@@ -1401,6 +1409,38 @@ void SideChain::add_onion_pubkeys(const std::vector<hash>& pubkeys)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<hash> SideChain::seen_i2p_dest_hashes() const
|
||||
{
|
||||
std::vector<hash> result;
|
||||
|
||||
ReadLock lock(m_seenDataLock);
|
||||
|
||||
result.reserve(m_seenI2PDestHashes.size());
|
||||
|
||||
for (const auto& it : m_seenI2PDestHashes) {
|
||||
result.push_back(it.first);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SideChain::add_i2p_dest_hashes(const std::vector<hash>& dest_hashes)
|
||||
{
|
||||
if (dest_hashes.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
WriteLock lock(m_seenDataLock);
|
||||
|
||||
for (const hash& h : dest_hashes) {
|
||||
if (!h.empty()) {
|
||||
m_seenI2PDestHashes[h] = cur_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SideChain::verify_loop(PoolBlock* block)
|
||||
{
|
||||
// PoW is already checked at this point
|
||||
@@ -2445,7 +2485,7 @@ void SideChain::precalc_worker()
|
||||
|
||||
do {
|
||||
const PoolBlock* job;
|
||||
|
||||
|
||||
{
|
||||
MutexLock lock(m_precalcJobsMutex);
|
||||
|
||||
|
||||
+6
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
[[nodiscard]] uint64_t block_time() const { return m_targetBlockTime; }
|
||||
[[nodiscard]] FORCEINLINE uint64_t miner_count() const { ReadLock lock(m_seenDataLock); return m_seenWallets.size(); }
|
||||
[[nodiscard]] FORCEINLINE uint64_t onion_pubkeys_count() const { ReadLock lock(m_seenDataLock); return m_seenOnionPubkeys.size(); }
|
||||
[[nodiscard]] FORCEINLINE uint64_t i2p_dest_hashes_count() const { ReadLock lock(m_seenDataLock); return m_seenI2PDestHashes.size(); }
|
||||
[[nodiscard]] uint64_t last_updated() const;
|
||||
[[nodiscard]] bool is_default() const;
|
||||
[[nodiscard]] bool is_mini() const;
|
||||
@@ -90,6 +91,9 @@ public:
|
||||
[[nodiscard]] std::vector<hash> seen_onion_pubkeys() const;
|
||||
void add_onion_pubkeys(const std::vector<hash>& pubkeys);
|
||||
|
||||
[[nodiscard]] std::vector<hash> seen_i2p_dest_hashes() const;
|
||||
void add_i2p_dest_hashes(const std::vector<hash>& dest_hashes);
|
||||
|
||||
#ifdef P2POOL_UNIT_TESTS
|
||||
difficulty_type m_testMainChainDiff;
|
||||
const unordered_map<hash, PoolBlock*>& blocksById() const { return m_blocksById; }
|
||||
@@ -129,6 +133,7 @@ private:
|
||||
mutable ReadWriteLock m_seenDataLock;
|
||||
unordered_map<hash, uint64_t> m_seenWallets;
|
||||
unordered_map<hash, uint64_t> m_seenOnionPubkeys;
|
||||
unordered_map<hash, uint64_t> m_seenI2PDestHashes;
|
||||
uint64_t m_seenWalletsLastPruneTime;
|
||||
|
||||
// Used to quickly cut off multiple broadcasts of the same block by different peers. Only the first broadcast will be processed.
|
||||
|
||||
+47
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -44,7 +44,7 @@ static constexpr int32_t BAN_THRESHOLD_POINTS = -15;
|
||||
namespace p2pool {
|
||||
|
||||
StratumServer::StratumServer(p2pool* pool)
|
||||
: TCPServer(DEFAULT_BACKLOG, StratumClient::allocate, std::string())
|
||||
: TCPServer(DEFAULT_BACKLOG, StratumClient::allocate, std::string(), Params::ProxyType::INVALID, pool->params().m_stratumProxyProtocol)
|
||||
, m_pool(pool)
|
||||
, m_autoDiff(pool->params().m_autoDiff)
|
||||
, m_enableFullValidation(pool->params().m_enableFullValidation)
|
||||
@@ -70,6 +70,7 @@ StratumServer::StratumServer(p2pool* pool)
|
||||
|
||||
m_hashrateData[0] = { seconds_since_epoch(), 0 };
|
||||
|
||||
uv_mutex_init_checked(&m_resetShareCountersLock);
|
||||
uv_mutex_init_checked(&m_blobsQueueLock);
|
||||
uv_mutex_init_checked(&m_showWorkersLock);
|
||||
uv_mutex_init_checked(&m_rngLock);
|
||||
@@ -77,6 +78,9 @@ StratumServer::StratumServer(p2pool* pool)
|
||||
|
||||
m_extraNonce = get_random32();
|
||||
|
||||
uv_async_init_checked(&m_loop, &m_resetShareCountersAsync, on_reset_share_counters);
|
||||
m_resetShareCountersAsync.data = this;
|
||||
|
||||
uv_async_init_checked(&m_loop, &m_blobsAsync, on_blobs_ready);
|
||||
m_blobsAsync.data = this;
|
||||
m_blobsQueue.reserve(2);
|
||||
@@ -101,6 +105,7 @@ StratumServer::~StratumServer()
|
||||
}
|
||||
}
|
||||
|
||||
uv_mutex_destroy(&m_resetShareCountersLock);
|
||||
uv_mutex_destroy(&m_blobsQueueLock);
|
||||
uv_mutex_destroy(&m_showWorkersLock);
|
||||
uv_mutex_destroy(&m_rngLock);
|
||||
@@ -480,6 +485,8 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
|
||||
|
||||
update_auto_diff(client, share.m_timestamp, share.m_hashes);
|
||||
|
||||
++client->m_stratumShares;
|
||||
|
||||
// If this share is below sidechain difficulty, process it in this thread because it'll be quick
|
||||
if (!share.m_highEnoughDifficulty && !m_enableFullValidation) {
|
||||
on_share_found(&share.m_req);
|
||||
@@ -565,6 +572,7 @@ void StratumServer::show_workers()
|
||||
<< log::pad_right("uptime", 20)
|
||||
<< log::pad_right("difficulty", 20)
|
||||
<< log::pad_right("hashrate", 15)
|
||||
<< log::pad_right("shares", 12)
|
||||
<< "name"
|
||||
);
|
||||
|
||||
@@ -585,11 +593,16 @@ void StratumServer::show_workers()
|
||||
constexpr bool is_tls = false;
|
||||
#endif
|
||||
|
||||
char shares_buf[16] = {};
|
||||
log::Stream s(shares_buf);
|
||||
s << c->m_sidechainShares << '/' << c->m_stratumShares << '\0';
|
||||
|
||||
LOGINFO(0, log::pad_right(static_cast<const char*>(c->m_addrString), addr_len + 8)
|
||||
<< (is_tls ? "yes " : "no ")
|
||||
<< log::pad_right(log::Duration(cur_time - c->m_connectedTime), 20)
|
||||
<< log::pad_right(diff, 20)
|
||||
<< log::pad_right(log::Hashrate(c->m_autoDiff.lo / AUTO_DIFF_TARGET_TIME, m_autoDiff && (c->m_autoDiff != 0)), 15)
|
||||
<< log::pad_right(static_cast<const char*>(shares_buf), 12)
|
||||
<< (c->m_rpcId ? c->m_customUser : "not logged in")
|
||||
);
|
||||
++n;
|
||||
@@ -600,6 +613,22 @@ void StratumServer::show_workers()
|
||||
|
||||
void StratumServer::reset_share_counters()
|
||||
{
|
||||
MutexLock lock(m_resetShareCountersLock);
|
||||
|
||||
if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(&m_resetShareCountersAsync))) {
|
||||
uv_async_send(&m_resetShareCountersAsync);
|
||||
}
|
||||
}
|
||||
|
||||
void StratumServer::on_reset_share_counters()
|
||||
{
|
||||
check_event_loop_thread(__func__);
|
||||
|
||||
for (StratumClient* c = static_cast<StratumClient*>(m_connectedClientsList->m_next); c != m_connectedClientsList; c = static_cast<StratumClient*>(c->m_next)) {
|
||||
c->m_stratumShares = 0;
|
||||
c->m_sidechainShares = 0;
|
||||
}
|
||||
|
||||
WriteLock lock(m_hashrateDataLock);
|
||||
|
||||
m_cumulativeHashesAtLastShare = m_cumulativeHashes;
|
||||
@@ -1058,10 +1087,13 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
||||
|
||||
server->check_event_loop_thread(__func__);
|
||||
|
||||
bool share_found = false;
|
||||
|
||||
if (share->m_highEnoughDifficulty) {
|
||||
const char* s = share->m_clientCustomUser;
|
||||
if (share->m_result == SubmittedShare::Result::OK) {
|
||||
LOGINFO(0, log::Green() << "SHARE FOUND: mainchain height " << share->m_mainchainHeight << ", sidechain height " << share->m_sidechainHeight << ", diff " << share->m_sidechainDifficulty << ", client " << static_cast<char*>(share->m_clientAddrString) << (*s ? ", user " : "") << s << ", effort " << share->m_effort << '%');
|
||||
share_found = true;
|
||||
}
|
||||
else {
|
||||
static const char* reason_list[] = {
|
||||
@@ -1117,6 +1149,10 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
||||
|
||||
client->m_score += share->m_score;
|
||||
|
||||
if (share_found) {
|
||||
++client->m_sidechainShares;
|
||||
}
|
||||
|
||||
if (bad_share && (client->m_score <= BAN_THRESHOLD_POINTS)) {
|
||||
client->ban(server->m_banTime);
|
||||
client->close();
|
||||
@@ -1156,6 +1192,10 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
|
||||
|
||||
void StratumServer::on_shutdown()
|
||||
{
|
||||
{
|
||||
MutexLock lock(m_resetShareCountersLock);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_resetShareCountersAsync), nullptr);
|
||||
}
|
||||
{
|
||||
MutexLock lock(m_blobsQueueLock);
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&m_blobsAsync), nullptr);
|
||||
@@ -1181,6 +1221,8 @@ StratumServer::StratumClient::StratumClient()
|
||||
, m_customUser{}
|
||||
, m_lastJobTarget(0)
|
||||
, m_score(0)
|
||||
, m_stratumShares(0)
|
||||
, m_sidechainShares(0)
|
||||
{
|
||||
m_rawReadBuf[0] = '\0';
|
||||
m_stratumReadBuf[0] = '\0';
|
||||
@@ -1210,6 +1252,9 @@ void StratumServer::StratumClient::reset()
|
||||
m_lastJobTarget = 0;
|
||||
|
||||
m_score = 0;
|
||||
|
||||
m_stratumShares = 0;
|
||||
m_sidechainShares = 0;
|
||||
}
|
||||
|
||||
bool StratumServer::StratumClient::on_connect()
|
||||
|
||||
+10
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -91,6 +91,9 @@ public:
|
||||
uint64_t m_lastJobTarget;
|
||||
|
||||
int32_t m_score;
|
||||
|
||||
uint32_t m_stratumShares;
|
||||
uint32_t m_sidechainShares;
|
||||
};
|
||||
|
||||
[[nodiscard]] bool on_login(StratumClient* client, uint32_t id, const char* login);
|
||||
@@ -128,6 +131,12 @@ private:
|
||||
hash m_seedHash;
|
||||
};
|
||||
|
||||
uv_mutex_t m_resetShareCountersLock;
|
||||
uv_async_t m_resetShareCountersAsync;
|
||||
|
||||
static void on_reset_share_counters(uv_async_t* handle) { reinterpret_cast<StratumServer*>(handle->data)->on_reset_share_counters(); }
|
||||
void on_reset_share_counters();
|
||||
|
||||
uv_mutex_t m_blobsQueueLock;
|
||||
uv_async_t m_blobsAsync;
|
||||
std::vector<BlobsData*> m_blobsQueue;
|
||||
|
||||
+199
-40
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,7 +23,7 @@ static thread_local const char* log_category_prefix = "TCPServer ";
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
TCPServer::TCPServer(int default_backlog, allocate_client_callback allocate_new_client, const std::string& socks5Proxy)
|
||||
TCPServer::TCPServer(int default_backlog, allocate_client_callback allocate_new_client, const std::string& socks5Proxy, Params::ProxyType socks5ProxyType, bool proxyProtocol)
|
||||
: m_allocateNewClient(allocate_new_client)
|
||||
, m_defaultBacklog(default_backlog)
|
||||
, m_loopThread{}
|
||||
@@ -32,9 +32,11 @@ TCPServer::TCPServer(int default_backlog, allocate_client_callback allocate_new_
|
||||
, m_portMapping(0)
|
||||
#endif
|
||||
, m_socks5Proxy(socks5Proxy)
|
||||
, m_socks5ProxyType(socks5ProxyType)
|
||||
, m_socks5ProxyV6(false)
|
||||
, m_socks5ProxyIP{}
|
||||
, m_socks5ProxyPort(-1)
|
||||
, m_proxyProtocol(proxyProtocol)
|
||||
, m_finished(0)
|
||||
, m_listenPort(-1)
|
||||
, m_loop{}
|
||||
@@ -126,7 +128,7 @@ void TCPServer::parse_address_list_internal(const std::string& address_list, con
|
||||
}
|
||||
}
|
||||
|
||||
const uint32_t port = std::stoul(address.substr(k2 + 1), nullptr, 10);
|
||||
const uint32_t port = strtoul(address.c_str() + k2 + 1, nullptr, 10);
|
||||
if ((port > 0) && (port < 65536)) {
|
||||
callback(is_v6, address, ip, static_cast<int>(port));
|
||||
}
|
||||
@@ -319,9 +321,9 @@ bool TCPServer::connect_to_peer(bool is_v6, const raw_ip& ip, int port)
|
||||
bool TCPServer::connect_to_peer(const std::string& domain, int port)
|
||||
{
|
||||
if (m_socks5Proxy.empty()) {
|
||||
LOGERR(1, "Can't connect to " << domain << ": SOCKS5 proxy is required");
|
||||
return false;
|
||||
}
|
||||
LOGERR(1, "Can't connect to " << domain << ": SOCKS5 proxy is required");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_finished.load()) {
|
||||
return false;
|
||||
@@ -337,7 +339,8 @@ bool TCPServer::connect_to_peer(const std::string& domain, int port)
|
||||
s << domain << ':' << port << '\0';
|
||||
|
||||
if (s.m_spilled) {
|
||||
LOGERR(1, "Can't connect to " << domain << ": too long domain name");
|
||||
LOGERR(1, "Can't connect to " << domain << ": too long domain name");
|
||||
return_client(client);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -427,6 +430,7 @@ bool TCPServer::connect_to_peer(Client* client)
|
||||
}
|
||||
else {
|
||||
LOGWARN(5, "failed to initiate tcp connection to " << static_cast<const char*>(client->m_addrString) << ": domain name is unresolved and SOCKS5 proxy is not enabled");
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(&client->m_socket), on_connection_error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -580,6 +584,11 @@ bool TCPServer::send_internal(Client* client, const Callback<size_t, uint8_t*, s
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_callbackBuf.empty()) {
|
||||
LOGERR(1, "callback buf is not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t bytes_written = callback(m_callbackBuf.data(), m_callbackBuf.size());
|
||||
|
||||
if (bytes_written > m_callbackBuf.size()) {
|
||||
@@ -611,7 +620,7 @@ bool TCPServer::send_internal(Client* client, const Callback<size_t, uint8_t*, s
|
||||
|
||||
uv_buf_t bufs[1];
|
||||
bufs[0].base = reinterpret_cast<char*>(buf->m_data);
|
||||
bufs[0].len = static_cast<int>(size);
|
||||
bufs[0].len = static_cast<uint32_t>(size);
|
||||
|
||||
const int err = uv_write(&buf->m_write, reinterpret_cast<uv_stream_t*>(&client->m_socket), bufs, 1, Client::on_write);
|
||||
if (err) {
|
||||
@@ -891,45 +900,52 @@ void TCPServer::on_new_client(uv_stream_t* server, Client* client)
|
||||
|
||||
LOGINFO(5, "new connection " << (client->m_isIncoming ? "from " : "to ") << log::Gray() << static_cast<char*>(client->m_addrString));
|
||||
|
||||
if (is_banned(client->isV6(), client->m_addr)) {
|
||||
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(client->m_addrString) << log::NoColor() << " is banned, disconnecting");
|
||||
client->close();
|
||||
return;
|
||||
if (m_proxyProtocol && client->m_isIncoming) {
|
||||
// Defer ban check and on_connect until real IP is extracted from PROXY protocol header
|
||||
client->m_proxyProtocolState = Client::ProxyProtocolState::ExpectingHeader;
|
||||
}
|
||||
|
||||
TCPServer* owner = client->m_owner;
|
||||
|
||||
if (owner->m_finished.load()) {
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (client->m_isIncoming || owner->m_socks5Proxy.empty()) {
|
||||
if (!client->on_connect()) {
|
||||
else {
|
||||
if (is_banned(client->isV6(), client->m_addr)) {
|
||||
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(client->m_addrString) << log::NoColor() << " is banned, disconnecting");
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const bool result = owner->send(client,
|
||||
[](uint8_t* buf, size_t buf_size) -> size_t
|
||||
{
|
||||
if (buf_size < 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf[0] = 5; // Protocol version (SOCKS5)
|
||||
buf[1] = 1; // NMETHODS
|
||||
buf[2] = 0; // Method 0 (no authentication)
|
||||
TCPServer* owner = client->m_owner;
|
||||
|
||||
return 3;
|
||||
});
|
||||
if (owner->m_finished.load()) {
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
client->m_socks5ProxyState = Client::Socks5ProxyState::MethodSelectionSent;
|
||||
if (client->m_isIncoming || owner->m_socks5Proxy.empty()) {
|
||||
if (!client->on_connect()) {
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
client->close();
|
||||
const bool result = owner->send(client,
|
||||
[](uint8_t* buf, size_t buf_size) -> size_t
|
||||
{
|
||||
if (buf_size < 3) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf[0] = 5; // Protocol version (SOCKS5)
|
||||
buf[1] = 1; // NMETHODS
|
||||
buf[2] = 0; // Method 0 (no authentication)
|
||||
|
||||
return 3;
|
||||
});
|
||||
|
||||
if (result) {
|
||||
client->m_socks5ProxyState = Client::Socks5ProxyState::MethodSelectionSent;
|
||||
}
|
||||
else {
|
||||
client->close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1084,6 +1100,7 @@ TCPServer::Client::Client(char* read_buf, size_t size)
|
||||
, m_port(0)
|
||||
, m_addrString{}
|
||||
, m_socks5ProxyState(Socks5ProxyState::Default)
|
||||
, m_proxyProtocolState(ProxyProtocolState::None)
|
||||
, m_resetCounter{ 0 }
|
||||
#ifdef WITH_TLS
|
||||
, m_tlsChecked(false)
|
||||
@@ -1110,6 +1127,7 @@ void TCPServer::Client::reset()
|
||||
m_port = -1;
|
||||
m_addrString[0] = '\0';
|
||||
m_socks5ProxyState = Socks5ProxyState::Default;
|
||||
m_proxyProtocolState = ProxyProtocolState::None;
|
||||
m_readBuf[0] = '\0';
|
||||
m_readBuf[m_readBufSize - 1] = '\0';
|
||||
|
||||
@@ -1154,7 +1172,12 @@ void TCPServer::Client::on_read(uv_stream_t* stream, ssize_t nread, const uv_buf
|
||||
|
||||
if (nread > 0) {
|
||||
if (client->m_owner && !client->m_owner->m_finished.load()) {
|
||||
if (client->m_socks5ProxyState == Socks5ProxyState::Default) {
|
||||
if (client->m_proxyProtocolState == ProxyProtocolState::ExpectingHeader) {
|
||||
if (!client->on_proxy_protocol(buf->base, static_cast<uint32_t>(nread))) {
|
||||
client->close();
|
||||
}
|
||||
}
|
||||
else if (client->m_socks5ProxyState == Socks5ProxyState::Default) {
|
||||
if (!client->on_read(buf->base, static_cast<uint32_t>(nread))) {
|
||||
client->close();
|
||||
}
|
||||
@@ -1243,7 +1266,8 @@ bool TCPServer::Client::on_proxy_handshake(const char* data, uint32_t size)
|
||||
m_socks5ProxyState = Socks5ProxyState::ConnectRequestSent;
|
||||
}
|
||||
else {
|
||||
close();
|
||||
LOGWARN(5, "Failed to send SOCKS5 proxy connect request");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1314,6 +1338,134 @@ bool TCPServer::Client::on_proxy_handshake(const char* data, uint32_t size)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TCPServer::Client::on_proxy_protocol(const char* data, uint32_t size)
|
||||
{
|
||||
// PROXY protocol v2 signature
|
||||
static constexpr uint8_t ppv2_signature[12] = { 0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A };
|
||||
|
||||
if ((data != m_readBuf + m_numRead) || (data + size > m_readBuf + m_readBufSize)) {
|
||||
LOGERR(1, "peer " << static_cast<char*>(m_addrString) << " invalid data pointer or size in on_proxy_protocol()");
|
||||
return false;
|
||||
}
|
||||
m_numRead += size;
|
||||
|
||||
// Need at least 16 bytes for the fixed header
|
||||
if (m_numRead < 16) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(m_readBuf);
|
||||
|
||||
// Validate 12-byte signature
|
||||
if (memcmp(p, ppv2_signature, 12) != 0) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " invalid PROXY protocol v2 signature");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Byte 12: version (high nibble) and command (low nibble)
|
||||
const uint8_t ver_cmd = p[12];
|
||||
const uint8_t version = (ver_cmd >> 4) & 0x0F;
|
||||
const uint8_t command = ver_cmd & 0x0F;
|
||||
|
||||
if (version != 2) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " unsupported PROXY protocol version " << version);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command > 1) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " invalid PROXY protocol command " << command);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Byte 13: address family (high nibble) and protocol (low nibble)
|
||||
const uint8_t family_proto = p[13];
|
||||
|
||||
// Bytes 14-15: address data length (big-endian), includes address block + optional TLV extensions
|
||||
const uint16_t addr_len = (static_cast<uint16_t>(p[14]) << 8) | static_cast<uint16_t>(p[15]);
|
||||
|
||||
const uint32_t total_header_len = 16 + static_cast<uint32_t>(addr_len);
|
||||
|
||||
if (total_header_len > m_readBufSize) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " PROXY protocol v2 header too large (" << total_header_len << " bytes)");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Wait for complete header
|
||||
if (m_numRead < total_header_len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// PROXY command: extract real client address
|
||||
if (command == 1) {
|
||||
const uint8_t family = (family_proto >> 4) & 0x0F;
|
||||
|
||||
if (family == 1) {
|
||||
// AF_INET: src(4) + dst(4) + sport(2) + dport(2) = 12 bytes minimum, may be larger with TLV extensions
|
||||
if (addr_len < 12) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " PROXY protocol v2 IPv4 address data too short (" << addr_len << " bytes)");
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(m_addr.data, raw_ip::ipv4_prefix, sizeof(raw_ip::ipv4_prefix));
|
||||
memcpy(m_addr.data + sizeof(raw_ip::ipv4_prefix), p + 16, 4);
|
||||
m_port = (static_cast<int>(p[24]) << 8) | static_cast<int>(p[25]);
|
||||
m_addressType = AddressType::IPv4;
|
||||
}
|
||||
else if (family == 2) {
|
||||
// AF_INET6: src(16) + dst(16) + sport(2) + dport(2) = 36 bytes minimum, may be larger with TLV extensions
|
||||
if (addr_len < 36) {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " PROXY protocol v2 IPv6 address data too short (" << addr_len << " bytes)");
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(m_addr.data, p + 16, 16);
|
||||
m_port = (static_cast<int>(p[48]) << 8) | static_cast<int>(p[49]);
|
||||
m_addressType = AddressType::IPv6;
|
||||
}
|
||||
else {
|
||||
LOGWARN(4, "peer " << static_cast<char*>(m_addrString) << " PROXY protocol v2 unsupported address family " << family);
|
||||
return false;
|
||||
}
|
||||
|
||||
init_addr_string();
|
||||
LOGINFO(5, "PROXY protocol v2: real address is " << log::Gray() << static_cast<char*>(m_addrString));
|
||||
}
|
||||
// LOCAL command (health checks): keep original address
|
||||
|
||||
// Move remaining data to beginning of buffer
|
||||
m_numRead -= total_header_len;
|
||||
if (m_numRead > 0) {
|
||||
memmove(m_readBuf, m_readBuf + total_header_len, m_numRead);
|
||||
}
|
||||
|
||||
m_proxyProtocolState = ProxyProtocolState::HeaderReceived;
|
||||
|
||||
// Deferred ban check with real IP
|
||||
if (m_owner->is_banned(isV6(), m_addr)) {
|
||||
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " is banned, disconnecting");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_owner->m_finished.load()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!on_connect()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pass remaining data to the protocol handler
|
||||
if (m_numRead > 0) {
|
||||
const uint32_t nread = m_numRead;
|
||||
m_numRead = 0;
|
||||
if (!on_read(m_readBuf, nread)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCPServer::Client::on_write(uv_write_t* req, int status)
|
||||
{
|
||||
WriteBuf* buf = static_cast<WriteBuf*>(req->data);
|
||||
@@ -1323,6 +1475,13 @@ void TCPServer::Client::on_write(uv_write_t* req, int status)
|
||||
if (server) {
|
||||
server->return_write_buffer(buf);
|
||||
}
|
||||
else {
|
||||
// no server to return buf to, so just delete it
|
||||
if (buf->m_data) {
|
||||
free_hook(buf->m_data);
|
||||
}
|
||||
delete buf;
|
||||
}
|
||||
|
||||
if (status != 0) {
|
||||
LOGWARN(5, "client " << static_cast<const char*>(client->m_addrString) << " failed to write data to client connection, error " << uv_err_name(status));
|
||||
|
||||
+13
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,6 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "uv_util.h"
|
||||
#include "params.h"
|
||||
|
||||
#ifdef WITH_TLS
|
||||
#include "tls.h"
|
||||
@@ -33,7 +34,7 @@ public:
|
||||
struct Client;
|
||||
typedef Client* (*allocate_client_callback)();
|
||||
|
||||
TCPServer(int default_backlog, allocate_client_callback allocate_new_client, const std::string& socks5Proxy);
|
||||
TCPServer(int default_backlog, allocate_client_callback allocate_new_client, const std::string& socks5Proxy, Params::ProxyType socks5ProxyType, bool proxyProtocol = false);
|
||||
virtual ~TCPServer();
|
||||
|
||||
[[nodiscard]] bool connect_to_peer(bool is_v6, const char* ip, int port);
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
[[nodiscard]] virtual bool on_connect() = 0;
|
||||
[[nodiscard]] virtual bool on_read(const char* data, uint32_t size) = 0;
|
||||
[[nodiscard]] bool on_proxy_handshake(const char* data, uint32_t size);
|
||||
[[nodiscard]] bool on_proxy_protocol(const char* data, uint32_t size);
|
||||
virtual void on_connect_failed(int /*err*/) {}
|
||||
virtual void on_read_failed(int /*err*/) {}
|
||||
virtual void on_disconnected() {}
|
||||
@@ -120,6 +122,12 @@ public:
|
||||
ConnectRequestSent,
|
||||
} m_socks5ProxyState;
|
||||
|
||||
enum class ProxyProtocolState : uint8_t {
|
||||
None,
|
||||
ExpectingHeader,
|
||||
HeaderReceived,
|
||||
} m_proxyProtocolState;
|
||||
|
||||
std::atomic<uint32_t> m_resetCounter;
|
||||
|
||||
#ifdef WITH_TLS
|
||||
@@ -191,10 +199,13 @@ protected:
|
||||
#endif
|
||||
|
||||
std::string m_socks5Proxy;
|
||||
Params::ProxyType m_socks5ProxyType;
|
||||
bool m_socks5ProxyV6;
|
||||
raw_ip m_socks5ProxyIP;
|
||||
int m_socks5ProxyPort;
|
||||
|
||||
bool m_proxyProtocol;
|
||||
|
||||
std::atomic<int> m_finished;
|
||||
int m_listenPort;
|
||||
|
||||
|
||||
+23
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -232,7 +232,16 @@ bool ServerTls::on_read_internal(const char* data, uint32_t size, const ReadCall
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!BIO_write_all(SSL_get_rbio(ssl), data, size)) {
|
||||
BIO* rbio = SSL_get_rbio(ssl);
|
||||
if (!rbio) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!BIO_write_all(rbio, data, size)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (BIO_ctrl_pending(rbio) > 32768u) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -266,9 +275,12 @@ bool ServerTls::on_read_internal(const char* data, uint32_t size, const ReadCall
|
||||
}
|
||||
}
|
||||
|
||||
if ((result < 0) && (SSL_get_error(ssl, result) == SSL_ERROR_WANT_READ)) {
|
||||
// Continue handshake, nothing to read yet
|
||||
return true;
|
||||
if (result < 0) {
|
||||
const int err = SSL_get_error(ssl, result);
|
||||
if ((err == SSL_ERROR_WANT_READ) || (err == SSL_ERROR_WANT_WRITE)) {
|
||||
// Continue handshake, nothing to read yet
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (result == 1) {
|
||||
@@ -289,11 +301,16 @@ bool ServerTls::on_read_internal(const char* data, uint32_t size, const ReadCall
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
const int err = SSL_get_error(ssl, bytes_read);
|
||||
return (err == SSL_ERROR_WANT_READ) || (err == SSL_ERROR_WANT_WRITE);
|
||||
}
|
||||
|
||||
bool ServerTls::on_write_internal(const uint8_t* data, size_t size, const WriteCallback::Base& write_callback)
|
||||
{
|
||||
if (size > static_cast<size_t>(std::numeric_limits<int>::max())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SSL* ssl = m_ssl.get();
|
||||
if (!ssl) {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+3
-7
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -986,7 +986,7 @@ std::string to_onion_v3(const hash& pubkey)
|
||||
|
||||
while (bit_size >= 5) {
|
||||
bit_size -= 5;
|
||||
result += "abcdefghijklmnopqrstuvwxyz234567"[(data >> bit_size) & 31];
|
||||
result += base32_alphabet[(data >> bit_size) & 31];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1014,12 +1014,8 @@ hash from_onion_v3(const std::string& address)
|
||||
return {};
|
||||
}
|
||||
|
||||
// Convert address to lowercase
|
||||
std::string s = address;
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
|
||||
|
||||
// Checksum validation
|
||||
if (to_onion_v3(result) != s) {
|
||||
if (to_onion_v3(result) != tolower(address)) {
|
||||
LOGWARN(3, "Invalid onion address \"" << address << "\": checksum failed");
|
||||
return {};
|
||||
}
|
||||
|
||||
+16
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -35,7 +35,7 @@
|
||||
namespace p2pool {
|
||||
|
||||
#define P2POOL_VERSION_MAJOR 4
|
||||
#define P2POOL_VERSION_MINOR 13
|
||||
#define P2POOL_VERSION_MINOR 14
|
||||
#define P2POOL_VERSION_PATCH 0
|
||||
|
||||
constexpr uint32_t P2POOL_VERSION = (P2POOL_VERSION_MAJOR << 16) | (P2POOL_VERSION_MINOR << 8) | P2POOL_VERSION_PATCH;
|
||||
@@ -395,6 +395,20 @@ FORCEINLINE void secure_zero_memory(T& value)
|
||||
secure_zero_memory(&value, sizeof(T));
|
||||
}
|
||||
|
||||
FORCEINLINE std::string tolower(const std::string& s)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(s.size() + 1);
|
||||
|
||||
for (char c : s) {
|
||||
result.push_back(static_cast<char>(std::tolower(c)));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
constexpr char base32_alphabet[] = "abcdefghijklmnopqrstuvwxyz234567";
|
||||
|
||||
std::string to_onion_v3(const hash& pubkey);
|
||||
hash from_onion_v3(const std::string& address);
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Portions Copyright (c) 2012-2013 The Cryptonote developers
|
||||
* Portions Copyright (c) 2014-2021 The Monero Project
|
||||
* Portions Copyright (c) 2021 XMRig <https://github.com/xmrig>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
+11
-4
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -38,6 +38,13 @@ ZMQReader::ZMQReader(const std::string& address, uint32_t zmq_port, const std::s
|
||||
m_proxy.clear();
|
||||
}
|
||||
|
||||
const bool is_v6 = address.find_first_of(':') != std::string::npos;
|
||||
|
||||
if (is_v6) {
|
||||
m_publisher.set(zmq::sockopt::ipv6, 1);
|
||||
m_subscriber.set(zmq::sockopt::ipv6, 1);
|
||||
}
|
||||
|
||||
char addr_buf[log::Stream::BUF_SIZE + 1];
|
||||
addr_buf[0] = '\0';
|
||||
|
||||
@@ -49,7 +56,7 @@ ZMQReader::ZMQReader(const std::string& address, uint32_t zmq_port, const std::s
|
||||
|
||||
try {
|
||||
log::Stream s(addr_buf);
|
||||
s << "tcp://127.0.0.1:" << port << '\0';
|
||||
s << (is_v6 ? "tcp://[::1]:" : "tcp://127.0.0.1:") << port << '\0';
|
||||
m_publisher.bind(addr_buf);
|
||||
m_publisherPort = static_cast<uint16_t>(port);
|
||||
break;
|
||||
@@ -65,11 +72,11 @@ ZMQReader::ZMQReader(const std::string& address, uint32_t zmq_port, const std::s
|
||||
throw zmq::error_t(EFSM);
|
||||
}
|
||||
|
||||
LOGINFO(5, "listening on tcp://127.0.0.1:" << m_publisherPort << " for internal communications");
|
||||
std::string addr(addr_buf);
|
||||
LOGINFO(5, "listening on " << addr << " for internal communications");
|
||||
|
||||
m_subscriber.set(zmq::sockopt::connect_timeout, 1000);
|
||||
|
||||
std::string addr(addr_buf);
|
||||
if (!connect(addr, false)) {
|
||||
throw zmq::error_t(EFSM);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -15,7 +15,7 @@ endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "3.5.2")
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "3.5.2")
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool_tests)
|
||||
endif()
|
||||
|
||||
@@ -60,6 +60,7 @@ set(SOURCES
|
||||
src/sha256_tests.cpp
|
||||
src/util_tests.cpp
|
||||
src/wallet_tests.cpp
|
||||
src/i2p_tests.cpp
|
||||
../external/src/crypto/sha256.c
|
||||
../external/src/cryptonote/crypto-ops-data.c
|
||||
../external/src/cryptonote/crypto-ops.c
|
||||
@@ -84,6 +85,7 @@ set(SOURCES
|
||||
../src/tcp_server.cpp
|
||||
../src/util.cpp
|
||||
../src/wallet.cpp
|
||||
../src/i2p.cpp
|
||||
)
|
||||
|
||||
if (WITH_INDEXED_HASHES)
|
||||
|
||||
@@ -13,6 +13,7 @@ set(WITH_DOCS OFF CACHE BOOL "")
|
||||
set(ENABLE_DRAFTS OFF CACHE BOOL "")
|
||||
set(BUILD_SHARED OFF CACHE BOOL "")
|
||||
set(ENABLE_CLANG OFF CACHE BOOL "")
|
||||
set(ENABLE_CLANG_TIDY OFF CACHE BOOL "")
|
||||
|
||||
set(CURL_TARGET_WINDOWS_VERSION "0x0600" CACHE STRING "")
|
||||
set(BUILD_CURL_EXE OFF CACHE BOOL "")
|
||||
|
||||
@@ -33,6 +33,16 @@ TEST(hash, constructor)
|
||||
memset(h.h, -1, HASH_SIZE);
|
||||
h = {};
|
||||
ASSERT_EQ(memcmp(h.h, buf, HASH_SIZE), 0);
|
||||
|
||||
hash h2{ "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" };
|
||||
for (uint8_t i = 0; i < HASH_SIZE; ++i) {
|
||||
ASSERT_EQ(h2.h[i], i);
|
||||
}
|
||||
|
||||
hash h3{ "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" };
|
||||
for (uint8_t i = 0; i < HASH_SIZE; ++i) {
|
||||
ASSERT_EQ(h3.h[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(hash, compare)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2024 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2026 jpk68
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "i2p.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
TEST(i2p, decode_encode)
|
||||
{
|
||||
const hash expected{
|
||||
0xad, 0xcc, 0x78, 0x7e, 0x8e, 0x46, 0xd9, 0xd4,
|
||||
0xd2, 0xa5, 0x56, 0x9d, 0x36, 0x5d, 0x67, 0xe4,
|
||||
0x0f, 0x60, 0xf3, 0x57, 0x18, 0x71, 0x32, 0x1e,
|
||||
0x60, 0x3c, 0x08, 0xa9, 0x38, 0x4b, 0x11, 0x27
|
||||
};
|
||||
|
||||
const std::string addr1 = "vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
const hash result1 = from_i2p_b32(addr1);
|
||||
|
||||
EXPECT_EQ(result1, expected);
|
||||
EXPECT_EQ(to_i2p_b32(result1), addr1);
|
||||
|
||||
// Uppercase
|
||||
const std::string addr2 = "VXGHQ7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
EXPECT_EQ(from_i2p_b32(addr2), expected);
|
||||
|
||||
// Invalid character
|
||||
const std::string addr3 = "1xghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
EXPECT_EQ(from_i2p_b32(addr3), hash());
|
||||
|
||||
// Too short
|
||||
EXPECT_EQ(from_i2p_b32(""), hash());
|
||||
|
||||
// No suffix
|
||||
EXPECT_EQ(from_i2p_b32("vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq"), hash());
|
||||
|
||||
// Too long
|
||||
EXPECT_EQ(from_i2p_b32("vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq2.b32.i2p"), hash());
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
Reference in New Issue
Block a user