Compare commits

...

38 Commits

Author SHA1 Message Date
sech1 bbee372a01 p2pool v4.10 2025-09-09 09:22:45 +02:00
sech1 5c907d39aa Fix: submit broadcasted Monero blocks one at a time 2025-09-07 19:39:10 +02:00
SChernykh 6d3fbc5467 Merge pull request #374 from gavinbarnard/gavinbarnard/fullvalidationoption
full share validation via cmdline option
2025-09-07 14:22:57 +02:00
gavinbarnard 068b286a88 full share validation via cmdline option 2025-09-06 18:05:11 +00:00
sech1 b7c4613d40 Fixed handling of multiple blocks from ZMQ 2025-09-06 14:25:57 +02:00
sech1 971f804a6e Fix: get missing blocks in a thread-safe way 2025-09-05 15:35:39 +02:00
sech1 830c78a032 Fixed build errors, refined Monero block broadcast logic 2025-09-03 14:35:53 +02:00
sech1 50634e5e79 Feature: broadcast all new Monero blocks through p2pool network for faster propagation 2025-09-03 10:07:39 +02:00
sech1 c5fba9992e Docker: use fresh checkpoints for faster Monero sync 2025-08-31 17:24:25 +02:00
sech1 29df28d3c8 Docker: fixed missing dependencies 2025-08-30 00:36:36 +02:00
sech1 4a2b75c7fb Build scripts: updated tool versions 2025-08-30 00:34:34 +02:00
sech1 2a9cf67c3a Docker: fixed Monero build again 2025-08-29 20:49:19 +02:00
sech1 3bcde151ee Updated docs: --enforce-dns-checkpointing is now recommended 2025-08-29 18:47:29 +02:00
sech1 b22088f330 CI: update to clang-21 2025-08-26 22:34:11 +02:00
sech1 bfb0b5383a Docker: fixed XMRig build 2025-08-24 19:43:54 +02:00
sech1 560f62a427 Docker: fixed Monero build 2025-08-24 11:28:03 +02:00
sech1 271a30998f Fixed cppcheck command line 2025-08-24 10:13:09 +02:00
sech1 3c4eeb49fd p2pool v4.9.1 2025-08-21 10:28:34 +02:00
sech1 257781f2e2 Docker: updated Ubuntu version 2025-08-20 10:17:16 +02:00
SChernykh fb85deabbe Merge pull request #368 from worldwideward/master
update Dockerfile base image
2025-08-11 18:22:29 +02:00
w 6bc30dc6e1 update Dockerfile base image 2025-08-11 10:18:56 +02:00
SChernykh 93395771d3 CI: temporary cppcheck fix 2025-08-05 13:48:22 +02:00
SChernykh d6c249ca17 Tari: fixed a crash when node is not available 2025-08-04 22:03:35 +02:00
SChernykh 07259e029a TCPServer: pass connection fails to clients 2025-08-02 14:59:49 +02:00
SChernykh b1348b6c80 Fixed asan error (use after poison) 2025-08-01 18:21:06 +02:00
SChernykh a977f988d5 Fixed cppcheck errors 2025-07-31 21:09:54 +02:00
SChernykh 847ffe3959 Updated build scripts 2025-07-28 00:05:28 +02:00
SChernykh ed2e0f1a1b Removed more unused code from tests 2025-07-27 14:05:35 +02:00
SChernykh 240cbd100e Removed unused code from tests, tweaked build scripts 2025-07-26 18:34:13 +02:00
SChernykh f7c1baa453 CI: removed gRPC from Alpine builds because they were too slow 2025-07-26 10:39:38 +02:00
SChernykh 644084a32f More build fixes 2025-07-26 01:15:42 +02:00
SChernykh baab8d3788 Reduced gRPC bloat 2025-07-25 23:23:12 +02:00
SChernykh ce1ef36613 Build fixes 2025-07-25 17:05:25 +02:00
SChernykh 3d08803709 Updated gRPC to v1.74.0 2025-07-25 13:28:07 +02:00
SChernykh a4a0c03517 Tari: fixed the previous fix 2025-07-25 09:49:08 +02:00
SChernykh fb21c917ac Compiler test scripts: don't compress the output 2025-07-24 16:07:11 +02:00
SChernykh 0d9670ee29 Fixed build errors 2025-07-24 14:42:03 +02:00
SChernykh ca47bed7b9 Workaround for read-only working directory 2025-07-24 13:27:59 +02:00
103 changed files with 62667 additions and 28197 deletions
+8 -4
View File
@@ -13,7 +13,7 @@ on:
jobs:
build-alpine-static:
timeout-minutes: 240
timeout-minutes: 90
runs-on: ubuntu-latest
strategy:
@@ -71,7 +71,7 @@ jobs:
run: |
mkdir build
cd build
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 }}
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' -DWITH_GRPC=OFF -DSTATIC_BINARY=ON -DARCH_ID=${{ matrix.config.arch }}
make -j$(nproc) p2pool
- name: Run RandomX tests
@@ -433,8 +433,8 @@ jobs:
strategy:
matrix:
config:
- {c: "gcc", cxx: "g++", flags: "-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes"}
- {c: "clang", cxx: "clang++", flags: "-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled"}
- {c: "gcc", cxx: "g++", flags: "-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes -Wno-unknown-attributes"}
- {c: "clang", cxx: "clang++", flags: "-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled -Wno-unknown-attributes"}
defaults:
run:
@@ -452,6 +452,10 @@ jobs:
update: true
install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-clang mingw-w64-x86_64-lld mingw-w64-x86_64-cmake make git
- name: Apply patch
run: |
git apply --verbose --ignore-whitespace --directory=external/src/grpc/third_party/protobuf patches/protobuf/protobuf.patch
- name: Build libcurl
run: |
cd external/src/curl
+1 -1
View File
@@ -12,7 +12,7 @@ on:
jobs:
clang-tidy:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Install clang
+2 -1
View File
@@ -32,6 +32,7 @@ jobs:
- name: Build cppcheck
run: |
cd cppcheck-main
git checkout 1d9ea2ffcca587f99c68f0b6a4c37d5b3e046c28
make -j$(nproc) cppcheck
- name: cmake p2pool
@@ -62,7 +63,7 @@ jobs:
cppcheck-windows:
timeout-minutes: 60
timeout-minutes: 120
runs-on: windows-latest
steps:
+2 -2
View File
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM debian:12-slim
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
@@ -25,7 +25,7 @@ RUN git submodule update --init --recursive && \
# ---
FROM ubuntu:20.04
FROM debian:12-slim
COPY --from=0 /usr/src/p2pool/build/p2pool /
RUN set -e && \
+5 -5
View File
@@ -154,7 +154,7 @@ sudo sysctl vm.nr_hugepages=3072
4. Check that ports 18080 (Monero p2p port) and 37889/37888 (P2Pool/P2Pool mini p2p port) are open in your local firewall to ensure better connectivity.
5. Start `monerod` with the following command/options:
```
./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist
./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
```
**Note:**
The `--zmq-pub` option is required for P2Pool to work properly.
@@ -163,7 +163,7 @@ The `--zmq-pub` option is required for P2Pool to work properly.
`--add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080` is needed to have guaranteed good working nodes in your connected peers.
`--disable-dns-checkpoints` is needed to avoid periodical lags when DNS is updated (it's not needed when mining)
`--enforce-dns-checkpointing` is needed to combat the selfish mining attempts by malicious actors
`--enable-dns-blocklist` is needed to ban known bad nodes
@@ -222,7 +222,7 @@ nocreate
8. Start `monerod` with the following command/options:
```
.\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist
.\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
```
**Note:**
The `--zmq-pub` option is required for P2Pool to work properly.
@@ -231,7 +231,7 @@ The `--zmq-pub` option is required for P2Pool to work properly.
`--add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080` is needed to have guaranteed good working nodes in your connected peers.
`--disable-dns-checkpoints` is needed to avoid periodical lags when DNS is updated (it's not needed when mining)
`--enforce-dns-checkpointing` is needed to combat the selfish mining attempts by malicious actors
`--enable-dns-blocklist` is needed to ban known bad nodes
@@ -253,7 +253,7 @@ The `--zmq-pub` option is required for P2Pool to work properly.
13. *(Optional but highly recommended)* You can create a Quickstart by creating a batch (.bat) file with the following contents and placing it in your P2Pool directory along with `xmrig.exe`.
```
@ECHO OFF
start cmd /k %~dp0\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist
start cmd /k %~dp0\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
ECHO Wait until the Monero daemon shows fully synced before continuing. This can take some time. Type 'status' in other window to check progress.
PAUSE
start cmd /k %~dp0\p2pool.exe --wallet YOUR_WALLET_ADDRESS --mini
+5
View File
@@ -1,8 +1,10 @@
set(protobuf_INSTALL OFF CACHE BOOL "Install protobuf binaries and files")
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests")
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build libprotoc and protoc compiler")
set(protobuf_BUILD_LIBUPB OFF CACHE BOOL "Build libupb")
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL "Build protobuf Shared Libraries")
set(protobuf_DISABLE_RTTI ON CACHE BOOL "Remove runtime type information in the binaries")
set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build with zlib support")
set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Build test suite")
set(utf8_range_ENABLE_INSTALL OFF CACHE BOOL "Configure installation")
@@ -32,6 +34,9 @@ endif()
add_definitions(-DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0)
add_definitions(-DGRPC_NO_RLS)
add_definitions(-DGRPC_NO_XDS)
add_subdirectory(external/src/grpc)
include_directories(external/src/grpc/third_party/abseil-cpp)
+1 -1
View File
@@ -4,7 +4,7 @@
../external/src/cryptonote/
../external/src/libuv/
../external/src/cppzmq/
../external/src/libzmq/
../external/src/libzmq/include/
../external/src/miniupnp/miniupnpc/include/
../external/src/randomx/src/
../external/src/rapidjson/include/
+1 -1
View File
@@ -1,5 +1,5 @@
@echo off
"..\cppcheck-main\bin\cppcheck.exe" ../src/*.cpp -D__cppcheck__ -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -D_WIN32=1 -D_WIN64=1 -DWIN32=1 -D_WINDOWS=1 -DNDEBUG=1 -DWITH_GRPC=1 -DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -DWITH_RANDOMX=1 -DWITH_UPNP=1 -DWITH_TLS=1 -DWITH_MERGE_MINING_DONATION=1 -DCURL_STATICLIB=1 -DWIN32_LEAN_AND_MEAN=1 -D_WIN32_WINNT=0x0600 -D_DISABLE_VECTOR_ANNOTATION=1 -D_DISABLE_STRING_ANNOTATION=1 -DZMQ_STATIC=1 -DHAVE_BITSCANREVERSE64=1 -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DMINIUPNP_STATICLIB=1 -DCARES_STATICLIB=1 -DCMAKE_INTDIR="Release" -D__SSE2__=1 -D_MSC_VER=1929 --platform=win64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --includes-file=includes.txt --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt
"..\cppcheck-main\bin\cppcheck.exe" ../src/*.cpp -D__cppcheck__ -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN -D_WIN32=1 -D_WIN64=1 -DWIN32=1 -D_WINDOWS=1 -DNDEBUG=1 -DWITH_GRPC=1 -DPROTOBUF_ENABLE_DEBUG_LOGGING_MAY_LEAK_PII=0 -DWITH_RANDOMX=1 -DWITH_UPNP=1 -DWITH_TLS=1 -DWITH_MERGE_MINING_DONATION=1 -DCURL_STATICLIB=1 -DWIN32_LEAN_AND_MEAN=1 -D_WIN32_WINNT=0x0600 -D_DISABLE_VECTOR_ANNOTATION=1 -D_DISABLE_STRING_ANNOTATION=1 -DZMQ_STATIC=1 -DZMQ_VERSION=40306 -DHAVE_BITSCANREVERSE64=1 -DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag -DMINIUPNP_STATICLIB=1 -DCARES_STATICLIB=1 -DCMAKE_INTDIR="Release" -D__SSE2__=1 -D_MSC_VER=1929 --platform=win64 --std=c++17 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --includes-file=includes.txt --suppressions-list=suppressions.txt --output-file=errors_full.txt --max-ctu-depth=3 --check-level=exhaustive --checkers-report=checkers_report.txt
findstr /V /C:"external\src" errors_full.txt > errors_filtered0.txt
findstr /V /C:":checkersReport" errors_filtered0.txt > errors_filtered.txt
+1 -1
View File
@@ -611,7 +611,7 @@ class MoneroConfigForm(ConfigFormBase):
self.sync_pruned_blocks = self.add(
npyscreen.Checkbox,
name="Sync Pruned Blocks",
value=False,
value=True,
begin_entry_at=self.name_size,
relx=self.indent,
)
+1 -1
View File
@@ -21,7 +21,7 @@
"limit_data_rates": false,
"rate_limit_up": "2048",
"rate_limit_down": "8192",
"sync_pruned_blocks": false,
"sync_pruned_blocks": true,
"fast_sync": true,
"monero_options": "",
"public_monero_node": "",
+1 -1
View File
@@ -118,7 +118,7 @@ services:
restart: unless-stopped
command: >-
--zmq-pub tcp://0.0.0.0:18083
--disable-dns-checkpoints
--enforce-dns-checkpointing
--enable-dns-blocklist
--out-peers 16
--in-peers 32
+1 -1
View File
@@ -23,7 +23,7 @@
"limit_data_rates": false,
"rate_limit_up": "2048",
"rate_limit_down": "8192",
"sync_pruned_blocks": false,
"sync_pruned_blocks": true,
"fast_sync": true,
"monero_options": "",
"public_monero_node": "",
+3 -1
View File
@@ -94,7 +94,7 @@ services:
restart: unless-stopped
command: >-
--zmq-pub tcp://0.0.0.0:18083
--disable-dns-checkpoints
--enforce-dns-checkpointing
--enable-dns-blocklist
--out-peers 16
--in-peers 32
@@ -111,6 +111,8 @@ services:
--prune-blockchain
--sync-pruned-blocks
+28 -11
View File
@@ -1,12 +1,14 @@
# Multistage docker build, requires docker 17.05
# builder stage
FROM ubuntu:20.04 as builder
FROM ubuntu:22.04 as builder
ARG MONERO_GIT_TAG="latest"
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
RUN apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
autoconf \
automake \
autotools-dev \
bsdmainutils \
@@ -15,32 +17,47 @@ RUN set -e && \
ccache \
cmake \
curl \
doxygen \
git \
libtool \
graphviz \
libtool libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libexpat1-dev \
qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev libboost-chrono-dev libboost-date-time-dev \
libboost-filesystem-dev libboost-locale-dev libboost-program-options-dev libboost-regex-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev \
pkg-config \
python3 \
gperf
WORKDIR /src
RUN git clone --recursive https://github.com/monero-project/monero && \
RUN git clone --recursive --branch release-v0.18 https://github.com/monero-project/monero && \
cd monero && \
if [ "x$MONERO_GIT_TAG" = "xlatest" ]; then MONERO_GIT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)); fi && \
git checkout $MONERO_GIT_TAG && \
git submodule sync && git submodule update --init --force --recursive && \
make -j$(nproc) depends target=$(contrib/depends/config.guess)
curl -L -O https://p2pool.io/checkpoints/checkpoints.dat && \
curl -L -O https://p2pool.io/checkpoints/checkpoints.patch && \
git apply checkpoints.patch && \
cp -f checkpoints.dat src/blocks && \
make -j$(nproc)
# ---
# runtime stage
FROM ubuntu:20.04
FROM ubuntu:22.04
COPY --from=0 /src/monero/build/*/release/bin /usr/local/bin/
COPY --from=0 /src/monero/build/Linux/*/release/bin /usr/local/bin/
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
RUN apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
ca-certificates \
netcat \
libboost-chrono-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-thread-dev \
libzmq5 \
libreadline8 \
libhidapi-libusb0 \
libunbound8 \
&& \
apt-get clean && \
rm -rf /var/lib/apt
+5 -4
View File
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
@@ -20,15 +20,16 @@ RUN git clone https://github.com/xmrig/xmrig.git && \
# ---
FROM ubuntu:20.04
FROM ubuntu:22.04
COPY --from=0 /usr/src/xmrig/build/xmrig /
RUN set -e && \
apt-get update -q -y --no-install-recommends && \
DEBIAN_FRONTEND="noninteractive" apt-get install -q -y --no-install-recommends \
libssl1.1 \
libcrypto++6 \
libuv1 \
libssl3 \
libcrypto++8 \
libhwloc15 \
&& \
apt-get clean
+9
View File
@@ -39,6 +39,7 @@
--rpc-ssl Enable SSL on RPC connections to the Monero node
--rpc-ssl-fingerprint base64-encoded fingerprint of the Monero node's certificate (optional, use it for certificate pinning)
--no-stratum-http Disable HTTP on Stratum ports
--full-validation Enables full share validation / increases CPU usage
```
### Example command line
@@ -116,3 +117,11 @@ openssl x509 -in rpc_ssl.crt -pubkey -noout -inform pem | openssl pkey -pubin -o
```
By default, `rpc_ssl.crt` can be found in Monero data directory: `/home/username/.bitmonero/rpc_ssl.crt` on Linux and `C:\ProgramData\bitmonero\rpc_ssl.crt` on Windows.
### Full validation
`--full-validation` is a boolean flag and will set the value to true; by default it is false to reduce CPU usage
Enable this if untrusted sources can submit shares to your p2pool server and you want to verify the validity of the shares PoW. Increases CPU usage.
This option is for shared mining services, and not neccessary in local setups.
+2 -2
View File
@@ -248,7 +248,7 @@ It's highly recommended to create a new wallet for mining because wallet address
<ul>
<li>Download the latest Monero <a href="https://www.getmonero.org/downloads/" target="_blank">release</a>
<li>[Optional] Open port <span>18080</span> (Monero p2p port) in your firewall to ensure better connectivity
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist</span>
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist</span>
<li>If your network connection's upload bandwidth is less than 10 Mbit, use <span>--out-peers 8 --in-peers 16</span> instead.
<li>Wait until it's fully synchronized. If you didn't run Monero node before, it can take up to several days to synchronize (5-6 hours on a modern PC with fast SSD and fast Internet connection). You can add <span>--prune-blockchain</span> argument to the command line to run a pruned node (3-4 times less disk usage)
</ul></details>
@@ -304,7 +304,7 @@ P2Pool is a decentralized community, there is no dedicated support. You can reac
<li><span style="font-size:2rem;color:#e09000;">I get an error "monerod RPC ... is incompatible, update to RPC >= v3.8"</span>
<ul><li>Use monerod v0.18.0.0 or newer</ul><br>
<li><span style="font-size:2rem;color:#e09000;">I get warnings "peer ... is ahead on mainchain (height ..., your height ...). Is your monerod stuck or lagging?"</span>
<ul><li>Make sure you add these arguments to monerod command line: <span style="color:#808080;">--zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist</span></ul><br>
<ul><li>Make sure you add these arguments to monerod command line: <span style="color:#808080;">--zmq-pub tcp://127.0.0.1:18083 --enforce-dns-checkpointing --enable-dns-blocklist</span></ul><br>
</ul>
</td></tr></table>
<br><br>
+2 -2
View File
@@ -248,7 +248,7 @@ It's highly recommended to create a new wallet for mining because wallet address
<ul>
<li>Download the latest Monero <a href="https://www.getmonero.org/downloads/" target="_blank">release</a>
<li>[Optional] Open port <span>18080</span> (Monero p2p port) in your firewall to ensure better connectivity
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist</span>
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist</span>
<li>If your network connection's upload bandwidth is less than 10 Mbit, use <span>--out-peers 8 --in-peers 16</span> instead.
<li>Wait until it's fully synchronized. If you didn't run Monero node before, it can take up to several days to synchronize (5-6 hours on a modern PC with fast SSD and fast Internet connection). You can add <span>--prune-blockchain</span> argument to the command line to run a pruned node (3-4 times less disk usage)
</ul></details>
@@ -304,7 +304,7 @@ P2Pool is a decentralized community, there is no dedicated support. You can reac
<li><span style="font-size:2rem;color:#e09000;">I get an error "monerod RPC ... is incompatible, update to RPC >= v3.8"</span>
<ul><li>Use monerod v0.18.0.0 or newer</ul><br>
<li><span style="font-size:2rem;color:#e09000;">I get warnings "peer ... is ahead on mainchain (height ..., your height ...). Is your monerod stuck or lagging?"</span>
<ul><li>Make sure you add these arguments to monerod command line: <span style="color:#808080;">--zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist</span></ul><br>
<ul><li>Make sure you add these arguments to monerod command line: <span style="color:#808080;">--zmq-pub tcp://127.0.0.1:18083 --enforce-dns-checkpointing --enable-dns-blocklist</span></ul><br>
</ul>
</td></tr></table>
<br><br>
Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

+320
View File
@@ -0,0 +1,320 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>P2Pool nano - Decentralized Monero mining pool</title>
<link rel="shortcut icon" type="image/png" href="favicon-32x32.png"/>
<meta name="viewport" content="width=device-width, initial-scale=0.5">
<style>
a {
color: #e09000;
-ms-touch-action: none;
touch-action: none;
}
a:visited {
color: #808080;
-ms-touch-action: none;
touch-action: none;
}
body {
background-color: #383838;
color: #e0e0e0;
font-family: Arial, sans-serif;
font-size: 1.5rem;
}
table {
color: #c0c0c0;
border-spacing:15px 5px;
font-size: 1.5rem;
}
table.menu_page {
width: 100%;
margin-left: auto;
margin-right: auto;
}
details > summary {
padding: 0.25rem;
font-size: 2.5rem;
-ms-touch-action: none;
touch-action: none;
}
details > ul > li > span {
color: #e09000;
}
</style>
<script>
function elapsedTimeStr(ts1, ts2, short_form) {
let s = ts2 - ts1;
if (s < 0) s = 0;
let m = Math.floor(s / 60) % 60;
let h = Math.floor(s / 3600) % 24;
let d = Math.floor(s / 86400);
if (short_form) {
if (s >= 86400) return d + 'd';
if (s >= 3600) return h + 'h';
return m + 'm';
}
else {
let result = m + 'm';
if (s >= 3600) result = h + 'h ' + result;
if (s >= 86400) result = d + 'd ' + h + 'h';
return result;
}
}
function set_effort(el, value) {
el.innerHTML = value.toFixed(2) + '%';
el.style = (value < 100.0) ? "color:#00C000;" : (value < 200.0) ? "color:#E0E000;" : "color:#FF0000;";
}
async function load_data() {
init_menu();
window.onresize = init_menu;
let pool_stats_req = await fetch('api/pool/stats');
let pool_blocks_req = await fetch('api/pool/blocks');
let network_stats_req = await fetch('api/network/stats');
let latest_release_req = await fetch('api/latest_release');
let pool_stats = JSON.parse(await pool_stats_req.text());
let pool_blocks = JSON.parse(await pool_blocks_req.text());
let network_stats = JSON.parse(await network_stats_req.text());
let latest_release = JSON.parse(await latest_release_req.text());
let pool_hashrate = pool_stats.pool_statistics.hashRate / 1e6;
let pplns_duration = pool_stats.pool_statistics.pplnsWeight / pool_stats.pool_statistics.hashRate;
let min_payout = 0.6 * pool_stats.pool_statistics.sidechainDifficulty / pool_stats.pool_statistics.pplnsWeight;
document.getElementById("pool_hashrate").innerHTML = pool_hashrate.toFixed(3) + ' MH/s';
document.getElementById("pplns_duration").innerHTML = elapsedTimeStr(0, pplns_duration, 0) + ' ' + Math.floor(pplns_duration % 60) + 's';
document.getElementById("pool_miners").innerHTML = pool_stats.pool_statistics.miners;
document.getElementById("min_payout").innerHTML = min_payout.toFixed(5) + ' XMR';
document.getElementById("latest_release").innerHTML = '<a href="' + latest_release.html_url + '" target="_blank">' + latest_release.name + '</a>';
let ts = Math.floor(Date.now() / 1000);
let n = pool_stats.pool_statistics.lastBlockFound;
document.getElementById("pool_last_block").innerHTML = n ? ('<a href="/explorer/block/' + n + '" target="_blank">' + n + '</a> (' + elapsedTimeStr(pool_stats.pool_statistics.lastBlockFoundTime, ts, 0) + ' ago)') : 'N/A';
document.getElementById("pool_total_blocks").innerHTML = pool_stats.pool_statistics.totalBlocksFound;
let t = document.getElementById('menu_blocks');
let cur_effort = (pool_stats.pool_statistics.totalHashes - ((pool_blocks.length > 0) ? pool_blocks[0].totalHashes : 0)) * 100.0 / network_stats.difficulty;
set_effort(document.getElementById("current_effort"), (cur_effort >= 0) ? cur_effort : 0);
let total_effort = 0.0;
let num_blocks_with_effort = 0;
for (let i = 0, m = Math.min(pool_blocks.length, 50); i < m; ++i) {
if (t.rows.length <= i + 1) t.insertRow(-1);
let row = t.rows[i + 1];
while (row.cells.length < 3) row.insertCell(-1);
let height = row.cells[0];
let effort = row.cells[1];
let age = row.cells[2];
n = pool_blocks[i].height;
height.innerHTML = '<a href="/explorer/block/' + pool_blocks[i].hash + '" target="_blank">' + n + '</a>';
let value = 0.0;
if ((i + 1 < pool_blocks.length) && (pool_blocks[i + 1].totalHashes > 0)) {
value = (pool_blocks[i].totalHashes - pool_blocks[i + 1].totalHashes) * 100.0 / pool_blocks[i].difficulty;
}
else {
value = pool_blocks[i].totalHashes * 100.0 / pool_blocks[i].difficulty;
}
total_effort += value;
++num_blocks_with_effort;
set_effort(effort, value);
age.innerHTML = elapsedTimeStr(pool_blocks[i].ts, ts, 1);
}
if (num_blocks_with_effort > 0) {
let average_effort = total_effort / num_blocks_with_effort;
set_effort(document.getElementById("average_effort"), average_effort);
}
let network_hashrate = network_stats.difficulty / 120e6;
document.getElementById("monero_hashrate").innerHTML = network_hashrate.toFixed(3) + ' MH/s';
document.getElementById("monero_last_block").innerHTML = network_stats.height + ' (' + elapsedTimeStr(network_stats.timestamp, ts, 0) + ' ago)';
}
const menu = ['pool', 'blocks', 'help', 'faq'];
function init_menu()
{
let is_mobile = false;
if (navigator.userAgentData) {
is_mobile = navigator.userAgentData.mobile;
}
else {
const mobile_preg = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i;
is_mobile = mobile_preg.test(navigator.userAgent) || mobile_preg.test(navigator.platform);
}
let e = document.getElementById('main_menu');
if (!is_mobile) {
e.style.cursor = "pointer";
document.querySelectorAll("details > summary").forEach(el => { el.style.cursor = "pointer"; });
}
e.style.width = (window.innerWidth > 1600) ? "1600px" : "100%";
menu.forEach(element => {
let e2 = document.getElementById('menu_' + element);
e2.style.width = e.style.width;
});
}
function toggle_menu(name) {
if (!name) {
name = 'pool';
}
menu.forEach(element => {
let e = document.getElementById('menu_' + element);
let b = document.getElementById('button_' + element);
if (element == name) {
e.style.display = 'block';
b.style.backgroundColor = '#646464';
window.location.hash = '#' + name;
}
else {
e.style.display = 'none';
b.style.backgroundColor = '#404040';
}
});
}
</script>
</head>
<body onload="load_data();setInterval(load_data, 2000);toggle_menu(window.location.hash.substr(1));">
<div style="font-size:3rem;text-align:center;">P2Pool nano</div><div style="font-size:1.1rem;text-align:center;">Decentralized Monero mining pool</div>
<div style="font-size:1rem;text-align:center;">Latest release: <span id="latest_release"><a href="https://github.com/SChernykh/p2pool/releases/latest" target="_blank">P2Pool</a></span></div>
<br>
<table id="main_menu" style="width:100%;margin-left:auto;margin-right:auto;table-layout:fixed;text-align:center;-ms-touch-action:none;touch-action:none;"><tr>
<td onclick="toggle_menu('pool')" id="button_pool">Pool</td>
<td onclick="toggle_menu('blocks')" id="button_blocks">Blocks</td>
<td onclick="toggle_menu('help')" id="button_help">Get started</td>
<td onclick="toggle_menu('faq')" id="button_faq">FAQ</td>
</tr></table>
<br>
<table id="menu_pool" class="menu_page">
<tr><td></td><td style="width:17rem;">Pool</td><td>Network</td></tr>
<tr><td style="padding-bottom: 1rem;"></td><td></td><td></td></tr>
<tr><td>Hashrate</td><td><span id="pool_hashrate">N/A</span></td><td><span id="monero_hashrate">N/A</span></td></tr>
<tr><td>Miners</td><td><span id="pool_miners">N/A</span></td><td></td></tr>
<tr><td>PPLNS window</td><td><span id="pplns_duration">N/A</span></td><td></td></tr>
<tr><td>Last block</td><td><span id="pool_last_block">N/A</span></td><td><span id="monero_last_block">N/A</span></td></tr>
<tr><td>Total blocks</td><td><span id="pool_total_blocks">N/A</span></td><td></td></tr>
<tr><td>Current effort</td><td><span id="current_effort">N/A</span></td><td></td></tr>
<tr><td>Average effort<br><div style="text-align:center;font-size:0.9rem">last 50 blocks</div></td><td><span id="average_effort">N/A</span></td><td></td></tr>
<tr><td>&nbsp;</td><td></td><td></td></tr>
<tr><td>Fee</td><td>0%</td><td></td></tr>
<tr><td>Min payout</td><td><span id="min_payout">0.00027 XMR</span></td><td></td></tr>
<tr><td>Payout scheme</td><td><a href="https://en.wikipedia.org/wiki/Mining_pool#Pay-per-last-N-shares" target="_blank">PPLNS</a></td><td></td></tr>
<tr><td>&nbsp;</td><td></td><td></td></tr>
<tr><td>Statistics</td><td><a href="https://nano.p2pool.observer/" target="_blank">P2Pool observer</a></td><td></td></tr>
</table>
<table id="menu_blocks" class="menu_page">
<tr><td style="padding-right:5rem;">Height</td><td style="padding-right:5rem;">Effort</td><td>Age</td></tr>
</table>
<table id="menu_help" class="menu_page"><tr><td>
<details><summary>P2Pool video guide</summary>
<ul>
<li>A detailed <a href="https://www.youtube.com/watch?v=NbxbRu-2GWI" target="_blank">video guide</a> to install P2Pool and start mining
</ul>
</details>
<details><summary>Setup Monero wallet</summary>
Wallets with confirmed P2Pool support<br>
<span style="font-size:0.9rem;color:#e09000;">You might not see P2Pool payouts in other wallets if they're not updated!</span>
<ul>
<li>Official <a href="https://www.getmonero.org/downloads/" target="_blank">Monero CLI and GUI v0.18.1.0</a> and newer
<li><a href="https://play.google.com/store/apps/details?id=com.m2049r.xmrwallet" target="_blank">Monerujo v3.0.2 "Fluorine Fermi"</a> and newer
<li><a href="https://play.google.com/store/apps/details?id=com.cakewallet.cake_wallet" target="_blank">Cake Wallet v4.4.5</a> and newer
<li><a href="https://featherwallet.org/" target="_blank">Feather Wallet v2.1.0</a> and newer
<li><a href="https://mymonero.com/" target="_blank">MyMonero</a>
</ul>
It's highly recommended to create a new wallet for mining because wallet addresses are public on p2pool. You have to use the primary wallet address for mining. Subaddresses and integrated addresses are not supported, just like with monerod solo mining.
</details>
<details><summary>Setup Monero node</summary>
<ul>
<li>Download the latest Monero <a href="https://www.getmonero.org/downloads/" target="_blank">release</a>
<li>[Optional] Open port <span>18080</span> (Monero p2p port) in your firewall to ensure better connectivity
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist</span>
<li>If your network connection's upload bandwidth is less than 10 Mbit, use <span>--out-peers 8 --in-peers 16</span> instead.
<li>Wait until it's fully synchronized. If you didn't run Monero node before, it can take up to several days to synchronize (5-6 hours on a modern PC with fast SSD and fast Internet connection). You can add <span>--prune-blockchain</span> argument to the command line to run a pruned node (3-4 times less disk usage)
</ul></details>
<details><summary>Setup P2Pool node</summary>
<ul>
<li>Download the latest P2Pool <a href="https://github.com/SChernykh/p2pool/releases/latest" target="_blank">release</a>
<li>[Optional] Open port <span>37889</span> (P2Pool port) or <span>37890</span> (P2Pool nano port) in your firewall to ensure better connectivity
<li>Run <span>./p2pool --host 127.0.0.1 --wallet YOUR_WALLET_ADDRESS --nano</span>
<li>It should take no more than 5-10 minutes to synchronize
</ul></details>
<details><summary>Miner software</summary>
<ul>
<li><a href="https://xmrig.com/" target="_blank">XMRig</a> is recommended. <a href="https://xmrig.com/proxy" target="_blank">XMRig Proxy</a> is fully supported.
<li>Once P2Pool sync is complete, XMRig should be able to connect to the stratum server on port <span>3333</span>
<li>Run <span>./xmrig -o 127.0.0.1:3333</span>. Note that you don't need to specify wallet address for xmrig. Wallet address set in xmrig config will be ignored!
<li>To set custom fixed difficulty for your miner (for example, <span>10000</span>), run <span>./xmrig -u x+10000 -o 127.0.0.1:3333</span>
<li>To connect another mining rig to your P2Pool node, run <span>./xmrig -o YOUR_P2POOL_NODE_IP:3333</span> on that mining rig
</ul></details>
<details><summary>Checking your progress</summary>
<ul>
<li>You can enter your wallet address at <a href="https://p2pool.observer/" target="_blank">P2Pool Observer</a>
<li>P2Pool Observer for P2Pool nano can be found <a href="https://nano.p2pool.observer/" target="_blank">here</a>
<li>You will find your wallet's statistics there only after you've mined at least 1 P2Pool share
</ul>
</details>
<details><summary>Help and support</summary>
P2Pool is a decentralized community, there is no dedicated support. You can reach and get help from other miners on:
<ul>
<li>IRC channels: <span>#p2pool-log</span> (<span>#p2pool-mini</span> for P2Pool mini) on <a href="https://libera.chat/" target="_blank">Libera.Chat</a>
<li>Reddit: <a href="https://reddit.com/r/MoneroMining/" target="_blank">r/MoneroMining</a>
</ul></details>
</td></tr></table>
<table id="menu_faq" class="menu_page"><tr><td>
<ul>
<li><span style="font-size:2rem;color:#e09000;">What are system requirements to run P2Pool?</span>
<ul><li>P2Pool needs 0.5 GB disc space and 2.6 GB RAM to run (0.6 GB RAM in light mode). Add this to monerod requirements if you run both on the same machine. Add <span style="color:#808080;">--light-mode</span> to p2pool command line to reduce the memory usage to 0.6 GB, or <span style="color:#808080;">--no-randomx --no-cache</span> to reduce the memory usage to less than 100 MB.</ul><br>
<li><span style="font-size:2rem;color:#e09000;">Does P2Pool work with XMRig Proxy?</span>
<ul><li>Yes, P2Pool fully supports <a href="https://xmrig.com/proxy" target="_blank">XMRig Proxy</a>.</ul><br>
<li><span style="font-size:2rem;color:#e09000;">Does monerod have to be run on the same machine as P2Pool?</span>
<ul><li>No, you can run them on different machines and even connect multiple p2pool instances to a single server running monerod</ul><br>
<li><span style="font-size:2rem;color:#e09000;">Does P2Pool work with pruned Monero node?</span>
<ul><li>Yes, you can use pruned Monero node to mine on P2Pool</ul><br>
<li><span style="font-size:2rem;color:#e09000;">Does P2Pool require incoming connections to work properly?</span>
<ul><li>P2Pool (and Monero) can work with only outgoing connections, but it's recommended to open ports 18080 (Monero) and 37889/37888/37890 (P2Pool/P2Pool mini/P2Pool nano) for better connectivity with the rest of the network.</ul><br>
<li><span style="font-size:2rem;color:#e09000;">I have been mining for several hours and still got no rewards?</span>
<ul><li>P2Pool doesn't work exactly like regular pools - there's no "pending balance" here. You need to find a pool share first and then wait for P2Pool to find a Monero block. You'll get a payout to your XMR wallet as soon as a block is found and you have shares in PPLNS window. It can take several days to a week to find a share if your hashrate is low. Type "status" command in P2Pool console or visit <a href="https://nano.p2pool.observer/" target="_blank">P2Pool observer</a> to check your progress.</ul><br>
<li><span style="font-size:2rem;color:#e09000;">I am mining but I can't find any shares</span>
<ul><li>First check for any warnings and errors in P2Pool console and logs. If everything works fine, you can check the <a href="https://p2pool.observer/calculate-share-time" target="_blank">average share time calculator</a> to get an idea how often you should find a share with your hashrate. If this time is more than 1 day, it's recommended to switch to P2Pool mini or P2Pool nano by adding <span style="color:#808080;">--mini</span> or <span style="color:#808080;">--nano</span> to P2Pool command line.</ul><br>
<li><span style="font-size:2rem;color:#e09000;">I get an error "monerod RPC ... is incompatible, update to RPC >= v3.8"</span>
<ul><li>Use monerod v0.18.0.0 or newer</ul><br>
<li><span style="font-size:2rem;color:#e09000;">I get warnings "peer ... is ahead on mainchain (height ..., your height ...). Is your monerod stuck or lagging?"</span>
<ul><li>Make sure you add these arguments to monerod command line: <span style="color:#808080;">--zmq-pub tcp://127.0.0.1:18083 --enforce-dns-checkpointing --enable-dns-blocklist</span></ul><br>
</ul>
</td></tr></table>
<br><br>
<div style="position:fixed;width:100%;bottom:0;background-color:#383838;font-size:1rem;text-align:center;color:#b0b0b0;">
<a href="api/" target="_blank">Pool API</a>&nbsp;|&nbsp;<a href="https://github.com/SChernykh/p2pool" target="_blank">Source</a>&nbsp;|&nbsp;<a href="http://yucmgsbw7nknw7oi3bkuwudvc657g2xcqahhbjyewazusyytapqo4xid.onion/nano/" target="_blank">Onion URL</a><br>
Donate to support the project:<br><span style="font-size:0.9rem;color:#b0b0b0;">44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg</span><br>
&nbsp;
</div>
</body>
</html>
+4
View File
@@ -0,0 +1,4 @@
To update the files:
- Build gRPC in `../../../grpc/.build` folder: `cmake .. && make -j$(nproc)`
- Run `../../../grpc/.build/third_party/protobuf/protoc --cpp_out=. --plugin=protoc-gen-grpc=../../../grpc/.build/grpc_cpp_plugin --grpc_out=. --proto_path=../../../grpc/third_party/protobuf/src --proto_path=. *.proto`
+132 -18
View File
@@ -19,6 +19,7 @@
#include <grpcpp/server_context.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
@@ -56,10 +57,13 @@ static const char* BaseNode_method_names[] = {
"/tari.rpc.BaseNode/ListConnectedPeers",
"/tari.rpc.BaseNode/GetMempoolStats",
"/tari.rpc.BaseNode/GetActiveValidatorNodes",
"/tari.rpc.BaseNode/GetValidatorNodeChanges",
"/tari.rpc.BaseNode/GetShardKey",
"/tari.rpc.BaseNode/GetTemplateRegistrations",
"/tari.rpc.BaseNode/GetSideChainUtxos",
"/tari.rpc.BaseNode/GetNetworkState",
"/tari.rpc.BaseNode/SearchPaymentReferences",
"/tari.rpc.BaseNode/SearchPaymentReferencesViaOutputHash",
};
std::unique_ptr< BaseNode::Stub> BaseNode::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
@@ -102,10 +106,13 @@ BaseNode::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel,
, rpcmethod_ListConnectedPeers_(BaseNode_method_names[30], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_GetMempoolStats_(BaseNode_method_names[31], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_GetActiveValidatorNodes_(BaseNode_method_names[32], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_GetShardKey_(BaseNode_method_names[33], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_GetTemplateRegistrations_(BaseNode_method_names[34], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_GetSideChainUtxos_(BaseNode_method_names[35], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_GetNetworkState_(BaseNode_method_names[36], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_GetValidatorNodeChanges_(BaseNode_method_names[33], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_GetShardKey_(BaseNode_method_names[34], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_GetTemplateRegistrations_(BaseNode_method_names[35], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_GetSideChainUtxos_(BaseNode_method_names[36], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_GetNetworkState_(BaseNode_method_names[37], options.suffix_for_stats(),::grpc::internal::RpcMethod::NORMAL_RPC, channel)
, rpcmethod_SearchPaymentReferences_(BaseNode_method_names[38], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
, rpcmethod_SearchPaymentReferencesViaOutputHash_(BaseNode_method_names[39], options.suffix_for_stats(),::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
{}
::grpc::ClientReader< ::tari::rpc::BlockHeaderResponse>* BaseNode::Stub::ListHeadersRaw(::grpc::ClientContext* context, const ::tari::rpc::ListHeadersRequest& request) {
@@ -255,23 +262,23 @@ void BaseNode::Stub::async::GetBlockFees(::grpc::ClientContext* context, const :
return result;
}
::grpc::Status BaseNode::Stub::GetVersion(::grpc::ClientContext* context, const ::tari::rpc::Empty& request, ::tari::rpc::StringValue* response) {
return ::grpc::internal::BlockingUnaryCall< ::tari::rpc::Empty, ::tari::rpc::StringValue, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_GetVersion_, context, request, response);
::grpc::Status BaseNode::Stub::GetVersion(::grpc::ClientContext* context, const ::tari::rpc::Empty& request, ::tari::rpc::BaseNodeGetVersionResponse* response) {
return ::grpc::internal::BlockingUnaryCall< ::tari::rpc::Empty, ::tari::rpc::BaseNodeGetVersionResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_GetVersion_, context, request, response);
}
void BaseNode::Stub::async::GetVersion(::grpc::ClientContext* context, const ::tari::rpc::Empty* request, ::tari::rpc::StringValue* response, std::function<void(::grpc::Status)> f) {
::grpc::internal::CallbackUnaryCall< ::tari::rpc::Empty, ::tari::rpc::StringValue, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetVersion_, context, request, response, std::move(f));
void BaseNode::Stub::async::GetVersion(::grpc::ClientContext* context, const ::tari::rpc::Empty* request, ::tari::rpc::BaseNodeGetVersionResponse* response, std::function<void(::grpc::Status)> f) {
::grpc::internal::CallbackUnaryCall< ::tari::rpc::Empty, ::tari::rpc::BaseNodeGetVersionResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetVersion_, context, request, response, std::move(f));
}
void BaseNode::Stub::async::GetVersion(::grpc::ClientContext* context, const ::tari::rpc::Empty* request, ::tari::rpc::StringValue* response, ::grpc::ClientUnaryReactor* reactor) {
void BaseNode::Stub::async::GetVersion(::grpc::ClientContext* context, const ::tari::rpc::Empty* request, ::tari::rpc::BaseNodeGetVersionResponse* response, ::grpc::ClientUnaryReactor* reactor) {
::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetVersion_, context, request, response, reactor);
}
::grpc::ClientAsyncResponseReader< ::tari::rpc::StringValue>* BaseNode::Stub::PrepareAsyncGetVersionRaw(::grpc::ClientContext* context, const ::tari::rpc::Empty& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::tari::rpc::StringValue, ::tari::rpc::Empty, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_GetVersion_, context, request);
::grpc::ClientAsyncResponseReader< ::tari::rpc::BaseNodeGetVersionResponse>* BaseNode::Stub::PrepareAsyncGetVersionRaw(::grpc::ClientContext* context, const ::tari::rpc::Empty& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::tari::rpc::BaseNodeGetVersionResponse, ::tari::rpc::Empty, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_GetVersion_, context, request);
}
::grpc::ClientAsyncResponseReader< ::tari::rpc::StringValue>* BaseNode::Stub::AsyncGetVersionRaw(::grpc::ClientContext* context, const ::tari::rpc::Empty& request, ::grpc::CompletionQueue* cq) {
::grpc::ClientAsyncResponseReader< ::tari::rpc::BaseNodeGetVersionResponse>* BaseNode::Stub::AsyncGetVersionRaw(::grpc::ClientContext* context, const ::tari::rpc::Empty& request, ::grpc::CompletionQueue* cq) {
auto* result =
this->PrepareAsyncGetVersionRaw(context, request, cq);
result->StartCall();
@@ -797,6 +804,29 @@ void BaseNode::Stub::async::GetActiveValidatorNodes(::grpc::ClientContext* conte
return ::grpc::internal::ClientAsyncReaderFactory< ::tari::rpc::GetActiveValidatorNodesResponse>::Create(channel_.get(), cq, rpcmethod_GetActiveValidatorNodes_, context, request, false, nullptr);
}
::grpc::Status BaseNode::Stub::GetValidatorNodeChanges(::grpc::ClientContext* context, const ::tari::rpc::GetValidatorNodeChangesRequest& request, ::tari::rpc::GetValidatorNodeChangesResponse* response) {
return ::grpc::internal::BlockingUnaryCall< ::tari::rpc::GetValidatorNodeChangesRequest, ::tari::rpc::GetValidatorNodeChangesResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_GetValidatorNodeChanges_, context, request, response);
}
void BaseNode::Stub::async::GetValidatorNodeChanges(::grpc::ClientContext* context, const ::tari::rpc::GetValidatorNodeChangesRequest* request, ::tari::rpc::GetValidatorNodeChangesResponse* response, std::function<void(::grpc::Status)> f) {
::grpc::internal::CallbackUnaryCall< ::tari::rpc::GetValidatorNodeChangesRequest, ::tari::rpc::GetValidatorNodeChangesResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetValidatorNodeChanges_, context, request, response, std::move(f));
}
void BaseNode::Stub::async::GetValidatorNodeChanges(::grpc::ClientContext* context, const ::tari::rpc::GetValidatorNodeChangesRequest* request, ::tari::rpc::GetValidatorNodeChangesResponse* response, ::grpc::ClientUnaryReactor* reactor) {
::grpc::internal::ClientCallbackUnaryFactory::Create< ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_GetValidatorNodeChanges_, context, request, response, reactor);
}
::grpc::ClientAsyncResponseReader< ::tari::rpc::GetValidatorNodeChangesResponse>* BaseNode::Stub::PrepareAsyncGetValidatorNodeChangesRaw(::grpc::ClientContext* context, const ::tari::rpc::GetValidatorNodeChangesRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create< ::tari::rpc::GetValidatorNodeChangesResponse, ::tari::rpc::GetValidatorNodeChangesRequest, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_GetValidatorNodeChanges_, context, request);
}
::grpc::ClientAsyncResponseReader< ::tari::rpc::GetValidatorNodeChangesResponse>* BaseNode::Stub::AsyncGetValidatorNodeChangesRaw(::grpc::ClientContext* context, const ::tari::rpc::GetValidatorNodeChangesRequest& request, ::grpc::CompletionQueue* cq) {
auto* result =
this->PrepareAsyncGetValidatorNodeChangesRaw(context, request, cq);
result->StartCall();
return result;
}
::grpc::Status BaseNode::Stub::GetShardKey(::grpc::ClientContext* context, const ::tari::rpc::GetShardKeyRequest& request, ::tari::rpc::GetShardKeyResponse* response) {
return ::grpc::internal::BlockingUnaryCall< ::tari::rpc::GetShardKeyRequest, ::tari::rpc::GetShardKeyResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_GetShardKey_, context, request, response);
}
@@ -875,6 +905,38 @@ void BaseNode::Stub::async::GetNetworkState(::grpc::ClientContext* context, cons
return result;
}
::grpc::ClientReader< ::tari::rpc::PaymentReferenceResponse>* BaseNode::Stub::SearchPaymentReferencesRaw(::grpc::ClientContext* context, const ::tari::rpc::SearchPaymentReferencesRequest& request) {
return ::grpc::internal::ClientReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(channel_.get(), rpcmethod_SearchPaymentReferences_, context, request);
}
void BaseNode::Stub::async::SearchPaymentReferences(::grpc::ClientContext* context, const ::tari::rpc::SearchPaymentReferencesRequest* request, ::grpc::ClientReadReactor< ::tari::rpc::PaymentReferenceResponse>* reactor) {
::grpc::internal::ClientCallbackReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(stub_->channel_.get(), stub_->rpcmethod_SearchPaymentReferences_, context, request, reactor);
}
::grpc::ClientAsyncReader< ::tari::rpc::PaymentReferenceResponse>* BaseNode::Stub::AsyncSearchPaymentReferencesRaw(::grpc::ClientContext* context, const ::tari::rpc::SearchPaymentReferencesRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(channel_.get(), cq, rpcmethod_SearchPaymentReferences_, context, request, true, tag);
}
::grpc::ClientAsyncReader< ::tari::rpc::PaymentReferenceResponse>* BaseNode::Stub::PrepareAsyncSearchPaymentReferencesRaw(::grpc::ClientContext* context, const ::tari::rpc::SearchPaymentReferencesRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(channel_.get(), cq, rpcmethod_SearchPaymentReferences_, context, request, false, nullptr);
}
::grpc::ClientReader< ::tari::rpc::PaymentReferenceResponse>* BaseNode::Stub::SearchPaymentReferencesViaOutputHashRaw(::grpc::ClientContext* context, const ::tari::rpc::FetchMatchingUtxosRequest& request) {
return ::grpc::internal::ClientReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(channel_.get(), rpcmethod_SearchPaymentReferencesViaOutputHash_, context, request);
}
void BaseNode::Stub::async::SearchPaymentReferencesViaOutputHash(::grpc::ClientContext* context, const ::tari::rpc::FetchMatchingUtxosRequest* request, ::grpc::ClientReadReactor< ::tari::rpc::PaymentReferenceResponse>* reactor) {
::grpc::internal::ClientCallbackReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(stub_->channel_.get(), stub_->rpcmethod_SearchPaymentReferencesViaOutputHash_, context, request, reactor);
}
::grpc::ClientAsyncReader< ::tari::rpc::PaymentReferenceResponse>* BaseNode::Stub::AsyncSearchPaymentReferencesViaOutputHashRaw(::grpc::ClientContext* context, const ::tari::rpc::FetchMatchingUtxosRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
return ::grpc::internal::ClientAsyncReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(channel_.get(), cq, rpcmethod_SearchPaymentReferencesViaOutputHash_, context, request, true, tag);
}
::grpc::ClientAsyncReader< ::tari::rpc::PaymentReferenceResponse>* BaseNode::Stub::PrepareAsyncSearchPaymentReferencesViaOutputHashRaw(::grpc::ClientContext* context, const ::tari::rpc::FetchMatchingUtxosRequest& request, ::grpc::CompletionQueue* cq) {
return ::grpc::internal::ClientAsyncReaderFactory< ::tari::rpc::PaymentReferenceResponse>::Create(channel_.get(), cq, rpcmethod_SearchPaymentReferencesViaOutputHash_, context, request, false, nullptr);
}
BaseNode::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[0],
@@ -949,11 +1011,11 @@ BaseNode::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[7],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< BaseNode::Service, ::tari::rpc::Empty, ::tari::rpc::StringValue, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
new ::grpc::internal::RpcMethodHandler< BaseNode::Service, ::tari::rpc::Empty, ::tari::rpc::BaseNodeGetVersionResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](BaseNode::Service* service,
::grpc::ServerContext* ctx,
const ::tari::rpc::Empty* req,
::tari::rpc::StringValue* resp) {
::tari::rpc::BaseNodeGetVersionResponse* resp) {
return service->GetVersion(ctx, req, resp);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
@@ -1209,6 +1271,16 @@ BaseNode::Service::Service() {
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[33],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< BaseNode::Service, ::tari::rpc::GetValidatorNodeChangesRequest, ::tari::rpc::GetValidatorNodeChangesResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](BaseNode::Service* service,
::grpc::ServerContext* ctx,
const ::tari::rpc::GetValidatorNodeChangesRequest* req,
::tari::rpc::GetValidatorNodeChangesResponse* resp) {
return service->GetValidatorNodeChanges(ctx, req, resp);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[34],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< BaseNode::Service, ::tari::rpc::GetShardKeyRequest, ::tari::rpc::GetShardKeyResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](BaseNode::Service* service,
::grpc::ServerContext* ctx,
@@ -1217,7 +1289,7 @@ BaseNode::Service::Service() {
return service->GetShardKey(ctx, req, resp);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[34],
BaseNode_method_names[35],
::grpc::internal::RpcMethod::SERVER_STREAMING,
new ::grpc::internal::ServerStreamingHandler< BaseNode::Service, ::tari::rpc::GetTemplateRegistrationsRequest, ::tari::rpc::GetTemplateRegistrationResponse>(
[](BaseNode::Service* service,
@@ -1227,7 +1299,7 @@ BaseNode::Service::Service() {
return service->GetTemplateRegistrations(ctx, req, writer);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[35],
BaseNode_method_names[36],
::grpc::internal::RpcMethod::SERVER_STREAMING,
new ::grpc::internal::ServerStreamingHandler< BaseNode::Service, ::tari::rpc::GetSideChainUtxosRequest, ::tari::rpc::GetSideChainUtxosResponse>(
[](BaseNode::Service* service,
@@ -1237,7 +1309,7 @@ BaseNode::Service::Service() {
return service->GetSideChainUtxos(ctx, req, writer);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[36],
BaseNode_method_names[37],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler< BaseNode::Service, ::tari::rpc::GetNetworkStateRequest, ::tari::rpc::GetNetworkStateResponse, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](BaseNode::Service* service,
@@ -1246,6 +1318,26 @@ BaseNode::Service::Service() {
::tari::rpc::GetNetworkStateResponse* resp) {
return service->GetNetworkState(ctx, req, resp);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[38],
::grpc::internal::RpcMethod::SERVER_STREAMING,
new ::grpc::internal::ServerStreamingHandler< BaseNode::Service, ::tari::rpc::SearchPaymentReferencesRequest, ::tari::rpc::PaymentReferenceResponse>(
[](BaseNode::Service* service,
::grpc::ServerContext* ctx,
const ::tari::rpc::SearchPaymentReferencesRequest* req,
::grpc::ServerWriter<::tari::rpc::PaymentReferenceResponse>* writer) {
return service->SearchPaymentReferences(ctx, req, writer);
}, this)));
AddMethod(new ::grpc::internal::RpcServiceMethod(
BaseNode_method_names[39],
::grpc::internal::RpcMethod::SERVER_STREAMING,
new ::grpc::internal::ServerStreamingHandler< BaseNode::Service, ::tari::rpc::FetchMatchingUtxosRequest, ::tari::rpc::PaymentReferenceResponse>(
[](BaseNode::Service* service,
::grpc::ServerContext* ctx,
const ::tari::rpc::FetchMatchingUtxosRequest* req,
::grpc::ServerWriter<::tari::rpc::PaymentReferenceResponse>* writer) {
return service->SearchPaymentReferencesViaOutputHash(ctx, req, writer);
}, this)));
}
BaseNode::Service::~Service() {
@@ -1300,7 +1392,7 @@ BaseNode::Service::~Service() {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status BaseNode::Service::GetVersion(::grpc::ServerContext* context, const ::tari::rpc::Empty* request, ::tari::rpc::StringValue* response) {
::grpc::Status BaseNode::Service::GetVersion(::grpc::ServerContext* context, const ::tari::rpc::Empty* request, ::tari::rpc::BaseNodeGetVersionResponse* response) {
(void) context;
(void) request;
(void) response;
@@ -1482,6 +1574,13 @@ BaseNode::Service::~Service() {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status BaseNode::Service::GetValidatorNodeChanges(::grpc::ServerContext* context, const ::tari::rpc::GetValidatorNodeChangesRequest* request, ::tari::rpc::GetValidatorNodeChangesResponse* response) {
(void) context;
(void) request;
(void) response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status BaseNode::Service::GetShardKey(::grpc::ServerContext* context, const ::tari::rpc::GetShardKeyRequest* request, ::tari::rpc::GetShardKeyResponse* response) {
(void) context;
(void) request;
@@ -1510,7 +1609,22 @@ BaseNode::Service::~Service() {
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status BaseNode::Service::SearchPaymentReferences(::grpc::ServerContext* context, const ::tari::rpc::SearchPaymentReferencesRequest* request, ::grpc::ServerWriter< ::tari::rpc::PaymentReferenceResponse>* writer) {
(void) context;
(void) request;
(void) writer;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
::grpc::Status BaseNode::Service::SearchPaymentReferencesViaOutputHash(::grpc::ServerContext* context, const ::tari::rpc::FetchMatchingUtxosRequest* request, ::grpc::ServerWriter< ::tari::rpc::PaymentReferenceResponse>* writer) {
(void) context;
(void) request;
(void) writer;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
} // namespace tari
} // namespace rpc
#include <grpcpp/ports_undef.inc>
File diff suppressed because it is too large Load Diff
+15680 -7427
View File
File diff suppressed because it is too large Load Diff
+12759 -6451
View File
File diff suppressed because it is too large Load Diff
+146 -23
View File
@@ -46,7 +46,7 @@ service BaseNode {
// Returns Block Fees
rpc GetBlockFees (BlockGroupRequest) returns (BlockGroupResponse);
// Get Version
rpc GetVersion(Empty) returns (StringValue);
rpc GetVersion(Empty) returns (BaseNodeGetVersionResponse);
// Check for new updates
rpc CheckForUpdates(Empty) returns (SoftwareUpdate);
// Get coins in circulation
@@ -95,11 +95,17 @@ service BaseNode {
rpc GetMempoolStats(Empty) returns (MempoolStatsResponse);
// Get VNs
rpc GetActiveValidatorNodes(GetActiveValidatorNodesRequest) returns (stream GetActiveValidatorNodesResponse);
rpc GetValidatorNodeChanges(GetValidatorNodeChangesRequest) returns (GetValidatorNodeChangesResponse);
rpc GetShardKey(GetShardKeyRequest) returns (GetShardKeyResponse);
// Get templates
rpc GetTemplateRegistrations(GetTemplateRegistrationsRequest) returns (stream GetTemplateRegistrationResponse);
rpc GetSideChainUtxos(GetSideChainUtxosRequest) returns (stream GetSideChainUtxosResponse);
rpc GetNetworkState(GetNetworkStateRequest) returns (GetNetworkStateResponse);
// PayRef (Payment Reference) lookup for block explorers and external services
rpc SearchPaymentReferences(SearchPaymentReferencesRequest) returns (stream PaymentReferenceResponse);
// PayRef (Payment Reference) lookup for block explorers and external services via output hash
rpc SearchPaymentReferencesViaOutputHash(FetchMatchingUtxosRequest) returns (stream PaymentReferenceResponse);
}
message GetAssetMetadataRequest {
@@ -174,6 +180,42 @@ enum BaseNodeState{
SYNC_FAILED = 6;
}
message ReadinessStatus {
enum State {
NOT_READY = 0;
STARTING_UP = 1;
// Database phase (10-19)
DATABASE_INITIALIZING = 10;
// Recovery phase (20-29)
RECOVERING_PREPARING = 20;
RECOVERING_REBUILDING = 21;
RECOVERING_REBUILDING_DATABASE = 22;
// Context building phase (30-39)
BUILDING_CONTEXT_BLOCKCHAIN = 32;
BUILDING_CONTEXT_BOOTSTRAP = 34;
READY = 100;
}
oneof status {
State state = 1;
MigrationProgress migration = 2;
}
uint64 timestamp = 6;
}
message MigrationProgress {
uint64 current_block = 1;
uint64 total_blocks = 2;
double progress_percentage = 3;
uint64 current_db_version = 4;
uint64 target_db_version = 5;
}
/// return type of GetNewBlockTemplate
message NewBlockTemplateResponse {
NewBlockTemplate new_block_template = 1;
@@ -226,9 +268,24 @@ message NetworkDifficultyResponse {
// A generic single value response for a specific height
message ValueAtHeightResponse {
// This is the total circulating token supply up to date ('mined_rewards + spendable_pre_mine').
uint64 circulating_supply = 1;
uint64 spendable_supply = 2;
// uint64 spendable_supply = 2; // No longer used
// This is the block height the values are valid for.
uint64 height = 3;
// This is the total mined rewards up to date, including time locked coinbase rewards that is not spendable.
uint64 mined_rewards = 4;
// This is the total spendable minded rewards up to date, which excludes all coinbase rewards that is
// still time locked.
uint64 spendable_rewards = 5;
// This is the total spendable pre-mine tokens released up to date, i.e. not time-locked anymore.
uint64 spendable_pre_mine = 6;
// This is the total spendable token supply up to date ('spendable_rewards + spendable_pre_mine').
uint64 total_spendable = 7;
// This is the total pre-mine tokens in the genesis block, time-locked and not time-locked.
uint64 total_pre_mine = 8;
// This is the total pre-mine tokens that are still time-locked up to date (`total_pre_mine - spendable_pre_mine`).
uint64 time_locked_pre_mine = 9;
}
// A generic uint value
@@ -236,9 +293,9 @@ message IntegerValue {
uint64 value = 1;
}
// A generic String value
message StringValue {
string value = 1;
message BaseNodeGetVersionResponse {
string version = 1;
uint32 network = 2;
}
/// GetBlockSize / GetBlockFees Request
@@ -481,48 +538,76 @@ message MempoolStatsResponse {
}
message GetActiveValidatorNodesRequest {
uint64 height = 1;
uint64 height = 1;
bytes sidechain_id = 2;
}
message GetActiveValidatorNodesResponse {
bytes shard_key = 1;
bytes public_key = 2;
bytes shard_key = 1;
bytes public_key = 2;
bytes sidechain_id = 3;
}
message GetValidatorNodeChangesRequest {
uint64 epoch = 1;
bytes sidechain_id = 2;
}
message ValidatorNodeChange {
oneof change {
ValidatorNodeChangeAdd add = 1;
ValidatorNodeChangeRemove remove = 2;
}
}
message ValidatorNodeChangeAdd {
uint64 activation_epoch = 1;
ValidatorNodeRegistration registration = 2;
uint64 minimum_value_promise = 3;
bytes shard_key = 4;
}
message ValidatorNodeChangeRemove {
bytes public_key = 1;
}
message GetValidatorNodeChangesResponse {
repeated ValidatorNodeChange changes = 1;
}
message GetShardKeyRequest {
uint64 height = 1;
bytes public_key = 2;
uint64 epoch = 1;
bytes public_key = 2;
}
message GetShardKeyResponse {
bytes shard_key = 1;
bool found = 2;
bytes shard_key = 1;
}
message GetTemplateRegistrationsRequest {
bytes start_hash = 1;
uint64 count = 2;
bytes start_hash = 1;
uint64 count = 2;
}
message GetTemplateRegistrationResponse {
bytes utxo_hash = 1;
TemplateRegistration registration = 2;
bytes utxo_hash = 1;
TemplateRegistration registration = 2;
}
message BlockInfo {
uint64 height = 1;
bytes hash = 2;
bytes next_block_hash = 3;
uint64 height = 1;
bytes hash = 2;
bytes next_block_hash = 3;
}
message GetSideChainUtxosRequest {
bytes start_hash = 1;
uint64 count = 2;
bytes start_hash = 1;
uint64 count = 2;
}
message GetSideChainUtxosResponse {
BlockInfo block_info = 1;
repeated TransactionOutput outputs = 2;
BlockInfo block_info = 1;
repeated TransactionOutput outputs = 2;
}
message GetNetworkStateRequest {
@@ -548,6 +633,8 @@ message GetNetworkStateResponse {
uint64 num_connections = 8;
//liveness results
repeated LivenessResult liveness_results = 9;
// readiness status
ReadinessStatus readiness_status = 11;
}
message LivenessResult{
@@ -559,3 +646,39 @@ message LivenessResult{
uint64 ping_latency = 3;
}
// PayRef (Payment Reference) search and lookup messages
// Request to search for outputs by payment reference
message SearchPaymentReferencesRequest {
// Payment reference as hex string (64 characters)
repeated string payment_reference_hex = 1;
repeated bytes payment_reference_bytes = 2;
// Optional: include spent outputs in results
bool include_spent = 3;
}
// Response containing payment reference match
message PaymentReferenceResponse {
// The payment reference that was found
string payment_reference_hex = 1;
// Block height where the output was mined
uint64 block_height = 2;
// Block hash where the output was mined
bytes block_hash = 3;
// Timestamp when the output was mined
uint64 mined_timestamp = 4;
// Output commitment (32 bytes)
bytes commitment = 5;
// Whether this output has been spent
bool is_spent = 6;
// Height where output was spent - will be 0 for unspent outputs as it is not applicable
uint64 spent_height = 7;
// Block hash where output was spent - will be empty for unspent outputs
bytes spent_block_hash = 8;
// Minimum value promise
uint64 min_value_promise = 9;
// Timestamp when the output was spent - will be 0 for unspent outputs as it is not applicable
uint64 spent_timestamp = 10;
// Output hash of the output
bytes output_hash = 11;
}
+2
View File
@@ -19,9 +19,11 @@
#include <grpcpp/server_context.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
} // namespace tari
} // namespace rpc
#include <grpcpp/ports_undef.inc>
+2
View File
@@ -46,6 +46,7 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
@@ -54,4 +55,5 @@ namespace rpc {
} // namespace tari
#include <grpcpp/ports_undef.inc>
#endif // GRPC_block_2eproto__INCLUDED
+1794 -1247
View File
File diff suppressed because it is too large Load Diff
+1499 -1095
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -19,9 +19,11 @@
#include <grpcpp/server_context.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
} // namespace tari
} // namespace rpc
#include <grpcpp/ports_undef.inc>
+2
View File
@@ -46,6 +46,7 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
@@ -54,4 +55,5 @@ namespace rpc {
} // namespace tari
#include <grpcpp/ports_undef.inc>
#endif // GRPC_network_2eproto__INCLUDED
+1964 -1162
View File
File diff suppressed because it is too large Load Diff
+1564 -1202
View File
File diff suppressed because it is too large Load Diff
@@ -19,9 +19,11 @@
#include <grpcpp/server_context.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
} // namespace tari
} // namespace rpc
#include <grpcpp/ports_undef.inc>
@@ -46,6 +46,7 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
@@ -54,4 +55,5 @@ namespace rpc {
} // namespace tari
#include <grpcpp/ports_undef.inc>
#endif // GRPC_sidechain_5ftypes_2eproto__INCLUDED
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+119 -24
View File
@@ -26,43 +26,59 @@ package tari.rpc;
import "types.proto";
message SideChainFeature {
oneof side_chain_feature {
ValidatorNodeRegistration validator_node_registration = 1;
TemplateRegistration template_registration = 2;
ConfidentialOutputData confidential_output = 3;
}
oneof feature {
ValidatorNodeRegistration validator_node_registration = 1;
TemplateRegistration template_registration = 2;
ConfidentialOutputData confidential_output = 3;
EvictionProof eviction_proof = 4;
ValidatorNodeExit validator_node_exit = 5;
}
SideChainId sidechain_id = 6;
}
message SideChainId {
bytes public_key = 1;
Signature knowledge_proof = 2;
}
message ValidatorNodeRegistration {
bytes public_key = 1;
Signature signature = 2;
bytes public_key = 1;
Signature signature = 2;
bytes claim_public_key = 3;
uint64 max_epoch = 4;
}
message ValidatorNodeExit {
bytes public_key = 1;
Signature signature = 2;
uint64 max_epoch = 3;
}
message TemplateRegistration {
bytes author_public_key = 1;
Signature author_signature = 2;
string template_name = 3;
uint32 template_version = 4;
TemplateType template_type = 5;
BuildInfo build_info = 6;
bytes binary_sha = 7;
string binary_url = 8;
bytes author_public_key = 1;
Signature author_signature = 2;
string template_name = 3;
uint32 template_version = 4;
TemplateType template_type = 5;
BuildInfo build_info = 6;
bytes binary_sha = 7;
string binary_url = 8;
}
message ConfidentialOutputData {
bytes claim_public_key = 1;
bytes claim_public_key = 1;
}
message TemplateType {
oneof template_type {
WasmInfo wasm = 1;
FlowInfo flow = 2;
ManifestInfo manifest = 3;
}
oneof template_type {
WasmInfo wasm = 1;
FlowInfo flow = 2;
ManifestInfo manifest = 3;
}
}
message WasmInfo {
uint32 abi_version = 1;
uint32 abi_version = 1;
}
message FlowInfo {
@@ -72,6 +88,85 @@ message ManifestInfo {
}
message BuildInfo {
string repo_url = 1;
bytes commit_hash = 2;
string repo_url = 1;
bytes commit_hash = 2;
}
message EvictionProof {
CommitProof proof = 1;
}
message CommitProof {
oneof version {
CommitProofV1 v1 = 1;
}
}
message CommitProofV1 {
bytes command = 1;
SidechainBlockCommitProof commit_proof = 2;
bytes encoded_inclusion_proof = 3;
}
message SidechainBlockCommitProof {
SidechainBlockHeader header = 1;
repeated CommitProofElement proof_elements = 2;
}
message CommitProofElement {
oneof proof_element {
QuorumCertificate quorum_certificate = 1;
DummyChain dummy_chain = 2;
}
}
message DummyChain {
repeated ChainLink chain_links = 1;
}
message ChainLink {
bytes header_hash = 1;
bytes parent_id = 2;
}
message SidechainBlockHeader {
uint32 network = 1;
bytes parent_id = 2;
bytes justify_id = 3;
uint64 height = 4;
uint64 epoch = 5;
ShardGroup shard_group = 6;
bytes proposed_by = 7;
bytes state_merkle_root = 8;
bytes command_merkle_root = 9;
Signature signature = 11;
bytes metadata_hash = 10;
}
message ShardGroup {
uint32 start = 1;
uint32 end_inclusive = 2;
}
message EvictAtom {
bytes public_key = 1;
}
message QuorumCertificate {
bytes header_hash = 1;
bytes parent_id = 2;
repeated ValidatorSignature signatures = 3;
QuorumDecision decision = 4;
}
enum QuorumDecision {
Accept = 0;
Reject = 1;
}
message ValidatorSignature {
bytes public_key = 1;
Signature signature = 2;
}
+2
View File
@@ -19,9 +19,11 @@
#include <grpcpp/server_context.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
} // namespace tari
} // namespace rpc
#include <grpcpp/ports_undef.inc>
+2
View File
@@ -46,6 +46,7 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
@@ -54,4 +55,5 @@ namespace rpc {
} // namespace tari
#include <grpcpp/ports_undef.inc>
#endif // GRPC_transaction_2eproto__INCLUDED
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4
View File
@@ -115,6 +115,10 @@ message TransactionOutput {
bytes encrypted_data = 10;
// The minimum value of the commitment that is proven by the range proof (in MicroMinotari)
uint64 minimum_value_promise = 11;
// Payment reference (PayRef) - 32-byte Blake2b hash of (block_hash || output_hash)
// This provides a unique, deterministic reference for the output that can be used
// for payment verification without revealing wallet ownership
bytes payment_reference = 12;
}
// Options for UTXOs
+2
View File
@@ -19,9 +19,11 @@
#include <grpcpp/server_context.h>
#include <grpcpp/impl/service_type.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
} // namespace tari
} // namespace rpc
#include <grpcpp/ports_undef.inc>
+2
View File
@@ -46,6 +46,7 @@
#include <grpcpp/support/status.h>
#include <grpcpp/support/stub_options.h>
#include <grpcpp/support/sync_stream.h>
#include <grpcpp/ports_def.inc>
namespace tari {
namespace rpc {
@@ -54,4 +55,5 @@ namespace rpc {
} // namespace tari
#include <grpcpp/ports_undef.inc>
#endif // GRPC_types_2eproto__INCLUDED
+3218 -2066
View File
File diff suppressed because it is too large Load Diff
+2066 -1459
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -126,7 +126,6 @@ message ConsensusConstants {
uint64 block_weight_kernels = 16;
uint64 pre_mine_value = 17;
uint64 max_script_byte_size = 18;
uint64 validator_node_validity_period = 19;
uint64 effective_from_height = 20;
Range valid_blockchain_version_range = 21;
uint64 max_randomx_seed_height = 22;
@@ -144,4 +143,6 @@ message ConsensusConstants {
uint64 inflation_bips = 35;
uint64 tail_epoch_length = 36;
uint64 max_block_coinbase_count = 37;
uint32 vn_registration_max_vns_initial_epoch = 38;
uint32 vn_registration_max_vns_per_epoch = 39;
}
+2
View File
@@ -9,4 +9,6 @@
#define ASAN_UNPOISON_MEMORY_REGION(addr, size) __asan_unpoison_memory_region((addr), (size))
#endif
#define __asan_address_is_poisoned(addr) false
#endif // P2POOL_EXTERNAL_SRC_COMMON_SANITIZER_ASAN_INTERFACE_H
+14 -13
View File
@@ -1,16 +1,16 @@
diff --git a/src/crypto/rand_extra/windows.c b/src/crypto/rand_extra/windows.c
index a44774d23..09cf10942 100644
--- a/src/crypto/rand_extra/windows.c
+++ b/src/crypto/rand_extra/windows.c
@@ -26,6 +26,7 @@
OPENSSL_MSVC_PRAGMA(warning(push, 3))
diff --git a/src/crypto/rand/windows.cc b/src/crypto/rand/windows.cc
index 59df467e7..aa5ac076c 100644
--- a/src/crypto/rand/windows.cc
+++ b/src/crypto/rand/windows.cc
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <windows.h>
+#include <wincrypt.h>
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
@@ -61,16 +62,40 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
@@ -57,16 +58,40 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
// See: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
typedef BOOL (WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData);
static ProcessPrngFunction g_processprng_fn = NULL;
@@ -25,21 +25,22 @@ index a44774d23..09cf10942 100644
HMODULE hmod = LoadLibraryW(L"bcryptprimitives");
- if (hmod == NULL) {
- abort();
- }
- g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
- if (g_processprng_fn == NULL) {
- abort();
+
+ if (hmod) {
+ g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
+ if (g_processprng_fn) {
+ return;
+ }
}
- g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
- if (g_processprng_fn == NULL) {
- abort();
+ }
+
+ if (CryptAcquireContext(&g_hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
+ g_processprng_fn = &wrapper_CryptGenRandom;
+ return;
+ }
}
+
+ DWORD err = GetLastError();
+ if (err == NTE_BAD_KEYSET) {
@@ -50,7 +51,7 @@ index a44774d23..09cf10942 100644
+ else {
+ err = GetLastError();
+ }
}
+ }
+
+ abort();
}
+35
View File
@@ -0,0 +1,35 @@
diff --git a/src/google/protobuf/generated_message_tctable_lite.cc b/src/google/protobuf/generated_message_tctable_lite.cc
index 5758c1602..e425d6715 100644
--- a/src/google/protobuf/generated_message_tctable_lite.cc
+++ b/src/google/protobuf/generated_message_tctable_lite.cc
@@ -406,7 +406,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {
if (entry == nullptr) {
if (export_called_function) *test_out = {table->fallback, tag};
data.data = tag;
- PROTOBUF_MUSTTAIL return table->fallback(PROTOBUF_TC_PARAM_PASS);
+ return table->fallback(PROTOBUF_TC_PARAM_PASS);
}
// The handler may need the tag and the entry to resolve fallback logic. Both
@@ -468,7 +468,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::MiniParse(PROTOBUF_TC_PARAM_DECL) {
TailCallParseFunc parse_fn = kMiniParseTable[field_type];
if (export_called_function) *test_out = {parse_fn, tag, entry};
- PROTOBUF_MUSTTAIL return parse_fn(PROTOBUF_TC_PARAM_PASS);
+ return parse_fn(PROTOBUF_TC_PARAM_PASS);
}
PROTOBUF_NOINLINE const char* TcParser::MiniParse(
diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
index edd6d5122..da894d384 100644
--- a/src/google/protobuf/port_def.inc
+++ b/src/google/protobuf/port_def.inc
@@ -506,7 +506,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
#error PROTOBUF_ATTRIBUTE_WEAK was previously defined
#endif
#if ABSL_HAVE_ATTRIBUTE(weak) && !defined(__APPLE__) && \
- (!defined(_WIN32) || __clang_major__ < 9) && !defined(__MINGW32__)
+ (!defined(_WIN32) || (defined(__clang_major__) && (__clang_major__ < 9))) && !defined(__MINGW32__)
#define PROTOBUF_ATTRIBUTE_WEAK __attribute__((weak))
#define PROTOBUF_HAVE_ATTRIBUTE_WEAK 1
#else
+1 -1
View File
@@ -7,7 +7,7 @@ cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 --build-arg CLANG_VERSION=$2 -t p2pool_compiler_test_clang_$1_$2 .
docker create --name p2pool_compiler_test_clang_$1_$2_container p2pool_compiler_test_clang_$1_$2:latest
docker cp p2pool_compiler_test_clang_$1_$2_container:/p2pool/logs.tar.gz clang_$2_logs.tar.gz
docker cp p2pool_compiler_test_clang_$1_$2_container:/p2pool/output.log clang_$2_output.log
docker rm p2pool_compiler_test_clang_$1_$2_container
docker image rm -f p2pool_compiler_test_clang_$1_$2
-2
View File
@@ -8,5 +8,3 @@ git submodule update --recursive --jobs $(nproc)
export COMPILER="-DCMAKE_C_COMPILER=clang-$2 -DCMAKE_CXX_COMPILER=clang++-$2"
./test2.sh
tar -czvf /p2pool/logs.tar.gz /p2pool/output.log
+1 -1
View File
@@ -7,7 +7,7 @@ cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 --build-arg GCC_VERSION=$2 -t p2pool_compiler_test_gcc_$1_$2 .
docker create --name p2pool_compiler_test_gcc_$1_$2_container p2pool_compiler_test_gcc_$1_$2:latest
docker cp p2pool_compiler_test_gcc_$1_$2_container:/p2pool/logs.tar.gz gcc_$2_logs.tar.gz
docker cp p2pool_compiler_test_gcc_$1_$2_container:/p2pool/output.log gcc_$2_output.log
docker rm p2pool_compiler_test_gcc_$1_$2_container
docker image rm -f p2pool_compiler_test_gcc_$1_$2
-2
View File
@@ -8,5 +8,3 @@ git submodule update --recursive --jobs $(nproc)
export COMPILER="-DCMAKE_C_COMPILER=/usr/local/gcc-$2/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/gcc-$2/bin/g++ -DCMAKE_AR=/usr/local/gcc-$2/bin/gcc-ar -DCMAKE_RANLIB=/usr/local/gcc-$2/bin/gcc-ranlib"
./test2.sh
tar -czvf /p2pool/logs.tar.gz /p2pool/output.log
@@ -106,11 +106,11 @@ mkdir build && cd build
make -j$(nproc)
make install
echo "Installing GCC 15.1.0"
echo "Installing GCC 15.2.0"
cd /root
git clone --depth 1 --branch releases/gcc-15.1.0 --jobs $(nproc) git://gcc.gnu.org/git/gcc.git gcc-15
git clone --depth 1 --branch releases/gcc-15.2.0 --jobs $(nproc) git://gcc.gnu.org/git/gcc.git gcc-15
cd gcc-15
contrib/download_prerequisites
+14 -10
View File
@@ -1,6 +1,6 @@
#!/bin/sh
# Example usage: release_scripts/build_all.sh v4.8.1
# Example usage: release_scripts/build_all.sh v4.9
cd "$(dirname "$0")"
@@ -11,12 +11,16 @@ if [ $? -ne 0 ]; then
images/ubuntu/build.sh
fi
gnome-terminal --tab -- freebsd_aarch64/build.sh $1
gnome-terminal --tab -- freebsd_x64/build.sh $1
gnome-terminal --tab -- linux_aarch64/build.sh $1
gnome-terminal --tab -- linux_riscv64/build.sh $1
gnome-terminal --tab -- linux_x64/build.sh $1
gnome-terminal --tab -- windows_x64/build.sh $1
gnome-terminal --tab -- macos_aarch64/build.sh $1
gnome-terminal --tab -- macos_x64/build.sh $1
gnome-terminal --tab -- source/build.sh $1
N=$(($(nproc)-1))
N1=$(($N/2))
N2=$(($N1+1))
gnome-terminal --tab -- freebsd_aarch64/build.sh $1 0-$N1
gnome-terminal --tab -- freebsd_x64/build.sh $1 $N2-$N
gnome-terminal --tab -- linux_aarch64/build.sh $1 0-$N1
gnome-terminal --tab -- linux_riscv64/build.sh $1 $N2-$N
gnome-terminal --tab -- linux_x64/build.sh $1 0-$N1
gnome-terminal --tab -- windows_x64/build.sh $1 $N2-$N
gnome-terminal --tab -- macos_aarch64/build.sh $1 0-$N1
gnome-terminal --tab -- macos_x64/build.sh $1 $N2-$N
gnome-terminal --tab -- source/build.sh $1 0-$N1
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_aarch64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_aarch64_build_$1 .
docker create --name p2pool_freebsd_aarch64_build_$1_container p2pool_freebsd_aarch64_build_$1:latest
docker cp p2pool_freebsd_aarch64_build_$1_container:/p2pool/build/p2pool-$1-freebsd-aarch64.tar.gz ../p2pool-$1-freebsd-aarch64.tar.gz
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_x64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_freebsd_x64_build_$1 .
docker create --name p2pool_freebsd_x64_build_$1_container p2pool_freebsd_x64_build_$1:latest
docker cp p2pool_freebsd_x64_build_$1_container:/p2pool/build/p2pool-$1-freebsd-x64.tar.gz ../p2pool-$1-freebsd-x64.tar.gz
+34 -11
View File
@@ -3,27 +3,29 @@ set -e
# Software versions to install
_7ZIP_VERSION=2409
BINUTILS_VERSION=2_44
_7ZIP_VERSION=2501
BINUTILS_VERSION=2_45
CLANG_VERSION=20.1.8
CMAKE_VERSION=4.0.3
CMAKE_VERSION=4.1.1
FREEBSD_VERSION=12.4
GCC_VERSION=15.1.0
GLIBC_VERSION=2.41
LINUX_HEADERS_VERSION=6.15.4
GCC_VERSION=15.2.0
GLIBC_VERSION=2.42
LINUX_HEADERS_VERSION=6.16.3
MACOSX_SDK_VERSION=15.5
MAKE_VERSION=4.4.1
MINGW_VERSION=13.0.0
XZ_VERSION=5.8.1
TAR_VERSION=1.35
_7ZIP_SHA256="914c7e20ad5ef8e4d3cf08620ff8894b28fe11b7eb99809d6930870fbe48a281"
CMAKE_SHA256="585ae9e013107bc8e7c7c9ce872cbdcbdff569e675b07ef57aacfb88c886faac"
_7ZIP_SHA256="4ca3b7c6f2f67866b92622818b58233dc70367be2f36b498eb0bdeaaa44b53f4"
CMAKE_SHA256="5a6c61cb62b38e153148a2c8d4af7b3d387f0c8c32b6dbceb5eb4af113efd65a"
FREEBSD_AARCH64_SHA256="6c401819bfb93e810c9f9aa670a1e4685f924df5e7e0c9c6397dd6c16c954fa2"
FREEBSD_X86_64_SHA256="581c7edacfd2fca2bdf5791f667402d22fccd8a5e184635e0cac075564d57aa8"
GLIBC_SHA256="a5a26b22f545d6b7d7b3dd828e11e428f24f4fac43c934fb071b6a7d0828e901"
HEADERS_SHA256="0eafd627b602f58d73917d00e4fc3196ba18cba67df6995a42aa74744d8efa16"
GLIBC_SHA256="d1775e32e4628e64ef930f435b67bb63af7599acb6be2b335b9f19f16509f17f"
HEADERS_SHA256="80439ba055c12f541abf44b8fc3c9b825a8f42fc25ce67462ec7e556c5790b85"
MACOSX_SDK_SHA256="c15cf0f3f17d714d1aa5a642da8e118db53d79429eb015771ba816aa7c6c1cbd"
MAKE_SHA256="dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"
TAR_SHA256="4d62ff37342ec7aed748535323930c7cf94acf71c3591882b26a7ea50f3edc16"
echo "Install prerequisites"
@@ -112,7 +114,7 @@ fi
tar xvf $CMAKE_FILE
cp $CMAKE_NAME/bin/* /usr/local/bin
cp -r $CMAKE_NAME/share/cmake-4.0 /usr/local/share
cp -r $CMAKE_NAME/share/cmake-4.1 /usr/local/share
echo "Install make"
@@ -427,6 +429,27 @@ make -j$(nproc)
cp -f lzma* /usr/bin
cp -f xz* /usr/bin
echo "Install tar"
cd /root
TAR_FILE=tar-$TAR_VERSION.tar.xz
curl -L -O https://ftpmirror.gnu.org/tar/$TAR_FILE
TAR_FILE_SHA256="$(sha256sum $TAR_FILE | awk '{ print $1 }')"
if [ $TAR_FILE_SHA256 != $TAR_SHA256 ]; then
echo "Error: SHA256 sum does not match for $TAR_FILE - expected $TAR_SHA256, got $TAR_FILE_SHA256"
exit 1
fi
tar xvf $TAR_FILE
cd tar-$TAR_VERSION
FORCE_UNSAFE_CONFIGURE=1 ./configure
make -j$(nproc)
make install
echo "Deleting system glibc files to force our glibc"
rm /usr/lib/x86_64-linux-gnu/crt1.o
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_aarch64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_aarch64_build_$1 .
docker create --name p2pool_ubuntu_aarch64_build_$1_container p2pool_ubuntu_aarch64_build_$1:latest
docker cp p2pool_ubuntu_aarch64_build_$1_container:/p2pool/build/p2pool-$1-linux-aarch64.tar.gz ../p2pool-$1-linux-aarch64.tar.gz
@@ -3,7 +3,7 @@ set -e
cd /p2pool
git fetch --jobs=$(nproc)
git checkout $3
git checkout $2
git submodule update --recursive --jobs $(nproc)
export TZ=UTC0
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_riscv64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_ubuntu_riscv64_build_$1 .
docker create --name p2pool_ubuntu_riscv64_build_$1_container p2pool_ubuntu_riscv64_build_$1:latest
docker cp p2pool_ubuntu_riscv64_build_$1_container:/p2pool/build/p2pool-$1-linux-riscv64.tar.gz ../p2pool-$1-linux-riscv64.tar.gz
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_linux_x64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_linux_x64_build_$1 .
docker create --name p2pool_linux_x64_build_$1_container p2pool_linux_x64_build_$1:latest
docker cp p2pool_linux_x64_build_$1_container:/p2pool/build/p2pool-$1-linux-x64.tar.gz ../p2pool-$1-linux-x64.tar.gz
+1 -1
View File
@@ -1,4 +1,4 @@
FROM p2pool_build_ubuntu
ARG P2POOL_VERSION
ADD p2pool_macos_aarch64.sh zutil.patch /p2pool/
ADD p2pool_macos_aarch64.sh /p2pool/
RUN /p2pool/p2pool_macos_aarch64.sh p2pool-${P2POOL_VERSION}-macos-aarch64 ${P2POOL_VERSION}
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_macos_aarch64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_macos_aarch64_build_$1 .
docker create --name p2pool_macos_aarch64_build_$1_container p2pool_macos_aarch64_build_$1:latest
docker cp p2pool_macos_aarch64_build_$1_container:/p2pool/build/p2pool-$1-macos-aarch64.tar.gz ../p2pool-$1-macos-aarch64.tar.gz
@@ -19,8 +19,6 @@ flags_datetime="-D__DATE__=\"\\\"$CURRENT_DATE\\\"\" -D__TIME__=\"\\\"$CURRENT_T
flags_libs="-Os -flto -w $flags_size $flags_datetime"
flags_p2pool="$flags_size $flags_datetime"
patch -u /p2pool/external/src/grpc/third_party/zlib/zutil.h -i /p2pool/zutil.patch
cd /p2pool/external/src/curl
cmake . -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=../../../cmake/macos_aarch64_toolchain_clang.cmake -DCMAKE_C_FLAGS="$flags_libs" -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 -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include
make -j$(nproc)
-10
View File
@@ -1,10 +0,0 @@
--- zutil.h
+++ zutil.h
@@ -144,7 +144,6 @@
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
# endif
+1 -1
View File
@@ -1,4 +1,4 @@
FROM p2pool_build_ubuntu
ARG P2POOL_VERSION
ADD p2pool_macos_x64.sh zutil.patch /p2pool/
ADD p2pool_macos_x64.sh /p2pool/
RUN /p2pool/p2pool_macos_x64.sh p2pool-${P2POOL_VERSION}-macos-x64 ${P2POOL_VERSION}
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_macos_x64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_macos_x64_build_$1 .
docker create --name p2pool_macos_x64_build_$1_container p2pool_macos_x64_build_$1:latest
docker cp p2pool_macos_x64_build_$1_container:/p2pool/build/p2pool-$1-macos-x64.tar.gz ../p2pool-$1-macos-x64.tar.gz
@@ -19,8 +19,6 @@ flags_datetime="-D__DATE__=\"\\\"$CURRENT_DATE\\\"\" -D__TIME__=\"\\\"$CURRENT_T
flags_libs="-Os -flto -w $flags_size $flags_datetime"
flags_p2pool="$flags_size $flags_datetime"
patch -u /p2pool/external/src/grpc/third_party/zlib/zutil.h -i /p2pool/zutil.patch
cd /p2pool/external/src/curl
cmake . -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=../../../cmake/macos_x86_64_toolchain_clang.cmake -DCMAKE_C_FLAGS="$flags_libs" -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 -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF -DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON -DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON -DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON -DCURL_DISABLE_NEGOTIATE_AUTH=ON -DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/src/include
make -j$(nproc)
-10
View File
@@ -1,10 +0,0 @@
--- zutil.h
+++ zutil.h
@@ -144,7 +144,6 @@
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
# endif
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_source_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_source_build_$1 .
docker create --name p2pool_source_build_$1_container p2pool_source_build_$1:latest
docker cp p2pool_source_build_$1_container:/p2pool_source-$1.tar.xz ../p2pool_source-$1.tar.xz
+8 -2
View File
@@ -1,10 +1,16 @@
#!/bin/sh
# Example usage: ./build.sh v4.8.1
# Example usage: ./build.sh v4.9
cd "$(dirname "$0")"
docker build --build-arg P2POOL_VERSION=$1 -t p2pool_windows_x64_build_$1 .
if [ "$2" ]; then
cpu_set="--cpuset-cpus $2"
else
cpu_set=""
fi
docker build $cpu_set --build-arg P2POOL_VERSION=$1 -t p2pool_windows_x64_build_$1 .
docker create --name p2pool_windows_x64_build_$1_container p2pool_windows_x64_build_$1:latest
docker cp p2pool_windows_x64_build_$1_container:/p2pool/build/p2pool-$1-windows-x64.zip ../p2pool-$1-windows-x64.zip
@@ -18,8 +18,8 @@ flags_datetime="-D__DATE__=\"\\\"$CURRENT_DATE\\\"\" -D__TIME__=\"\\\"$CURRENT_T
flags_libs="--target=x86_64-pc-windows-gnu -Os -flto -Wl,/timestamp:$BUILD_TIMESTAMP -fuse-ld=lld -w $flags_size $flags_datetime"
flags_p2pool="--target=x86_64-pc-windows-gnu -Wl,/timestamp:$BUILD_TIMESTAMP -fuse-ld=lld -femulated-tls -Wno-unused-command-line-argument $flags_size $flags_datetime"
flags_cxx_headers="-isystem /usr/local/x86_64-w64-mingw32/include/c++ -isystem /usr/local/x86_64-w64-mingw32/include/c++/15.1.0 -isystem /usr/local/x86_64-w64-mingw32/include"
flags_p2pool="--target=x86_64-pc-windows-gnu -Wl,/timestamp:$BUILD_TIMESTAMP -fuse-ld=lld -femulated-tls -Wno-unused-command-line-argument -Wno-unknown-attributes $flags_size $flags_datetime"
flags_cxx_headers="-isystem /usr/local/x86_64-w64-mingw32/include/c++ -isystem /usr/local/x86_64-w64-mingw32/include/c++/15.2.0 -isystem /usr/local/x86_64-w64-mingw32/include"
cd /p2pool
git apply --verbose --ignore-whitespace --directory=external/src/grpc/third_party/boringssl-with-bazel patches/boringssl/win7.patch
+16
View File
@@ -166,6 +166,14 @@ struct alignas(uint64_t) hash
FORCEINLINE hash() : h{} {}
constexpr hash(std::initializer_list<uint8_t> l) : h{} {
auto it = l.begin();
for (size_t i = 0; (i < HASH_SIZE) && (it != l.end()); ++i, ++it) {
h[i] = *it;
}
}
FORCEINLINE bool operator<(const hash& other) const
{
const uint64_t* a = u64();
@@ -496,6 +504,14 @@ struct raw_ip
static_assert(sizeof(raw_ip) == 16, "struct raw_ip has invalid size");
struct MoneroBlockBroadcastHeader
{
uint32_t header_size;
uint32_t miner_tx_size;
};
static_assert(sizeof(MoneroBlockBroadcastHeader) == sizeof(uint32_t) * 2, "struct MoneroBlockBroadcastHeader has invalid size");
void* malloc_hook(size_t n) noexcept;
void* realloc_hook(void* ptr, size_t size) noexcept;
void* calloc_hook(size_t count, size_t size) noexcept;
+1
View File
@@ -57,6 +57,7 @@ struct parse_wrapper<T, out_type> \
JSON_VALUE_PARSER(String, const char*)
JSON_VALUE_PARSER(String, std::string)
JSON_VALUE_PARSER(Uint, uint8_t)
JSON_VALUE_PARSER(Uint, uint32_t)
JSON_VALUE_PARSER(Uint64, uint64_t)
JSON_VALUE_PARSER(Bool, bool)
+2 -2
View File
@@ -25,7 +25,7 @@ LOG_CATEGORY(JSONRPCRequest)
namespace p2pool {
namespace JSONRPCRequest {
struct CurlContext
struct CurlContext : public nocopy_nomove
{
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);
~CurlContext();
@@ -481,7 +481,7 @@ void CurlContext::shutdown()
void Call(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)
{
if (!loop) {
loop = uv_default_loop();
loop = uv_default_loop_checked();
}
const bool result = CallOnLoop(loop,
+3 -1
View File
@@ -20,7 +20,9 @@
namespace p2pool {
namespace JSONRPCRequest {
typedef Callback<void, const char*, size_t, double>::Base CallbackBase;
typedef Callback<void, const char* /*msg*/, size_t /*msg_size*/, double /*tcp_ping*/>::Base CallbackBase;
FORCEINLINE static constexpr void dummy_callback(const char* /*msg*/, size_t /*msg_size*/, double /*tcp_ping*/) {}
void Call(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);
+3
View File
@@ -26,6 +26,9 @@ enum KeccakParams {
extern const uint64_t keccakf_rndc[24];
// keccak hash of a single 0x00 byte
constexpr hash keccak_0x00{ 0xbc, 0x36, 0x78, 0x9e, 0x7a, 0x1e, 0x28, 0x14, 0x36, 0x46, 0x42, 0x29, 0x82, 0x8f, 0x81, 0x7d, 0x66, 0x12, 0xf7, 0xb4, 0x77, 0xd6, 0x65, 0x91, 0xff, 0x96, 0xa9, 0xe0, 0x64, 0xbc, 0xc9, 0x8a };
typedef void (*keccakf_func)(std::array<uint64_t, 25>&);
extern keccakf_func keccakf;
+45 -13
View File
@@ -38,6 +38,7 @@
#endif // WITH_GRPC
#include <filesystem>
#include <fstream>
#ifdef WITH_RANDOMX
#include "randomx.h"
@@ -99,6 +100,7 @@ void p2pool_usage()
"--rpc-ssl-fingerprint base64-encoded fingerprint of the Monero node's certificate (optional, use it for certificate pinning)\n"
#endif
"--no-stratum-http Disable HTTP on Stratum ports\n"
"--full-validation Enables full share validation / increases CPU usage\n"
"--help Show this help message\n\n"
"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",
@@ -220,6 +222,9 @@ int main(int argc, char* argv[])
return 0;
}
bool is_mini = false;
bool is_nano = false;
for (int i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "/help") || !strcmp(argv[i], "-h") || !strcmp(argv[i], "/h")) {
p2pool_usage();
@@ -237,25 +242,52 @@ int main(int argc, char* argv[])
if ((strcmp(argv[i], "--data-dir") == 0) && (i + 1 < argc)) {
std::string path = argv[++i];
if (!path.empty() && (path.back() != '/')
#ifdef _WIN32
&& (path.back() != '\\')
#endif
) {
path.append(1, '/');
}
p2pool::DATA_DIR = std::move(path);
p2pool::fixup_path(p2pool::DATA_DIR);
}
// Try to create it if it doesn't exist
if (!p2pool::DATA_DIR.empty()) {
std::error_code err;
std::filesystem::create_directories(p2pool::DATA_DIR, err);
if (!strcmp(argv[i], "--mini")) is_mini = true;
if (!strcmp(argv[i], "--nano")) is_nano = true;
}
// If the data directory is not set, check if P2Pool has write access to the current directory
// If it doesn't, switch to user's home directory
if (p2pool::DATA_DIR.empty()) {
std::ofstream f("p2pool.tmp");
if (f && f.put(' ')) {
f.close();
std::remove("p2pool.tmp");
}
else {
char buf[1024];
size_t size = sizeof(buf);
if (uv_os_homedir(buf, &size) == 0) {
p2pool::DATA_DIR.assign(buf, size);
p2pool::fixup_path(p2pool::DATA_DIR);
p2pool::DATA_DIR += ".p2pool/";
if (is_mini) {
p2pool::DATA_DIR += "mini/";
}
else if (is_nano) {
p2pool::DATA_DIR += "nano/";
}
}
}
}
if (!p2pool::DATA_DIR.empty()) {
printf("Using \"%s\" for P2Pool files\n", p2pool::DATA_DIR.c_str());
}
// Try to create it if it doesn't exist
if (!p2pool::DATA_DIR.empty()) {
std::error_code err;
std::filesystem::create_directories(p2pool::DATA_DIR, err);
}
#if defined(_WIN32) && defined(_MSC_VER) && !defined(NDEBUG)
SymInitialize(GetCurrentProcess(), NULL, TRUE);
#endif
+24 -5
View File
@@ -287,6 +287,9 @@ void MergeMiningClientTari::on_external_block(const PoolBlock& block)
chain_params.aux_diff = diff;
}
}
else {
m_previousAuxHashesFoundIndex = std::numeric_limits<uint32_t>::max();
}
if (!diff.check_pow(block.m_powHash)) {
LOGINFO(4, "External aux job solution found, but it doesn't have enough PoW (block diff = " << block.m_difficulty << ", Tari diff = " << diff << ')');
@@ -867,6 +870,10 @@ bool MergeMiningClientTari::TariServer::connect_upstream(TariClient* downstream)
upstream->m_pairedClient = downstream;
upstream->m_pairedClientSavedResetCounter = downstream->m_resetCounter;
upstream->m_connectionPending = true;
downstream->m_pairedClient = upstream;
downstream->m_pairedClientSavedResetCounter = upstream->m_resetCounter;
return true;
}
@@ -882,6 +889,7 @@ const char* MergeMiningClientTari::TariServer::get_log_category() const
MergeMiningClientTari::TariClient::TariClient()
: Client(m_buf, sizeof(m_buf))
, m_connectionPending(false)
, m_pairedClient(nullptr)
, m_pairedClientSavedResetCounter(std::numeric_limits<uint32_t>::max())
{
@@ -889,12 +897,23 @@ MergeMiningClientTari::TariClient::TariClient()
}
void MergeMiningClientTari::TariClient::reset()
{
m_pendingData.clear();
m_connectionPending = false;
break_pairing();
}
void MergeMiningClientTari::TariClient::break_pairing()
{
if (is_paired()) {
m_pairedClient->m_pairedClient = nullptr;
m_pairedClient->close();
m_pairedClient = nullptr;
m_pairedClient->m_pairedClientSavedResetCounter = std::numeric_limits<uint32_t>::max();
if (!m_pairedClient->m_connectionPending) {
m_pairedClient->close();
}
}
m_pairedClient = nullptr;
m_pairedClientSavedResetCounter = std::numeric_limits<uint32_t>::max();
}
@@ -910,10 +929,10 @@ bool MergeMiningClientTari::TariClient::on_connect()
}
else {
// The outgoing connection is ready now
m_connectionPending = false;
// Check if the incoming connection (downstream) has already sent something that needs to be relayed
TariClient* downstream = m_pairedClient;
downstream->m_pairedClient = this;
downstream->m_pairedClientSavedResetCounter = m_resetCounter;
const std::vector<uint8_t>& v = downstream->m_pendingData;
@@ -944,7 +963,7 @@ bool MergeMiningClientTari::TariClient::on_read(const char* data, uint32_t size)
return false;
}
if (!is_paired()) {
if (!is_paired() || m_pairedClient->m_connectionPending) {
LOGWARN(5, "Read " << size << " bytes from " << static_cast<char*>(m_addrString) << " but it's not paired yet. Buffering it.");
m_pendingData.insert(m_pendingData.end(), data, data + size);
return true;
+5
View File
@@ -116,12 +116,17 @@ private:
void reset() override;
[[nodiscard]] bool on_connect() override;
[[nodiscard]] bool on_read(const char* data, uint32_t size) override;
void on_connect_failed(int /*err*/) override { break_pairing(); }
void on_disconnected() override { break_pairing(); }
alignas(8) char m_buf[BUF_SIZE];
std::vector<uint8_t> m_pendingData;
bool m_connectionPending;
bool is_paired() const { return m_pairedClient && (m_pairedClient->m_resetCounter == m_pairedClientSavedResetCounter); }
void break_pairing();
TariClient* m_pairedClient;
uint32_t m_pairedClientSavedResetCounter;
};
+324
View File
@@ -20,6 +20,8 @@
#include "p2pool.h"
#include "params.h"
#include "keccak.h"
#include "merkle.h"
#include "pow_hash.h"
#include "side_chain.h"
#include "pool_block.h"
#include "block_cache.h"
@@ -79,6 +81,7 @@ P2PServer::P2PServer(p2pool* pool)
m_blockDeserializeBuf.reserve(MAX_BLOCK_SIZE);
m_auxJobMessages.reserve(1024);
m_MoneroBlockBroadcasts.reserve(1024);
// Diffuse the initial state in case it has low quality
m_rng.discard(10000);
@@ -130,6 +133,16 @@ P2PServer::P2PServer(p2pool* pool)
m_AuxJobBroadcastAsync.data = this;
#endif
uv_mutex_init_checked(&m_MoneroBlockBroadcastsLock);
uv_mutex_init_checked(&m_MoneroBlocksToBroadcastLock);
err = uv_async_init(&m_loop, &m_MoneroBlocksToBroadcastAsync, on_monero_block_broadcast);
if (err) {
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
PANIC_STOP();
}
m_MoneroBlocksToBroadcastAsync.data = this;
err = uv_timer_init(&m_loop, &m_timer);
if (err) {
LOGERR(1, "failed to create timer, error " << uv_err_name(err));
@@ -171,6 +184,9 @@ P2PServer::~P2PServer()
uv_mutex_destroy(&m_AuxJobBroadcastLock);
#endif
uv_mutex_destroy(&m_MoneroBlockBroadcastsLock);
uv_mutex_destroy(&m_MoneroBlocksToBroadcastLock);
delete m_block;
delete m_cache;
@@ -1104,6 +1120,7 @@ void P2PServer::show_peers() const
case PROTOCOL_VERSION_1_1: s << " p1.1"; break;
case PROTOCOL_VERSION_1_2: s << " p1.2"; break;
case PROTOCOL_VERSION_1_3: s << " p1.3"; break;
case PROTOCOL_VERSION_1_4: s << " p1.4"; break;
default: s << " p?"; break;
}
}
@@ -1178,6 +1195,7 @@ void P2PServer::on_timer()
check_for_updates();
api_update_local_stats();
clean_aux_job_messages();
clean_monero_block_broadcasts();
}
void P2PServer::flush_cache()
@@ -1427,6 +1445,11 @@ void P2PServer::on_shutdown()
uv_close(reinterpret_cast<uv_handle_t*>(&m_AuxJobBroadcastAsync), nullptr);
}
#endif
{
MutexLock lock(m_MoneroBlocksToBroadcastLock);
uv_close(reinterpret_cast<uv_handle_t*>(&m_MoneroBlocksToBroadcastAsync), nullptr);
}
}
void P2PServer::api_update_local_stats()
@@ -1588,6 +1611,149 @@ void P2PServer::clean_aux_job_messages()
}
}
void P2PServer::clean_monero_block_broadcasts()
{
if ((m_timerCounter & 255) != 0) {
return;
}
MutexLock lock(m_MoneroBlockBroadcastsLock);
if (m_MoneroBlockBroadcasts.empty()) {
return;
}
const uint64_t cur_time = seconds_since_epoch();
for (auto it = m_MoneroBlockBroadcasts.begin(); it != m_MoneroBlockBroadcasts.end();) {
if (cur_time > it->second + MONERO_BROADCAST_TIMEOUT) {
it = m_MoneroBlockBroadcasts.erase(it);
}
else {
++it;
}
}
}
void P2PServer::submit_monero_blocks()
{
if (m_MoneroBlocksToSubmit.empty()) {
return;
}
LOGINFO(6, "submit_monero_blocks: started, queue size = " << m_MoneroBlocksToSubmit.size());
const Params::Host& host = m_pool->current_host();
JSONRPCRequest::call(
host.m_address,
host.m_rpcPort,
m_MoneroBlocksToSubmit.front(),
host.m_rpcLogin,
m_socks5Proxy,
host.m_rpcSSL,
host.m_rpcSSL_Fingerprint,
JSONRPCRequest::dummy_callback,
[this](const char* data, size_t size, double)
{
if (size > 0) {
LOGERR(3, "on_monero_block_broadcast: submit_block RPC request failed, error " << log::const_buf(data, size));
}
if (!m_MoneroBlocksToSubmit.empty()) {
m_MoneroBlocksToSubmit.pop_front();
}
LOGINFO(6, "submit_monero_blocks: finished, queue size = " << m_MoneroBlocksToSubmit.size());
submit_monero_blocks();
},
&m_loop
);
}
void P2PServer::broadcast_monero_block_async(std::vector<std::vector<uint8_t>>&& blobs)
{
MutexLock lock(m_MoneroBlocksToBroadcastLock);
m_MoneroBlocksToBroadcast = std::move(blobs);
const int err = uv_async_send(&m_MoneroBlocksToBroadcastAsync);
if (err) {
LOGERR(1, "uv_async_send failed, error " << uv_err_name(err));
}
}
void P2PServer::broadcast_monero_block_handler()
{
std::vector<std::vector<uint8_t>> blobs;
{
MutexLock lock(m_MoneroBlocksToBroadcastLock);
blobs = std::move(m_MoneroBlocksToBroadcast);
}
for (const std::vector<uint8_t>& blob : blobs) {
if (!blob.empty()) {
broadcast_monero_block(blob.data(), static_cast<uint32_t>(blob.size()), nullptr, false);
}
}
}
void P2PServer::broadcast_monero_block(const uint8_t* data, uint32_t data_size, const P2PClient* source, bool duplicate_check_done)
{
check_event_loop_thread(__func__);
if (data_size < sizeof(MoneroBlockBroadcastHeader)) {
LOGWARN(3, "broadcast_monero_block: data_size is too small: " << data_size);
return;
}
if (!duplicate_check_done && !store_monero_block_broadcast(data + sizeof(MoneroBlockBroadcastHeader), data_size - sizeof(MoneroBlockBroadcastHeader))) {
LOGINFO(6, "broadcast_monero_block: skipping duplicate broadcast");
return;
}
for (P2PClient* client = static_cast<P2PClient*>(m_connectedClientsList->m_next); client != m_connectedClientsList; client = static_cast<P2PClient*>(client->m_next)) {
if ((source && (client == source)) || !client->is_good() || (client->m_protocolVersion < PROTOCOL_VERSION_1_4)) {
continue;
}
const bool result = send(client, [client, data, data_size](uint8_t* buf, size_t buf_size) -> size_t {
LOGINFO(6, "sending MONERO_BLOCK_BROADCAST to " << static_cast<char*>(client->m_addrString));
if (buf_size < 1 + sizeof(uint32_t) + data_size) {
return 0;
}
uint8_t* p = buf;
*(p++) = static_cast<uint8_t>(MessageId::MONERO_BLOCK_BROADCAST);
memcpy(p, &data_size, sizeof(uint32_t));
p += sizeof(uint32_t);
memcpy(p, data, data_size);
p += data_size;
return p - buf;
});
if (!result) {
LOGWARN(5, "failed to send MONERO_BLOCK_BROADCAST to " << static_cast<char*>(client->m_addrString) << ", disconnecting");
client->close();
}
}
}
bool P2PServer::store_monero_block_broadcast(const uint8_t* data, uint32_t data_size)
{
hash digest;
sha256(data, data_size, digest.h);
// Every message can be received from multiple peers, so broadcast it only once
MutexLock lock(m_MoneroBlockBroadcastsLock);
return m_MoneroBlockBroadcasts.emplace(*digest.u64(), seconds_since_epoch()).second;
}
P2PServer::P2PClient::~P2PClient()
{
}
@@ -1901,6 +2067,23 @@ bool P2PServer::P2PClient::on_read(const char* data, uint32_t size)
}
}
break;
case MessageId::MONERO_BLOCK_BROADCAST:
LOGINFO(6, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent MONERO_BLOCK_BROADCAST (" << bytes_left << " bytes in the buffer)");
if (bytes_left >= 1 + sizeof(uint32_t)) {
const uint32_t msg_size = read_unaligned(reinterpret_cast<uint32_t*>(buf + 1));
if (bytes_left >= 1 + sizeof(uint32_t) + msg_size) {
bytes_read = 1 + sizeof(uint32_t) + msg_size;
if (!on_monero_block_broadcast(buf + 1 + sizeof(uint32_t), msg_size)) {
ban(DEFAULT_BAN_TIME);
server->remove_peer_from_list(this);
return false;
}
}
}
break;
}
if (bytes_read) {
@@ -2822,6 +3005,147 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
return true;
}
bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_t size) const
{
P2PServer* server = static_cast<P2PServer*>(m_owner);
if (size < sizeof(MoneroBlockBroadcastHeader)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST size: " << size);
return false;
}
const uint8_t* buf0 = buf;
uint32_t size0 = size;
MoneroBlockBroadcastHeader data;
memcpy(&data, buf, sizeof(data));
buf += sizeof(data);
size -= sizeof(data);
const uint64_t header_and_miner_tx_size = static_cast<uint64_t>(data.header_size) + data.miner_tx_size;
if ((data.header_size < 43) || (data.header_size > 128) || (data.miner_tx_size < 64) || (header_and_miner_tx_size >= size)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST header: " << data.header_size << ", " << data.miner_tx_size << ", " << size);
return false;
}
uint32_t num_transactions;
const uint8_t* tx_hashes = readVarint(buf + header_and_miner_tx_size, buf + size, num_transactions);
if (!tx_hashes) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: tx_hashes not found");
return false;
}
if ((num_transactions >= MAX_BLOCK_SIZE / HASH_SIZE) || (num_transactions * HASH_SIZE != size - static_cast<uint32_t>(tx_hashes - buf))) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: invalid number of transactions " << num_transactions);
return false;
}
if (buf[data.header_size] != TX_VERSION) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: TX_VERSION byte not found");
return false;
}
uint64_t unlock_height;
if (!readVarint(buf + data.header_size + 1, buf + header_and_miner_tx_size, unlock_height)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: unlock_height not found");
return false;
}
p2pool* pool = server->m_pool;
// Ignore blocks which already unlocked
const MinerData miner_data = pool->miner_data();
const uint64_t cur_height = miner_data.height;
if (unlock_height < cur_height) {
LOGINFO(5, "Outdated MONERO_BLOCK_BROADCAST: unlock_height = " << unlock_height << ", current height = " << cur_height << " - ignored");
return true;
}
// Ignore repeated old messages
if (!server->store_monero_block_broadcast(buf, size)) {
LOGINFO(6, "Repeated MONERO_BLOCK_BROADCAST - ignored");
return true;
}
const uint64_t height = unlock_height - MINER_REWARD_UNLOCK_TIME;
LOGINFO(6, "on_monero_block_broadcast: height = " << height);
difficulty_type diff;
if (!pool->get_difficulty_at_height(height, diff)) {
LOGWARN(3, "MONERO_BLOCK_BROADCAST: couldn't get difficulty at height " << height);
diff = miner_data.difficulty;
}
// Use 90% of this height's difficulty to account for possible altchain deviations
diff -= diff / 10;
hash seed;
if (!pool->get_seed(height, seed)) {
LOGWARN(3, "MONERO_BLOCK_BROADCAST: couldn't get seed for height " << height);
return true;
}
hash hashes[3] = { {}, keccak_0x00, {} };
// "miner_tx_size - 1" because the last byte is 0x00 (base rct data), it goes into the second hash
keccak(buf + data.header_size, static_cast<int>(data.miner_tx_size) - 1, hashes[0].h);
std::vector<hash> transactions(num_transactions + 1);
keccak(reinterpret_cast<uint8_t*>(hashes), sizeof(hashes), transactions[0].h);
if (num_transactions > 0) {
memcpy(transactions.data() + 1, tx_hashes, num_transactions * HASH_SIZE);
}
root_hash root;
merkle_hash(transactions, root);
std::vector<uint8_t> blob;
blob.reserve(data.header_size + HASH_SIZE + 2);
blob.insert(blob.end(), buf, buf + data.header_size);
blob.insert(blob.end(), root.h, root.h + HASH_SIZE);
writeVarint(num_transactions + 1, blob);
hash pow_hash;
if (!pool->hasher()->calculate(blob.data(), blob.size(), height, seed, pow_hash, false)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: failed to calculate PoW hash");
return false;
}
if (!diff.check_pow(pow_hash)) {
LOGWARN(3, "Invalid MONERO_BLOCK_BROADCAST: diff check failed, PoW hash = " << pow_hash);
return false;
}
server->broadcast_monero_block(buf0, size0, this, true);
std::string request;
request.reserve(size * 2 + 128);
request.append("{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"submit_block\",\"params\":[\"");
for (size_t i = 0; i < size; ++i) {
request.append(1, "0123456789abcdef"[buf[i] >> 4]);
request.append(1, "0123456789abcdef"[buf[i] & 15]);
}
request.append("\"]}");
server->m_MoneroBlocksToSubmit.emplace_back(std::move(request));
// Kick the JSON RPC request loop only when the first request arrives
// The other requests will be queued and submit_monero_blocks() will process them one by one
if (server->m_MoneroBlocksToSubmit.size() == 1) {
server->submit_monero_blocks();
}
return true;
}
bool P2PServer::P2PClient::handle_incoming_block_async(const PoolBlock* block, uint64_t max_time_delta)
{
P2PServer* server = static_cast<P2PServer*>(m_owner);
+28 -2
View File
@@ -40,8 +40,9 @@ static constexpr uint32_t PROTOCOL_VERSION_1_0 = 0x00010000UL;
static constexpr uint32_t PROTOCOL_VERSION_1_1 = 0x00010001UL;
static constexpr uint32_t PROTOCOL_VERSION_1_2 = 0x00010002UL;
static constexpr uint32_t PROTOCOL_VERSION_1_3 = 0x00010003UL;
static constexpr uint32_t PROTOCOL_VERSION_1_4 = 0x00010004UL;
static constexpr uint32_t SUPPORTED_PROTOCOL_VERSION = PROTOCOL_VERSION_1_3;
static constexpr uint32_t SUPPORTED_PROTOCOL_VERSION = PROTOCOL_VERSION_1_4;
class P2PServer : public TCPServer
{
@@ -59,7 +60,9 @@ public:
BLOCK_NOTIFY,
// Donation messages are signed by author's private keys to prevent their abuse/misuse.
AUX_JOB_DONATION,
LAST = AUX_JOB_DONATION,
// Broadcast 3rd-party Monero blocks to make the whole Monero network faster
MONERO_BLOCK_BROADCAST,
LAST = MONERO_BLOCK_BROADCAST,
};
explicit P2PServer(p2pool *pool);
@@ -118,6 +121,7 @@ public:
void on_peer_list_response(const uint8_t* buf);
void on_block_notify(const uint8_t* buf);
[[nodiscard]] bool on_aux_job_donation(const uint8_t* buf, uint32_t size);
[[nodiscard]] bool on_monero_block_broadcast(const uint8_t* buf, uint32_t size) const;
[[nodiscard]] bool handle_incoming_block_async(const PoolBlock* block, uint64_t max_time_delta = 0);
static void handle_incoming_block(p2pool* pool, PoolBlock& block, std::vector<hash>& missing_blocks, bool& result);
@@ -212,6 +216,12 @@ public:
void broadcast_aux_job_donation(const uint8_t* data, uint32_t data_size, uint64_t timestamp, const P2PClient* source, bool duplicate_check_done);
void broadcast_monero_block_async(std::vector<std::vector<uint8_t>>&& blobs);
void broadcast_monero_block_handler();
void broadcast_monero_block(const uint8_t* data, uint32_t data_size, const P2PClient* source, bool duplicate_check_done);
bool store_monero_block_broadcast(const uint8_t* data, uint32_t data_size);
private:
[[nodiscard]] const char* get_log_category() const override;
@@ -307,12 +317,16 @@ private:
enum {
AUX_JOB_TIMEOUT = 3600,
MONERO_BROADCAST_TIMEOUT = 3600 * 6,
};
unordered_set<std::pair<uint64_t, uint64_t>> m_auxJobMessages;
std::vector<uint8_t> m_auxJobLastMessage;
uint64_t m_auxJobLastMessageTimestamp;
uv_mutex_t m_MoneroBlockBroadcastsLock;
unordered_map<uint64_t, uint64_t> m_MoneroBlockBroadcasts;
void send_aux_job_donation(P2PServer::P2PClient* client, const uint8_t* data, uint32_t data_size);
void clean_aux_job_messages();
@@ -332,6 +346,18 @@ private:
static void on_aux_job_broadcast(uv_async_t* handle) { reinterpret_cast<P2PServer*>(handle->data)->broadcast_aux_job_donation_handler(); }
void broadcast_aux_job_donation_handler();
#endif
uv_mutex_t m_MoneroBlocksToBroadcastLock;
std::vector<std::vector<uint8_t>> m_MoneroBlocksToBroadcast;
uv_async_t m_MoneroBlocksToBroadcastAsync;
std::deque<std::string> m_MoneroBlocksToSubmit;
static void on_monero_block_broadcast(uv_async_t* handle) { reinterpret_cast<P2PServer*>(handle->data)->broadcast_monero_block_handler(); }
void clean_monero_block_broadcasts();
void submit_monero_blocks();
};
} // namespace p2pool
+107 -30
View File
@@ -17,7 +17,9 @@
#include "common.h"
#include "p2pool.h"
#ifndef P2POOL_UNIT_TESTS
#include "zmq_reader.h"
#endif
#include "mempool.h"
#include "json_rpc_request.h"
#include "rapidjson_wrapper.h"
@@ -27,11 +29,13 @@
#include "side_chain.h"
#include "stratum_server.h"
#include "p2p_server.h"
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
#include "miner.h"
#endif
#include "params.h"
#ifndef P2POOL_UNIT_TESTS
#include "console_commands.h"
#endif
#include "crypto.h"
#include "p2pool_api.h"
#include "pool_block.h"
@@ -154,9 +158,18 @@ p2pool::p2pool(int argc, char* argv[])
}
m_reconnectToHostAsync.data = this;
err = uv_async_init(uv_default_loop_checked(), &m_getMissingHeightsAsync, on_get_missing_heights);
if (err) {
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
throw std::exception();
}
m_getMissingHeightsAsync.data = this;
uv_rwlock_init_checked(&m_mainchainLock);
uv_rwlock_init_checked(&m_minerDataLock);
#ifndef P2POOL_UNIT_TESTS
uv_rwlock_init_checked(&m_ZMQReaderLock);
#endif
uv_rwlock_init_checked(&m_mergeMiningClientsLock);
#ifdef WITH_MERGE_MINING_DONATION
@@ -166,13 +179,15 @@ p2pool::p2pool(int argc, char* argv[])
uv_rwlock_init_checked(&m_auxIdLock);
uv_mutex_init_checked(&m_foundBlocksLock);
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
uv_mutex_init_checked(&m_minerLock);
#endif
uv_mutex_init_checked(&m_submitBlockDataLock);
uv_mutex_init_checked(&m_submitAuxBlockDataLock);
uv_mutex_init_checked(&m_missingHeightsLock);
m_api = p->m_apiPath.empty() ? nullptr : new p2pool_api(p->m_apiPath, p->m_localStats);
if (p->m_localStats && !m_api) {
@@ -208,6 +223,7 @@ p2pool::p2pool(int argc, char* argv[])
m_blockTemplate = new BlockTemplate(m_sideChain, m_hasher);
m_mempool = new Mempool();
#ifndef P2POOL_UNIT_TESTS
try {
m_consoleCommands = new ConsoleCommands(this);
}
@@ -215,6 +231,7 @@ p2pool::p2pool(int argc, char* argv[])
LOGERR(1, "Couldn't start console commands handler");
m_consoleCommands = nullptr;
}
#endif
}
p2pool::~p2pool()
@@ -237,7 +254,9 @@ p2pool::~p2pool()
uv_rwlock_destroy(&m_mainchainLock);
uv_rwlock_destroy(&m_minerDataLock);
#ifndef P2POOL_UNIT_TESTS
uv_rwlock_destroy(&m_ZMQReaderLock);
#endif
uv_rwlock_destroy(&m_mergeMiningClientsLock);
#ifdef WITH_MERGE_MINING_DONATION
@@ -247,13 +266,15 @@ p2pool::~p2pool()
uv_rwlock_destroy(&m_auxIdLock);
uv_mutex_destroy(&m_foundBlocksLock);
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
uv_mutex_destroy(&m_minerLock);
#endif
uv_mutex_destroy(&m_submitBlockDataLock);
uv_mutex_destroy(&m_submitAuxBlockDataLock);
uv_mutex_destroy(&m_missingHeightsLock);
delete m_api;
delete m_sideChain;
delete m_hasher;
@@ -340,7 +361,7 @@ bool p2pool::get_seed(uint64_t height, hash& seed) const
return true;
}
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
void p2pool::print_miner_status()
{
MutexLock lock(m_minerLock);
@@ -487,31 +508,64 @@ void p2pool::handle_miner_data(MinerData& data)
missing_heights.erase(std::unique(missing_heights.begin(), missing_heights.end()), missing_heights.end());
}
for (uint64_t h : missing_heights) {
LOGWARN(3, "Mainchain data for height " << h << " is missing, requesting it from monerod again");
MutexLock lock(m_missingHeightsLock);
m_missingHeights = std::move(missing_heights);
char buf[log::Stream::BUF_SIZE + 1] = {};
log::Stream s(buf);
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_header_by_height\",\"params\":{\"height\":" << h << "}}\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, h](const char* data, size_t size, double)
{
ChainMain block;
if (!parse_block_header(data, size, block)) {
LOGERR(1, "couldn't download block header for height " << h);
}
},
[h](const char* data, size_t size, double)
{
if (size > 0) {
LOGERR(1, "couldn't download block header for height " << h << ", error " << log::const_buf(data, size));
}
});
if (!m_missingHeights.empty()) {
const int err = uv_async_send(&m_getMissingHeightsAsync);
if (err) {
LOGERR(1, "uv_async_send failed, error " << uv_err_name(err));
}
}
}
}
void p2pool::get_missing_heights()
{
uint64_t h;
{
MutexLock lock(m_missingHeightsLock);
if (m_missingHeights.empty()) {
return;
}
h = m_missingHeights.back();
m_missingHeights.pop_back();
}
LOGWARN(3, "Mainchain data for height " << h << " is missing, requesting it from monerod again");
char buf[log::Stream::BUF_SIZE + 1] = {};
log::Stream s(buf);
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block_header_by_height\",\"params\":{\"height\":" << h << "}}\0";
const Params::Host& host = current_host();
JSONRPCRequest::call(host.m_address, host.m_rpcPort, buf, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint,
[this, h](const char* data, size_t size, double)
{
ChainMain block;
if (!parse_block_header(data, size, block)) {
LOGERR(1, "couldn't download block header for height " << h);
MutexLock lock(m_missingHeightsLock);
m_missingHeights.push_back(h);
}
get_missing_heights();
},
[this, h](const char* data, size_t size, double)
{
if (size > 0) {
LOGERR(1, "couldn't download block header for height " << h << ", error " << log::const_buf(data, size));
MutexLock lock(m_missingHeightsLock);
m_missingHeights.push_back(h);
}
get_missing_heights();
});
}
const char* BLOCK_FOUND = "\n\
-----------------------------------------------------------------------------------------------\n\
| ###### # ####### ##### # # ####### ####### # # # # ###### |\n\
@@ -589,6 +643,10 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
m_zmqLastActive = seconds_since_epoch();
}
void p2pool::handle_monero_block_broadcast(std::vector<std::vector<uint8_t>>&& blobs)
{
m_p2pServer->broadcast_monero_block_async(std::move(blobs));
}
#ifdef WITH_MERGE_MINING_DONATION
void p2pool::set_aux_job_donation(const std::vector<IMergeMiningClient::ChainParameters>& chain_params)
@@ -965,7 +1023,9 @@ void p2pool::on_stop(uv_async_t* async)
{
p2pool* pool = reinterpret_cast<p2pool*>(async->data);
#ifndef P2POOL_UNIT_TESTS
delete pool->m_consoleCommands;
#endif
if (pool->m_api) {
pool->m_api->on_stop();
@@ -976,6 +1036,7 @@ void p2pool::on_stop(uv_async_t* async)
uv_close(reinterpret_cast<uv_handle_t*>(&pool->m_blockTemplateAsync), nullptr);
uv_close(reinterpret_cast<uv_handle_t*>(&pool->m_stopAsync), nullptr);
uv_close(reinterpret_cast<uv_handle_t*>(&pool->m_reconnectToHostAsync), nullptr);
uv_close(reinterpret_cast<uv_handle_t*>(&pool->m_getMissingHeightsAsync), nullptr);
init_signals(pool, false);
@@ -1029,6 +1090,9 @@ void p2pool::submit_block() const
const uint32_t nonce = submit_data.nonce;
const uint32_t extra_nonce = submit_data.extra_nonce;
std::vector<uint8_t> blob;
blob.reserve(submit_data.blob.size());
for (size_t i = 0; i < submit_data.blob.size(); ++i) {
uint8_t b;
if (nonce_offset && nonce_offset <= i && i < nonce_offset + sizeof(submit_data.nonce)) {
@@ -1045,11 +1109,16 @@ void p2pool::submit_block() const
else {
b = submit_data.blob[i];
}
request.append(1, "0123456789abcdef"[b >> 4]);
request.append(1, "0123456789abcdef"[b & 15]);
blob.push_back(b);
}
request.append("\"]}");
m_p2pServer->store_monero_block_broadcast(blob.data(), static_cast<uint32_t>(blob.size()));
const Params::Host& host = current_host();
JSONRPCRequest::call(host.m_address, host.m_rpcPort, request, host.m_rpcLogin, m_params->m_socks5Proxy, host.m_rpcSSL, host.m_rpcSSL_Fingerprint,
@@ -1144,7 +1213,7 @@ void p2pool::update_block_template()
stratum_on_block();
api_update_pool_stats();
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
if (m_isAlternativeBlock.exchange(false)) {
MutexLock lock(m_minerLock);
@@ -1278,11 +1347,10 @@ void p2pool::download_block_headers4(uint64_t start_height, uint64_t current_hei
if (m_serversStarted.exchange(1) == 0) {
m_p2pServer = new P2PServer(this);
m_stratumServer = new StratumServer(this);
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
if (m_params->m_minerThreads) {
start_mining(m_params->m_minerThreads);
}
#endif
{
WriteLock lock(m_ZMQReaderLock);
@@ -1295,6 +1363,7 @@ void p2pool::download_block_headers4(uint64_t start_height, uint64_t current_hei
PANIC_STOP();
}
}
#endif
api_update_network_stats();
get_miner_data();
@@ -1393,7 +1462,7 @@ void p2pool::update_median_timestamp()
void p2pool::stratum_on_block()
{
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
{
MutexLock lock(m_minerLock);
@@ -2063,7 +2132,7 @@ bool p2pool::get_difficulty_at_height(uint64_t height, difficulty_type& diff)
return true;
}
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
void p2pool::start_mining(uint32_t threads)
{
stop_mining();
@@ -2168,8 +2237,12 @@ void p2pool::stop()
bool p2pool::zmq_running() const
{
#ifdef P2POOL_UNIT_TESTS
return true;
#else
ReadLock lock(m_ZMQReaderLock);
return m_ZMQReader && m_ZMQReader->is_running();
#endif
}
const Params::Host& p2pool::switch_host()
@@ -2190,6 +2263,7 @@ void p2pool::reconnect_to_host()
return;
}
#ifndef P2POOL_UNIT_TESTS
const Params::Host& new_host = switch_host();
WriteLock lock(m_ZMQReaderLock);
@@ -2209,6 +2283,7 @@ void p2pool::reconnect_to_host()
if (m_ZMQReader) {
get_miner_data(false);
}
#endif
}
int p2pool::run()
@@ -2245,10 +2320,12 @@ int p2pool::run()
const int rc = uv_run(uv_default_loop_checked(), UV_RUN_DEFAULT);
LOGINFO(1, "uv_run exited, result = " << rc);
#ifndef P2POOL_UNIT_TESTS
WriteLock lock(m_ZMQReaderLock);
delete m_ZMQReader;
m_ZMQReader = nullptr;
#endif
}
catch (const std::exception& e) {
LOGERR(1, "exception " << e.what());
@@ -2259,7 +2336,7 @@ int p2pool::run()
bkg_jobs_tracker->wait();
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
{
MutexLock lock(m_minerLock);
+16 -3
View File
@@ -77,7 +77,7 @@ public:
StratumServer* stratum_server() const { return m_stratumServer; }
P2PServer* p2p_server() const { return m_p2pServer; }
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
void print_miner_status();
#endif
@@ -86,6 +86,7 @@ public:
virtual void handle_tx(TxMempoolData& tx) override;
virtual void handle_miner_data(MinerData& data) override;
virtual void handle_chain_main(ChainMain& data, const char* extra) override;
virtual void handle_monero_block_broadcast(std::vector<std::vector<uint8_t>>&& blobs) override;
#ifdef WITH_MERGE_MINING_DONATION
void set_aux_job_donation(const std::vector<IMergeMiningClient::ChainParameters>& chain_params);
@@ -127,7 +128,7 @@ public:
bool get_difficulty_at_height(uint64_t height, difficulty_type& diff);
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
void start_mining(uint32_t threads);
void stop_mining();
#endif
@@ -150,6 +151,7 @@ private:
static void on_update_block_template(uv_async_t* async) { reinterpret_cast<p2pool*>(async->data)->update_block_template(); }
static void on_stop(uv_async_t*);
static void on_reconnect_to_host(uv_async_t* async) { reinterpret_cast<p2pool*>(async->data)->reconnect_to_host(); }
static void on_get_missing_heights(uv_async_t* async) { reinterpret_cast<p2pool*>(async->data)->get_missing_heights(); }
void submit_block() const;
void submit_aux_block() const;
@@ -226,12 +228,14 @@ private:
std::atomic<bool> m_startupFinished{ false };
#ifdef WITH_RANDOMX
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
uv_mutex_t m_minerLock;
Miner* m_miner = nullptr;
#endif
#ifndef P2POOL_UNIT_TESTS
ConsoleCommands* m_consoleCommands;
#endif
struct SubmitBlockData
{
@@ -258,8 +262,17 @@ private:
uint64_t m_startTime;
uv_async_t m_reconnectToHostAsync;
uv_async_t m_getMissingHeightsAsync;
mutable uv_mutex_t m_missingHeightsLock;
mutable std::vector<uint64_t> m_missingHeights;
void get_missing_heights();
#ifndef P2POOL_UNIT_TESTS
mutable uv_rwlock_t m_ZMQReaderLock;
ZMQReader* m_ZMQReader = nullptr;
#endif
mutable uv_rwlock_t m_mergeMiningClientsLock;
std::vector<IMergeMiningClient*> m_mergeMiningClients;
+5
View File
@@ -258,6 +258,11 @@ Params::Params(int argc, char* const argv[])
}
#endif
if (strcmp(argv[i], "--full-validation") == 0) {
m_enableFullValidation = true;
ok = true;
}
if (!ok) {
// Wait to avoid log messages overlapping with printf() calls and making a mess on screen
std::this_thread::sleep_for(std::chrono::milliseconds(10));
+1
View File
@@ -116,6 +116,7 @@ struct Params
uint8_t priv_key[64];
};
#endif
bool m_enableFullValidation = false;
};
} // namespace p2pool
+1 -6
View File
@@ -343,13 +343,8 @@ bool PoolBlock::get_pow_hash(RandomX_Hasher_Base* hasher, uint64_t height, const
alignas(8) uint8_t hashes[HASH_SIZE * 3];
uint64_t* second_hash = reinterpret_cast<uint64_t*>(hashes + HASH_SIZE);
// Second hash is keccak of base rct data (it doesn't exist for the coinbase transaction, so it's a hash of a single 0x00 byte)
second_hash[0] = 0x14281e7a9e7836bcull;
second_hash[1] = 0x7d818f8229424636ull;
second_hash[2] = 0x9165d677b4f71266ull;
second_hash[3] = 0x8ac9bc64e0a996ffull;
memcpy(hashes + HASH_SIZE, keccak_0x00.h, HASH_SIZE);
// Third hash is null because there is no rct data in the coinbase transaction
memset(hashes + HASH_SIZE * 2, 0, HASH_SIZE);
+5 -5
View File
@@ -47,6 +47,7 @@ StratumServer::StratumServer(p2pool* pool)
: TCPServer(DEFAULT_BACKLOG, StratumClient::allocate, std::string())
, m_pool(pool)
, m_autoDiff(pool->params().m_autoDiff)
, m_enableFullValidation(pool->params().m_enableFullValidation)
, m_rng(RandomDeviceSeed::instance)
, m_cumulativeHashes(0)
, m_cumulativeHashesAtLastShare(0)
@@ -480,7 +481,7 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
update_auto_diff(client, share.m_timestamp, share.m_hashes);
// If this share is below sidechain difficulty, process it in this thread because it'll be quick
if (!share.m_highEnoughDifficulty) {
if (!share.m_highEnoughDifficulty && !m_enableFullValidation) {
on_share_found(&share.m_req);
on_after_share_found(&share.m_req, 0);
return true;
@@ -951,7 +952,7 @@ void StratumServer::on_share_found(uv_work_t* req)
return;
}
if (share->m_highEnoughDifficulty) {
if (share->m_highEnoughDifficulty || server->m_enableFullValidation) {
BACKGROUND_JOB_START(StratumServer::on_share_found);
}
@@ -960,7 +961,7 @@ void StratumServer::on_share_found(uv_work_t* req)
const uint64_t target = share->m_target;
const uint64_t hashes = share->m_hashes;
if (share->m_highEnoughDifficulty) {
if (share->m_highEnoughDifficulty || server->m_enableFullValidation) {
if (pool->stopped()) {
LOGWARN(0, "p2pool is shutting down, but a share was found. Trying to process it anyway!");
}
@@ -1024,8 +1025,7 @@ void StratumServer::on_share_found(uv_work_t* req)
prev_time = server->m_lastSidechainShareFoundTime;
server->m_lastSidechainShareFoundTime = cur_time;
}
if (!pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
if (share->m_highEnoughDifficulty && !pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
WriteLock lock(server->m_hashrateDataLock);
if (server->m_totalFoundSidechainShares > 0) {
+1 -1
View File
@@ -115,7 +115,7 @@ private:
p2pool* m_pool;
bool m_autoDiff;
bool m_enableFullValidation;
struct BlobsData
{
uint32_t m_extraNonceStart;
+1
View File
@@ -766,6 +766,7 @@ void TCPServer::on_connect(uv_connect_t* req, int status)
LOGWARN(5, "failed to connect to " << static_cast<char*>(client->m_addrString) << ", error " << uv_err_name(status));
}
server->on_connect_failed(client->m_isV6, client->m_addr, client->m_port);
client->on_connect_failed(status);
uv_close(reinterpret_cast<uv_handle_t*>(&client->m_socket), on_connection_error);
return;
}
+1
View File
@@ -65,6 +65,7 @@ public:
[[nodiscard]] virtual bool on_connect() = 0;
[[nodiscard]] virtual bool on_read(const char* data, uint32_t size) = 0;
[[nodiscard]] bool on_proxy_handshake(const char* data, uint32_t size);
virtual void on_connect_failed(int /*err*/) {}
virtual void on_read_failed(int /*err*/) {}
virtual void on_disconnected() {}
+18
View File
@@ -40,7 +40,10 @@
#include <resolv.h>
#endif
#ifndef P2POOL_UNIT_TESTS
#include <curl/curl.h>
#endif
#include <zmq.h>
#ifdef HAVE_GLIBC
@@ -75,7 +78,9 @@ const char* VERSION = "v" STR2(P2POOL_VERSION_MAJOR) "." STR2(P2POOL_VERSION_MIN
std::string p2pool_version()
{
#ifndef P2POOL_UNIT_TESTS
const curl_version_info_data* curl_version_data = curl_version_info(CURLVERSION_NOW);
#endif
int zmq_major, zmq_minor, zmq_patch;
zmq_version(&zmq_major, &zmq_minor, &zmq_patch);
@@ -91,7 +96,9 @@ std::string p2pool_version()
#ifdef WITH_GRPC
<< " - grpc " << GRPC_CPP_VERSION_STRING << '\n'
#endif
#ifndef P2POOL_UNIT_TESTS
<< " - libcurl " << (curl_version_data ? curl_version_data->version : "unknown") << '\n'
#endif
<< " - libuv " << uv_version_string() << '\n'
<< " - libzmq " << zmq_major << '.' << zmq_minor << '.' << zmq_patch << '\n'
#ifdef WITH_UPNP
@@ -103,6 +110,17 @@ std::string p2pool_version()
return std::string(buf, s.m_pos);
}
void fixup_path(std::string& path)
{
if (!path.empty() && (path.back() != '/')
#ifdef _WIN32
&& (path.back() != '\\')
#endif
) {
path.append(1, '/');
}
}
const uint8_t ED25519_MASTER_PUBLIC_KEY[32] = {51,175,37,73,203,241,188,115,195,255,123,53,218,120,90,74,186,240,82,178,67,139,124,91,180,106,188,181,187,51,236,10};
std::string DATA_DIR;
+4 -1
View File
@@ -35,7 +35,7 @@
namespace p2pool {
#define P2POOL_VERSION_MAJOR 4
#define P2POOL_VERSION_MINOR 9
#define P2POOL_VERSION_MINOR 10
#define P2POOL_VERSION_PATCH 0
constexpr uint32_t P2POOL_VERSION = (P2POOL_VERSION_MAJOR << 16) | (P2POOL_VERSION_MINOR << 8) | P2POOL_VERSION_PATCH;
@@ -92,6 +92,7 @@ struct MinerCallbackHandler
virtual void handle_tx(TxMempoolData& tx) = 0;
virtual void handle_miner_data(MinerData& data) = 0;
virtual void handle_chain_main(ChainMain& data, const char* extra) = 0;
virtual void handle_monero_block_broadcast(std::vector<std::vector<uint8_t>>&& blobs) = 0;
};
template<typename T>
@@ -383,6 +384,8 @@ void minidump_and_crash(size_t delay);
std::string p2pool_version();
void fixup_path(std::string& path);
} // namespace p2pool
void memory_tracking_start();
+170
View File
@@ -253,6 +253,168 @@ bool ZMQReader::connect(const std::string& address, bool keep_monitor)
return true;
}
static std::vector<uint8_t> construct_monero_block_blob(rapidjson::Value* value)
{
std::vector<uint8_t> empty_blob;
#define X(type, name) type name; if (!parseValue(*value, #name, name)) return empty_blob;
X(uint8_t, major_version);
X(uint8_t, minor_version);
X(uint64_t, timestamp);
X(std::string, prev_id);
X(uint32_t, nonce);
#undef X
auto miner_tx = value->FindMember("miner_tx");
if ((miner_tx == value->MemberEnd()) || !miner_tx->value.IsObject()) {
LOGWARN(3, "construct_monero_block_blob: miner_tx not found or is not an object");
return empty_blob;
}
uint8_t version;
if (!parseValue(miner_tx->value, "version", version)) {
LOGWARN(3, "construct_monero_block_blob: version not found");
return empty_blob;
}
uint64_t unlock_height;
if (!parseValue(miner_tx->value, "unlock_time", unlock_height)) {
LOGWARN(3, "construct_monero_block_blob: unlock_time not found");
return empty_blob;
}
std::string extra;
if (!parseValue(miner_tx->value, "extra", extra)) {
LOGWARN(3, "construct_monero_block_blob: extra not found");
return empty_blob;
}
auto outputs = miner_tx->value.FindMember("outputs");
if ((outputs == miner_tx->value.MemberEnd()) || !outputs->value.IsArray()) {
LOGWARN(3, "construct_monero_block_blob: outputs not found or is not an array");
return empty_blob;
}
auto tx_hashes = value->FindMember("tx_hashes");
if ((tx_hashes == value->MemberEnd()) || !tx_hashes->value.IsArray()) {
LOGWARN(3, "construct_monero_block_blob: tx_hashes not found or is not an array");
return empty_blob;
}
std::vector<uint8_t> blob;
blob.reserve(16384);
blob.push_back(major_version);
blob.push_back(minor_version);
writeVarint(timestamp, blob);
hash h;
if (!from_hex(prev_id.c_str(), prev_id.length(), h)) {
LOGWARN(3, "construct_monero_block_blob: invalid prev_id " << prev_id);
return empty_blob;
}
blob.insert(blob.end(), h.h, h.h + HASH_SIZE);
blob.insert(blob.end(), reinterpret_cast<const uint8_t*>(&nonce), reinterpret_cast<const uint8_t*>(&nonce) + NONCE_SIZE);
MoneroBlockBroadcastHeader data;
data.header_size = static_cast<uint32_t>(blob.size());
blob.insert(blob.end(), version);
writeVarint(unlock_height, blob);
blob.push_back(1);
blob.push_back(TXIN_GEN);
writeVarint(unlock_height - MINER_REWARD_UNLOCK_TIME, blob);
auto arr = outputs->value.GetArray();
writeVarint(arr.Size(), blob);
for (rapidjson::Value* i = arr.begin(); i != arr.end(); ++i) {
auto amount = i->FindMember("amount");
if ((amount == i->MemberEnd()) || !amount->value.IsUint64()) {
LOGWARN(3, "construct_monero_block_blob: amount not found or is not UInt64");
return empty_blob;
}
auto to_tagged_key = i->FindMember("to_tagged_key");
if ((to_tagged_key == i->MemberEnd()) || !to_tagged_key->value.IsObject()) {
LOGWARN(3, "construct_monero_block_blob: to_tagged_key not found or is not an object");
return empty_blob;
}
auto key = to_tagged_key->value.FindMember("key");
if ((key == to_tagged_key->value.MemberEnd()) || !key->value.IsString()) {
LOGWARN(3, "construct_monero_block_blob: key not found or is not a string");
return empty_blob;
}
auto view_tag = to_tagged_key->value.FindMember("view_tag");
if ((view_tag == to_tagged_key->value.MemberEnd()) || !view_tag->value.IsString()) {
LOGWARN(3, "construct_monero_block_blob: view_tag not found or is not a string");
return empty_blob;
}
writeVarint(amount->value.GetUint64(), blob);
blob.push_back(TXOUT_TO_TAGGED_KEY);
if (!from_hex(key->value.GetString(), key->value.GetStringLength(), h)) {
LOGWARN(3, "construct_monero_block_blob: invalid key " << key->value.GetString());
return empty_blob;
}
blob.insert(blob.end(), h.h, h.h + HASH_SIZE);
std::vector<uint8_t> t;
if (!from_hex(view_tag->value.GetString(), view_tag->value.GetStringLength(), t) || (t.size() != 1)) {
LOGWARN(3, "construct_monero_block_blob: invalid view_tag " << view_tag->value.GetString());
return empty_blob;
}
blob.push_back(t[0]);
}
std::vector<uint8_t> t;
if (!from_hex(extra.c_str(), extra.length(), t) || t.empty()) {
LOGWARN(3, "construct_monero_block_blob: invalid extra " << extra);
return empty_blob;
}
writeVarint(t.size(), blob);
blob.insert(blob.end(), t.begin(), t.end());
blob.push_back(0);
data.miner_tx_size = static_cast<uint32_t>(blob.size()) - data.header_size;
auto arr2 = tx_hashes->value.GetArray();
writeVarint(arr2.Size(), blob);
for (rapidjson::Value* i = arr2.begin(); i != arr2.end(); ++i) {
if (!i->IsString() || !from_hex(i->GetString(), i->GetStringLength(), h)) {
LOGWARN(3, "construct_monero_block_blob: invalid tx_hash " << i->GetString());
return empty_blob;
}
blob.insert(blob.end(), h.h, h.h + HASH_SIZE);
}
const uint8_t* p = reinterpret_cast<const uint8_t*>(&data);
blob.insert(blob.begin(), p, p + sizeof(data));
return blob;
}
void ZMQReader::parse(char* data, size_t size)
{
char* value = data;
@@ -349,7 +511,13 @@ void ZMQReader::parse(char* data, size_t size)
}
auto arr = doc.GetArray();
std::vector<std::vector<uint8_t>> blobs;
blobs.reserve(arr.Size());
for (Value* i = arr.begin(); i != arr.end(); ++i) {
blobs.emplace_back(construct_monero_block_blob(i));
if (!PARSE(*i, m_chainmainData, timestamp)) {
LOGWARN(1, "json-full-chain_main timestamp failed to parse, skipping it");
continue;
@@ -411,6 +579,8 @@ void ZMQReader::parse(char* data, size_t size)
m_handler->handle_chain_main(m_chainmainData, extra_it->value.GetString());
}
m_handler->handle_monero_block_broadcast(std::move(blobs));
}
}
+1 -1
View File
@@ -22,7 +22,7 @@
namespace p2pool {
class ZMQReader {
class ZMQReader : public nocopy_nomove {
public:
ZMQReader(const std::string& address, uint32_t zmq_port, const std::string& proxy, MinerCallbackHandler* handler);
~ZMQReader();

Some files were not shown because too many files have changed in this diff Show More