Compare commits

..

75 Commits

Author SHA1 Message Date
SChernykh 06463e3e68 p2pool v4.8.1 2025-06-25 08:03:43 +02:00
SChernykh 52d3454b0f CI: added pruned and compact block blobs test 2025-06-24 23:13:58 +02:00
SChernykh 927258396e Merge pull request #365 from Low-power/update-stratum-hashrate-data-without-connected-workers
Hash rate values in `local/stratum` API file stuck after all workers disconnected
2025-06-24 13:41:15 +02:00
SChernykh b9face492d CI: always save coverage data 2025-06-24 10:36:39 +02:00
WHR d289526f45 Stratum: update hash rate data on new block template, even when no workers connected 2025-06-24 16:32:16 +08:00
SChernykh 1b05f1e750 Block parser: stricter checks 2025-06-24 00:57:13 +02:00
SChernykh 10d583adb6 Added more checks to readVarint 2025-06-23 13:06:01 +02:00
SChernykh 1b863109f9 CI: more tests 2025-06-22 23:18:36 +02:00
SChernykh e5d487aa50 CI: added more tests 2025-06-22 21:58:57 +02:00
SChernykh e69f5722df CI: use clang-20 for code coverage 2025-06-22 17:22:35 +02:00
SChernykh b3678bfbe9 CI: added submit_sidechain_block test 2025-06-22 13:40:00 +02:00
SChernykh 7a82b0fe43 Deploy code coverage report 2025-06-22 11:11:06 +02:00
SChernykh 5aea5768a7 CI: more tests 2025-06-21 16:20:24 +02:00
SChernykh 3f54025384 CI: added more block template tests 2025-06-21 13:16:56 +02:00
SChernykh c421324b73 SideChain: fixed a synchronization blocker bug 2025-06-21 01:06:36 +02:00
SChernykh 0535ca2892 CI: added more tests 2025-06-20 23:30:10 +02:00
SChernykh e68a31f72a CI: added more crypto tests 2025-06-20 22:06:52 +02:00
SChernykh 02533848d2 Updated cppzmq 2025-06-20 19:52:54 +02:00
SChernykh 6cd79b3a48 CI: added more tests to improve code coverage 2025-06-20 19:49:30 +02:00
SChernykh 3d1ef0d049 CI: added code coverage workflow 2025-06-20 18:23:26 +02:00
SChernykh 547b3430c2 CI: added nano sidechain dump to tests 2025-06-20 11:24:49 +02:00
SChernykh 88df27a359 CI: block verify - more tests 2025-06-20 08:33:21 +02:00
SChernykh 7eaef5faca CI: use the latest cppcheck code again 2025-06-18 18:40:32 +02:00
SChernykh 9cb9545ce6 CI: use native runner for Ubuntu ARM64 builds 2025-06-16 17:00:55 +02:00
SChernykh 60285a21dd p2pool v4.8 2025-06-15 09:57:28 +02:00
SChernykh 8f716bd1f1 Merge pull request #363 from Low-power/last-pool-share-found-time-in-local-stratum-api
API: add `last_share_found_time` in `local/stratum`
2025-06-14 12:52:07 +02:00
WHR 009fa0f474 API: add 'last_share_found_time' in local/stratum 2025-06-14 10:26:07 +08:00
SChernykh cea19f1c0d Log: reopen it in the worker thread only
Moved it to the worker thread to contain  it - there is no need to have outside access to its data.
2025-06-12 11:48:55 +02:00
SChernykh 0d0bf9cdee Merge pull request #362 from Low-power/reopen-log-file
Reopening of the log file on SIGUSR1 didn't work as expected
2025-06-11 23:11:32 +02:00
SChernykh c353daeb85 TCPServer: fixed SOCKS5 error checking logic 2025-06-11 20:14:35 +02:00
WHR 865bce5774 Always reopen the log file on SIGUSR1 2025-06-12 00:53:44 +08:00
SChernykh 853b942af7 Console: fixed command length calculation 2025-06-11 16:48:48 +02:00
SChernykh a9d9e1b48a Merge pull request #361 from Low-power/docs-bsd-rc-script
Create document for running P2Pool as a service on FreeBSD
2025-06-11 13:33:23 +02:00
SChernykh 2f06a8b9b8 Fixed build 2025-06-11 12:45:35 +02:00
WHR 197b260d88 Create document for running P2Pool as a service on FreeBSD 2025-06-11 18:38:47 +08:00
SChernykh 26bf2f07a0 Console: don't let random unformatted data end up in the log 2025-06-11 11:49:38 +02:00
SChernykh 09532c901a CMake: removed unused dependencies 2025-06-11 10:22:07 +02:00
SChernykh ab89a3c792 Fixed GCC-8 builds 2025-06-10 22:20:55 +02:00
SChernykh 2fe5dd8a36 Console: don't listen on a TCP port when local API is not enabled 2025-06-10 22:11:26 +02:00
SChernykh 17279708e5 Console: limit access via TCP 2025-06-10 21:51:05 +02:00
SChernykh e577b298b6 CI: fixed MSVC paths 2025-06-10 20:57:01 +02:00
SChernykh d66a2603e3 Merge pull request #360 from Low-power/mebibyte-unit
Correct unit prefix symbol for unit `mebibyte`
2025-06-10 19:30:08 +02:00
SChernykh 8bb317c4b7 CI: added Ubuntu RISC-V build, fixed Windows builds 2025-06-10 19:13:14 +02:00
SChernykh 9ce118ed82 Merge pull request #358 from Low-power/configurable-stratum-ban-time
Make ban time of stratum clients configurable
2025-06-10 18:34:16 +02:00
WHR aa303a96d1 Correct unit prefix symbol for unit 'mebibyte' 2025-06-10 21:16:21 +08:00
WHR 6c4520481b Make ban time of stratum clients configurable via '--stratum-ban-time' option 2025-06-10 20:08:09 +08:00
SChernykh 62707656eb Merge pull request #357 from Low-power/kilohash-per-second-unit
Correct unit prefix symbol for unit `kilohash per second`
2025-06-10 14:06:00 +02:00
WHR 20caceee5d Correct unit prefix symbol for unit 'kilohash per second' 2025-06-10 11:38:25 +08:00
SChernykh 3ac7c0c243 CI: use latest-stable Alpine branch for the RISC-V build 2025-06-09 15:38:37 +02:00
SChernykh ae6a08ee25 Self-test: added more output 2025-06-09 08:35:39 +02:00
SChernykh afa82f4b48 Fixed build 2025-06-08 23:46:10 +02:00
SChernykh e7f87085fb Fixed host ping time calculation when using SOCKS5 proxy 2025-06-08 20:37:55 +02:00
SChernykh 3147a2e968 Fixed build errors 2025-06-06 20:21:47 +02:00
SChernykh 435e6c7599 Tari: added block push via gRPC API 2025-06-06 19:02:08 +02:00
SChernykh ce840733f1 Merge mining: get a new block template immediately after submitting a block. 2025-06-06 12:36:17 +02:00
SChernykh 54d278643d CI: sync test - added merge mining 2025-06-05 23:22:11 +02:00
SChernykh 8d639bfcf2 API: added chain ID to the merge mining data 2025-06-05 11:31:06 +02:00
SChernykh d3026a97b7 API: added merge mining data 2025-06-04 11:46:10 +02:00
SChernykh 77c28df3f0 Updated curl to 8.14.1 2025-06-04 10:09:41 +02:00
SChernykh b06fcc7516 Fix: don't use outdated merge mining data
And warn the user in the log
2025-06-02 14:09:28 +02:00
SChernykh a01ea2d9d8 Updated Monero/P2Pool hardfork info 2025-05-30 14:19:52 +02:00
SChernykh 0d7b110f15 Fix: more robust startup sequence 2025-05-29 17:44:08 +02:00
SChernykh 7cd21f5d0e p2pool v4.7 2025-05-29 13:43:07 +02:00
SChernykh 886da5a73e CI: fixed msys2 clang build 2025-05-29 09:16:03 +02:00
SChernykh bfa30254df Fixed build errors 2025-05-28 20:10:52 +02:00
SChernykh b589d373ea P2Pool-nano: display correct parameters at start-up 2025-05-28 17:47:18 +02:00
SChernykh 8333f7800f P2Pool-nano: fixed sync when using restricted RPC nodes 2025-05-28 17:13:16 +02:00
SChernykh 91fb15e967 Updated curl to 8.14.0 2025-05-28 16:16:12 +02:00
SChernykh e0c1d9377c P2Pool-nano support 2025-05-28 15:04:11 +02:00
SChernykh 3f80244d84 Updated miniupnp 2025-05-27 15:10:51 +02:00
SChernykh 433a1991bc Updated cppzmq 2025-05-27 15:07:40 +02:00
SChernykh 915be9e39f Tari: fixed max gRPC message size 2025-05-27 12:58:54 +02:00
SChernykh b9e415c659 Updated Tari gRPC proto files 2025-05-25 10:07:28 +02:00
SChernykh 1e2e5b85aa CI: don't build extra binaries when building tests 2025-05-23 10:45:40 +02:00
SChernykh 40999f0056 Fix: failure to connect to a node if its domain resolves to an IPv6 address 2025-05-21 10:34:22 +02:00
66 changed files with 3077 additions and 704 deletions
+123 -29
View File
@@ -14,14 +14,14 @@ jobs:
build-alpine-static:
timeout-minutes: 240
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
matrix:
config:
- {arch: x86_64, branch: latest-stable, flags: "-ffunction-sections"}
- {arch: aarch64, branch: latest-stable, flags: "-ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"}
- {arch: riscv64, branch: edge, flags: "-ffunction-sections"}
- {arch: riscv64, branch: latest-stable, flags: "-ffunction-sections"}
steps:
- name: Setup Alpine Linux
@@ -63,7 +63,7 @@ jobs:
cd external/src/libzmq
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -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
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM="3.5" -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
make -j$(nproc)
- name: Build p2pool
@@ -71,7 +71,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DSTATIC_BINARY=ON -DARCH_ID=${{ matrix.config.arch }}
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM="3.5" -DCMAKE_C_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }} -Wl,-s -Wl,--gc-sections' -DSTATIC_BINARY=ON -DARCH_ID=${{ matrix.config.arch }}
make -j$(nproc) p2pool
- name: Run RandomX tests
@@ -88,8 +88,8 @@ jobs:
cd tests
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -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=${{ matrix.config.arch }}
make -j$(nproc)
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM="3.5" -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=${{ matrix.config.arch }}
make -j$(nproc) p2pool_tests
- name: Run tests
shell: alpine.sh {0}
@@ -130,7 +130,7 @@ jobs:
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libsodium-dev libpgm-dev libnorm-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev ${{ matrix.config.c }} ${{ matrix.config.cpp }}
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev ${{ matrix.config.c }} ${{ matrix.config.cpp }}
- name: Checkout repository
uses: actions/checkout@v4
@@ -157,7 +157,7 @@ jobs:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cpp }} -DCMAKE_C_FLAGS='${{ matrix.config.flags }}' -DCMAKE_CXX_FLAGS='${{ matrix.config.flags }}' -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
make -j$(nproc)
make -j$(nproc) p2pool_tests
- name: Run tests
run: |
@@ -237,7 +237,7 @@ jobs:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -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 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
make -j$(nproc)
make -j$(nproc) p2pool_tests
- name: Run tests
run: |
@@ -259,14 +259,13 @@ jobs:
strategy:
matrix:
config:
- {os: ubuntu-22.04, flags: "-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"}
- {os: ubuntu-24.04, flags: "-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"}
- {os: ubuntu-22.04-arm, flags: "-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"}
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y git build-essential cmake gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu qemu-user
sudo apt install -y git build-essential cmake
- name: Checkout repository
uses: actions/checkout@v4
@@ -276,7 +275,7 @@ jobs:
- name: Build libcurl
run: |
cd external/src/curl
cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/aarch64_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 -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include
cmake . -DCMAKE_BUILD_TYPE=Release -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 -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include
make -j$(nproc)
cd lib && mkdir .libs && cp libcurl.a .libs
@@ -285,7 +284,7 @@ jobs:
cd external/src/libuv
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/aarch64_toolchain.cmake -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
make -j$(nproc)
- name: Build libzmq
@@ -293,36 +292,36 @@ jobs:
cd external/src/libzmq
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../../cmake/aarch64_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"
cmake .. -DCMAKE_BUILD_TYPE=Release -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/aarch64_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=aarch64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
cmake .. -DCMAKE_BUILD_TYPE=Release -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=aarch64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
make -j$(nproc) p2pool
- name: Run RandomX tests
run: |
cd build
qemu-aarch64 -L /usr/aarch64-linux-gnu p2pool --test
./p2pool --test
make -j$(nproc) randomx-tests
qemu-aarch64 -L /usr/aarch64-linux-gnu external/src/RandomX/randomx-tests
external/src/RandomX/randomx-tests
- name: Build tests
run: |
cd tests
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_STRIP=/usr/bin/aarch64-linux-gnu-strip -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=aarch64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
make -j$(nproc)
cmake .. -DCMAKE_BUILD_TYPE=Release -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=aarch64 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
make -j$(nproc) p2pool_tests
- name: Run tests
run: |
cd tests/build
gunzip *.gz
qemu-aarch64 -L /usr/aarch64-linux-gnu ./p2pool_tests
./p2pool_tests
- name: Archive binary
uses: actions/upload-artifact@v4
@@ -330,6 +329,102 @@ jobs:
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
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 -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include
make -j$(nproc)
cd lib && mkdir .libs && cp libcurl.a .libs
- 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
gunzip *.gz
- 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
@@ -400,7 +495,7 @@ jobs:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -DCMAKE_C_COMPILER=${{ matrix.config.c }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} -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 -DOPENSSL_NO_ASM=ON
make -j$(nproc)
make -j$(nproc) p2pool_tests
- name: Run tests
run: |
@@ -423,11 +518,10 @@ jobs:
matrix:
config:
- {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", rx: "ON", upnp: "ON", grpc: "ON", tls: "ON"}
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "ON", upnp: "ON", grpc: "ON", tls: "ON"}
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "ON", upnp: "ON", grpc: "OFF", tls: "ON"}
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "ON", grpc: "OFF", tls: "ON"}
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "ON"}
- {vs: Visual Studio 16 2019, os: 2019, vspath: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "OFF"}
- {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", rx: "ON", upnp: "ON", grpc: "OFF", tls: "ON"}
- {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", rx: "OFF", upnp: "ON", grpc: "OFF", tls: "ON"}
- {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "ON"}
- {vs: Visual Studio 17 2022, os: 2022, vspath: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise", rx: "OFF", upnp: "OFF", grpc: "OFF", tls: "OFF"}
steps:
- name: Checkout repository
@@ -541,7 +635,7 @@ jobs:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@15)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@15)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@15)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@15)/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
make -j4 p2pool_tests
- name: Run tests
run: |
@@ -609,7 +703,7 @@ jobs:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$(brew --prefix llvm@15)/bin/clang" -DCMAKE_CXX_COMPILER="$(brew --prefix llvm@15)/bin/clang++" -DCMAKE_AR="$(brew --prefix llvm@15)/bin/llvm-ar" -DCMAKE_RANLIB="$(brew --prefix llvm@15)/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
make -j3 p2pool_tests
- name: Run tests
run: |
+1 -1
View File
@@ -45,7 +45,7 @@ jobs:
steps:
- name: Install dependencies
run: |
sudo apt update && sudo apt install git build-essential cmake libuv1-dev libzmq3-dev libsodium-dev libpgm-dev libnorm-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev
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
+91
View File
@@ -0,0 +1,91 @@
name: Code coverage
on:
push:
branches: ["master"]
paths-ignore:
- 'docker-compose/**'
- 'docs/**'
- 'README.md'
pull_request:
jobs:
coverage:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake libuv1-dev libzmq3-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev lcov
- name: Install clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20 all
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build tests
run: |
cd tests
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DDEV_DEBUG=ON -DWITH_COVERAGE=ON -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=clang++-20 -DCMAKE_POLICY_VERSION_MINIMUM="3.5"
make -j$(nproc) p2pool_tests
- name: Run tests
run: |
cd tests/build
gunzip *.gz
LLVM_PROFILE_FILE="p2pool_tests.profraw" ./p2pool_tests
- name: Merge profile data
run: |
cd tests/build
llvm-profdata-20 merge -sparse ./p2pool_tests.profraw -o ./p2pool_tests.profdata
- name: Export profile data
run: |
cd tests/build
llvm-cov-20 export ./p2pool_tests -format=lcov -instr-profile=./p2pool_tests.profdata > coverage.info
- name: Run genhtml
run: |
cd tests/build
genhtml --demangle-cpp -o coverage coverage.info
- name: Checkout GitHub Pages repository
uses: actions/checkout@v4
with:
repository: SChernykh/SChernykh.github.io
token: ${{ secrets.PAGES_DEPLOY_TOKEN }}
path: gh-pages
- name: Copy coverage report to GitHub Pages repo
run: |
rm -rf gh-pages/p2pool-coverage
cp -r tests/build/coverage gh-pages/p2pool-coverage
- name: Commit and push coverage report
run: |
cd gh-pages
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add p2pool-coverage
git commit -m "Update p2pool coverage report"
git push
- name: Archive coverage data
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: p2pool-coverage
path: tests/build/coverage
+8 -8
View File
@@ -26,10 +26,10 @@ jobs:
submodules: recursive
- name: Checkout cppcheck
uses: actions/checkout@v4
with:
repository: danmar/cppcheck
path: cppcheck-main
run: |
git clone https://github.com/danmar/cppcheck cppcheck-main
git clone https://github.com/danmar/simplecpp simplecpp
cp -rf simplecpp cppcheck-main/externals
- name: Build cppcheck
run: |
@@ -74,10 +74,10 @@ jobs:
submodules: recursive
- name: Checkout cppcheck
uses: actions/checkout@v4
with:
repository: danmar/cppcheck
path: cppcheck-main
run: |
git clone https://github.com/danmar/cppcheck cppcheck-main
git clone https://github.com/danmar/simplecpp simplecpp
Copy-Item -Path "simplecpp" -Destination "cppcheck-main/externals" -Recurse -Force
- name: Build cppcheck
run: |
+9 -9
View File
@@ -69,7 +69,7 @@ jobs:
python ../tests/src/stratum_dummy.py 2 &
python ../tests/src/stratum_dummy.py 3 &
sudo sysctl vm.mmap_rnd_bits=28
TSAN_OPTIONS="suppressions=../tests/src/tsan_sup.txt halt_on_error=1 history_size=4" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
TSAN_OPTIONS="suppressions=../tests/src/tsan_sup.txt halt_on_error=1 history_size=4" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
@@ -155,7 +155,7 @@ jobs:
python ../tests/src/stratum_dummy.py 2 &
python ../tests/src/stratum_dummy.py 3 &
sudo sysctl vm.mmap_rnd_bits=28
MSAN_OPTIONS="halt_on_error=1" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
MSAN_OPTIONS="halt_on_error=1" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
@@ -180,7 +180,7 @@ jobs:
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libsodium-dev libpgm-dev libnorm-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev gcc-12 g++-12
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
@@ -202,7 +202,7 @@ jobs:
python ../tests/src/stratum_dummy.py 2 &
python ../tests/src/stratum_dummy.py 3 &
sudo sysctl vm.mmap_rnd_bits=28
UBSAN_OPTIONS="suppressions=../tests/src/ubsan_sup.txt halt_on_error=1" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
UBSAN_OPTIONS="suppressions=../tests/src/ubsan_sup.txt halt_on_error=1" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
@@ -227,7 +227,7 @@ jobs:
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install -y git build-essential cmake libuv1-dev libzmq3-dev libsodium-dev libpgm-dev libnorm-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev gcc-12 g++-12
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
@@ -249,7 +249,7 @@ jobs:
python ../tests/src/stratum_dummy.py 2 &
python ../tests/src/stratum_dummy.py 3 &
sudo sysctl vm.mmap_rnd_bits=28
ASAN_OPTIONS="detect_stack_use_after_return=1 atexit=1" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
ASAN_OPTIONS="detect_stack_use_after_return=1 atexit=1" ./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
@@ -318,7 +318,7 @@ jobs:
python3 ../tests/src/stratum_dummy.py 1 &
python3 ../tests/src/stratum_dummy.py 2 &
python3 ../tests/src/stratum_dummy.py 3 &
./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
./p2pool --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
@@ -363,7 +363,7 @@ jobs:
start python ../../tests/src/stratum_dummy.py 1
start python ../../tests/src/stratum_dummy.py 2
start python ../../tests/src/stratum_dummy.py 3
p2pool.exe --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
p2pool.exe --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
@@ -406,7 +406,7 @@ jobs:
Start-Process python -ArgumentList "../../tests/src/stratum_dummy.py 1"
Start-Process python -ArgumentList "../../tests/src/stratum_dummy.py 2"
Start-Process python -ArgumentList "../../tests/src/stratum_dummy.py 3"
./p2pool.exe --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
./p2pool.exe --host node.monerodevs.org --rpc-port 18089 --zmq-port 18084 --host node.richfowler.net --rpc-port 18089 --zmq-port 18084 --rpc-ssl --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg ${{ secrets.MM_PARAMS }} --mini --out-peers 200 --data-api data --local-api --loglevel 6
- name: Check p2pool.log
run: |
+8 -16
View File
@@ -256,22 +256,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
find_library(CURL_LIBRARY NAMES curl)
endif()
endif()
find_library(SODIUM_LIBRARY sodium)
endif()
find_library(PGM_LIBRARY pgm)
find_library(NORM_LIBRARY norm)
if (PGM_LIBRARY)
set(LIBS ${LIBS} ${PGM_LIBRARY})
endif()
if (NORM_LIBRARY)
set(LIBS ${LIBS} ${NORM_LIBRARY})
endif()
if (SODIUM_LIBRARY)
set(LIBS ${LIBS} ${SODIUM_LIBRARY})
endif()
if(APPLE)
@@ -435,6 +419,10 @@ if (STATIC_BINARY OR STATIC_LIBS)
set(STATIC_LIBS ${STATIC_LIBS} ssl crypto)
endif()
if ((CMAKE_CXX_COMPILER_ID MATCHES GNU) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9))
set(STATIC_LIBS ${STATIC_LIBS} stdc++fs)
endif()
target_link_libraries(${CMAKE_PROJECT_NAME}
"${CMAKE_SOURCE_DIR}/external/src/libzmq/build/lib/libzmq.a"
"${CMAKE_SOURCE_DIR}/external/src/libuv/build/libuv.a"
@@ -448,6 +436,10 @@ else()
set(LIBS ${LIBS} ssl crypto)
endif()
if ((CMAKE_CXX_COMPILER_ID MATCHES GNU) AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9))
set(LIBS ${LIBS} stdc++fs)
endif()
target_link_libraries(${CMAKE_PROJECT_NAME} debug ${ZMQ_LIBRARY_DEBUG} debug ${UV_LIBRARY_DEBUG} debug ${CURL_LIBRARY_DEBUG} optimized ${ZMQ_LIBRARY} optimized ${UV_LIBRARY} optimized ${CURL_LIBRARY} ${LIBS})
endif()
+2 -3
View File
@@ -75,14 +75,13 @@ First you need to find a pool share. This share will stay in [PPLNS](https://en.
## Monero version support
- The latest Monero network upgrade happened on August 13th, 2022 (block 2,688,888).
- The latest P2Pool network upgrade happened on March 18th, 2023 at 21:00 UTC.
- Next P2Pool network upgrade will happen on October 12th, 2024 at 20:00 UTC.
- The latest P2Pool network upgrade happened on October 12th, 2024 at 20:00 UTC.
In order to continue mining on P2Pool, you must update both Monero and P2Pool software to the latest available versions as soon as they are released.
|Monero protocol version|Required Monero software version|Required P2Pool version
|-|-|-|
|v15, v16 (active after August 13th, 2022)|v0.18.0.0 or newer, v0.18.3.4 is recommended|v4.0 or newer
|v15, v16 (active after August 13th, 2022)|v0.18.0.0 or newer, v0.18.4.0 is recommended|v4.0 or newer
## How to mine on P2Pool
-8
View File
@@ -1,8 +0,0 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++)
set(CMAKE_STRIP /usr/bin/aarch64-linux-gnu-strip)
+1 -1
View File
@@ -17,7 +17,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(GENERAL_FLAGS "${GENERAL_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
endif()
set(WARNING_FLAGS "-Wall -Wextra -Wcast-qual -Wlogical-op -Wundef -Wformat=2 -Wpointer-arith -Werror -Wno-error=inline -Wno-error=unused-function")
set(WARNING_FLAGS "-Wall -Wextra -Wcast-qual -Wlogical-op -Wundef -Wformat=2 -Wpointer-arith -Werror -Wno-error=inline -Wno-error=unused-function -Wno-error=strict-overflow")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.5.0)
set(WARNING_FLAGS "${WARNING_FLAGS} -Wstrict-overflow=2")
+8
View File
@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSTEM_PROCESSOR riscv64)
set(CMAKE_C_COMPILER /usr/bin/riscv64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/riscv64-linux-gnu-g++)
set(CMAKE_STRIP /usr/bin/riscv64-linux-gnu-strip)
+93
View File
@@ -0,0 +1,93 @@
## Setting up P2Pool as a service controlled by a RC script (FreeBSD, and possibly other)
In order to use this RC script, it is required to create a `p2pool` user account on the system for this service. An example **passwd(5)** line for this user would be:
```
p2pool:*:818:818::0:0:Monero P2Pool:/var/db/p2pool:/usr/sbin/nologin
```
Also an example **group(5)** line:
```
p2pool:*:818:
```
When creating such an user and a group, make sure the UID and GID aren't being used by any other user/group in the system. The home directory of the user will be used as the data directory of P2Pool; set it to your desired location as needed.
The RC script assumes the P2Pool executable is installed as `/usr/local/bin/p2pool`.
### /usr/local/etc/rc.d/p2pool
```sh
#!/bin/sh
# PROVIDE: p2pool
# REQUIRE: LOGIN FILESYSTEMS
# KEYWORD: shutdown
. /etc/rc.subr
name=p2pool
rcvar=p2pool_enable
load_rc_config $name
: ${p2pool_enable:="NO"} ${p2pool_local_api:="NO"}
[ -z "$p2pool_wallet" ] && exit 1
p2pool_user=p2pool
p2pool_home="`getent passwd ${p2pool_user} | cut -d : -f 6`"
[ -z "$p2pool_home" ] && exit 1
p2pool_env="HOME=$p2pool_home"
p2pool_chdir="$p2pool_home"
procname=/usr/local/bin/p2pool
pidfile="$p2pool_home/p2pool.pid"
command=/usr/sbin/daemon
flags="-p ${pidfile} -f -- ${procname} ${p2pool_flags} --data-dir ${p2pool_home} --wallet ${p2pool_wallet}"
[ -n "${p2pool_api_path}" ] && flags="${flags} --data-api ${p2pool_api_path}"
if checkyesno p2pool_local_api; then
if [ -n "${p2pool_api_path}" ]; then
flags="${flags} --local-api"
else
echo 'Warning: p2pool_local_api="YES" requires p2pool_api_path being set, ignoring' 1>&2
fi
fi
start_precmd="p2pool_prestart"
stop_postcmd="rm -f ${pidfile}"
p2pool_prestart() {
if [ -n "${p2pool_api_path}" ]; then
[ -d "${p2pool_api_path}" ] || mkdir -p "${p2pool_api_path}"
gid="`getent passwd ${p2pool_user} | cut -d : -f 4`"
chown ${p2pool_user}:${gid} "${p2pool_api_path}"
fi
}
run_rc_command "$1"
```
### Configuration variables in /etc/rc.conf (or /etc/rc.conf.local)
* `p2pool_enable` Set to `YES` to enable this service; required.
* `p2pool_wallet` Your wallet address; required.
* `p2pool_api_path` Path to API directory (See p2pool option `--data-api`), this directory will be created automatically if not already exists, on service startup; optional.
* `p2pool_local_api` Set to `YES` to enable creation of `local` path in API directory (See p2pool option `--local-api`), requires `p2pool_api_path` also being set; optional.
* `p2pool_flags` Additional options you want to pass to p2pool; optional.
#### Example
```sh
p2pool_enable="YES"
p2pool_wallet="44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg"
p2pool_api_path="/tmp/p2pool-api"
p2pool_local_api="YES"
p2pool_flags="--host 127.0.0.1 --in-peers 200"
```
## /usr/local/etc/newsyslog.conf.d/p2pool.conf (optional)
You can create this drop-in **newsyslog(8)** configuration file to periodically rotate the P2Pool log file. The drop-in location `/usr/local/etc/newsyslog.conf.d/` assumes that `/etc/newsyslog.conf` contains an `include` directive for searching drop-in configuration files in it.
This example assumes `/var/db/p2pool` as your P2Pool data directory.
```
# log file owner:group mode count size (KiB) when flags pid file signal
/var/db/p2pool/p2pool.log p2pool:p2pool 640 16 65536 @0101T BEJ /var/db/p2pool/p2pool.pid SIGUSR1
```
You should adjust the `count`, `size`, `when` and/or `flags` fields to fit your needs.
+2
View File
@@ -8,6 +8,7 @@
--stratum Comma-separated list of IP:port for stratum server to listen on
--p2p Comma-separated list of IP:port for p2p server to listen on
--addpeers Comma-separated list of IP:port of other p2pool nodes to connect to
--stratum-ban-time N Number of seconds to ban misbehaving stratum client, default is 600
--light-mode Don't allocate RandomX dataset, saves 2GB of RAM
--loglevel Verbosity of the log, integer number between 0 and 6
--data-dir Path to store general p2pool files (log, cache, peer data, etc.), default is current directory
@@ -22,6 +23,7 @@
--in-peers N Maximum number of incoming connections for p2p server (any value between 10 and 450)
--start-mining N Start built-in miner using N threads (any value between 1 and 64)
--mini Connect to p2pool-mini sidechain. Note that it will also change default p2p port from 37889 to 37888
--nano Connect to p2pool-nano sidechain. Note that it will also change default p2p port from 37889 to 37890
--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
+27
View File
@@ -18,3 +18,30 @@ start_mining **T**|start mining (**T** is the number of threads to use, must be
stop_mining|stop mining
exit|terminate p2pool
version|show p2pool version
### Non-interactive console access
It's possible to send console commands via a local TCP connection. For this, you need to enable the API: `--data-api api --local-api`.
A sample Python script that sends console commands to P2Pool via TCP:
```
import sys
import socket
import json
with open('api/local/console', 'r') as file:
data = json.load(file)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', data['tcp_port']))
command = data['cookie'];
command += sys.argv[1];
command += '\n';
s.sendall(command.encode('utf-8'))
s.close()
```
Run it in P2Pool's directory: `python3 ./p2pool_cmd.py status`
File diff suppressed because it is too large Load Diff
+640 -70
View File
@@ -172,6 +172,9 @@ extern ListAssetRegistrationsResponseDefaultTypeInternal _ListAssetRegistrations
class ListHeadersRequest;
struct ListHeadersRequestDefaultTypeInternal;
extern ListHeadersRequestDefaultTypeInternal _ListHeadersRequest_default_instance_;
class LivenessResult;
struct LivenessResultDefaultTypeInternal;
extern LivenessResultDefaultTypeInternal _LivenessResult_default_instance_;
class MempoolStatsResponse;
struct MempoolStatsResponseDefaultTypeInternal;
extern MempoolStatsResponseDefaultTypeInternal _MempoolStatsResponse_default_instance_;
@@ -583,20 +586,31 @@ class ValueAtHeightResponse final : public ::google::protobuf::Message
// accessors -------------------------------------------------------
enum : int {
kValueFieldNumber = 1,
kHeightFieldNumber = 2,
kCirculatingSupplyFieldNumber = 1,
kSpendableSupplyFieldNumber = 2,
kHeightFieldNumber = 3,
};
// uint64 value = 1;
void clear_value() ;
::uint64_t value() const;
void set_value(::uint64_t value);
// uint64 circulating_supply = 1;
void clear_circulating_supply() ;
::uint64_t circulating_supply() const;
void set_circulating_supply(::uint64_t value);
private:
::uint64_t _internal_value() const;
void _internal_set_value(::uint64_t value);
::uint64_t _internal_circulating_supply() const;
void _internal_set_circulating_supply(::uint64_t value);
public:
// uint64 height = 2;
// uint64 spendable_supply = 2;
void clear_spendable_supply() ;
::uint64_t spendable_supply() const;
void set_spendable_supply(::uint64_t value);
private:
::uint64_t _internal_spendable_supply() const;
void _internal_set_spendable_supply(::uint64_t value);
public:
// uint64 height = 3;
void clear_height() ;
::uint64_t height() const;
void set_height(::uint64_t value);
@@ -611,7 +625,7 @@ class ValueAtHeightResponse final : public ::google::protobuf::Message
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
1, 2, 0,
2, 3, 0,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
@@ -627,7 +641,8 @@ class ValueAtHeightResponse final : public ::google::protobuf::Message
::google::protobuf::Arena* arena);
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena, const Impl_& from);
::uint64_t value_;
::uint64_t circulating_supply_;
::uint64_t spendable_supply_;
::uint64_t height_;
mutable ::google::protobuf::internal::CachedSize _cached_size_;
PROTOBUF_TSAN_DECLARE_MEMBER
@@ -2291,8 +2306,9 @@ class NetworkDifficultyResponse final : public ::google::protobuf::Message
kTimestampFieldNumber = 4,
kPowAlgoFieldNumber = 5,
kSha3XEstimatedHashRateFieldNumber = 6,
kRandomxEstimatedHashRateFieldNumber = 7,
kMoneroRandomxEstimatedHashRateFieldNumber = 7,
kNumCoinbasesFieldNumber = 8,
kTariRandomxEstimatedHashRateFieldNumber = 10,
};
// repeated bytes coinbase_extras = 9;
int coinbase_extras_size() const;
@@ -2382,14 +2398,14 @@ class NetworkDifficultyResponse final : public ::google::protobuf::Message
void _internal_set_sha3x_estimated_hash_rate(::uint64_t value);
public:
// uint64 randomx_estimated_hash_rate = 7;
void clear_randomx_estimated_hash_rate() ;
::uint64_t randomx_estimated_hash_rate() const;
void set_randomx_estimated_hash_rate(::uint64_t value);
// uint64 monero_randomx_estimated_hash_rate = 7;
void clear_monero_randomx_estimated_hash_rate() ;
::uint64_t monero_randomx_estimated_hash_rate() const;
void set_monero_randomx_estimated_hash_rate(::uint64_t value);
private:
::uint64_t _internal_randomx_estimated_hash_rate() const;
void _internal_set_randomx_estimated_hash_rate(::uint64_t value);
::uint64_t _internal_monero_randomx_estimated_hash_rate() const;
void _internal_set_monero_randomx_estimated_hash_rate(::uint64_t value);
public:
// uint64 num_coinbases = 8;
@@ -2401,13 +2417,23 @@ class NetworkDifficultyResponse final : public ::google::protobuf::Message
::uint64_t _internal_num_coinbases() const;
void _internal_set_num_coinbases(::uint64_t value);
public:
// uint64 tari_randomx_estimated_hash_rate = 10;
void clear_tari_randomx_estimated_hash_rate() ;
::uint64_t tari_randomx_estimated_hash_rate() const;
void set_tari_randomx_estimated_hash_rate(::uint64_t value);
private:
::uint64_t _internal_tari_randomx_estimated_hash_rate() const;
void _internal_set_tari_randomx_estimated_hash_rate(::uint64_t value);
public:
// @@protoc_insertion_point(class_scope:tari.rpc.NetworkDifficultyResponse)
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
4, 9, 0,
4, 10, 0,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
@@ -2430,8 +2456,9 @@ class NetworkDifficultyResponse final : public ::google::protobuf::Message
::uint64_t timestamp_;
::uint64_t pow_algo_;
::uint64_t sha3x_estimated_hash_rate_;
::uint64_t randomx_estimated_hash_rate_;
::uint64_t monero_randomx_estimated_hash_rate_;
::uint64_t num_coinbases_;
::uint64_t tari_randomx_estimated_hash_rate_;
mutable ::google::protobuf::internal::CachedSize _cached_size_;
PROTOBUF_TSAN_DECLARE_MEMBER
};
@@ -2858,6 +2885,203 @@ class MempoolStatsResponse final : public ::google::protobuf::Message
};
// -------------------------------------------------------------------
class LivenessResult final : public ::google::protobuf::Message
/* @@protoc_insertion_point(class_definition:tari.rpc.LivenessResult) */ {
public:
inline LivenessResult() : LivenessResult(nullptr) {}
~LivenessResult() override;
template <typename = void>
explicit PROTOBUF_CONSTEXPR LivenessResult(
::google::protobuf::internal::ConstantInitialized);
inline LivenessResult(const LivenessResult& from) : LivenessResult(nullptr, from) {}
inline LivenessResult(LivenessResult&& from) noexcept
: LivenessResult(nullptr, std::move(from)) {}
inline LivenessResult& operator=(const LivenessResult& from) {
CopyFrom(from);
return *this;
}
inline LivenessResult& operator=(LivenessResult&& from) noexcept {
if (this == &from) return *this;
if (GetArena() == from.GetArena()
#ifdef PROTOBUF_FORCE_COPY_IN_MOVE
&& GetArena() != nullptr
#endif // !PROTOBUF_FORCE_COPY_IN_MOVE
) {
InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.unknown_fields<::google::protobuf::UnknownFieldSet>(::google::protobuf::UnknownFieldSet::default_instance);
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields()
ABSL_ATTRIBUTE_LIFETIME_BOUND {
return _internal_metadata_.mutable_unknown_fields<::google::protobuf::UnknownFieldSet>();
}
static const ::google::protobuf::Descriptor* descriptor() {
return GetDescriptor();
}
static const ::google::protobuf::Descriptor* GetDescriptor() {
return default_instance().GetMetadata().descriptor;
}
static const ::google::protobuf::Reflection* GetReflection() {
return default_instance().GetMetadata().reflection;
}
static const LivenessResult& default_instance() {
return *internal_default_instance();
}
static inline const LivenessResult* internal_default_instance() {
return reinterpret_cast<const LivenessResult*>(
&_LivenessResult_default_instance_);
}
static constexpr int kIndexInFileMessages = 57;
friend void swap(LivenessResult& a, LivenessResult& b) { a.Swap(&b); }
inline void Swap(LivenessResult* other) {
if (other == this) return;
#ifdef PROTOBUF_FORCE_COPY_IN_SWAP
if (GetArena() != nullptr && GetArena() == other->GetArena()) {
#else // PROTOBUF_FORCE_COPY_IN_SWAP
if (GetArena() == other->GetArena()) {
#endif // !PROTOBUF_FORCE_COPY_IN_SWAP
InternalSwap(other);
} else {
::google::protobuf::internal::GenericSwap(this, other);
}
}
void UnsafeArenaSwap(LivenessResult* other) {
if (other == this) return;
ABSL_DCHECK(GetArena() == other->GetArena());
InternalSwap(other);
}
// implements Message ----------------------------------------------
LivenessResult* New(::google::protobuf::Arena* arena = nullptr) const final {
return ::google::protobuf::Message::DefaultConstruct<LivenessResult>(arena);
}
using ::google::protobuf::Message::CopyFrom;
void CopyFrom(const LivenessResult& from);
using ::google::protobuf::Message::MergeFrom;
void MergeFrom(const LivenessResult& from) { LivenessResult::MergeImpl(*this, from); }
private:
static void MergeImpl(
::google::protobuf::MessageLite& to_msg,
const ::google::protobuf::MessageLite& from_msg);
public:
ABSL_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final;
::size_t ByteSizeLong() const final;
const char* _InternalParse(const char* ptr, ::google::protobuf::internal::ParseContext* ctx) final;
::uint8_t* _InternalSerialize(
::uint8_t* target,
::google::protobuf::io::EpsCopyOutputStream* stream) const final;
int GetCachedSize() const { return _impl_._cached_size_.Get(); }
private:
void SharedCtor(::google::protobuf::Arena* arena);
void SharedDtor();
void InternalSwap(LivenessResult* other);
private:
friend class ::google::protobuf::internal::AnyMetadata;
static ::absl::string_view FullMessageName() { return "tari.rpc.LivenessResult"; }
protected:
explicit LivenessResult(::google::protobuf::Arena* arena);
LivenessResult(::google::protobuf::Arena* arena, const LivenessResult& from);
LivenessResult(::google::protobuf::Arena* arena, LivenessResult&& from) noexcept
: LivenessResult(arena) {
*this = ::std::move(from);
}
const ::google::protobuf::MessageLite::ClassData* GetClassData()
const final;
public:
::google::protobuf::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
enum : int {
kPeerNodeIdFieldNumber = 1,
kDiscoverLatencyFieldNumber = 2,
kPingLatencyFieldNumber = 3,
};
// bytes peer_node_id = 1;
void clear_peer_node_id() ;
const std::string& peer_node_id() const;
template <typename Arg_ = const std::string&, typename... Args_>
void set_peer_node_id(Arg_&& arg, Args_... args);
std::string* mutable_peer_node_id();
PROTOBUF_NODISCARD std::string* release_peer_node_id();
void set_allocated_peer_node_id(std::string* value);
private:
const std::string& _internal_peer_node_id() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_peer_node_id(
const std::string& value);
std::string* _internal_mutable_peer_node_id();
public:
// uint64 discover_latency = 2;
void clear_discover_latency() ;
::uint64_t discover_latency() const;
void set_discover_latency(::uint64_t value);
private:
::uint64_t _internal_discover_latency() const;
void _internal_set_discover_latency(::uint64_t value);
public:
// uint64 ping_latency = 3;
void clear_ping_latency() ;
::uint64_t ping_latency() const;
void set_ping_latency(::uint64_t value);
private:
::uint64_t _internal_ping_latency() const;
void _internal_set_ping_latency(::uint64_t value);
public:
// @@protoc_insertion_point(class_scope:tari.rpc.LivenessResult)
private:
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
2, 3, 0,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
friend class ::google::protobuf::Arena;
template <typename T>
friend class ::google::protobuf::Arena::InternalHelper;
using InternalArenaConstructable_ = void;
using DestructorSkippable_ = void;
struct Impl_ {
inline explicit constexpr Impl_(
::google::protobuf::internal::ConstantInitialized) noexcept;
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena);
inline explicit Impl_(::google::protobuf::internal::InternalVisibility visibility,
::google::protobuf::Arena* arena, const Impl_& from);
::google::protobuf::internal::ArenaStringPtr peer_node_id_;
::uint64_t discover_latency_;
::uint64_t ping_latency_;
mutable ::google::protobuf::internal::CachedSize _cached_size_;
PROTOBUF_TSAN_DECLARE_MEMBER
};
union { Impl_ _impl_; };
friend struct ::TableStruct_base_5fnode_2eproto;
};
// -------------------------------------------------------------------
class ListHeadersRequest final : public ::google::protobuf::Message
/* @@protoc_insertion_point(class_definition:tari.rpc.ListHeadersRequest) */ {
public:
@@ -8495,14 +8719,34 @@ class GetNetworkStateResponse final : public ::google::protobuf::Message
// accessors -------------------------------------------------------
enum : int {
kLivenessResultsFieldNumber = 9,
kMetadataFieldNumber = 1,
kBaseNodeStateFieldNumber = 3,
kInitialSyncAchievedFieldNumber = 2,
kFailedCheckpointsFieldNumber = 4,
kRewardFieldNumber = 5,
kSha3XEstimatedHashRateFieldNumber = 6,
kRandomxEstimatedHashRateFieldNumber = 7,
kMoneroRandomxEstimatedHashRateFieldNumber = 7,
kNumConnectionsFieldNumber = 8,
kTariRandomxEstimatedHashRateFieldNumber = 10,
};
// repeated .tari.rpc.LivenessResult liveness_results = 9;
int liveness_results_size() const;
private:
int _internal_liveness_results_size() const;
public:
void clear_liveness_results() ;
::tari::rpc::LivenessResult* mutable_liveness_results(int index);
::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>* mutable_liveness_results();
private:
const ::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>& _internal_liveness_results() const;
::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>* _internal_mutable_liveness_results();
public:
const ::tari::rpc::LivenessResult& liveness_results(int index) const;
::tari::rpc::LivenessResult* add_liveness_results();
const ::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>& liveness_results() const;
// .tari.rpc.MetaData metadata = 1;
bool has_metadata() const;
void clear_metadata() ;
@@ -8568,14 +8812,34 @@ class GetNetworkStateResponse final : public ::google::protobuf::Message
void _internal_set_sha3x_estimated_hash_rate(::uint64_t value);
public:
// uint64 randomx_estimated_hash_rate = 7;
void clear_randomx_estimated_hash_rate() ;
::uint64_t randomx_estimated_hash_rate() const;
void set_randomx_estimated_hash_rate(::uint64_t value);
// uint64 monero_randomx_estimated_hash_rate = 7;
void clear_monero_randomx_estimated_hash_rate() ;
::uint64_t monero_randomx_estimated_hash_rate() const;
void set_monero_randomx_estimated_hash_rate(::uint64_t value);
private:
::uint64_t _internal_randomx_estimated_hash_rate() const;
void _internal_set_randomx_estimated_hash_rate(::uint64_t value);
::uint64_t _internal_monero_randomx_estimated_hash_rate() const;
void _internal_set_monero_randomx_estimated_hash_rate(::uint64_t value);
public:
// uint64 num_connections = 8;
void clear_num_connections() ;
::uint64_t num_connections() const;
void set_num_connections(::uint64_t value);
private:
::uint64_t _internal_num_connections() const;
void _internal_set_num_connections(::uint64_t value);
public:
// uint64 tari_randomx_estimated_hash_rate = 10;
void clear_tari_randomx_estimated_hash_rate() ;
::uint64_t tari_randomx_estimated_hash_rate() const;
void set_tari_randomx_estimated_hash_rate(::uint64_t value);
private:
::uint64_t _internal_tari_randomx_estimated_hash_rate() const;
void _internal_set_tari_randomx_estimated_hash_rate(::uint64_t value);
public:
// @@protoc_insertion_point(class_scope:tari.rpc.GetNetworkStateResponse)
@@ -8583,7 +8847,7 @@ class GetNetworkStateResponse final : public ::google::protobuf::Message
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
3, 7, 1,
4, 10, 2,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
@@ -8601,13 +8865,16 @@ class GetNetworkStateResponse final : public ::google::protobuf::Message
::google::protobuf::Arena* arena, const Impl_& from);
::google::protobuf::internal::HasBits<1> _has_bits_;
mutable ::google::protobuf::internal::CachedSize _cached_size_;
::google::protobuf::RepeatedPtrField< ::tari::rpc::LivenessResult > liveness_results_;
::tari::rpc::MetaData* metadata_;
int base_node_state_;
bool initial_sync_achieved_;
bool failed_checkpoints_;
::uint64_t reward_;
::uint64_t sha3x_estimated_hash_rate_;
::uint64_t randomx_estimated_hash_rate_;
::uint64_t monero_randomx_estimated_hash_rate_;
::uint64_t num_connections_;
::uint64_t tari_randomx_estimated_hash_rate_;
PROTOBUF_TSAN_DECLARE_MEMBER
};
union { Impl_ _impl_; };
@@ -11085,6 +11352,7 @@ class GetNewBlockResult final : public ::google::protobuf::Message
kBlockHashFieldNumber = 1,
kMergeMiningHashFieldNumber = 3,
kTariUniqueIdFieldNumber = 4,
kVmKeyFieldNumber = 6,
kBlockFieldNumber = 2,
kMinerDataFieldNumber = 5,
};
@@ -11135,6 +11403,22 @@ class GetNewBlockResult final : public ::google::protobuf::Message
const std::string& value);
std::string* _internal_mutable_tari_unique_id();
public:
// bytes vm_key = 6;
void clear_vm_key() ;
const std::string& vm_key() const;
template <typename Arg_ = const std::string&, typename... Args_>
void set_vm_key(Arg_&& arg, Args_... args);
std::string* mutable_vm_key();
PROTOBUF_NODISCARD std::string* release_vm_key();
void set_allocated_vm_key(std::string* value);
private:
const std::string& _internal_vm_key() const;
inline PROTOBUF_ALWAYS_INLINE void _internal_set_vm_key(
const std::string& value);
std::string* _internal_mutable_vm_key();
public:
// .tari.rpc.Block block = 2;
bool has_block() const;
@@ -11171,7 +11455,7 @@ class GetNewBlockResult final : public ::google::protobuf::Message
class _Internal;
friend class ::google::protobuf::internal::TcParser;
static const ::google::protobuf::internal::TcParseTable<
3, 5, 2,
3, 6, 2,
0, 2>
_table_;
friend class ::google::protobuf::MessageLite;
@@ -11192,6 +11476,7 @@ class GetNewBlockResult final : public ::google::protobuf::Message
::google::protobuf::internal::ArenaStringPtr block_hash_;
::google::protobuf::internal::ArenaStringPtr merge_mining_hash_;
::google::protobuf::internal::ArenaStringPtr tari_unique_id_;
::google::protobuf::internal::ArenaStringPtr vm_key_;
::tari::rpc::Block* block_;
::tari::rpc::MinerData* miner_data_;
PROTOBUF_TSAN_DECLARE_MEMBER
@@ -14188,26 +14473,48 @@ inline void NetworkDifficultyResponse::_internal_set_sha3x_estimated_hash_rate(:
_impl_.sha3x_estimated_hash_rate_ = value;
}
// uint64 randomx_estimated_hash_rate = 7;
inline void NetworkDifficultyResponse::clear_randomx_estimated_hash_rate() {
// uint64 monero_randomx_estimated_hash_rate = 7;
inline void NetworkDifficultyResponse::clear_monero_randomx_estimated_hash_rate() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.randomx_estimated_hash_rate_ = ::uint64_t{0u};
_impl_.monero_randomx_estimated_hash_rate_ = ::uint64_t{0u};
}
inline ::uint64_t NetworkDifficultyResponse::randomx_estimated_hash_rate() const {
// @@protoc_insertion_point(field_get:tari.rpc.NetworkDifficultyResponse.randomx_estimated_hash_rate)
return _internal_randomx_estimated_hash_rate();
inline ::uint64_t NetworkDifficultyResponse::monero_randomx_estimated_hash_rate() const {
// @@protoc_insertion_point(field_get:tari.rpc.NetworkDifficultyResponse.monero_randomx_estimated_hash_rate)
return _internal_monero_randomx_estimated_hash_rate();
}
inline void NetworkDifficultyResponse::set_randomx_estimated_hash_rate(::uint64_t value) {
_internal_set_randomx_estimated_hash_rate(value);
// @@protoc_insertion_point(field_set:tari.rpc.NetworkDifficultyResponse.randomx_estimated_hash_rate)
inline void NetworkDifficultyResponse::set_monero_randomx_estimated_hash_rate(::uint64_t value) {
_internal_set_monero_randomx_estimated_hash_rate(value);
// @@protoc_insertion_point(field_set:tari.rpc.NetworkDifficultyResponse.monero_randomx_estimated_hash_rate)
}
inline ::uint64_t NetworkDifficultyResponse::_internal_randomx_estimated_hash_rate() const {
inline ::uint64_t NetworkDifficultyResponse::_internal_monero_randomx_estimated_hash_rate() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.randomx_estimated_hash_rate_;
return _impl_.monero_randomx_estimated_hash_rate_;
}
inline void NetworkDifficultyResponse::_internal_set_randomx_estimated_hash_rate(::uint64_t value) {
inline void NetworkDifficultyResponse::_internal_set_monero_randomx_estimated_hash_rate(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.randomx_estimated_hash_rate_ = value;
_impl_.monero_randomx_estimated_hash_rate_ = value;
}
// uint64 tari_randomx_estimated_hash_rate = 10;
inline void NetworkDifficultyResponse::clear_tari_randomx_estimated_hash_rate() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.tari_randomx_estimated_hash_rate_ = ::uint64_t{0u};
}
inline ::uint64_t NetworkDifficultyResponse::tari_randomx_estimated_hash_rate() const {
// @@protoc_insertion_point(field_get:tari.rpc.NetworkDifficultyResponse.tari_randomx_estimated_hash_rate)
return _internal_tari_randomx_estimated_hash_rate();
}
inline void NetworkDifficultyResponse::set_tari_randomx_estimated_hash_rate(::uint64_t value) {
_internal_set_tari_randomx_estimated_hash_rate(value);
// @@protoc_insertion_point(field_set:tari.rpc.NetworkDifficultyResponse.tari_randomx_estimated_hash_rate)
}
inline ::uint64_t NetworkDifficultyResponse::_internal_tari_randomx_estimated_hash_rate() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.tari_randomx_estimated_hash_rate_;
}
inline void NetworkDifficultyResponse::_internal_set_tari_randomx_estimated_hash_rate(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.tari_randomx_estimated_hash_rate_ = value;
}
// uint64 num_coinbases = 8;
@@ -14338,29 +14645,51 @@ NetworkDifficultyResponse::_internal_mutable_coinbase_extras() {
// ValueAtHeightResponse
// uint64 value = 1;
inline void ValueAtHeightResponse::clear_value() {
// uint64 circulating_supply = 1;
inline void ValueAtHeightResponse::clear_circulating_supply() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.value_ = ::uint64_t{0u};
_impl_.circulating_supply_ = ::uint64_t{0u};
}
inline ::uint64_t ValueAtHeightResponse::value() const {
// @@protoc_insertion_point(field_get:tari.rpc.ValueAtHeightResponse.value)
return _internal_value();
inline ::uint64_t ValueAtHeightResponse::circulating_supply() const {
// @@protoc_insertion_point(field_get:tari.rpc.ValueAtHeightResponse.circulating_supply)
return _internal_circulating_supply();
}
inline void ValueAtHeightResponse::set_value(::uint64_t value) {
_internal_set_value(value);
// @@protoc_insertion_point(field_set:tari.rpc.ValueAtHeightResponse.value)
inline void ValueAtHeightResponse::set_circulating_supply(::uint64_t value) {
_internal_set_circulating_supply(value);
// @@protoc_insertion_point(field_set:tari.rpc.ValueAtHeightResponse.circulating_supply)
}
inline ::uint64_t ValueAtHeightResponse::_internal_value() const {
inline ::uint64_t ValueAtHeightResponse::_internal_circulating_supply() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.value_;
return _impl_.circulating_supply_;
}
inline void ValueAtHeightResponse::_internal_set_value(::uint64_t value) {
inline void ValueAtHeightResponse::_internal_set_circulating_supply(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.value_ = value;
_impl_.circulating_supply_ = value;
}
// uint64 height = 2;
// uint64 spendable_supply = 2;
inline void ValueAtHeightResponse::clear_spendable_supply() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.spendable_supply_ = ::uint64_t{0u};
}
inline ::uint64_t ValueAtHeightResponse::spendable_supply() const {
// @@protoc_insertion_point(field_get:tari.rpc.ValueAtHeightResponse.spendable_supply)
return _internal_spendable_supply();
}
inline void ValueAtHeightResponse::set_spendable_supply(::uint64_t value) {
_internal_set_spendable_supply(value);
// @@protoc_insertion_point(field_set:tari.rpc.ValueAtHeightResponse.spendable_supply)
}
inline ::uint64_t ValueAtHeightResponse::_internal_spendable_supply() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.spendable_supply_;
}
inline void ValueAtHeightResponse::_internal_set_spendable_supply(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.spendable_supply_ = value;
}
// uint64 height = 3;
inline void ValueAtHeightResponse::clear_height() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.height_ = ::uint64_t{0u};
@@ -15973,6 +16302,56 @@ inline void GetNewBlockResult::set_allocated_miner_data(::tari::rpc::MinerData*
// @@protoc_insertion_point(field_set_allocated:tari.rpc.GetNewBlockResult.miner_data)
}
// bytes vm_key = 6;
inline void GetNewBlockResult::clear_vm_key() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.vm_key_.ClearToEmpty();
}
inline const std::string& GetNewBlockResult::vm_key() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:tari.rpc.GetNewBlockResult.vm_key)
return _internal_vm_key();
}
template <typename Arg_, typename... Args_>
inline PROTOBUF_ALWAYS_INLINE void GetNewBlockResult::set_vm_key(Arg_&& arg,
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.vm_key_.SetBytes(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:tari.rpc.GetNewBlockResult.vm_key)
}
inline std::string* GetNewBlockResult::mutable_vm_key() ABSL_ATTRIBUTE_LIFETIME_BOUND {
std::string* _s = _internal_mutable_vm_key();
// @@protoc_insertion_point(field_mutable:tari.rpc.GetNewBlockResult.vm_key)
return _s;
}
inline const std::string& GetNewBlockResult::_internal_vm_key() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.vm_key_.Get();
}
inline void GetNewBlockResult::_internal_set_vm_key(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.vm_key_.Set(value, GetArena());
}
inline std::string* GetNewBlockResult::_internal_mutable_vm_key() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
return _impl_.vm_key_.Mutable( GetArena());
}
inline std::string* GetNewBlockResult::release_vm_key() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
// @@protoc_insertion_point(field_release:tari.rpc.GetNewBlockResult.vm_key)
return _impl_.vm_key_.Release();
}
inline void GetNewBlockResult::set_allocated_vm_key(std::string* value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.vm_key_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.vm_key_.IsDefault()) {
_impl_.vm_key_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:tari.rpc.GetNewBlockResult.vm_key)
}
// -------------------------------------------------------------------
// GetNewBlockBlobResult
@@ -18368,26 +18747,217 @@ inline void GetNetworkStateResponse::_internal_set_sha3x_estimated_hash_rate(::u
_impl_.sha3x_estimated_hash_rate_ = value;
}
// uint64 randomx_estimated_hash_rate = 7;
inline void GetNetworkStateResponse::clear_randomx_estimated_hash_rate() {
// uint64 monero_randomx_estimated_hash_rate = 7;
inline void GetNetworkStateResponse::clear_monero_randomx_estimated_hash_rate() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.randomx_estimated_hash_rate_ = ::uint64_t{0u};
_impl_.monero_randomx_estimated_hash_rate_ = ::uint64_t{0u};
}
inline ::uint64_t GetNetworkStateResponse::randomx_estimated_hash_rate() const {
// @@protoc_insertion_point(field_get:tari.rpc.GetNetworkStateResponse.randomx_estimated_hash_rate)
return _internal_randomx_estimated_hash_rate();
inline ::uint64_t GetNetworkStateResponse::monero_randomx_estimated_hash_rate() const {
// @@protoc_insertion_point(field_get:tari.rpc.GetNetworkStateResponse.monero_randomx_estimated_hash_rate)
return _internal_monero_randomx_estimated_hash_rate();
}
inline void GetNetworkStateResponse::set_randomx_estimated_hash_rate(::uint64_t value) {
_internal_set_randomx_estimated_hash_rate(value);
// @@protoc_insertion_point(field_set:tari.rpc.GetNetworkStateResponse.randomx_estimated_hash_rate)
inline void GetNetworkStateResponse::set_monero_randomx_estimated_hash_rate(::uint64_t value) {
_internal_set_monero_randomx_estimated_hash_rate(value);
// @@protoc_insertion_point(field_set:tari.rpc.GetNetworkStateResponse.monero_randomx_estimated_hash_rate)
}
inline ::uint64_t GetNetworkStateResponse::_internal_randomx_estimated_hash_rate() const {
inline ::uint64_t GetNetworkStateResponse::_internal_monero_randomx_estimated_hash_rate() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.randomx_estimated_hash_rate_;
return _impl_.monero_randomx_estimated_hash_rate_;
}
inline void GetNetworkStateResponse::_internal_set_randomx_estimated_hash_rate(::uint64_t value) {
inline void GetNetworkStateResponse::_internal_set_monero_randomx_estimated_hash_rate(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.randomx_estimated_hash_rate_ = value;
_impl_.monero_randomx_estimated_hash_rate_ = value;
}
// uint64 tari_randomx_estimated_hash_rate = 10;
inline void GetNetworkStateResponse::clear_tari_randomx_estimated_hash_rate() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.tari_randomx_estimated_hash_rate_ = ::uint64_t{0u};
}
inline ::uint64_t GetNetworkStateResponse::tari_randomx_estimated_hash_rate() const {
// @@protoc_insertion_point(field_get:tari.rpc.GetNetworkStateResponse.tari_randomx_estimated_hash_rate)
return _internal_tari_randomx_estimated_hash_rate();
}
inline void GetNetworkStateResponse::set_tari_randomx_estimated_hash_rate(::uint64_t value) {
_internal_set_tari_randomx_estimated_hash_rate(value);
// @@protoc_insertion_point(field_set:tari.rpc.GetNetworkStateResponse.tari_randomx_estimated_hash_rate)
}
inline ::uint64_t GetNetworkStateResponse::_internal_tari_randomx_estimated_hash_rate() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.tari_randomx_estimated_hash_rate_;
}
inline void GetNetworkStateResponse::_internal_set_tari_randomx_estimated_hash_rate(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.tari_randomx_estimated_hash_rate_ = value;
}
// uint64 num_connections = 8;
inline void GetNetworkStateResponse::clear_num_connections() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.num_connections_ = ::uint64_t{0u};
}
inline ::uint64_t GetNetworkStateResponse::num_connections() const {
// @@protoc_insertion_point(field_get:tari.rpc.GetNetworkStateResponse.num_connections)
return _internal_num_connections();
}
inline void GetNetworkStateResponse::set_num_connections(::uint64_t value) {
_internal_set_num_connections(value);
// @@protoc_insertion_point(field_set:tari.rpc.GetNetworkStateResponse.num_connections)
}
inline ::uint64_t GetNetworkStateResponse::_internal_num_connections() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.num_connections_;
}
inline void GetNetworkStateResponse::_internal_set_num_connections(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.num_connections_ = value;
}
// repeated .tari.rpc.LivenessResult liveness_results = 9;
inline int GetNetworkStateResponse::_internal_liveness_results_size() const {
return _internal_liveness_results().size();
}
inline int GetNetworkStateResponse::liveness_results_size() const {
return _internal_liveness_results_size();
}
inline void GetNetworkStateResponse::clear_liveness_results() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.liveness_results_.Clear();
}
inline ::tari::rpc::LivenessResult* GetNetworkStateResponse::mutable_liveness_results(int index)
ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_mutable:tari.rpc.GetNetworkStateResponse.liveness_results)
return _internal_mutable_liveness_results()->Mutable(index);
}
inline ::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>* GetNetworkStateResponse::mutable_liveness_results()
ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_mutable_list:tari.rpc.GetNetworkStateResponse.liveness_results)
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
return _internal_mutable_liveness_results();
}
inline const ::tari::rpc::LivenessResult& GetNetworkStateResponse::liveness_results(int index) const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:tari.rpc.GetNetworkStateResponse.liveness_results)
return _internal_liveness_results().Get(index);
}
inline ::tari::rpc::LivenessResult* GetNetworkStateResponse::add_liveness_results() ABSL_ATTRIBUTE_LIFETIME_BOUND {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
::tari::rpc::LivenessResult* _add = _internal_mutable_liveness_results()->Add();
// @@protoc_insertion_point(field_add:tari.rpc.GetNetworkStateResponse.liveness_results)
return _add;
}
inline const ::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>& GetNetworkStateResponse::liveness_results() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_list:tari.rpc.GetNetworkStateResponse.liveness_results)
return _internal_liveness_results();
}
inline const ::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>&
GetNetworkStateResponse::_internal_liveness_results() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.liveness_results_;
}
inline ::google::protobuf::RepeatedPtrField<::tari::rpc::LivenessResult>*
GetNetworkStateResponse::_internal_mutable_liveness_results() {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return &_impl_.liveness_results_;
}
// -------------------------------------------------------------------
// LivenessResult
// bytes peer_node_id = 1;
inline void LivenessResult::clear_peer_node_id() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.peer_node_id_.ClearToEmpty();
}
inline const std::string& LivenessResult::peer_node_id() const
ABSL_ATTRIBUTE_LIFETIME_BOUND {
// @@protoc_insertion_point(field_get:tari.rpc.LivenessResult.peer_node_id)
return _internal_peer_node_id();
}
template <typename Arg_, typename... Args_>
inline PROTOBUF_ALWAYS_INLINE void LivenessResult::set_peer_node_id(Arg_&& arg,
Args_... args) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.peer_node_id_.SetBytes(static_cast<Arg_&&>(arg), args..., GetArena());
// @@protoc_insertion_point(field_set:tari.rpc.LivenessResult.peer_node_id)
}
inline std::string* LivenessResult::mutable_peer_node_id() ABSL_ATTRIBUTE_LIFETIME_BOUND {
std::string* _s = _internal_mutable_peer_node_id();
// @@protoc_insertion_point(field_mutable:tari.rpc.LivenessResult.peer_node_id)
return _s;
}
inline const std::string& LivenessResult::_internal_peer_node_id() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.peer_node_id_.Get();
}
inline void LivenessResult::_internal_set_peer_node_id(const std::string& value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.peer_node_id_.Set(value, GetArena());
}
inline std::string* LivenessResult::_internal_mutable_peer_node_id() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
return _impl_.peer_node_id_.Mutable( GetArena());
}
inline std::string* LivenessResult::release_peer_node_id() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
// @@protoc_insertion_point(field_release:tari.rpc.LivenessResult.peer_node_id)
return _impl_.peer_node_id_.Release();
}
inline void LivenessResult::set_allocated_peer_node_id(std::string* value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.peer_node_id_.SetAllocated(value, GetArena());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
if (_impl_.peer_node_id_.IsDefault()) {
_impl_.peer_node_id_.Set("", GetArena());
}
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
// @@protoc_insertion_point(field_set_allocated:tari.rpc.LivenessResult.peer_node_id)
}
// uint64 discover_latency = 2;
inline void LivenessResult::clear_discover_latency() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.discover_latency_ = ::uint64_t{0u};
}
inline ::uint64_t LivenessResult::discover_latency() const {
// @@protoc_insertion_point(field_get:tari.rpc.LivenessResult.discover_latency)
return _internal_discover_latency();
}
inline void LivenessResult::set_discover_latency(::uint64_t value) {
_internal_set_discover_latency(value);
// @@protoc_insertion_point(field_set:tari.rpc.LivenessResult.discover_latency)
}
inline ::uint64_t LivenessResult::_internal_discover_latency() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.discover_latency_;
}
inline void LivenessResult::_internal_set_discover_latency(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.discover_latency_ = value;
}
// uint64 ping_latency = 3;
inline void LivenessResult::clear_ping_latency() {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.ping_latency_ = ::uint64_t{0u};
}
inline ::uint64_t LivenessResult::ping_latency() const {
// @@protoc_insertion_point(field_get:tari.rpc.LivenessResult.ping_latency)
return _internal_ping_latency();
}
inline void LivenessResult::set_ping_latency(::uint64_t value) {
_internal_set_ping_latency(value);
// @@protoc_insertion_point(field_set:tari.rpc.LivenessResult.ping_latency)
}
inline ::uint64_t LivenessResult::_internal_ping_latency() const {
PROTOBUF_TSAN_READ(&_impl_._tsan_detect_race);
return _impl_.ping_latency_;
}
inline void LivenessResult::_internal_set_ping_latency(::uint64_t value) {
PROTOBUF_TSAN_WRITE(&_impl_._tsan_detect_race);
_impl_.ping_latency_ = value;
}
#ifdef __GNUC__
+21 -4
View File
@@ -218,15 +218,17 @@ message NetworkDifficultyResponse {
uint64 timestamp = 4;
uint64 pow_algo = 5;
uint64 sha3x_estimated_hash_rate = 6;
uint64 randomx_estimated_hash_rate = 7;
uint64 monero_randomx_estimated_hash_rate = 7;
uint64 tari_randomx_estimated_hash_rate = 10;
uint64 num_coinbases = 8;
repeated bytes coinbase_extras = 9;
}
// A generic single value response for a specific height
message ValueAtHeightResponse {
uint64 value= 1;
uint64 height = 2;
uint64 circulating_supply = 1;
uint64 spendable_supply = 2;
uint64 height = 3;
}
// A generic uint value
@@ -382,6 +384,7 @@ message GetNewBlockResult{
bytes merge_mining_hash =3;
bytes tari_unique_id =4;
MinerData miner_data = 5;
bytes vm_key = 6;
}
// This is the message that is returned for a miner after it asks for a new block.
@@ -539,6 +542,20 @@ message GetNetworkStateResponse {
// estimate sha3x hash rate
uint64 sha3x_estimated_hash_rate = 6;
// estimate randomx hash rate
uint64 randomx_estimated_hash_rate = 7;
uint64 monero_randomx_estimated_hash_rate = 7;
uint64 tari_randomx_estimated_hash_rate = 10;
// number of connections
uint64 num_connections = 8;
//liveness results
repeated LivenessResult liveness_results = 9;
}
message LivenessResult{
// node id
bytes peer_node_id = 1;
// time to discover
uint64 discover_latency = 2;
// Dial latency
uint64 ping_latency = 3;
}
+21 -20
View File
@@ -371,22 +371,22 @@ const char descriptor_table_protodef_block_2eproto[] ABSL_ATTRIBUTE_SECTION_VARI
"tal_script_offset\030\017 \001(\014\022\031\n\021validator_nod"
"e_mr\030\020 \001(\014\022\033\n\023validator_node_size\030\021 \001(\004\""
"1\n\013ProofOfWork\022\020\n\010pow_algo\030\001 \001(\004\022\020\n\010pow_"
"data\030\004 \001(\014\"o\n\007PowAlgo\022,\n\010pow_algo\030\001 \001(\0162"
"\032.tari.rpc.PowAlgo.PowAlgos\"6\n\010PowAlgos\022"
"\025\n\021POW_ALGOS_RANDOMX\020\000\022\023\n\017POW_ALGOS_SHA3"
"X\020\001\"U\n\005Block\022%\n\006header\030\001 \001(\0132\025.tari.rpc."
"BlockHeader\022%\n\004body\030\002 \001(\0132\027.tari.rpc.Agg"
"regateBody\"H\n\017HistoricalBlock\022\025\n\rconfirm"
"ations\030\001 \001(\004\022\036\n\005block\030\002 \001(\0132\017.tari.rpc.B"
"lock\"\252\001\n\026NewBlockHeaderTemplate\022\017\n\007versi"
"on\030\001 \001(\r\022\016\n\006height\030\002 \001(\004\022\021\n\tprev_hash\030\003 "
"\001(\014\022\033\n\023total_kernel_offset\030\004 \001(\014\022\"\n\003pow\030"
"\005 \001(\0132\025.tari.rpc.ProofOfWork\022\033\n\023total_sc"
"ript_offset\030\007 \001(\014\"\207\001\n\020NewBlockTemplate\0220"
"\n\006header\030\001 \001(\0132 .tari.rpc.NewBlockHeader"
"Template\022%\n\004body\030\002 \001(\0132\027.tari.rpc.Aggreg"
"ateBody\022\032\n\022is_mempool_in_sync\030\003 \001(\010b\006pro"
"to3"
"data\030\004 \001(\014\"\210\001\n\007PowAlgo\022,\n\010pow_algo\030\001 \001(\016"
"2\032.tari.rpc.PowAlgo.PowAlgos\"O\n\010PowAlgos"
"\022\026\n\022POW_ALGOS_RANDOMXM\020\000\022\023\n\017POW_ALGOS_SH"
"A3X\020\001\022\026\n\022POW_ALGOS_RANDOMXT\020\002\"U\n\005Block\022%"
"\n\006header\030\001 \001(\0132\025.tari.rpc.BlockHeader\022%\n"
"\004body\030\002 \001(\0132\027.tari.rpc.AggregateBody\"H\n\017"
"HistoricalBlock\022\025\n\rconfirmations\030\001 \001(\004\022\036"
"\n\005block\030\002 \001(\0132\017.tari.rpc.Block\"\252\001\n\026NewBl"
"ockHeaderTemplate\022\017\n\007version\030\001 \001(\r\022\016\n\006he"
"ight\030\002 \001(\004\022\021\n\tprev_hash\030\003 \001(\014\022\033\n\023total_k"
"ernel_offset\030\004 \001(\014\022\"\n\003pow\030\005 \001(\0132\025.tari.r"
"pc.ProofOfWork\022\033\n\023total_script_offset\030\007 "
"\001(\014\"\207\001\n\020NewBlockTemplate\0220\n\006header\030\001 \001(\013"
"2 .tari.rpc.NewBlockHeaderTemplate\022%\n\004bo"
"dy\030\002 \001(\0132\027.tari.rpc.AggregateBody\022\032\n\022is_"
"mempool_in_sync\030\003 \001(\010b\006proto3"
};
static const ::_pbi::DescriptorTable* const descriptor_table_block_2eproto_deps[1] =
{
@@ -396,7 +396,7 @@ static ::absl::once_flag descriptor_table_block_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_block_2eproto = {
false,
false,
1083,
1109,
descriptor_table_protodef_block_2eproto,
"block.proto",
&descriptor_table_block_2eproto_once,
@@ -432,15 +432,16 @@ const ::google::protobuf::EnumDescriptor* PowAlgo_PowAlgos_descriptor() {
return file_level_enum_descriptors_block_2eproto[0];
}
PROTOBUF_CONSTINIT const uint32_t PowAlgo_PowAlgos_internal_data_[] = {
131072u, 0u, };
196608u, 0u, };
bool PowAlgo_PowAlgos_IsValid(int value) {
return 0 <= value && value <= 1;
return 0 <= value && value <= 2;
}
#if (__cplusplus < 201703) && \
(!defined(_MSC_VER) || (_MSC_VER >= 1900 && _MSC_VER < 1912))
constexpr PowAlgo_PowAlgos PowAlgo::POW_ALGOS_RANDOMX;
constexpr PowAlgo_PowAlgos PowAlgo::POW_ALGOS_RANDOMXM;
constexpr PowAlgo_PowAlgos PowAlgo::POW_ALGOS_SHA3X;
constexpr PowAlgo_PowAlgos PowAlgo::POW_ALGOS_RANDOMXT;
constexpr PowAlgo_PowAlgos PowAlgo::PowAlgos_MIN;
constexpr PowAlgo_PowAlgos PowAlgo::PowAlgos_MAX;
constexpr int PowAlgo::PowAlgos_ARRAYSIZE;
+7 -5
View File
@@ -84,8 +84,9 @@ namespace protobuf {
namespace tari {
namespace rpc {
enum PowAlgo_PowAlgos : int {
PowAlgo_PowAlgos_POW_ALGOS_RANDOMX = 0,
PowAlgo_PowAlgos_POW_ALGOS_RANDOMXM = 0,
PowAlgo_PowAlgos_POW_ALGOS_SHA3X = 1,
PowAlgo_PowAlgos_POW_ALGOS_RANDOMXT = 2,
PowAlgo_PowAlgos_PowAlgo_PowAlgos_INT_MIN_SENTINEL_DO_NOT_USE_ =
std::numeric_limits<::int32_t>::min(),
PowAlgo_PowAlgos_PowAlgo_PowAlgos_INT_MAX_SENTINEL_DO_NOT_USE_ =
@@ -95,8 +96,8 @@ enum PowAlgo_PowAlgos : int {
bool PowAlgo_PowAlgos_IsValid(int value);
extern const uint32_t PowAlgo_PowAlgos_internal_data_[];
constexpr PowAlgo_PowAlgos PowAlgo_PowAlgos_PowAlgos_MIN = static_cast<PowAlgo_PowAlgos>(0);
constexpr PowAlgo_PowAlgos PowAlgo_PowAlgos_PowAlgos_MAX = static_cast<PowAlgo_PowAlgos>(1);
constexpr int PowAlgo_PowAlgos_PowAlgos_ARRAYSIZE = 1 + 1;
constexpr PowAlgo_PowAlgos PowAlgo_PowAlgos_PowAlgos_MAX = static_cast<PowAlgo_PowAlgos>(2);
constexpr int PowAlgo_PowAlgos_PowAlgos_ARRAYSIZE = 2 + 1;
const ::google::protobuf::EnumDescriptor*
PowAlgo_PowAlgos_descriptor();
template <typename T>
@@ -109,7 +110,7 @@ const std::string& PowAlgo_PowAlgos_Name(T value) {
template <>
inline const std::string& PowAlgo_PowAlgos_Name(PowAlgo_PowAlgos value) {
return ::google::protobuf::internal::NameOfDenseEnum<PowAlgo_PowAlgos_descriptor,
0, 1>(
0, 2>(
static_cast<int>(value));
}
inline bool PowAlgo_PowAlgos_Parse(absl::string_view name, PowAlgo_PowAlgos* value) {
@@ -430,8 +431,9 @@ class PowAlgo final : public ::google::protobuf::Message
::google::protobuf::Metadata GetMetadata() const final;
// nested types ----------------------------------------------------
using PowAlgos = PowAlgo_PowAlgos;
static constexpr PowAlgos POW_ALGOS_RANDOMX = PowAlgo_PowAlgos_POW_ALGOS_RANDOMX;
static constexpr PowAlgos POW_ALGOS_RANDOMXM = PowAlgo_PowAlgos_POW_ALGOS_RANDOMXM;
static constexpr PowAlgos POW_ALGOS_SHA3X = PowAlgo_PowAlgos_POW_ALGOS_SHA3X;
static constexpr PowAlgos POW_ALGOS_RANDOMXT = PowAlgo_PowAlgos_POW_ALGOS_RANDOMXT;
static inline bool PowAlgos_IsValid(int value) {
return PowAlgo_PowAlgos_IsValid(value);
}
+2 -1
View File
@@ -80,8 +80,9 @@ message ProofOfWork {
message PowAlgo {
// The permitted pow algorithms
enum PowAlgos {
POW_ALGOS_RANDOMX = 0; // Accessible as `grpc::pow_algo::PowAlgos::Randomx`
POW_ALGOS_RANDOMXM = 0; // Accessible as `grpc::pow_algo::PowAlgos::RandomxM`
POW_ALGOS_SHA3X = 1; // Accessible as `grpc::pow_algo::PowAlgos::Sha3x`
POW_ALGOS_RANDOMXT = 2; // Accessible as `grpc::pow_algo::PowAlgos::RandomxT`
}
// The pow algo to use
PowAlgos pow_algo = 1;
+1 -1
View File
@@ -741,7 +741,7 @@ void BlockTemplate::fill_optimal_knapsack(const MinerData& data, uint64_t base_r
constexpr uint64_t FEE_COEFF = 1000;
const uint64_t n = m_mempoolTxs.size();
const uint64_t max_weight = data.median_weight + (data.median_weight / 32) - miner_tx_weight;
const uint64_t max_weight = data.median_weight + (data.median_weight / 8) - miner_tx_weight;
m_knapsack.resize((n + 1) * max_weight);
memset(m_knapsack.data(), 0, max_weight * sizeof(uint32_t));
+55 -36
View File
@@ -84,21 +84,30 @@ ConsoleCommands::ConsoleCommands(p2pool* pool)
}
}
std::random_device rd;
std::mt19937_64 rng(rd());
for (int i = 0; i < 10; ++i) {
if (start_listening(false, "127.0.0.1", 49152 + (rng() % 16384))) {
break;
}
}
if (m_listenPort < 0) {
LOGERR(1, "failed to listen on TCP port");
throw std::exception();
}
if (m_pool->api() && m_pool->params().m_localStats) {
std::mt19937_64 rng(RandomDeviceSeed::instance);
// Diffuse the initial state in case it has low quality
rng.discard(10000);
for (int i = 0; i < 10; ++i) {
if (start_listening(false, "127.0.0.1", 49152 + (rng() % 16384))) {
break;
}
}
if (m_listenPort < 0) {
LOGERR(1, "failed to listen on TCP port");
throw std::exception();
}
// 20 random characters in the range [32, 126] should be enough for 128 bits of entropy
m_cookie.resize(20);
for (char& c : m_cookie) {
c = static_cast<char>(rng() % (127 - 32) + 32);
}
m_pool->api()->set(p2pool_api::Category::LOCAL, "console",
[stdin_type, this](log::Stream& s)
{
@@ -114,7 +123,7 @@ ConsoleCommands::ConsoleCommands(p2pool* pool)
s << static_cast<int>(stdin_type);
}
s << "\",\"tcp_port\":" << m_listenPort << '}';
s << "\",\"tcp_port\":" << m_listenPort << ",\"cookie\":\"" << log::EscapedString(m_cookie) << "\"}";
});
}
@@ -349,7 +358,7 @@ void ConsoleCommands::stdinReadCallback(uv_stream_t* stream, ssize_t nread, cons
ConsoleCommands* pThis = static_cast<ConsoleCommands*>(stream->data);
if (nread > 0) {
pThis->process_input(pThis->m_command, buf->base, static_cast<uint32_t>(nread));
pThis->process_input(pThis->m_command, buf->base, static_cast<uint32_t>(nread), false);
}
else if (nread < 0) {
LOGWARN(4, "read error " << uv_err_name(static_cast<int>(nread)));
@@ -359,7 +368,7 @@ void ConsoleCommands::stdinReadCallback(uv_stream_t* stream, ssize_t nread, cons
}
void ConsoleCommands::process_input(std::string& command, const char* data, uint32_t size)
void ConsoleCommands::process_input(std::string& command, const char* data, uint32_t size, bool check_cookie)
{
command.append(data, size);
@@ -370,31 +379,41 @@ void ConsoleCommands::process_input(std::string& command, const char* data, uint
}
command[k] = '\0';
cmd* c = cmds;
for (; c->name.len; ++c) {
if (!strncmp(command.c_str(), c->name.str, c->name.len)) {
const char* args = (c->name.len + 1 <= k) ? (command.c_str() + c->name.len + 1) : "";
if (check_cookie && ((k <= m_cookie.length()) || (memcmp(command.data(), m_cookie.data(), m_cookie.length()) != 0))) {
LOGWARN(4, "cookie check failed, skipping command " << log::MaskNonASCII(command));
}
else {
if (check_cookie) {
command.erase(0, m_cookie.length());
k -= m_cookie.length();
}
// Skip spaces
while ((args[0] == ' ') || (args[0] == '\t')) {
++args;
}
cmd* c = cmds;
for (; c->name.len; ++c) {
if (!strncmp(command.c_str(), c->name.str, c->name.len)) {
const char* args = (c->name.len + 1 <= k) ? (command.c_str() + c->name.len + 1) : "";
// Check if an argument is required
if (strlen(c->arg) && !strlen(args)) {
LOGWARN(0, c->name.str << " requires arguments");
do_help(nullptr, nullptr);
// Skip spaces
while ((args[0] == ' ') || (args[0] == '\t')) {
++args;
}
// Check if an argument is required
if (strlen(c->arg) && !strlen(args)) {
LOGWARN(0, c->name.str << " requires arguments");
do_help(nullptr, nullptr);
break;
}
c->func(m_pool, args);
break;
}
c->func(m_pool, args);
break;
}
}
if (!c->name.len) {
LOGWARN(0, "Unknown command " << command.c_str());
do_help(nullptr, nullptr);
if (!c->name.len) {
LOGWARN(0, "Unknown command " << log::MaskNonASCII(command));
do_help(nullptr, nullptr);
}
}
k = command.find_first_not_of("\r\n", k + 1);
+3 -2
View File
@@ -40,7 +40,7 @@ public:
size_t size() const override { return sizeof(ConsoleClient); }
bool on_connect() override { return true; };
bool on_read(const char* data, uint32_t size) override { static_cast<ConsoleCommands*>(m_owner)->process_input(m_command, data, size); return true; };
bool on_read(const char* data, uint32_t size) override { static_cast<ConsoleCommands*>(m_owner)->process_input(m_command, data, size, true); return true; };
alignas(8) char m_consoleReadBuf[1024] = {};
@@ -62,11 +62,12 @@ private:
bool m_readBufInUse;
std::string m_command;
std::string m_cookie;
static void allocCallback(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
static void stdinReadCallback(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
void process_input(std::string& command, const char* data, uint32_t size);
void process_input(std::string& command, const char* data, uint32_t size, bool check_cookie);
};
} // namespace p2pool
+8 -4
View File
@@ -80,6 +80,8 @@ struct CurlContext
uint64_t m_startTime;
uint64_t m_connectedTime;
std::string m_proxy;
};
CurlContext::CurlContext(const std::string& address, int port, const std::string& req, const std::string& auth, const std::string& proxy, bool ssl, const std::string& ssl_fingerprint, CallbackBase* cb, CallbackBase* close_cb, uv_loop_t* loop)
@@ -93,6 +95,7 @@ CurlContext::CurlContext(const std::string& address, int port, const std::string
, m_headers(nullptr)
, m_startTime(0)
, m_connectedTime(0)
, m_proxy(proxy)
{
m_pollHandles.reserve(2);
@@ -111,8 +114,10 @@ CurlContext::CurlContext(const std::string& address, int port, const std::string
(void)ssl_fingerprint;
#endif
const bool is_v6 = (address.find(':') != std::string::npos);
log::Stream s(buf);
s << protocol << address << ':' << port;
s << protocol << (is_v6 ? "[" : "") << address << (is_v6 ? "]:" : ":") << port;
if (!m_req.empty() && (m_req.front() == '/')) {
s << m_req.c_str() << '\0';
@@ -242,9 +247,8 @@ CurlContext::~CurlContext()
double tcp_ping = 0.0;
if (m_error.empty() && !m_response.empty()) {
if (m_connectedTime) {
tcp_ping = static_cast<double>(m_connectedTime - m_startTime) / 1000.0;
}
const uint64_t t = (m_proxy.empty() && m_connectedTime) ? m_connectedTime : microseconds_since_epoch();
tcp_ping = static_cast<double>(t - m_startTime) / 1000.0;
(*m_callback)(m_response.data(), m_response.size(), tcp_ping);
}
delete m_callback;
+61 -11
View File
@@ -24,6 +24,10 @@
#include <stdlib.h>
#include <clocale>
#if defined(_WIN32) && !defined(S_ISREG)
#define S_ISREG(M) (((M) & _S_IFMT) == _S_IFREG)
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
@@ -118,6 +122,7 @@ public:
: m_writePos(0)
, m_readPos(0)
, m_stopped(false)
, m_needReopen(false)
{
#if defined(_WIN32) && defined(_MSC_VER) && !defined(NDEBUG)
SetUnhandledExceptionFilter(UnhandledExceptionFilter);
@@ -128,11 +133,6 @@ public:
std::setlocale(LC_ALL, "en_001");
m_logFilePath = DATA_DIR + log_file_name;
m_logFile.open(m_logFilePath, std::ios::app | std::ios::binary);
if (!m_logFile.is_open()) {
fprintf(stderr, "failed to open %s: error %d\n", m_logFilePath.c_str(), errno);
}
m_buf.resize(BUF_SIZE);
@@ -219,6 +219,12 @@ public:
const std::string& log_file_path() const { return m_logFilePath; }
FORCEINLINE void schedule_reopen()
{
m_needReopen = true;
uv_cond_signal(&m_cond);
}
private:
static void init_uv_threadpool()
{
@@ -245,13 +251,41 @@ private:
}
}
bool reopen(struct stat& st)
{
st = {};
if (m_logFile.is_open()) {
m_logFile.close();
}
m_logFile.open(m_logFilePath, std::ios::app | std::ios::binary);
if (!m_logFile.is_open()) {
return false;
}
if (stat(m_logFilePath.c_str(), &st) != 0) {
st = {};
return false;
}
return true;
}
private:
static void run_wrapper(void* arg) { reinterpret_cast<Worker*>(arg)->run(); }
NOINLINE void run()
{
set_thread_name("Logger");
struct stat log_file_st;
if (!reopen(log_file_st)) {
fprintf(stderr, "failed to open %s: error %d\n", m_logFilePath.c_str(), errno);
}
do {
uv_mutex_lock(&m_mutex);
if (m_readPos == m_writePos.load()) {
@@ -264,6 +298,14 @@ private:
}
uv_mutex_unlock(&m_mutex);
bool expected = true;
if (m_needReopen.compare_exchange_strong(expected, false)) {
// Reopen the log file on request (logrotate support)
if(reopen(log_file_st)) {
LOGINFO(0, "reopened " << m_logFilePath);
}
}
for (uint32_t writePos = m_writePos.load(); m_readPos != writePos; writePos = m_writePos.load()) {
// We have at least one log slot pending, possibly more than one
// Process everything in a loop before reading m_writePos again
@@ -327,11 +369,18 @@ private:
if (m_logFile.is_open()) {
m_logFile.flush();
// Reopen the log file if it's been moved (logrotate support)
// Automatically reopen the file if either it
// no longer exists or it is now a different
// regular file; this detects manual moving or
// recreating of the file
struct stat buf;
if (stat(m_logFilePath.c_str(), &buf) != 0) {
m_logFile.close();
m_logFile.open(m_logFilePath, std::ios::app | std::ios::binary);
if (stat(m_logFilePath.c_str(), &buf) == 0) {
if(log_file_st.st_dev && log_file_st.st_ino && S_ISREG(buf.st_mode) &&
(buf.st_dev != log_file_st.st_dev || buf.st_ino != log_file_st.st_ino)) {
reopen(log_file_st);
}
} else if(errno == ENOENT) {
reopen(log_file_st);
}
}
@@ -376,6 +425,7 @@ private:
uv_thread_t m_worker;
bool m_stopped;
std::atomic<bool> m_needReopen;
std::ofstream m_logFile;
std::string m_logFilePath;
@@ -445,7 +495,7 @@ void reopen()
{
// This will trigger the worker thread which will then reopen log file if it's been moved
#ifndef P2POOL_LOG_DISABLE
LOGINFO(0, "reopening " << worker->log_file_path());
worker->schedule_reopen();
#endif
}
+46 -1
View File
@@ -344,7 +344,7 @@ template<> struct log::Stream::Entry<Hashrate>
const double x = static_cast<double>(value.m_data);
static constexpr const char* units[] = { "H/s", "KH/s", "MH/s", "GH/s", "TH/s", "PH/s", "EH/s" };
static constexpr const char* units[] = { "H/s", "kH/s", "MH/s", "GH/s", "TH/s", "PH/s", "EH/s" };
int n;
char buf[32];
@@ -435,6 +435,51 @@ template<> struct log::Stream::Entry<Duration>
}
};
struct EscapedString
{
explicit FORCEINLINE EscapedString(const std::string& data, const char* characters_to_escape = "\"\\", char escape_character = '\\')
{
m_data.reserve(data.length() * 2);
for (const char c : data) {
if (strchr(characters_to_escape, c)) {
m_data.append(1, escape_character);
}
m_data.append(1, c);
}
}
FORCEINLINE operator const std::string&() const { return m_data; }
std::string m_data;
};
template<> struct log::Stream::Entry<EscapedString>
{
static FORCEINLINE void put(const EscapedString& value, Stream* wrapper) { *wrapper << value.m_data; }
};
struct MaskNonASCII
{
explicit FORCEINLINE MaskNonASCII(const std::string& data, char mask_character = '?') : m_data(data)
{
for (char& c : m_data) {
if ((c < 32) || (c >= 127)) {
c = mask_character;
}
}
}
FORCEINLINE operator const std::string&() const { return m_data; }
std::string m_data;
};
template<> struct log::Stream::Entry<MaskNonASCII>
{
static FORCEINLINE void put(const MaskNonASCII& value, Stream* wrapper) { *wrapper << value.m_data; }
};
template<typename T>
struct PadRight
{
+40 -1
View File
@@ -21,6 +21,22 @@
#include "stratum_server.h"
#include "p2p_server.h"
#include <curl/curl.h>
#ifdef WITH_GRPC
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4574)
#endif
#include <grpc/grpc.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif // WITH_GRPC
#include <filesystem>
#ifdef WITH_RANDOMX
@@ -46,6 +62,7 @@ void p2pool_usage()
"--stratum Comma-separated list of IP:port for stratum server to listen on\n"
"--p2p Comma-separated list of IP:port for p2p server to listen on\n"
"--addpeers Comma-separated list of IP:port of other p2pool nodes to connect to\n"
"--stratum-ban-time N Number of seconds to ban misbehaving stratum client, default is %u\n"
"--light-mode Don't allocate RandomX dataset, saves 2GB of RAM\n"
"--loglevel Verbosity of the log, integer number between 0 and %d\n"
"--data-dir Path to store general p2pool files (log, cache, peer data, etc.), default is current directory\n"
@@ -62,6 +79,7 @@ void p2pool_usage()
"--in-peers N Maximum number of incoming connections for p2p server (any value between 10 and 450)\n"
"--start-mining N Start built-in miner using N threads (any value between 1 and 64)\n"
"--mini Connect to p2pool-mini sidechain. Note that it will also change default p2p port from %d to %d\n"
"--nano Connect to p2pool-nano sidechain. Note that it will also change default p2p port from %d to %d\n"
"--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"
@@ -85,9 +103,12 @@ void p2pool_usage()
"Example command line:\n\n"
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",
p2pool::VERSION,
static_cast<uint32_t>(p2pool::DEFAULT_STRATUM_BAN_TIME),
p2pool::log::MAX_GLOBAL_LOG_LEVEL,
p2pool::DEFAULT_P2P_PORT,
p2pool::DEFAULT_P2P_PORT_MINI,
p2pool::DEFAULT_P2P_PORT,
p2pool::DEFAULT_P2P_PORT_NANO,
#ifdef _WIN32
"p2pool.exe"
#else
@@ -105,6 +126,8 @@ void p2pool_version()
int p2pool_test()
{
printf("Self-test started\n");
#ifdef WITH_RANDOMX
const char myKey[] = "test key 000";
const char myInput[] = "This is a test";
@@ -119,7 +142,10 @@ int p2pool_test()
return 1;
}
}
printf("RandomX cache allocated\n");
randomx_init_cache(myCache, myKey, sizeof(myKey) - 1);
printf("RandomX cache initialized\n");
randomx_dataset* myDataset = randomx_alloc_dataset(flags | RANDOMX_FLAG_LARGE_PAGES);
if (!myDataset) {
@@ -129,6 +155,7 @@ int p2pool_test()
return 1;
}
}
printf("RandomX dataset allocated\n");
{
const uint32_t numThreads = std::max(std::thread::hardware_concurrency(), 1U);
@@ -149,6 +176,7 @@ int p2pool_test()
t.join();
}
}
printf("RandomX dataset initialized\n");
randomx_release_cache(myCache);
@@ -160,12 +188,15 @@ int p2pool_test()
return 1;
}
}
printf("RandomX VM created\n");
memset(hash, 0, sizeof(hash));
memcpy(hash, myInput, sizeof(myInput));
for (size_t i = 0; i < 100; ++i) {
for (int i = 0; i < 100; ++i) {
printf("RandomX: calculating hash %d...", i);
randomx_calculate_hash(myMachine, &hash, sizeof(hash), hash);
printf("done\n");
}
char buf[RANDOMX_HASH_SIZE * 2 + 1] = {};
@@ -248,6 +279,10 @@ int main(int argc, char* argv[])
return result;
}
#ifdef WITH_GRPC
grpc_init();
#endif
try {
p2pool::p2pool pool(argc, argv);
result = pool.run();
@@ -256,6 +291,10 @@ int main(int argc, char* argv[])
result = 1;
}
#ifdef WITH_GRPC
grpc_shutdown();
#endif
curl_global_cleanup();
p2pool::destroy_crypto_cache();
+33 -7
View File
@@ -48,8 +48,10 @@ struct TrackedAllocation
FORCEINLINE bool operator<(const TrackedAllocation& rhs) { return memcmp(stack_trace, rhs.stack_trace, sizeof(stack_trace)) < 0; }
FORCEINLINE bool operator==(const TrackedAllocation& rhs) { return memcmp(stack_trace, rhs.stack_trace, sizeof(stack_trace)) == 0; }
void print(HANDLE h) const
void print(HANDLE h, bool& is_grpc) const
{
is_grpc = false;
char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)] = {};
PSYMBOL_INFO pSymbol = reinterpret_cast<PSYMBOL_INFO>(buffer);
@@ -66,13 +68,21 @@ struct TrackedAllocation
if (SymFromAddr(h, address, &t1, pSymbol) && SymGetLineFromAddr64(h, address, &t2, &line)) {
const char* s = line.FileName;
const char* file_name = nullptr;
while (*s) {
if ((*s == '\\') || (*s == '/')) {
file_name = s + 1;
}
++s;
}
printf("%-25s %s (line %lu)\n", file_name ? file_name : line.FileName, pSymbol->Name, line.LineNumber);
s = pSymbol->Name;
printf("%-25s %s (line %lu)\n", file_name ? file_name : line.FileName, s, line.LineNumber);
if (!is_grpc && ((strstr(s, "grpc::") == s) || (strstr(s, "grpc_core::") == s) || (strstr(s, "grpc_init") == s))) {
is_grpc = true;
}
}
}
printf("\n");
@@ -130,7 +140,8 @@ void show_top_10_allocations()
for (TrackedAllocation* p = buf; (p < buf + 10) && (p < end); ++p) {
printf("%I64u bytes allocated at:\n", p->allocated_size);
p->print(h);
bool is_grpc;
p->print(h, is_grpc);
}
}
@@ -314,21 +325,36 @@ bool memory_tracking_stop()
const HANDLE h = GetCurrentProcess();
uint64_t total_leaks = 0;
uint64_t grpc_leaks = 0;
for (uint32_t i = 0; i < N; ++i) {
const TrackedAllocation& t = allocations[i];
if (t.allocated_size) {
total_leaks += t.allocated_size;
printf("Memory leak detected, %I64u bytes allocated at %p by thread %u:\n", t.allocated_size, t.p, t.thread_id);
t.print(h);
bool is_grpc;
t.print(h, is_grpc);
if (is_grpc) {
printf("^^^ grpc leak ^^^\n\n");
grpc_leaks += t.allocated_size;
}
else {
printf("^^^ non-grpc leak ^^^\n\n");
total_leaks += t.allocated_size;
}
}
}
if (total_leaks > 0) {
printf("%I64u bytes leaked\n\n", total_leaks);
}
else {
if (grpc_leaks > 0) {
printf("%I64u bytes leaked by gRPC\n\n", grpc_leaks);
}
if ((total_leaks == 0) && (grpc_leaks == 0)) {
printf("No memory leaks detected\n\n");
}
+6
View File
@@ -50,6 +50,12 @@ public:
}
}
void clear()
{
WriteLock lock(m_lock);
m_transactions.clear();
}
private:
mutable uv_rwlock_t m_lock;
unordered_map<hash, TxMempoolData> m_transactions;
+8
View File
@@ -28,10 +28,17 @@ class IMergeMiningClient
public:
struct ChainParameters
{
ChainParameters() : last_updated(0) {}
enum {
EXPIRE_TIME = 1800,
};
hash aux_id;
hash aux_hash;
std::vector<uint8_t> aux_blob;
difficulty_type aux_diff;
uint64_t last_updated;
};
public:
@@ -43,6 +50,7 @@ public:
virtual 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) = 0;
virtual void print_status() const = 0;
virtual void api_status(log::Stream&) const = 0;
};
} // namespace p2pool
+29 -6
View File
@@ -31,6 +31,7 @@ namespace p2pool {
MergeMiningClientJSON_RPC::MergeMiningClientJSON_RPC(p2pool* pool, const std::string& host, const std::string& wallet)
: m_host(host)
, m_port(80)
, m_chainParamsTimestamp(0)
, m_auxWallet(wallet)
, m_ping(0.0)
, m_pool(pool)
@@ -281,6 +282,9 @@ bool MergeMiningClientJSON_RPC::parse_merge_mining_get_aux_block(const char* dat
m_chainParams.aux_hash = h;
m_chainParams.aux_diff.lo = result["aux_diff"].GetUint64();
m_chainParams.aux_diff.hi = 0;
m_chainParams.last_updated = seconds_since_epoch();
m_chainParamsTimestamp = time(nullptr);
changed = true;
@@ -318,6 +322,8 @@ void MergeMiningClientJSON_RPC::submit_solution(const std::vector<uint8_t>& /*co
if (size > 0) {
LOGERR(3, "couldn't submit merge mining solution to " << m_host << ':' << m_port << ", error " << log::const_buf(data, size));
}
// Get new mining job
on_timer();
}, &m_loop);
}
@@ -332,19 +338,40 @@ void MergeMiningClientJSON_RPC::print_status() const
);
}
bool MergeMiningClientJSON_RPC::get_params(ChainParameters& out_params) const
void MergeMiningClientJSON_RPC::api_status(log::Stream& s) const
{
ReadLock lock(m_lock);
s << '{'
<< "\"api\":\"JSON RPC\","
<< "\"id\":\"" << m_chainParams.aux_id << "\","
<< "\"host\":\"" << m_host << ':' << m_port << "\","
<< "\"wallet\":\"" << m_auxWallet << "\","
<< "\"difficulty\":" << m_chainParams.aux_diff << ","
<< "\"timestamp\":" << m_chainParamsTimestamp
<< '}';
}
bool MergeMiningClientJSON_RPC::get_params(ChainParameters& out_params) const
{
const uint64_t t = seconds_since_epoch();
ReadLock lock(m_lock);
if (m_chainParams.aux_id.empty() || m_chainParams.aux_diff.empty()) {
return false;
}
if (t >= m_chainParams.last_updated + ChainParameters::EXPIRE_TIME) {
LOGWARN(4, m_host << ':' << m_port << " merge mining data is outdated (" << (t - m_chainParams.last_updated) << " seconds old)");
return false;
}
out_params = m_chainParams;
return true;
}
bool MergeMiningClientJSON_RPC::parse_merge_mining_submit_solution(const char* data, size_t size)
bool MergeMiningClientJSON_RPC::parse_merge_mining_submit_solution(const char* data, size_t size) const
{
auto err = [this](const char* msg) {
LOGWARN(3, "merge_mining_submit_solution to " << m_host << ':' << m_port << " failed: " << msg);
@@ -393,10 +420,6 @@ bool MergeMiningClientJSON_RPC::parse_merge_mining_submit_solution(const char* d
}
LOGINFO(0, log::LightGreen() << "merge_mining_submit_solution to " << m_host << ':' << m_port << ": " << status);
// Get new mining job
on_timer();
return true;
}
+4 -1
View File
@@ -35,6 +35,7 @@ public:
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;
private:
static void loop(void* data);
@@ -48,7 +49,7 @@ private:
void merge_mining_get_aux_block(uint64_t height, const hash& prev_id, const std::string& wallet);
bool parse_merge_mining_get_aux_block(const char* data, size_t size, bool& changed);
bool parse_merge_mining_submit_solution(const char* data, size_t size);
bool parse_merge_mining_submit_solution(const char* data, size_t size) const;
std::string m_host;
uint32_t m_port;
@@ -56,6 +57,8 @@ private:
mutable uv_rwlock_t m_lock;
ChainParameters m_chainParams;
uint64_t m_chainParamsTimestamp;
std::string m_auxWallet;
double m_ping;
+181 -13
View File
@@ -25,6 +25,7 @@
#include "pool_block.h"
#include "merkle.h"
#include "side_chain.h"
#include <fstream>
LOG_CATEGORY(MergeMiningClientTari)
@@ -34,6 +35,7 @@ namespace p2pool {
MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, const std::string& wallet)
: m_chainParams{}
, m_chainParamsTimestamp(0)
, m_previousAuxHashes{}
, m_previousAuxHashesIndex(0)
, m_auxWallet(wallet)
@@ -42,6 +44,7 @@ MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, con
, m_server(new TariServer(pool->params().m_socks5Proxy))
, m_hostStr(host)
, m_workerStop(0)
, m_pushBlockStop(0)
{
if (host.find(TARI_PREFIX) != 0) {
LOGERR(1, "Invalid host " << host << " - \"" << TARI_PREFIX << "\" prefix not found");
@@ -84,23 +87,54 @@ MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, con
log::Stream s(buf);
s << "127.0.0.1:" << m_server->external_listen_port();
grpc::ChannelArguments cArgs;
m_channelArgs.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 1000);
cArgs.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 1000);
cArgs.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 1000);
cArgs.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 10000);
m_channelArgs.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 1000);
m_channelArgs.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 10000);
m_TariNode = new BaseNode::Stub(grpc::CreateCustomChannel(buf, grpc::InsecureChannelCredentials(), cArgs));
m_channelArgs.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1);
m_channelArgs.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, -1);
m_TariNode = new BaseNode::Stub(grpc::CreateCustomChannel(buf, grpc::InsecureChannelCredentials(), m_channelArgs));
uv_mutex_init_checked(&m_workerLock);
uv_cond_init_checked(&m_workerCond);
const int err = uv_thread_create(&m_worker, run_wrapper, this);
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()) {
while (f.good()) {
std::string node;
std::getline(f, node);
if (!node.empty()) {
PushBlockThreadData* data = new PushBlockThreadData{ {}, this, std::move(node) };
err = uv_thread_create(&data->m_worker, push_block_thread, data);
if (err) {
LOGERR(1, "failed to start block pusher thread for node " << data->m_node << ", error " << uv_err_name(err));
delete data;
}
else {
m_pushBlockThreads.push_back(data);
// Limit to 16 nodes. More will be just an overkill and a waste of bandwidth.
if (m_pushBlockThreads.size() >= 16) {
break;
}
}
}
}
}
}
MergeMiningClientTari::~MergeMiningClientTari()
@@ -114,6 +148,20 @@ MergeMiningClientTari::~MergeMiningClientTari()
}
uv_thread_join(&m_worker);
if (!m_pushBlockThreads.empty()) {
m_pushBlockStop.exchange(1);
{
MutexLock lock(m_pushBlockLock);
uv_cond_broadcast(&m_pushBlockCond);
}
for (PushBlockThreadData* data : m_pushBlockThreads) {
uv_thread_join(&data->m_worker);
delete data;
}
m_pushBlockThreads.clear();
}
m_server->shutdown_tcp();
delete m_server;
@@ -124,17 +172,27 @@ MergeMiningClientTari::~MergeMiningClientTari()
uv_mutex_destroy(&m_workerLock);
uv_cond_destroy(&m_workerCond);
uv_mutex_destroy(&m_pushBlockLock);
uv_cond_destroy(&m_pushBlockCond);
LOGINFO(1, "stopped");
}
bool MergeMiningClientTari::get_params(ChainParameters& out_params) const
{
const uint64_t t = seconds_since_epoch();
ReadLock lock(m_chainParamsLock);
if (m_chainParams.aux_id.empty() || m_chainParams.aux_diff.empty()) {
return false;
}
if (t >= m_chainParams.last_updated + ChainParameters::EXPIRE_TIME) {
LOGWARN(4, m_hostStr << " merge mining data is outdated (" << (t - m_chainParams.last_updated) << " seconds old)");
return false;
}
out_params = m_chainParams;
return true;
}
@@ -332,7 +390,7 @@ void MergeMiningClientTari::submit_solution(const std::vector<uint8_t>& coinbase
}
ProofOfWork* pow = block.mutable_header()->mutable_pow();
pow->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMX);
pow->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMXM);
{
std::string data;
@@ -436,6 +494,18 @@ void MergeMiningClientTari::submit_solution(const std::vector<uint8_t>& coinbase
pow->set_pow_data(data);
}
{
const std::string& h = block.header().hash();
LOGINFO(4, "Block " << log::hex_buf(h.data(), h.size()) << ": PoW data is set, everything is ready. Submitting it!");
}
if (!m_pushBlockThreads.empty()) {
MutexLock lock(m_pushBlockLock);
m_blockToPush = block;
uv_cond_broadcast(&m_pushBlockCond);
}
struct Work
{
uv_work_t req;
@@ -461,6 +531,10 @@ void MergeMiningClientTari::submit_solution(const std::vector<uint8_t>& coinbase
const std::string& h = response.block_hash();
LOGINFO(0, log::LightGreen() << "Mined Tari block " << log::hex_buf(h.data(), h.size()) << " at height " << block.header().height());
}
// We've just submitted a new block. Signal the polling thread to stop waiting and get a new block template.
MutexLock lock(client->m_workerLock);
uv_cond_signal(&client->m_workerCond);
}
} *work = new Work(this, std::move(block));
@@ -530,6 +604,23 @@ void MergeMiningClientTari::print_status() const
);
}
void MergeMiningClientTari::api_status(log::Stream& s) const
{
ReadLock lock(m_chainParamsLock);
s << '{'
<< "\"api\":\"Tari gRPC\","
<< "\"id\":\"" << m_chainParams.aux_id << "\","
<< "\"host\":\"" << m_hostStr << "\","
<< "\"wallet\":\"" << m_auxWallet << "\","
<< "\"height\":" << m_tariJobParams.height << ","
<< "\"difficulty\":" << m_tariJobParams.diff << ","
<< "\"reward\":" << m_tariJobParams.reward << ","
<< "\"fees\":" << m_tariJobParams.fees << ","
<< "\"timestamp\":" << m_chainParamsTimestamp
<< '}';
}
void MergeMiningClientTari::run_wrapper(void* arg)
{
reinterpret_cast<MergeMiningClientTari*>(arg)->run();
@@ -557,7 +648,7 @@ void MergeMiningClientTari::run()
(a.failed_checkpoints() == b.failed_checkpoints());
};
for (;;) {
while (!m_workerStop) {
const auto start_time = high_resolution_clock::now();
// Force frequent enough updates (at least every 30 seconds)
@@ -583,7 +674,7 @@ void MergeMiningClientTari::run()
GetNewBlockTemplateWithCoinbasesRequest request{};
PowAlgo* algo = new PowAlgo();
algo->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMX);
algo->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMXM);
request.clear_algo();
request.set_allocated_algo(algo);
@@ -656,8 +747,11 @@ void MergeMiningClientTari::run()
std::copy(mm_hash.begin(), mm_hash.end(), m_chainParams.aux_hash.h);
m_chainParams.aux_diff = static_cast<difficulty_type>(response.miner_data().target_difficulty());
m_chainParams.last_updated = seconds_since_epoch();
m_tariBlock = response.block();
m_chainParamsTimestamp = time(nullptr);
m_tariBlock = std::move(*response.mutable_block());
LOGINFO(4, "Tari aux block template: height = " << job_params.height
<< ", diff = " << job_params.diff
@@ -681,8 +775,8 @@ void MergeMiningClientTari::run()
const int64_t timeout = std::max<int64_t>(500'000'000 - dt, 1'000'000);
if ((m_workerStop.load() != 0) || (uv_cond_timedwait(&m_workerCond, &m_workerLock, timeout) != UV_ETIMEDOUT)) {
return;
if (!m_workerStop) {
uv_cond_timedwait(&m_workerCond, &m_workerLock, timeout);
}
}
}
@@ -852,4 +946,78 @@ bool MergeMiningClientTari::TariClient::on_read(const char* data, uint32_t size)
});
}
void MergeMiningClientTari::push_block_thread(void* arg)
{
set_thread_name("Push Tari block");
PushBlockThreadData* data = reinterpret_cast<PushBlockThreadData*>(arg);
LOGINFO(1, "push block thread ready for " << data->m_node);
try {
data->m_client->push_blocks_to(data->m_node);
}
catch (const std::exception& e) {
LOGERR(0, "Exception in push_blocks_to(" << data->m_node << "): " << e.what());
}
LOGINFO(1, "push block thread stopped for " << data->m_node);
}
void MergeMiningClientTari::push_blocks_to(const std::string& node_address)
{
using namespace tari::rpc;
std::unique_ptr<BaseNode::Stub> node(new BaseNode::Stub(grpc::CreateCustomChannel(node_address, grpc::InsecureChannelCredentials(), m_channelArgs)));
grpc::ClientContext get_tip_info_ctx{};
Empty get_tip_info_request{};
TipInfoResponse tip_info{};
const grpc::Status get_tip_info_status = node->GetTipInfo(&get_tip_info_ctx, get_tip_info_request, &tip_info);
if (!get_tip_info_status.ok()) {
LOGWARN(4, "GetTipInfo failed for " << node_address << ": " << get_tip_info_status.error_message());
if (!get_tip_info_status.error_details().empty()) {
LOGWARN(4, "GetTipInfo failed for " << node_address << ": " << get_tip_info_status.error_details());
}
}
else {
LOGINFO(4, node_address << " is at block height " << tip_info.metadata().best_block_height());
}
while (!m_pushBlockStop) {
Block block;
{
MutexLock lock(m_pushBlockLock);
uv_cond_wait(&m_pushBlockCond, &m_pushBlockLock);
if (m_pushBlockStop) {
return;
}
block = m_blockToPush;
}
const std::string& h = block.header().hash();
LOGINFO(4, "Pushing block " << log::hex_buf(h.data(), h.size()) << " to " << node_address);
grpc::ClientContext ctx;
SubmitBlockResponse response;
const grpc::Status status = node->SubmitBlock(&ctx, block, &response);
if (!status.ok()) {
LOGWARN(4, "SubmitBlock failed for " << node_address << ": " << status.error_message());
if (!status.error_details().empty()) {
LOGWARN(4, "SubmitBlock failed for " << node_address << ": " << status.error_details());
}
}
else {
const std::string& h1 = response.block_hash();
LOGINFO(0, log::LightGreen() << "Pushed Tari block " << log::hex_buf(h1.data(), h1.size()) << " to " << node_address);
}
}
}
} // namespace p2pool
+22
View File
@@ -38,11 +38,14 @@ public:
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;
private:
mutable uv_rwlock_t m_chainParamsLock;
ChainParameters m_chainParams;
uint64_t m_chainParamsTimestamp;
enum {
NUM_PREVIOUS_HASHES = 8,
};
@@ -96,6 +99,7 @@ private:
const std::string m_hostStr;
grpc::ChannelArguments m_channelArgs;
tari::rpc::BaseNode::Stub* m_TariNode;
struct TariClient : public TCPServer::Client
@@ -127,6 +131,24 @@ private:
static void run_wrapper(void* arg);
void run();
uv_mutex_t m_pushBlockLock;
uv_cond_t m_pushBlockCond;
std::atomic<uint32_t> m_pushBlockStop;
tari::rpc::Block m_blockToPush;
struct PushBlockThreadData
{
uv_thread_t m_worker;
MergeMiningClientTari* m_client;
std::string m_node;
};
std::vector<PushBlockThreadData*> m_pushBlockThreads;
static void push_block_thread(void* arg);
void push_blocks_to(const std::string& node_address);
};
} // namespace p2pool
+16 -5
View File
@@ -26,6 +26,12 @@ namespace p2pool {
void merkle_hash(const std::vector<hash>& hashes, root_hash& root)
{
const size_t count = hashes.size();
if (count == 0) {
root.clear();
return;
}
const uint8_t* h = hashes[0].h;
if (count == 1) {
@@ -62,10 +68,15 @@ void merkle_hash(const std::vector<hash>& hashes, root_hash& root)
void merkle_hash_full_tree(const std::vector<hash>& hashes, std::vector<std::vector<hash>>& tree)
{
const size_t count = hashes.size();
const uint8_t* h = hashes[0].h;
tree.clear();
if (count == 0) {
return;
}
const uint8_t* h = hashes[0].h;
if (count == 1) {
tree.push_back(hashes);
}
@@ -181,14 +192,14 @@ bool get_merkle_proof(const std::vector<std::vector<hash>>& tree, const hash& h,
root_hash get_root_from_proof(hash h, const std::vector<hash>& proof, size_t index, size_t count)
{
if (count == 1) {
return root_hash(h);
}
if (index >= count) {
return root_hash();
}
if (count == 1) {
return root_hash(h);
}
hash tmp[2];
if (count == 2) {
+31 -22
View File
@@ -47,6 +47,7 @@ LOG_CATEGORY(P2PServer)
static constexpr char saved_peer_list_file_name[] = "p2pool_peers.txt";
static const char* seed_nodes[] = { "seeds.p2pool.io", "main.p2poolpeers.net", "main.gupax.io", "" };
static const char* seed_nodes_mini[] = { "seeds-mini.p2pool.io", "mini.p2poolpeers.net", "mini.gupax.io", "" };
static const char* seed_nodes_nano[] = { "seeds-nano.p2pool.io", "nano.p2poolpeers.net", "nano.gupax.io", ""};
static constexpr int DEFAULT_BACKLOG = 16;
static constexpr uint64_t DEFAULT_BAN_TIME = 600;
@@ -606,6 +607,9 @@ void P2PServer::load_peer_list()
else if (m_pool->side_chain().is_mini()) {
load_from_seed_nodes(seed_nodes_mini, DEFAULT_P2P_PORT_MINI);
}
else if (m_pool->side_chain().is_nano()) {
load_from_seed_nodes(seed_nodes_nano, DEFAULT_P2P_PORT_NANO);
}
}
// Finally load peers from p2pool_peers.txt
@@ -698,7 +702,7 @@ void P2PServer::load_monerod_peer_list()
#undef ERR_STR
const int port = m_pool->side_chain().is_mini() ? DEFAULT_P2P_PORT_MINI : DEFAULT_P2P_PORT;
const int port = m_pool->side_chain().is_mini() ? DEFAULT_P2P_PORT_MINI : (m_pool->side_chain().is_nano() ? DEFAULT_P2P_PORT_NANO : DEFAULT_P2P_PORT);
const SizeType n = white_list.Size();
@@ -802,29 +806,12 @@ void P2PServer::Peer::normalize()
}
}
void P2PServer::broadcast(const PoolBlock& block, const PoolBlock* parent)
P2PServer::Broadcast::Broadcast(const PoolBlock& block, const PoolBlock* parent)
{
// Don't broadcast blocks when shutting down
if (m_finished.load()) {
return;
}
Broadcast* data = this;
MinerData miner_data = m_pool->miner_data();
if (block.m_txinGenHeight + 2 < miner_data.height) {
LOGWARN(3, "Trying to broadcast a stale block " << block.m_sidechainId << " (mainchain height " << block.m_txinGenHeight << ", current height is " << miner_data.height << ')');
return;
}
if (block.m_txinGenHeight > miner_data.height + 2) {
LOGWARN(3, "Trying to broadcast a block " << block.m_sidechainId << " ahead on mainchain (mainchain height " << block.m_txinGenHeight << ", current height is " << miner_data.height << ')');
return;
}
Broadcast* data = new Broadcast{};
data->id = block.m_sidechainId;
data->received_timestamp = block.m_receivedTimestamp;
id = block.m_sidechainId;
received_timestamp = block.m_receivedTimestamp;
int outputs_offset, outputs_blob_size;
const std::vector<uint8_t> mainchain_data = block.serialize_mainchain_data(nullptr, nullptr, &outputs_offset, &outputs_blob_size);
@@ -891,6 +878,28 @@ void P2PServer::broadcast(const PoolBlock& block, const PoolBlock* parent)
data->ancestor_hashes.reserve(block.m_uncles.size() + 1);
data->ancestor_hashes = block.m_uncles;
data->ancestor_hashes.push_back(block.m_parent);
}
void P2PServer::broadcast(const PoolBlock& block, const PoolBlock* parent)
{
// Don't broadcast blocks when shutting down
if (m_finished.load()) {
return;
}
MinerData miner_data = m_pool->miner_data();
if (block.m_txinGenHeight + 2 < miner_data.height) {
LOGWARN(3, "Trying to broadcast a stale block " << block.m_sidechainId << " (mainchain height " << block.m_txinGenHeight << ", current height is " << miner_data.height << ')');
return;
}
if (block.m_txinGenHeight > miner_data.height + 2) {
LOGWARN(3, "Trying to broadcast a block " << block.m_sidechainId << " ahead on mainchain (mainchain height " << block.m_txinGenHeight << ", current height is " << miner_data.height << ')');
return;
}
Broadcast* data = new Broadcast(block, parent);
LOGINFO(5, "Broadcasting block " << block.m_sidechainId << " (height " << block.m_sidechainHeight << "): " << data->compact_blob.size() << '/' << data->pruned_blob.size() << '/' << data->blob.size() << " bytes (compact/pruned/full)");
+14 -11
View File
@@ -34,6 +34,7 @@ static_assert((P2P_BUF_SIZE & (P2P_BUF_SIZE - 1)) == 0, "P2P_BUF_SIZE is not a p
static constexpr size_t PEER_LIST_RESPONSE_MAX_PEERS = 16;
static constexpr int DEFAULT_P2P_PORT = 37889;
static constexpr int DEFAULT_P2P_PORT_MINI = 37888;
static constexpr int DEFAULT_P2P_PORT_NANO = 37890;
static constexpr uint32_t PROTOCOL_VERSION_1_0 = 0x00010000UL;
static constexpr uint32_t PROTOCOL_VERSION_1_1 = 0x00010001UL;
@@ -167,6 +168,19 @@ public:
};
};
struct Broadcast
{
Broadcast(const PoolBlock& block, const PoolBlock* parent);
hash id;
uint64_t received_timestamp;
std::vector<uint8_t> blob;
std::vector<uint8_t> pruned_blob;
std::vector<uint8_t> compact_blob;
std::vector<hash> ancestor_hashes;
};
void broadcast(const PoolBlock& block, const PoolBlock* parent);
[[nodiscard]] uint64_t get_random64();
[[nodiscard]] uint64_t get_peerId() const { return m_peerId; }
@@ -261,17 +275,6 @@ private:
std::vector<Peer> m_peerListMonero;
std::atomic<uint64_t> m_peerListLastSaved;
struct Broadcast
{
hash id;
uint64_t received_timestamp;
std::vector<uint8_t> blob;
std::vector<uint8_t> pruned_blob;
std::vector<uint8_t> compact_blob;
std::vector<hash> ancestor_hashes;
};
uv_mutex_t m_broadcastLock;
uv_async_t m_broadcastAsync;
std::vector<Broadcast*> m_broadcastQueue;
+132 -31
View File
@@ -49,8 +49,6 @@
LOG_CATEGORY(P2Pool)
constexpr int BLOCK_HEADERS_REQUIRED = 720;
constexpr uint64_t SEEDHASH_EPOCH_BLOCKS = 2048;
constexpr uint64_t SEEDHASH_EPOCH_LAG = 64;
@@ -58,6 +56,8 @@ constexpr char FOUND_BLOCKS_FILE[] = "p2pool.blocks";
namespace p2pool {
static uint64_t BLOCK_HEADERS_REQUIRED = 720;
p2pool::p2pool(int argc, char* argv[])
: m_stopped(false)
, m_updateSeed(true)
@@ -78,6 +78,11 @@ p2pool::p2pool(int argc, char* argv[])
m_params = p;
// P2Pool-nano requires more Monero blocks for the initial sync
if (m_params->m_nano) {
BLOCK_HEADERS_REQUIRED = 1440;
}
bkg_jobs_tracker = new BackgroundJobTracker();
#ifdef WITH_UPNP
@@ -175,10 +180,10 @@ p2pool::p2pool(int argc, char* argv[])
throw std::exception();
}
m_sideChain = new SideChain(this, type, p->m_mini ? "mini" : nullptr);
m_sideChain = new SideChain(this, type, p->m_mini ? "mini" : (p->m_nano ? "nano" : nullptr));
if (p->m_p2pAddresses.empty()) {
const int p2p_port = m_sideChain->is_mini() ? DEFAULT_P2P_PORT_MINI : DEFAULT_P2P_PORT;
const int p2p_port = m_sideChain->is_mini() ? DEFAULT_P2P_PORT_MINI : (m_sideChain->is_nano() ? DEFAULT_P2P_PORT_NANO : DEFAULT_P2P_PORT);
char buf[48] = {};
log::Stream s(buf);
@@ -385,7 +390,7 @@ void p2pool::handle_tx(TxMempoolData& tx)
void p2pool::handle_miner_data(MinerData& data)
{
#if TEST_MEMPOOL_PICKING_ALGORITHM
if (m_mempool->m_transactions.size() < data.tx_backlog.size()) {
if (m_mempool->size() < data.tx_backlog.size()) {
m_mempool->swap(data.tx_backlog);
}
#else
@@ -664,7 +669,7 @@ void p2pool::update_aux_data(const hash& chain_id)
aux_id.emplace_back(c.aux_id);
}
}
else {
else if (mm_donation_params_last_updated) {
LOGINFO(5, "update_aux_data: merge mining donation data is stale, not using it");
}
#endif
@@ -711,6 +716,8 @@ void p2pool::update_aux_data(const hash& chain_id)
#if defined(WITH_MERGE_MINING_DONATION) && defined(WITH_TLS)
send_aux_job_donation();
#endif
api_update_aux_data();
}
}
@@ -1148,7 +1155,7 @@ void p2pool::update_block_template()
#endif
}
void p2pool::download_block_headers(uint64_t current_height)
void p2pool::download_block_headers1(uint64_t current_height)
{
const uint64_t seed_height = get_seed_height(current_height);
const uint64_t prev_seed_height = (seed_height > SEEDHASH_EPOCH_BLOCKS) ? (seed_height - SEEDHASH_EPOCH_BLOCKS) : 0;
@@ -1158,37 +1165,107 @@ void p2pool::download_block_headers(uint64_t current_height)
const Params::Host& host = current_host();
// First download 2 RandomX seeds
const uint64_t seed_heights[2] = { prev_seed_height, seed_height };
for (uint64_t height : seed_heights) {
s.m_pos = 0;
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_header_by_height\",\"params\":{\"height\":" << prev_seed_height << "}}\0";
JSONRPCRequest::call(host.m_address, host.m_rpcPort, buf, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint,
[this, prev_seed_height, current_height](const char* data, size_t size, double) {
ChainMain block;
if (parse_block_header(data, size, block)) {
// Do it synchronously to make sure stratum and p2p don't start before it's finished
m_hasher->set_old_seed(block.id);
download_block_headers2(current_height);
}
else {
LOGERR(1, "fatal error: couldn't download block header for seed height " << prev_seed_height);
download_block_headers1(current_height);
}
},
[this, prev_seed_height, current_height](const char* data, size_t size, double) {
if (size > 0) {
LOGERR(1, "fatal error: couldn't download block header for seed height " << prev_seed_height << ", error " << log::const_buf(data, size));
download_block_headers1(current_height);
}
});
}
void p2pool::download_block_headers2(uint64_t current_height)
{
const uint64_t seed_height = get_seed_height(current_height);
char buf[log::Stream::BUF_SIZE + 1] = {};
log::Stream s(buf);
const Params::Host& host = current_host();
s.m_pos = 0;
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_header_by_height\",\"params\":{\"height\":" << seed_height << "}}\0";
JSONRPCRequest::call(host.m_address, host.m_rpcPort, buf, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint,
[this, seed_height, current_height](const char* data, size_t size, double) {
ChainMain block;
if (parse_block_header(data, size, block)) {
const uint64_t start_height = (current_height > BLOCK_HEADERS_REQUIRED) ? (current_height - BLOCK_HEADERS_REQUIRED) : 0;
download_block_headers3(start_height, current_height);
}
else {
LOGERR(1, "fatal error: couldn't download block header for seed height " << seed_height);
download_block_headers2(current_height);
}
},
[this, seed_height, current_height](const char* data, size_t size, double) {
if (size > 0) {
LOGERR(1, "fatal error: couldn't download block header for seed height " << seed_height << ", error " << log::const_buf(data, size));
download_block_headers2(current_height);
}
});
}
void p2pool::download_block_headers3(uint64_t start_height, uint64_t current_height)
{
// Workaround the restricted RPC limit
constexpr uint64_t RESTRICTED_BLOCK_HEADER_RANGE = 1000;
if (current_height - start_height > RESTRICTED_BLOCK_HEADER_RANGE + 1) {
char buf[log::Stream::BUF_SIZE + 1] = {};
log::Stream s(buf);
const Params::Host& host = current_host();
const uint64_t next_height = start_height + RESTRICTED_BLOCK_HEADER_RANGE;
s.m_pos = 0;
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_header_by_height\",\"params\":{\"height\":" << height << "}}\0";
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_headers_range\",\"params\":{\"start_height\":" << start_height << ",\"end_height\":" << next_height << "}}\0";
JSONRPCRequest::call(host.m_address, host.m_rpcPort, buf, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint,
[this, prev_seed_height, height](const char* data, size_t size, double)
{
ChainMain block;
if (parse_block_header(data, size, block)) {
if (height == prev_seed_height) {
// Do it synchronously to make sure stratum and p2p don't start before it's finished
m_hasher->set_old_seed(block.id);
}
[this, start_height, next_height, host, current_height](const char* data, size_t size, double) {
if (parse_block_headers_range(data, size) == next_height - start_height + 1) {
download_block_headers3(next_height + 1, current_height);
}
else {
LOGERR(1, "fatal error: couldn't download block header for seed height " << height);
PANIC_STOP();
LOGERR(1, "Couldn't download block headers for heights " << start_height << " - " << next_height);
download_block_headers3(start_height, current_height);
}
},
[height](const char* data, size_t size, double)
{
[this, start_height, next_height, current_height](const char* data, size_t size, double) {
if (size > 0) {
LOGERR(1, "fatal error: couldn't download block header for seed height " << height << ", error " << log::const_buf(data, size));
PANIC_STOP();
LOGERR(1, "Couldn't download block headers for heights " << start_height << " - " << next_height << ", error " << log::const_buf(data, size));
download_block_headers3(start_height, current_height);
}
});
}
);
}
else {
download_block_headers4(start_height, current_height);
}
}
const uint64_t start_height = (current_height > BLOCK_HEADERS_REQUIRED) ? (current_height - BLOCK_HEADERS_REQUIRED) : 0;
void p2pool::download_block_headers4(uint64_t start_height, uint64_t current_height)
{
char buf[log::Stream::BUF_SIZE + 1] = {};
log::Stream s(buf);
const Params::Host& host = current_host();
s.m_pos = 0;
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_headers_range\",\"params\":{\"start_height\":" << start_height << ",\"end_height\":" << current_height - 1 << "}}\0";
@@ -1251,14 +1328,14 @@ void p2pool::download_block_headers(uint64_t current_height)
}
else {
LOGERR(1, "Couldn't download block headers for heights " << start_height << " - " << current_height - 1);
download_block_headers(current_height);
download_block_headers4(start_height, current_height);
}
},
[this, start_height, current_height](const char* data, size_t size, double)
{
if (size > 0) {
LOGERR(1, "Couldn't download block headers for heights " << start_height << " - " << current_height - 1 << ", error " << log::const_buf(data, size));
download_block_headers(current_height);
download_block_headers4(start_height, current_height);
}
});
}
@@ -1610,7 +1687,7 @@ void p2pool::parse_get_miner_data_rpc(const char* data, size_t size)
handle_miner_data(minerData);
if (m_serversStarted.load() == 0) {
download_block_headers(minerData.height);
download_block_headers1(minerData.height);
}
}
@@ -1864,7 +1941,7 @@ void p2pool::cleanup_mainchain_data(uint64_t height)
// Expects m_mainchainLock to be already locked here
// Deletes everything older than 720 blocks, except for the 3 latest RandomX seed heights
constexpr uint64_t PRUNE_DISTANCE = BLOCK_HEADERS_REQUIRED;
const uint64_t PRUNE_DISTANCE = BLOCK_HEADERS_REQUIRED;
const uint64_t seed_height = get_seed_height(height);
const std::array<uint64_t, 3> seed_heights{ seed_height, seed_height - SEEDHASH_EPOCH_BLOCKS, seed_height - SEEDHASH_EPOCH_BLOCKS * 2 };
@@ -1949,6 +2026,30 @@ void p2pool::on_external_block(const PoolBlock& block)
}
}
void p2pool::api_update_aux_data()
{
if (!m_api || !m_params->m_localStats || m_stopped) {
return;
}
m_api->set(p2pool_api::Category::LOCAL, "merge_mining",
[this](log::Stream& s)
{
s << "{\"chains\":[";
{
ReadLock lock(m_mergeMiningClientsLock);
for (size_t i = 0, n = m_mergeMiningClients.size(); i < n; ++i) {
if (i > 0) {
s << ',';
}
m_mergeMiningClients[i]->api_status(s);
}
}
s << "]}";
});
}
bool p2pool::get_difficulty_at_height(uint64_t height, difficulty_type& diff)
{
ReadLock lock(m_mainchainLock);
+7 -1
View File
@@ -112,13 +112,19 @@ public:
void update_block_template_async(bool is_alternative_block = false);
void update_block_template();
void download_block_headers(uint64_t current_height);
// TODO refactor this bullshit later
void download_block_headers1(uint64_t current_height);
void download_block_headers2(uint64_t current_height);
void download_block_headers3(uint64_t start_height, uint64_t current_height);
void download_block_headers4(uint64_t start_height, uint64_t current_height);
bool chainmain_get_by_hash(const hash& id, ChainMain& data) const;
void api_update_block_found(const ChainMain* data, const PoolBlock* block, bool update_stats_mod = true);
void on_external_block(const PoolBlock& block);
void api_update_aux_data();
bool get_difficulty_at_height(uint64_t height, difficulty_type& diff);
#ifdef WITH_RANDOMX
+11 -6
View File
@@ -64,11 +64,11 @@ p2pool_api::p2pool_api(const std::string& api_path, const bool local_stats)
m_poolPath = m_apiPath + "pool/";
m_localPath = m_apiPath + "local/";
create_dir(m_networkPath);
create_dir(m_poolPath);
create_dir(m_networkPath, false);
create_dir(m_poolPath, false);
if (local_stats) {
create_dir(m_localPath);
create_dir(m_localPath, true);
}
}
@@ -77,14 +77,16 @@ p2pool_api::~p2pool_api()
uv_mutex_destroy(&m_dumpDataLock);
}
void p2pool_api::create_dir(const std::string& path)
void p2pool_api::create_dir(const std::string& path, bool is_restricted)
{
(void) is_restricted;
#ifdef _MSC_VER
int result = _mkdir(path.c_str());
#else
int result = mkdir(path.c_str()
#ifndef _WIN32
, 0775
, is_restricted ? 0750 : 0775
#endif
);
#endif
@@ -169,7 +171,10 @@ void p2pool_api::dump_to_file()
#endif
;
const int result = uv_fs_open(uv_default_loop_checked(), &work->req, work->tmp_name.c_str(), flags, 0644, on_fs_open);
// LOCAL category has restricted access
const int mode = (work->tmp_name.find(m_localPath) == 0) ? 0640 : 0644;
const int result = uv_fs_open(uv_default_loop_checked(), &work->req, work->tmp_name.c_str(), flags, mode, on_fs_open);
if (result < 0) {
LOGWARN(4, "failed to open " << work->tmp_name << ", error " << uv_err_name(result));
delete work;
+1 -1
View File
@@ -41,7 +41,7 @@ public:
void set(Category category, const char* filename, T&& callback) { dump_to_file_async_internal(category, filename, Callback<void, log::Stream&>::Derived<T>(std::move(callback))); }
private:
void create_dir(const std::string& path);
void create_dir(const std::string& path, bool is_restricted);
static void on_dump_to_file(uv_async_t* async) { reinterpret_cast<p2pool_api*>(async->data)->dump_to_file(); }
+26
View File
@@ -26,6 +26,9 @@ void p2pool_usage();
namespace p2pool {
static constexpr uint64_t MIN_STRATUM_BAN_TIME = UINT64_C(1);
static constexpr uint64_t MAX_STRATUM_BAN_TIME = (UINT64_C(1) << 34) - 1;
Params::Params(int argc, char* const argv[])
{
for (int i = 1; i < argc; ++i) {
@@ -79,6 +82,11 @@ Params::Params(int argc, char* const argv[])
ok = true;
}
if ((strcmp(argv[i], "--stratum-ban-time") == 0) && (i + 1 < argc)) {
m_stratumBanTime = strtoull(argv[++i], nullptr, 10);
ok = true;
}
if ((strcmp(argv[i], "--p2p") == 0) && (i + 1 < argc)) {
m_p2pAddresses = argv[++i];
ok = true;
@@ -153,6 +161,11 @@ Params::Params(int argc, char* const argv[])
ok = true;
}
if (strcmp(argv[i], "--nano") == 0) {
m_nano = true;
ok = true;
}
if (strcmp(argv[i], "--no-autodiff") == 0) {
m_autoDiff = false;
ok = true;
@@ -279,6 +292,14 @@ Params::Params(int argc, char* const argv[])
m_stratumAddresses = buf;
}
if(m_stratumBanTime < MIN_STRATUM_BAN_TIME) {
LOGWARN(1, "Value for --stratum-ban-time is too low, adjusting to " << MIN_STRATUM_BAN_TIME);
m_stratumBanTime = MIN_STRATUM_BAN_TIME;
} else if(m_stratumBanTime > MAX_STRATUM_BAN_TIME) {
LOGWARN(1, "Value for --stratum-ban-time is too high, adjusting to " << MAX_STRATUM_BAN_TIME);
m_stratumBanTime = MAX_STRATUM_BAN_TIME;
}
}
bool Params::valid() const
@@ -300,6 +321,11 @@ bool Params::valid() const
}
#endif
if (m_mini && m_nano) {
LOGERR(1, "You can't have both --mini and --nano in the command line");
return false;
}
return true;
}
+4
View File
@@ -21,6 +21,8 @@
namespace p2pool {
static constexpr uint64_t DEFAULT_STRATUM_BAN_TIME = 600;
struct Params
{
Params(int argc, char* const argv[]);
@@ -74,6 +76,7 @@ struct Params
std::string m_p2pPeerList;
std::string m_sidechainConfig;
std::string m_apiPath;
uint64_t m_stratumBanTime = DEFAULT_STRATUM_BAN_TIME;
bool m_localStats = false;
bool m_blockCache = true;
#ifdef WITH_RANDOMX
@@ -85,6 +88,7 @@ struct Params
uint32_t m_maxIncomingPeers = 450;
uint32_t m_minerThreads = 0;
bool m_mini = false;
bool m_nano = false;
bool m_autoDiff = true;
std::string m_socks5Proxy;
bool m_dns = true;
+1 -1
View File
@@ -389,8 +389,8 @@ bool PoolBlock::get_pow_hash(RandomX_Hasher_Base* hasher, uint64_t height, const
root_hash tmp_root;
merkle_hash(m_transactions, tmp_root);
memcpy(blob + blob_size, tmp_root.h, HASH_SIZE);
blob_size += HASH_SIZE;
}
blob_size += HASH_SIZE;
writeVarint(count, [&blob, &blob_size](uint8_t b) { blob[blob_size++] = b; });
+6
View File
@@ -115,6 +115,12 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
uint64_t reward;
READ_VARINT(reward);
// TxOutput max value check
if (reward >= (1ULL << 56)) {
return __LINE__;
}
t.m_reward = reward;
total_reward += reward;
+1 -1
View File
@@ -84,7 +84,7 @@ RandomX_Hasher::RandomX_Hasher(p2pool* pool)
memory_allocated = (memory_allocated + (1 << 20) - 1) >> 20;
LOGINFO(1, "allocated " << memory_allocated << " MB");
LOGINFO(1, "allocated " << memory_allocated << " MiB");
}
RandomX_Hasher::~RandomX_Hasher()
+35 -4
View File
@@ -57,6 +57,7 @@ namespace p2pool {
static constexpr uint8_t default_consensus_id[HASH_SIZE] = { 34,175,126,231,181,11,104,146,227,153,218,107,44,108,68,39,178,81,4,212,169,4,142,0,177,110,157,240,68,7,249,24 };
static constexpr uint8_t mini_consensus_id[HASH_SIZE] = { 57,130,201,26,149,174,199,250,66,80,189,18,108,216,194,220,136,23,63,24,64,113,221,44,219,86,39,163,53,24,126,196 };
static constexpr uint8_t nano_consensus_id[HASH_SIZE] = { 171,248,206,148,210,226,114,99,250,145,221,96,13,216,23,63,104,53,129,168,244,80,141,138,157,250,50,54,37,189,5,89 };
NetworkType SideChain::s_networkType = NetworkType::Invalid;
@@ -84,6 +85,11 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name)
LOGINFO(1, log::LightCyan() << "network type = " << type);
if (m_poolName == "nano") {
m_targetBlockTime = 30;
m_unclePenalty = 10;
}
if (m_pool && !load_config(m_pool->params().m_sidechainConfig)) {
PANIC_STOP();
}
@@ -118,6 +124,7 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name)
constexpr char default_config[] = "mainnet\0" "default\0" "\0" "10\0" "100000\0" "2160\0" "20\0";
constexpr char mini_config[] = "mainnet\0" "mini\0" "\0" "10\0" "100000\0" "2160\0" "20\0";
constexpr char nano_config[] = "mainnet\0" "nano\0" "\0" "30\0" "100000\0" "2160\0" "10\0";
// Hardcoded default consensus ID
if ((s.m_pos == sizeof(default_config) - 1) && (memcmp(buf, default_config, sizeof(default_config) - 1) == 0)) {
@@ -127,6 +134,10 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name)
else if ((s.m_pos == sizeof(mini_config) - 1) && (memcmp(buf, mini_config, sizeof(mini_config) - 1) == 0)) {
m_consensusId.assign(mini_consensus_id, mini_consensus_id + HASH_SIZE);
}
// Hardcoded nano consensus ID
else if ((s.m_pos == sizeof(nano_config) - 1) && (memcmp(buf, nano_config, sizeof(nano_config) - 1) == 0)) {
m_consensusId.assign(nano_consensus_id, nano_consensus_id + HASH_SIZE);
}
else {
#ifdef WITH_RANDOMX
const randomx_flags flags = randomx_get_flags();
@@ -1062,7 +1073,7 @@ void SideChain::print_status(bool obtain_sidechain_lock) const
"\nMonero node = " << m_pool->current_host().m_displayName <<
"\nMain chain height = " << m_pool->block_template().height() <<
"\nMain chain hashrate = " << log::Hashrate(network_hashrate) <<
"\nSide chain ID = " << (is_default() ? "default" : (is_mini() ? "mini" : m_consensusIdDisplayStr.c_str())) <<
"\nSide chain ID = " << (is_default() ? "default" : (is_mini() ? "mini" : (is_nano() ? "nano" : m_consensusIdDisplayStr.c_str()))) <<
"\nSide chain height = " << tip_height + 1 <<
"\nSide chain hashrate = " << log::Hashrate(pool_hashrate) <<
(hashrate_est ? "\nYour hashrate (pool-side) = " : "") << (hashrate_est ? log::Hashrate(hashrate_est) : log::Hashrate()) <<
@@ -1185,6 +1196,11 @@ bool SideChain::is_mini() const
return (memcmp(m_consensusId.data(), mini_consensus_id, HASH_SIZE) == 0);
}
bool SideChain::is_nano() const
{
return (memcmp(m_consensusId.data(), nano_consensus_id, HASH_SIZE) == 0);
}
uint64_t SideChain::bottom_height(const PoolBlock* tip) const
{
if (!tip) {
@@ -1428,9 +1444,24 @@ void SideChain::verify_loop(PoolBlock* block)
continue;
}
const std::vector<PoolBlock*>& next_blocks = it->second;
if (!next_blocks.empty()) {
blocks_to_verify.insert(blocks_to_verify.end(), next_blocks.begin(), next_blocks.end());
for (PoolBlock* b : it->second) {
if ((i == 1) && (b->m_parent == block->m_sidechainId)) {
// Update depth if needed
if (b->m_depth + 1 < block->m_depth) {
b->m_depth = block->m_depth - 1;
}
blocks_to_verify.push_back(b);
}
else for (const hash& h : b->m_uncles) {
if (h == block->m_sidechainId) {
// Update depth if needed
if (b->m_depth + i < block->m_depth) {
b->m_depth = block->m_depth - i;
}
blocks_to_verify.push_back(b);
break;
}
}
}
}
}
+1 -1
View File
@@ -29,7 +29,6 @@ class P2PServer;
struct MinerShare
{
FORCEINLINE MinerShare() : m_weight(), m_wallet(nullptr) {}
FORCEINLINE MinerShare(const difficulty_type& w, const Wallet* x) : m_weight(w), m_wallet(x) {}
FORCEINLINE bool operator==(const MinerShare& s) const { return *m_wallet == *s.m_wallet; }
@@ -79,6 +78,7 @@ public:
[[nodiscard]] uint64_t last_updated() const;
[[nodiscard]] bool is_default() const;
[[nodiscard]] bool is_mini() const;
[[nodiscard]] bool is_nano() const;
[[nodiscard]] uint64_t bottom_height(const PoolBlock* tip) const;
[[nodiscard]] const PoolBlock* chainTip() const { return m_chainTip; }
+39 -6
View File
@@ -29,7 +29,6 @@
LOG_CATEGORY(StratumServer)
static constexpr int DEFAULT_BACKLOG = 128;
static constexpr uint64_t DEFAULT_BAN_TIME = 600;
static constexpr uint64_t MIN_DIFF = 1000;
static constexpr uint64_t AUTO_DIFF_TARGET_TIME = 30;
@@ -58,6 +57,7 @@ StratumServer::StratumServer(p2pool* pool)
, m_cumulativeFoundSharesDiff(0.0)
, m_totalFoundSidechainShares(0)
, m_totalFailedSidechainShares(0)
, m_lastSidechainShareFoundTime(0)
, m_totalStratumShares(0)
, m_apiLastUpdateTime(0)
{
@@ -84,6 +84,7 @@ StratumServer::StratumServer(p2pool* pool)
m_showWorkersAsync.data = this;
const Params& params = pool->params();
m_banTime = params.m_stratumBanTime;
start_listening(params.m_stratumAddresses, params.m_upnp && params.m_upnpStratum);
}
@@ -112,6 +113,7 @@ void StratumServer::on_block(const BlockTemplate& block)
const uint32_t num_connections = m_numConnections;
if (num_connections == 0) {
LOGINFO(4, "no clients connected");
update_hashrate_data(0, seconds_since_epoch());
api_update_local_stats(seconds_since_epoch());
return;
}
@@ -185,6 +187,7 @@ void StratumServer::on_block(const BlockTemplate& block)
}
}
update_hashrate_data(0, seconds_since_epoch());
api_update_local_stats(seconds_since_epoch());
}
@@ -601,6 +604,7 @@ void StratumServer::reset_share_counters()
m_cumulativeHashesAtLastShare = m_cumulativeHashes;
m_totalFoundSidechainShares = 0;
m_totalFailedSidechainShares = 0;
m_lastSidechainShareFoundTime = 0;
}
bool StratumServer::http_enabled() const
@@ -791,7 +795,7 @@ void StratumServer::on_blobs_ready()
// Not logged in yet, on_login() will send the job to this client. Also close inactive connections.
if (cur_time >= client->m_connectedTime + 10) {
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " didn't send login data");
client->ban(DEFAULT_BAN_TIME);
client->ban(m_banTime);
client->close();
}
continue;
@@ -891,6 +895,26 @@ void StratumServer::update_hashrate_data(uint64_t hashes, uint64_t timestamp)
if (hashes) {
m_cumulativeHashes += hashes;
++m_totalStratumShares;
// P2Pool-nano warning
#ifndef P2POOL_LOG_DISABLE
// Check the hashrate when enough shares is found
if (((m_totalStratumShares & 63) == 0) && m_pool->side_chain().is_nano()) {
const HashrateData& head = m_hashrateData[m_hashrateDataHead];
const HashrateData& tail = m_hashrateData[m_hashrateDataTail_24h];
const int64_t dt = static_cast<int64_t>(head.m_timestamp - tail.m_timestamp);
if (dt > 0) {
const uint64_t total_hashes = head.m_cumulativeHashes - tail.m_cumulativeHashes;
const uint64_t hashrate = total_hashes / dt;
if (hashrate > 30000) {
LOGINFO(0, log::LightRed() << "Your hashrate is " << log::Hashrate(hashrate) << ". Please switch from P2Pool-nano to P2Pool-mini or P2Pool-main. P2Pool-nano is recommended only for small-scale miners.");
}
}
}
#endif // P2POOL_LOG_DISABLE
}
HashrateData* data = m_hashrateData;
@@ -985,6 +1009,8 @@ void StratumServer::on_share_found(uv_work_t* req)
share->m_score = GOOD_SHARE_POINTS;
const double diff = sidechain_difficulty.to_double();
time_t prev_time;
const time_t cur_time = time(nullptr);
{
WriteLock lock(server->m_hashrateDataLock);
@@ -994,6 +1020,9 @@ void StratumServer::on_share_found(uv_work_t* req)
server->m_cumulativeFoundSharesDiff += diff;
++server->m_totalFoundSidechainShares;
prev_time = server->m_lastSidechainShareFoundTime;
server->m_lastSidechainShareFoundTime = cur_time;
}
if (!pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
@@ -1002,6 +1031,7 @@ void StratumServer::on_share_found(uv_work_t* req)
if (server->m_totalFoundSidechainShares > 0) {
--server->m_totalFoundSidechainShares;
++server->m_totalFailedSidechainShares;
server->m_lastSidechainShareFoundTime = prev_time;
}
}
}
@@ -1086,7 +1116,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
client->m_score += share->m_score;
if (bad_share && (client->m_score <= BAN_THRESHOLD_POINTS)) {
client->ban(DEFAULT_BAN_TIME);
client->ban(server->m_banTime);
client->close();
}
else if (!result) {
@@ -1094,7 +1124,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
}
}
else if (bad_share) {
server->ban(share->m_clientIPv6, share->m_clientAddr, DEFAULT_BAN_TIME);
server->ban(share->m_clientIPv6, share->m_clientAddr, server->m_banTime);
}
if (share->m_allocated) {
@@ -1204,7 +1234,7 @@ bool StratumServer::StratumClient::on_read(const char* data, uint32_t size)
auto on_parse = [this](const char* data, uint32_t size) {
if (static_cast<size_t>(m_stratumReadBufBytes) + size > STRATUM_BUF_SIZE) {
LOGWARN(4, "client " << static_cast<const char*>(m_addrString) << " sent too long Stratum message");
ban(DEFAULT_BAN_TIME);
ban(static_cast<StratumServer*>(m_owner)->m_banTime);
return false;
}
@@ -1232,7 +1262,7 @@ bool StratumServer::StratumClient::on_read(const char* data, uint32_t size)
*c = '\0';
if (!process_request(line_start, static_cast<uint32_t>(c - line_start))) {
ban(DEFAULT_BAN_TIME);
ban(static_cast<StratumServer*>(m_owner)->m_banTime);
return false;
}
@@ -1474,6 +1504,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
uint64_t hashes_since_last_share;
double average_effort;
uint32_t shares_found, shares_failed;
time_t last_share_found_time;
uint64_t total_stratum_shares;
{
@@ -1505,6 +1536,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
shares_found = m_totalFoundSidechainShares;
shares_failed = m_totalFailedSidechainShares;
last_share_found_time = m_lastSidechainShareFoundTime;
total_stratum_shares = m_totalStratumShares;
}
@@ -1526,6 +1558,7 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
<< ",\"hashrate_24h\":" << hashrate_24h
<< ",\"total_hashes\":" << total_hashes
<< ",\"total_stratum_shares\":" << total_stratum_shares
<< ",\"last_share_found_time\":" << last_share_found_time
<< ",\"shares_found\":" << shares_found
<< ",\"shares_failed\":" << shares_failed
<< ",\"average_effort\":" << average_effort
+3
View File
@@ -203,8 +203,11 @@ private:
double m_cumulativeFoundSharesDiff;
uint32_t m_totalFoundSidechainShares;
uint32_t m_totalFailedSidechainShares;
time_t m_lastSidechainShareFoundTime;
uint64_t m_totalStratumShares;
uint64_t m_banTime;
std::atomic<uint64_t> m_apiLastUpdateTime;
std::deque<SubmittedShare*> m_pendingShareChecks;
+2 -2
View File
@@ -1148,7 +1148,7 @@ bool TCPServer::Client::on_proxy_handshake(const char* data, uint32_t size)
switch (m_socks5ProxyState) {
case Socks5ProxyState::MethodSelectionSent:
if (m_numRead >= 2) {
if ((m_readBuf[0] != 5) && (m_readBuf[1] != 0)) {
if ((m_readBuf[0] != 5) || (m_readBuf[1] != 0)) {
LOGWARN(5, "SOCKS5 proxy returned an invalid METHOD selection message");
return false;
}
@@ -1192,7 +1192,7 @@ bool TCPServer::Client::on_proxy_handshake(const char* data, uint32_t size)
case Socks5ProxyState::ConnectRequestSent:
if (m_numRead >= 4) {
const uint8_t* p = reinterpret_cast<uint8_t*>(m_readBuf);
if ((p[0] != 5) && (p[1] != 0) && p[2] != 0) {
if ((p[0] != 5) || (p[1] != 0) || p[2] != 0) {
LOGWARN(5, "SOCKS5 proxy returned an invalid reply to CONNECT");
return false;
}
+9 -2
View File
@@ -35,8 +35,8 @@
namespace p2pool {
#define P2POOL_VERSION_MAJOR 4
#define P2POOL_VERSION_MINOR 6
#define P2POOL_VERSION_PATCH 0
#define P2POOL_VERSION_MINOR 8
#define P2POOL_VERSION_PATCH 1
constexpr uint32_t P2POOL_VERSION = (P2POOL_VERSION_MAJOR << 16) | (P2POOL_VERSION_MINOR << 8) | P2POOL_VERSION_PATCH;
@@ -175,6 +175,8 @@ template<> FORCEINLINE bool out_of_range<uint64_t>(uint64_t) { return false; }
template<typename T>
const uint8_t* readVarint(const uint8_t* data, const uint8_t* data_end, T& b)
{
static_assert(std::is_unsigned_v<T>, "readVarint works only with unsigned types");
uint64_t result = 0;
int k = 0;
@@ -184,6 +186,11 @@ const uint8_t* readVarint(const uint8_t* data, const uint8_t* data_end, T& b)
}
const uint64_t cur_byte = *(data++);
if (k && (cur_byte == 0)) {
return nullptr;
}
result |= (cur_byte & 0x7F) << k;
if ((k > 0) && (shiftleft128(cur_byte & 0x7F, 0, k) != 0)) {
+14 -2
View File
@@ -5,6 +5,12 @@ include(cmake/standard.cmake)
option(STATIC_LIBS "Use locally built libuv and libzmq static libs" OFF)
option(WITH_LTO "Use link-time compiler optimization (if linking fails for you, run cmake with -DWITH_LTO=OFF)" ON)
option(WITH_COVERAGE "Generate code coverage data" OFF)
option(DEV_DEBUG "[Developer only] Compile a debug build" OFF)
if (DEV_DEBUG)
add_definitions(-DDEV_DEBUG)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
@@ -22,8 +28,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
include(cmake/msvc_libs.cmake)
endif()
add_subdirectory(../external/src/RandomX RandomX)
set(LIBS ${LIBS} randomx)
if (STATIC_LIBS AND WIN32 AND (CMAKE_CXX_COMPILER_ID MATCHES Clang))
set(LIBS ${LIBS} "${CMAKE_SOURCE_DIR}/../build/external/src/RandomX/librandomx.a")
else()
add_subdirectory(../external/src/RandomX RandomX)
set(LIBS ${LIBS} randomx)
endif()
add_definitions(-DWITH_RANDOMX)
add_subdirectory(cmake/ssl)
@@ -208,3 +219,4 @@ add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMA
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/block.dat" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump.dat.gz" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump_mini.dat.gz" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump_nano.dat.gz" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
+22 -6
View File
@@ -1,10 +1,17 @@
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(GENERAL_FLAGS "-pthread")
set(WARNING_FLAGS "-Wall -Wextra")
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -s")
if (WITH_LTO)
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -flto=auto -fuse-linker-plugin")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(OPTIMIZATION_FLAGS "-O0 -g3")
if (WITH_COVERAGE)
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} --coverage")
endif()
else()
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -s")
if (WITH_LTO)
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -flto=auto -fuse-linker-plugin")
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
@@ -45,10 +52,19 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES Clang)
endif()
set(WARNING_FLAGS "-Wall -Wextra -Wno-undefined-internal")
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -fmerge-all-constants")
if (WITH_LTO)
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -flto")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(OPTIMIZATION_FLAGS "-O0 -g3")
else()
set(OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -fmerge-all-constants")
if (WITH_LTO)
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -flto")
endif()
endif()
if (WITH_COVERAGE)
set(OPTIMIZATION_FLAGS "${OPTIMIZATION_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERAL_FLAGS} ${WARNING_FLAGS} ${OPTIMIZATION_FLAGS}")
+154 -13
View File
@@ -26,6 +26,13 @@
namespace p2pool {
static hash H(const char* s)
{
hash result;
from_hex(s, strlen(s), result);
return result;
};
TEST(block_template, update)
{
init_crypto_cache();
@@ -34,15 +41,6 @@ TEST(block_template, update)
BlockTemplate tpl(&sidechain, nullptr);
tpl.rng().seed(123);
auto H = [](const char* s)
{
std::stringstream ss;
ss << s;
hash result;
ss >> result;
return result;
};
MinerData data;
data.major_version = 16;
data.height = 2762973;
@@ -58,6 +56,7 @@ TEST(block_template, update)
// Test 1: empty template
tpl.update(data, mempool, &wallet);
ASSERT_EQ(tpl.get_reward(), 600000000000ULL);
const PoolBlock* b = tpl.pool_block_template();
ASSERT_EQ(b->m_sidechainId, H("2c90c1926a75c81afd49bf4a4b63e9de7b4c153866411c47e7af864b547c23ec"));
@@ -68,7 +67,7 @@ TEST(block_template, update)
hash seed_hash;
size_t nonce_offset;
uint32_t template_id;
tpl.get_hashing_blobs(0, 10000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
tpl.get_hashing_blobs(0, 1000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
ASSERT_EQ(height, 2762973);
ASSERT_EQ(diff, 300346053753ULL);
@@ -79,7 +78,7 @@ TEST(block_template, update)
hash blobs_hash;
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
ASSERT_EQ(blobs_hash, H("c043b754d043b4f6fe3f70273a937c77ff75a5afba9a6ca92776e79da28a1165"));
ASSERT_EQ(blobs_hash, H("da11e1ee86779a559df63a55e0b238ce5a67b977e0f68a0b347a39d37096a4bc"));
// Test 2: mempool with high fee and low fee transactions, it must choose high fee transactions
for (uint64_t i = 0; i < 512; ++i) {
@@ -89,8 +88,10 @@ TEST(block_template, update)
tx.weight = 1500;
mempool.add(tx);
}
ASSERT_EQ(mempool.size(), 512);
tpl.update(data, mempool, &wallet);
ASSERT_EQ(tpl.get_reward(), 612054770773ULL);
ASSERT_EQ(b->m_sidechainId, H("c9df4853003ab436416b9fc9a5a072d16b4dede849e697a8be2ebb9c88c8ec72"));
ASSERT_EQ(b->m_transactions.size(), 203);
@@ -99,7 +100,7 @@ TEST(block_template, update)
ASSERT_GE(*reinterpret_cast<const uint64_t*>(b->m_transactions[i].h), 256);
}
tpl.get_hashing_blobs(0, 10000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
tpl.get_hashing_blobs(0, 1000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
ASSERT_EQ(height, 2762973);
ASSERT_EQ(diff, 300346053753ULL);
@@ -109,7 +110,147 @@ TEST(block_template, update)
ASSERT_EQ(template_id, 2U);
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
ASSERT_EQ(blobs_hash, H("f00e196216d160a4fcbf468f748205039d276d62edfa6c6fd4c81dbd1f62d9b7"));
ASSERT_EQ(blobs_hash, H("20aa6a98ca92bc4564bcdc367c078425d4b44b156c2bc7bb703ef055e4fd2c1b"));
// Test 3: small but not empty mempool, and aux chains
std::vector<TxMempoolData> transactions;
for (uint64_t i = 0; i < 10; ++i) {
TxMempoolData tx;
*reinterpret_cast<uint64_t*>(tx.id.h) = i;
tx.fee = 30000000;
tx.weight = 1500;
transactions.push_back(tx);
}
mempool.swap(transactions);
ASSERT_EQ(mempool.size(), 10);
data.aux_chains.emplace_back(H("01f0cf665bd4cd31cbb2b2470236389c483522b350335e10a4a5dca34cb85990"), H("d9de1cfba7cdbd47f12f77addcb39b24c1ae7a16c35372bf28d6aee5d7579ee6"), difficulty_type(1000000));
tpl.update(data, mempool, &wallet);
ASSERT_EQ(tpl.get_reward(), 600300000000ULL);
ASSERT_EQ(b->m_sidechainId, H("c32abac2cad40e263a94f5f43f90e0a7d7d4b151305b79951dbc8c88c3180613"));
ASSERT_EQ(b->m_transactions.size(), 11);
tpl.get_hashing_blobs(0, 1000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
ASSERT_EQ(height, 2762973);
ASSERT_EQ(diff, 300346053753ULL);
ASSERT_EQ(sidechain_diff, sidechain.difficulty());
ASSERT_EQ(seed_hash, data.seed_hash);
ASSERT_EQ(nonce_offset, 39U);
ASSERT_EQ(template_id, 3U);
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
ASSERT_EQ(blobs_hash, H("536c0ee8013718b174b63613939379939cee2267e803f77cdabb05fcb47e846f"));
// Test 4: mempool with a lot of transactions with various fees, all parts of transaction picking algorithm should be tested
mempool.clear();
std::mt19937_64 rng;
for (uint64_t i = 0; i < 10000; ++i) {
TxMempoolData tx;
*reinterpret_cast<uint64_t*>(tx.id.h) = i;
tx.weight = 1500 + (rng() % 10007);
tx.fee = 30000000 + (rng() % 100000007);
mempool.add(tx);
}
ASSERT_EQ(mempool.size(), 10000);
tpl.update(data, mempool, &wallet);
ASSERT_EQ(tpl.get_reward(), 619742028747ULL);
ASSERT_EQ(b->m_sidechainId, H("69e7dd43dd99ac6be3f57ca333cc0d814189e83aee1773c99a341aca085c0d46"));
ASSERT_EQ(b->m_transactions.size(), 174);
tpl.get_hashing_blobs(0, 1000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
ASSERT_EQ(height, 2762973);
ASSERT_EQ(diff, 300346053753ULL);
ASSERT_EQ(sidechain_diff, sidechain.difficulty());
ASSERT_EQ(seed_hash, data.seed_hash);
ASSERT_EQ(nonce_offset, 39U);
ASSERT_EQ(template_id, 4U);
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
ASSERT_EQ(blobs_hash, H("4f62562aa84400eb085f58447d8daa45257369f1ec046b2150212329c9e86ae4"));
destroy_crypto_cache();
}
TEST(block_template, submit_sidechain_block)
{
init_crypto_cache();
SideChain sidechain(nullptr, NetworkType::Mainnet, "unit_test");
ASSERT_EQ(sidechain.consensus_hash(), H("81d45b62c10afa4fdda7cebb02dd5ad82c43b577eb3fb0857824427c55fd8a8d"));
BlockTemplate tpl(&sidechain, nullptr);
tpl.rng().seed(123);
BlockTemplate tpl2(&sidechain, nullptr);
tpl2.rng().seed(456);
BlockTemplate tpl3(&sidechain, nullptr);
tpl3.rng().seed(789);
MinerData data;
data.major_version = 16;
data.height = 2762973;
data.prev_id = H("81a0260b29d5224e88d04b11faff321fbdc11c4570779386b2a1817a86dc622c");
data.seed_hash = H("33d0fb381466f04d6a1919ced3b698f54a28add3da5a6479b096c67df7a4974c");
data.difficulty = { 300346053753ULL, 0 };
data.median_weight = 300000;
data.already_generated_coins = 18204981557254756780ULL;
data.median_timestamp = (1ULL << 35) - (sidechain.chain_window_size() * 2 + 10) * sidechain.block_time() - 3600;
Mempool mempool;
Wallet wallet("44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg");
std::mt19937_64 rng(101112);
for (uint64_t i = 0, i2 = 0, i3 = 0; i < sidechain.chain_window_size() * 3; ++i) {
tpl.update(data, mempool, &wallet);
if ((rng() % 31) == 0) {
tpl2.update(data, mempool, &wallet);
if ((rng() % 11) == 0) {
tpl3.update(data, mempool, &wallet);
++i3;
ASSERT_TRUE(tpl3.submit_sidechain_block(i3, 0, 0));
}
++i2;
ASSERT_TRUE(tpl2.submit_sidechain_block(i2, 0, 0));
}
ASSERT_TRUE(tpl.submit_sidechain_block(i + 1, 0, 0));
data.median_timestamp += sidechain.block_time();
}
ASSERT_EQ(sidechain.difficulty(), 219467);
ASSERT_EQ(sidechain.blocksById().size(), 4487);
ASSERT_TRUE(sidechain.precalcFinished());
const PoolBlock* tip = sidechain.chainTip();
ASSERT_TRUE(tip != nullptr);
ASSERT_TRUE(tip->m_verified);
ASSERT_FALSE(tip->m_invalid);
ASSERT_EQ(tip->m_txinGenHeight, data.height);
ASSERT_EQ(tip->m_sidechainHeight, sidechain.chain_window_size() * 3 - 1);
ASSERT_EQ(tip->m_sidechainId, H("12d57571a28d62d2b6dca3a647500d23ac22864138b22a133f237b459a0862da"));
destroy_crypto_cache();
}
+20 -2
View File
@@ -27,8 +27,22 @@ TEST(crypto, derivation)
{
init_crypto_cache();
// Run the tests twice to check how crypto cache works
for (int i = 0; i < 2; ++i) {
hash pub, sec;
generate_keys(pub, sec);
ASSERT_TRUE(check_keys(pub, sec));
sec.h[HASH_SIZE - 1] = 0xff;
ASSERT_FALSE(check_keys(pub, sec));
// Run the tests several times to check how crypto cache works
for (int i = 0; i < 4; ++i) {
if (i == 2) {
clear_crypto_cache(seconds_since_epoch() - 1);
}
else if (i == 3) {
clear_crypto_cache(seconds_since_epoch() + 1);
}
std::ifstream f("crypto_tests.txt");
ASSERT_EQ(f.good() && f.is_open(), true);
do {
@@ -44,6 +58,9 @@ TEST(crypto, derivation)
}
uint8_t view_tag;
ASSERT_EQ(p2pool::generate_key_derivation(key1, key2, 0, derivation, view_tag), result);
ASSERT_EQ(p2pool::generate_key_derivation(key1, key2, 1, derivation, view_tag), result);
ASSERT_EQ(p2pool::generate_key_derivation(key1, key2, 2, derivation, view_tag), result);
ASSERT_EQ(p2pool::generate_key_derivation(key1, key2, 3, derivation, view_tag), result);
if (result) {
ASSERT_EQ(derivation, expected_derivation);
}
@@ -89,6 +106,7 @@ TEST(crypto, derivation)
} while (!f.eof());
}
clear_crypto_cache(0);
destroy_crypto_cache();
}
+18 -3
View File
@@ -416,12 +416,18 @@ TEST(difficulty_type, div128)
TEST(difficulty_type, compare)
{
const difficulty_type diff[4] = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
const difficulty_type diff[9] = {
{ 0, 0 }, { 1, 0 }, { 2, 0 },
{ 0, 1 }, { 1, 1 }, { 2, 1 },
{ 0, 2 }, { 1, 2 }, { 2, 2 },
};
for (int i = 0; i <= 3; ++i) {
for (int j = 0; j <= 3; ++j) {
for (int i = 0; i < 9; ++i) {
for (int j = 0; j < 9; ++j) {
ASSERT_EQ(diff[i] > diff[j], i > j);
ASSERT_EQ(diff[i] < diff[j], i < j);
ASSERT_EQ(diff[i] >= diff[j], i >= j);
ASSERT_EQ(diff[i] <= diff[j], i <= j);
ASSERT_EQ(diff[i] == diff[j], i == j);
ASSERT_EQ(diff[i] != diff[j], i != j);
}
@@ -451,6 +457,15 @@ TEST(difficulty_type, input_output)
test_value(7766279631452241921ull, 5, "100000000000000000001");
test_value(14083847773837265618ull, 6692605942ull, "123456789012345678901234567890");
test_value(std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max(), "340282366920938463463374607431768211455");
std::stringstream ss;
difficulty_type diff;
ss << "340599339356 test";
ss >> diff;
ASSERT_EQ(diff.lo, 340599339356ull);
ASSERT_EQ(diff.hi, 0ull);
}
TEST(difficulty_type, json_parser)
+17
View File
@@ -70,9 +70,19 @@ TEST(hash, input_output)
std::stringstream ss;
ss << h;
ASSERT_EQ(ss.str(), s);
hash h2;
ss >> h2;
ASSERT_EQ(h2, h);
hash h3;
ASSERT_TRUE(from_hex(s, strlen(s), h3));
ASSERT_EQ(h3, h);
std::vector<uint8_t> v;
ASSERT_TRUE(from_hex(s, strlen(s), v));
ASSERT_EQ(v.size(), HASH_SIZE);
ASSERT_EQ(memcmp(v.data(), h.h, HASH_SIZE), 0);
};
hash h;
@@ -90,6 +100,13 @@ TEST(hash, input_output)
h.h[i] = 0xff - i;
}
check(h, "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0");
ASSERT_FALSE(from_hex("123", 3, h));
ASSERT_FALSE(from_hex("000000000000000000000000000000000000000000000000000000000000000z", HASH_SIZE * 2, h));
std::vector<uint8_t> v;
ASSERT_FALSE(from_hex("123", 3, v));
ASSERT_FALSE(from_hex("000000000000000000000000000000000000000000000000000000000000000z", HASH_SIZE * 2, v));
}
TEST(hash, json_parser)
+1
View File
@@ -28,6 +28,7 @@ using namespace p2pool;
int main(int argc, char** argv)
{
set_main_thread();
p2pool_usage();
PoolBlock::s_precalculatedSharesLock = new ReadWriteLock();
+35
View File
@@ -93,6 +93,15 @@ TEST(merkle, tree)
auto check_full_tree = [&hashes, &root]() {
std::vector<std::vector<hash>> tree;
{
hash h;
std::vector<hash> proof;
uint32_t path;
ASSERT_FALSE(get_merkle_proof(tree, h, proof, path));
}
merkle_hash_full_tree(hashes, tree);
ASSERT_GE(tree.size(), 1);
@@ -127,12 +136,15 @@ TEST(merkle, tree)
}
}
const hash empty_hash;
for (size_t i = 0, n = hashes.size(); i < n; ++i) {
const hash& h = hashes[i];
std::vector<hash> proof;
uint32_t path;
ASSERT_TRUE(get_merkle_proof(tree, h, proof, path));
ASSERT_FALSE(get_merkle_proof(tree, empty_hash, proof, path));
uint32_t path_monero;
ASSERT_TRUE(tree_path(n, i, &path_monero));
@@ -140,10 +152,33 @@ TEST(merkle, tree)
ASSERT_TRUE(verify_merkle_proof(h, proof, i, n, root));
ASSERT_TRUE(verify_merkle_proof(h, proof, path, root));
ASSERT_FALSE(verify_merkle_proof(h, proof, n, n, root));
ASSERT_FALSE(verify_merkle_proof(empty_hash, proof, i, n, root));
ASSERT_FALSE(verify_merkle_proof(empty_hash, proof, path, root));
while (!proof.empty()) {
proof.pop_back();
ASSERT_FALSE(verify_merkle_proof(h, proof, i, n, root));
ASSERT_FALSE(verify_merkle_proof(h, proof, path, root));
}
ASSERT_EQ(get_position_from_path(n, path), i);
}
};
// 0 leaves
uint32_t path_monero;
ASSERT_FALSE(tree_path(0, 0, &path_monero));
merkle_hash(std::vector<hash>(), root);
ASSERT_TRUE(root.empty());
std::vector<std::vector<hash>> tree;
merkle_hash_full_tree(std::vector<hash>(), tree);
ASSERT_TRUE(tree.empty());
// 1 leaf
merkle_hash(hashes, root);
ASSERT_EQ(root, input[0]);
+80 -5
View File
@@ -20,6 +20,7 @@
#include "pool_block.h"
#include "pow_hash.h"
#include "side_chain.h"
#include "p2p_server.h"
#include "gtest/gtest.h"
#include <fstream>
@@ -53,9 +54,23 @@ TEST(pool_block, deserialize)
ASSERT_EQ(b.deserialize(buf.data(), buf.size(), sidechain, nullptr, false), 0);
{
const PoolBlock::full_id id = b.get_full_id();
ASSERT_EQ(memcmp(id.data(), b.m_sidechainId.h, HASH_SIZE), 0);
ASSERT_EQ(memcmp(id.data() + HASH_SIZE, &b.m_nonce, NONCE_SIZE), 0);
ASSERT_EQ(memcmp(id.data() + HASH_SIZE + NONCE_SIZE, &b.m_extraNonce, EXTRA_NONCE_SIZE), 0);
}
ASSERT_EQ(b.get_payout(Wallet("4B4aCvEcZr6GcusVJfEds2LXixCeJ2dQBaDUCguWmzi5L7PW5tVXfAnE4cn1mQdiNzH6zWcEPMQTiYTsNcX44ryxCJWZKZH")), 17411468548U);
ASSERT_EQ(b.get_payout(Wallet("43VbH7CQCJqhH1d327TBenCs9hFN3zvcgX5YZdGyJfEE5rabasAtKhyPsKmbYSU9AmMReACZrz9j5U2Ba6WXWoQpVi38AJn")), 1404738424U);
ASSERT_EQ(b.get_payout(Wallet("46r3PD45TYH9jVf8sEejW9JdK1EgNe6BeYLdGyJTU1MRctoevAHXpzSjBMJhdkLirGXwiWdZejSRZ8MZP72artSD17LprKY")), 1419699645U);
ASSERT_EQ(b.get_payout(Wallet("44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg")), 0U);
size_t header_size, miner_tx_size;
int outputs_offset, outputs_blob_size;
const std::vector<uint8_t> mainchain_data = b.serialize_mainchain_data(&header_size, &miner_tx_size, &outputs_offset, &outputs_blob_size);
const std::vector<uint8_t> sidechain_data = b.serialize_sidechain_data();
ASSERT_EQ(mainchain_data.size(), 1829U);
ASSERT_EQ(header_size, 43U);
@@ -103,6 +118,12 @@ TEST(pool_block, deserialize)
ASSERT_EQ(b.m_difficulty.check_pow(pow_hash), true);
// Test self-assignment
b = b;
ASSERT_EQ(b.serialize_mainchain_data(), mainchain_data);
ASSERT_EQ(b.serialize_sidechain_data(), sidechain_data);
destroy_crypto_cache();
}
@@ -116,18 +137,29 @@ TEST(pool_block, verify)
const char* m_fileName;
uint64_t m_txinGenHeight;
uint64_t m_sidechainHeight;
uint32_t m_expectedSharesNextBlock;
bool m_shuffle;
} tests[2] = {
{ "default", "sidechain_dump.dat", 3258121, 9443762, true },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, false },
} tests[6] = {
{ "default", "sidechain_dump.dat", 3258121, 9443762, 30, false },
{ "default", "sidechain_dump.dat", 3258121, 9443762, 30, true },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, 593, false },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, 593, true },
{ "nano", "sidechain_dump_nano.dat", 3438036, 116651, 131, false },
{ "nano", "sidechain_dump_nano.dat", 3438036, 116651, 131, true },
};
for (const STest& t : tests)
{
SideChain sidechain(nullptr, NetworkType::Mainnet, t.m_poolName);
// Difficulty of block 3256320
sidechain.m_testMainChainDiff = difficulty_type(374140388237ULL, 0ULL);
if (strcmp(t.m_poolName, "nano") == 0) {
// Difficulty of block 3436544
sidechain.m_testMainChainDiff = difficulty_type(568969201978ULL, 0ULL);
}
else {
// Difficulty of block 3256320
sidechain.m_testMainChainDiff = difficulty_type(374140388237ULL, 0ULL);
}
std::ifstream f(t.m_fileName, std::ios::binary | std::ios::ate);
ASSERT_EQ(f.good() && f.is_open(), true);
@@ -180,6 +212,49 @@ TEST(pool_block, verify)
ASSERT_EQ(tip->m_txinGenHeight, t.m_txinGenHeight);
ASSERT_EQ(tip->m_sidechainHeight, t.m_sidechainHeight);
PoolBlock block;
block.m_minerWallet.decode("44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg");
std::vector<MinerShare> shares;
sidechain.fill_sidechain_data(block, shares);
ASSERT_EQ(block.m_sidechainHeight, t.m_sidechainHeight + 1);
ASSERT_EQ(shares.size(), t.m_expectedSharesNextBlock);
const PoolBlock* parent = sidechain.find_block(tip->m_parent);
ASSERT_TRUE(parent != nullptr);
// Check pruned and compact broadcast blobs
auto tip_full_blob = tip->serialize_mainchain_data();
auto v2 = tip->serialize_sidechain_data();
tip_full_blob.insert(tip_full_blob.end(), v2.begin(), v2.end());
P2PServer::Broadcast broadcast(*tip, parent);
{
PoolBlock block2;
ASSERT_EQ(block2.deserialize(broadcast.pruned_blob.data(), broadcast.pruned_blob.size(), sidechain, nullptr, false), 0);
auto v1 = block2.serialize_mainchain_data();
v2 = block2.serialize_sidechain_data();
v1.insert(v1.end(), v2.begin(), v2.end());
ASSERT_EQ(v1, tip_full_blob);
}
if (!broadcast.compact_blob.empty()) {
PoolBlock block3;
ASSERT_EQ(block3.deserialize(broadcast.compact_blob.data(), broadcast.compact_blob.size(), sidechain, nullptr, true), 0);
auto v1 = block3.serialize_mainchain_data();
v2 = block3.serialize_sidechain_data();
v1.insert(v1.end(), v2.begin(), v2.end());
ASSERT_EQ(v1, tip_full_blob);
}
}
destroy_crypto_cache();
Binary file not shown.
+18
View File
@@ -80,6 +80,24 @@ TEST(util, varint)
// Invalid value 2
uint8_t buf2[1] = { 0x80 };
ASSERT_EQ(readVarint(buf2, buf2 + 1, check), nullptr);
// Invalid value 3
uint8_t buf3[16];
memset(buf3, 128, sizeof(buf3));
ASSERT_EQ(readVarint(buf3, buf3 + sizeof(buf3), check), nullptr);
// Invalid value 4
uint32_t check2;
uint8_t buf4[] = {255, 255, 255, 255, 127};
ASSERT_EQ(readVarint(buf4, buf4 + sizeof(buf4), check2), nullptr);
// Invalid value 5
uint8_t buf5[] = {128, 0};
ASSERT_EQ(readVarint(buf5, buf5 + sizeof(buf5), check), nullptr);
// Invalid value 6 (2^64)
uint8_t buf6[] = {128, 128, 128, 128, 128, 128, 128, 128, 128, 2};
ASSERT_EQ(readVarint(buf6, buf6 + sizeof(buf6), check), nullptr);
}
TEST(util, bsr)
+9
View File
@@ -77,6 +77,15 @@ TEST(wallet, input_output)
s << w.view_public_key();
ASSERT_EQ(memcmp(buf, viewkey, HASH_SIZE * 2), 0);
// Test Wallet copy
Wallet w1(w);
ASSERT_EQ(w1.prefix(), w.prefix());
ASSERT_EQ(w1.spend_public_key(), w.spend_public_key());
ASSERT_EQ(w1.view_public_key(), w.view_public_key());
ASSERT_EQ(w1.checksum(), w.checksum());
ASSERT_EQ(w1.type(), w.type());
// Test Wallet::assign()
Wallet w2(nullptr);
w2.assign(w.spend_public_key(), w.view_public_key(), w.type());