Add I2P support
This commit is contained in:
@@ -131,6 +131,7 @@ set(HEADERS
|
||||
src/uv_util.h
|
||||
src/wallet.h
|
||||
src/zmq_reader.h
|
||||
src/i2p.h
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
@@ -164,6 +165,7 @@ set(SOURCES
|
||||
src/util.cpp
|
||||
src/wallet.cpp
|
||||
src/zmq_reader.cpp
|
||||
src/i2p.cpp
|
||||
)
|
||||
|
||||
if (AMD64)
|
||||
|
||||
@@ -66,7 +66,7 @@ Here's the comparison table of the different ways of mining. While pool mining i
|
||||
* Advanced mempool picking algorithm, it creates blocks with better reward than what monerod solo mining does
|
||||
* Password protected private pools
|
||||
* Highly reliable configurations are supported (multiple P2Pool nodes mining to the same wallet, each P2Pool node can use multiple Monero nodes and switch on the fly if an issue is detected)
|
||||
* Mining through [TOR](docs/TOR.MD) is fully supported
|
||||
* Mining through [TOR](docs/TOR.MD) and [I2P](docs/I2P.MD) are fully supported
|
||||
|
||||
## How payouts work in P2Pool
|
||||
|
||||
@@ -96,7 +96,7 @@ In order to continue mining on P2Pool, you must update both Monero and P2Pool so
|
||||
### General Considerations
|
||||
|
||||
- In order to mine on P2Pool, a synced Monero node using monerod v0.18.0.0 or newer is required. If you don't currently have one, you can download the [official Monero binaries](https://www.getmonero.org/downloads/), start `monerod` on your PC and wait until it's fully synced. Advanced Monero node setup instructions are [here](https://sethforprivacy.com/guides/run-a-monero-node-advanced/).
|
||||
- It is highly recommended that you create a separate restricted user account (in your OS) for mining. While P2Pool has been battle-tested for a long time now, any software may have unknown bugs/vulnerabilities.
|
||||
- It is highly recommended that you create a separate restricted user account (in your OS) for mining. While P2Pool has been battle-tested for a long time now, any software may have unknown bugs/vulnerabilities.
|
||||
- You can mine to a primary wallet address (the one starting with `4`) for mining. If you want to mine to a subaddress, you will need to provide both the main address (starting with 4) and the subaddress (starting with 8) using `--wallet` and `--subaddress` command line parameters.
|
||||
- You can add the `--mini` or `--nano` parameter to your P2Pool command to connect to the respective sidechain.
|
||||
> [!NOTE]
|
||||
@@ -105,7 +105,7 @@ In order to continue mining on P2Pool, you must update both Monero and P2Pool so
|
||||
> Using `--nano` will change the p2p port to 37890.<br>
|
||||
- Check that ports 18080 (Monero p2p port) and 37889/37888/37890 (P2Pool default/mini/nano p2p port) are open in your firewall to ensure better connectivity. If you're mining from a computer behind NAT (like a router) you could consider forwarding the ports to your local machine.
|
||||
- You can connect multiple miners to the same P2Pool node. The more the better!
|
||||
- The steps below assume that you run everything on the same machine. If it's not the case, change `127.0.0.1` to appropriate IP addresses for your setup.
|
||||
- The steps below assume that you run everything on the same machine. If it's not the case, change `127.0.0.1` to appropriate IP addresses for your setup.
|
||||
- It is highly recommended to create a new mainnet wallet for P2Pool mining because **wallet addresses are public on P2Pool**.
|
||||
|
||||
**Wallet software compatible with P2Pool payouts**
|
||||
@@ -157,15 +157,15 @@ Note that Tari will be mined in solo mode (only full Tari blocks can be mined fo
|
||||
1. Download the latest P2Pool binaries [here](https://github.com/SChernykh/p2pool/releases/latest).
|
||||
- Alternatively, grab the latest source code for P2Pool and [build it](#build-instructions).
|
||||
2. Download the latest XMRig (linux-static-x64) binary [here](https://github.com/xmrig/xmrig/releases/latest).
|
||||
3. Prepare enough huge pages (each of monerod/P2Pool/XMRig needs them):
|
||||
3. Prepare enough huge pages (each of monerod/P2Pool/XMRig needs them):
|
||||
```
|
||||
sudo sysctl vm.nr_hugepages=3072
|
||||
```
|
||||
4. Check that ports 18080 (Monero p2p port) and 37889/37888/37890 (P2Pool default/mini/nano p2p port) are open in your local firewall to ensure better connectivity.
|
||||
5. Start `monerod` with the following command/options:
|
||||
4. Check that ports 18080 (Monero p2p port) and 37889/37888/37890 (P2Pool default/mini/nano p2p port) are open in your local firewall to ensure better connectivity.
|
||||
5. Start `monerod` with the following command/options:
|
||||
```
|
||||
./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
|
||||
```
|
||||
```
|
||||
**Note:**
|
||||
The `--zmq-pub` option is required for P2Pool to work properly.
|
||||
|
||||
@@ -187,16 +187,16 @@ The `--zmq-pub` option is required for P2Pool to work properly.
|
||||
```
|
||||
./xmrig -o 127.0.0.1:3333
|
||||
```
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
```
|
||||
./xmrig -u x+10000 -o 127.0.0.1:3333
|
||||
```
|
||||
9. XMRig should connect and start mining!
|
||||
|
||||
**Additional Information:**
|
||||
**Additional Information:**
|
||||
- For a more in-depth beginner friendly walk-through with the option of using Docker, please see SethForPrivacy's guide at: https://sethforprivacy.com/guides/run-a-p2pool-node/
|
||||
- You can check the p2pool.log for any warnings or errors using the following command:
|
||||
- You can check the p2pool.log for any warnings or errors using the following command:
|
||||
```
|
||||
grep -E 'WARNING|ERROR' p2pool.log
|
||||
```
|
||||
@@ -213,7 +213,7 @@ nocreate
|
||||
}
|
||||
```
|
||||
|
||||
### Windows
|
||||
### Windows
|
||||
|
||||
**Note:** *Windows SmartScreen may block incoming connections by files that are "Downloaded from the Internet". You can allow 'p2pool.exe' and 'monerod.exe' by double-clicking them, clicking "More Info", then click "Run Anyway" and then closing them immediately so you can run them from the command line. Advanced users can use the PowerShell cmdlet `Unblock-File` to remove this flag.*
|
||||
|
||||
@@ -221,8 +221,8 @@ nocreate
|
||||
- Alternatively, grab the latest source code for P2Pool and [build it](#build-instructions).
|
||||
2. Download the latest XMRig binary [here](https://github.com/xmrig/xmrig/releases/latest).
|
||||
3. Expand the P2Pool binaries into an appropriate location (`%USERPROFILE%/bin` or `C:/bin/` are good options)
|
||||
4. Expand XMRig binary into an appropriate location (the same folder as P2Pool is fine).
|
||||
5. Prepare huge pages to work properly (each of monerod/P2Pool/XMRig needs them):
|
||||
4. Expand XMRig binary into an appropriate location (the same folder as P2Pool is fine).
|
||||
5. Prepare huge pages to work properly (each of monerod/P2Pool/XMRig needs them):
|
||||
- On Windows 10 or above, run XMRig at least once as Administrator (right-click Run As Administrator)
|
||||
- On earlier versions of Windows, you'll need to run XMRig as Administrator at least once per login.
|
||||
6. Create "Monero" folder inside extracted P2Pool folder and copy Monero binaries there.
|
||||
@@ -230,7 +230,7 @@ nocreate
|
||||
|
||||
**Note:** *When running the below commands, Windows Firewall may prompt to allow connections, click "Allow" if prompted.*
|
||||
|
||||
8. Start `monerod` with the following command/options:
|
||||
8. Start `monerod` with the following command/options:
|
||||
```
|
||||
.\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 32 --in-peers 64 --add-priority-node=p2pmd.xmrvsbeast.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --enforce-dns-checkpointing --enable-dns-blocklist
|
||||
```
|
||||
@@ -254,8 +254,8 @@ The `--zmq-pub` option is required for P2Pool to work properly.
|
||||
```
|
||||
.\xmrig.exe -o 127.0.0.1:3333
|
||||
```
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
- Note that you don't need to specify your wallet address for XMRig. **Wallet addresses set in XMRig config will be ignored!**
|
||||
- To set a custom fixed difficulty for your miner (for example, 10000), instead start XMRig with the following options:
|
||||
```
|
||||
xmrig.exe -u x+10000 -o 127.0.0.1:3333
|
||||
```
|
||||
@@ -299,7 +299,7 @@ pacman -S p2pool
|
||||
|
||||
### [Nix/NixOS](https://nixos.org)
|
||||
|
||||
This is a flake only project. So you have to use [nixUnstable with nix flakes](https://nixos.wiki/wiki/Flakes) to build or install P2Pool.
|
||||
This is a flake only project. So you have to use [nixUnstable with nix flakes](https://nixos.wiki/wiki/Flakes) to build or install P2Pool.
|
||||
The commands below use the new flake specific reference-format, so be sure to also set `ca-references` in `--experimental-features`.
|
||||
|
||||
Because this project has submodules which are not fixed in _nixUnstable_ yet you have to use the `nix/master` branch:
|
||||
@@ -330,7 +330,7 @@ cmake .. -G "Visual Studio 16 2019"
|
||||
```
|
||||
then open generated build\p2pool.sln in Visual Studio and build it there
|
||||
|
||||
Alternatively, you can select "Clone a repository" within the GUI, then select "Build" from the menu.
|
||||
Alternatively, you can select "Clone a repository" within the GUI, then select "Build" from the menu.
|
||||
|
||||
### macOS
|
||||
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
## Running P2Pool with I2P
|
||||
|
||||
P2Pool has several command-line options that should be used for I2P setup:
|
||||
|
||||
- `--socks5 IP:port` to specify your I2P SOCKS proxy address (usually `127.0.0.1:4447` if you are using i2pd or followed the guide below)
|
||||
- `--socks5-proxy-type i2p` to specify the type of SOCKS5 proxy being used
|
||||
- `--sam-port port` to specify the port number used by the I2P SAM bridge (`7656` by default)
|
||||
- `--no-dns` to disable all DNS queries and prevent DNS leaks. P2Pool only ever makes DNS requests to get a list of seed nodes, to resolve your Monero node's domain (if it's not set as an IP address), and to resolve manually added peers
|
||||
- `--no-upnp` to disable UPnP requests (they are sent to your router, so use this option if you are not on your home network)
|
||||
- `--i2p-address` your hidden service's `.b32.i2p` address (without port number). This address will be broadcast to other peers when you mine a share in P2Pool. This is to prevent address spamming - you have to mine a real share to be able to broadcast your I2P address.
|
||||
- **Attention: this also links the I2P address with the Monero wallet you use for mining. Create a new I2P address when mining through I2P, don't use your existing addresses to avoid metadata leaks.**
|
||||
- `--no-clearnet-p2p` to never connect to clearnet P2Pool nodes.
|
||||
|
||||
## Setting up I2P tunnels for P2Pool (i2pd on Linux)
|
||||
|
||||
Follow [these instructions](https://docs.i2pd.website/en/latest/user-guide/install/) to install i2pd on your system.
|
||||
First, ensure both the SOCKS proxy and SAM bridge tunnels are enabled (as they should be by default). See [here](https://docs.i2pd.website/en/latest/user-guide/configuration/) for more information.
|
||||
|
||||
You will need to modify some lines in the `tunnels.conf` file, usually located in `/var/lib/i2pd/tunnels.conf` on Linux.
|
||||
Add a server tunnel to allow inbound connections from peers:
|
||||
```ini
|
||||
[p2pool]
|
||||
type = server
|
||||
host = 127.0.0.1
|
||||
port = 28723
|
||||
keys = p2pool.dat
|
||||
```
|
||||
This will create a hidden service key in `/var/lib/i2pd/p2pool.dat`; you may want to back this up.
|
||||
Please note that you **must** use the port number shown above in order for other peers to be able to find you.
|
||||
|
||||
Restart i2pd:
|
||||
```bash
|
||||
sudo systemctl restart i2pd.service
|
||||
```
|
||||
|
||||
Get the hostname of your hidden service:
|
||||
```bash
|
||||
curl -s http://127.0.0.1:7070/?page=i2p_tunnels | grep -Eo "[a-zA-Z0-9./?=_%:-]*" | grep "28723"
|
||||
```
|
||||
|
||||
The resulting `.b32.i2p` address should then be used for the `--i2p-address` command-line parameter.
|
||||
|
||||
## Command line example
|
||||
```bash
|
||||
./p2pool --host MONERO_NODE_IP --wallet YOUR_WALLET --socks5 127.0.0.1:4447 --socks5-proxy-type i2p --sam-port 7656 --no-dns --no-upnp --i2p-address YOUR_I2P_ADDRESS
|
||||
```
|
||||
+12
-5
@@ -213,7 +213,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
|
||||
|
||||
// Block template construction is relatively slow, but it's better to keep the lock the whole time
|
||||
// instead of using temporary variables and making a quick swap in the end
|
||||
//
|
||||
//
|
||||
// All readers will line up for the new template instead of using the outdated template
|
||||
WriteLock lock(m_lock);
|
||||
|
||||
@@ -617,7 +617,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
|
||||
m_poolBlockTemplate->m_auxNonce = data.aux_nonce;
|
||||
|
||||
m_poolBlockTemplate->m_mergeMiningExtra.clear();
|
||||
|
||||
|
||||
for (const AuxChainData& c : data.aux_chains) {
|
||||
std::vector<uint8_t> v;
|
||||
v.reserve(HASH_SIZE + 16);
|
||||
@@ -644,6 +644,13 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
|
||||
m_poolBlockTemplate->m_mergeMiningExtra.emplace(keccak_onion_address_v3, std::vector(buf, buf + sizeof(buf)));
|
||||
}
|
||||
|
||||
if (!params.m_i2pDestinationHash.empty()) {
|
||||
uint8_t buf[HASH_SIZE + 2] = {};
|
||||
memcpy(buf, params.m_i2pDestinationHash.h, HASH_SIZE);
|
||||
|
||||
m_poolBlockTemplate->m_mergeMiningExtra.emplace(keccak_i2p_b32_address, std::vector(buf, buf + sizeof(buf)));
|
||||
}
|
||||
|
||||
init_merge_mining_merkle_proof();
|
||||
|
||||
const std::vector<uint8_t> sidechain_data = m_poolBlockTemplate->serialize_sidechain_data();
|
||||
@@ -752,7 +759,7 @@ void BlockTemplate::fill_optimal_knapsack(const MinerData& data, uint64_t base_r
|
||||
{
|
||||
// Find the maximum possible fee for every weight value and remember which tx leads to this fee/weight
|
||||
// Run time is O(N*W) where N is the number of transactions and W is the maximum block weight
|
||||
//
|
||||
//
|
||||
// Actual run time is 0.02-0.05 seconds on real full blocks
|
||||
// It's too slow and uses too much memory to be practical
|
||||
|
||||
@@ -975,7 +982,7 @@ int BlockTemplate::create_miner_tx(const MinerData& data, const std::vector<Mine
|
||||
LOGINFO(4, "increased EXTRA_NONCE from " << EXTRA_NONCE_SIZE << " to " << corrected_extra_nonce_size << " bytes to maintain miner tx weight");
|
||||
}
|
||||
writeVarint(corrected_extra_nonce_size, m_minerTxExtra);
|
||||
|
||||
|
||||
uint64_t extraNonceOffsetInMinerTx = m_minerTxExtra.size();
|
||||
m_minerTxExtra.insert(m_minerTxExtra.end(), corrected_extra_nonce_size, 0);
|
||||
|
||||
@@ -1406,7 +1413,7 @@ bool BlockTemplate::get_aux_proof(const uint32_t template_id, uint32_t extra_non
|
||||
uint32_t path2 = 0;
|
||||
|
||||
const bool result2 = get_merkle_proof(tree, h, proof2, path2);
|
||||
|
||||
|
||||
if ((result2 != result) || (proof2 != proof) || (path2 != path)) {
|
||||
LOGERR(1, "get_aux_proof: merkle_hash_with_proof and get_merkle_proof returned different results. Fix the code!");
|
||||
}
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2026 jpk68
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <curl/curl.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "i2p.h"
|
||||
#include "log.h"
|
||||
|
||||
LOG_CATEGORY(I2P)
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
hash from_i2p_b32(const std::string& address)
|
||||
{
|
||||
if ((address.length() < 8) || (address.find(".b32.i2p") != address.length() - 8)) {
|
||||
LOGWARN(3, "Invalid I2P address \"" << address << "\": doesn't end with \".b32.i2p\"");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (address.length() != 60) {
|
||||
LOGWARN(3, "Invalid I2P address \"" << address << "\": expected length 60, got " << address.length());
|
||||
return {};
|
||||
}
|
||||
|
||||
size_t pos = address.find('.');
|
||||
const std::string dest_hash = address.substr(0, pos);
|
||||
const hash result = from_i2p_b32_const(dest_hash.c_str());
|
||||
|
||||
if (result.empty()) {
|
||||
LOGWARN(3, "Invalid I2P address \"" << address << "\": has invalid character(s)");
|
||||
return {};
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string to_i2p_b32(const hash& dest_hash)
|
||||
{
|
||||
uint8_t buf[HASH_SIZE + 1];
|
||||
memcpy(buf, dest_hash.h, HASH_SIZE);
|
||||
buf[HASH_SIZE] = 0;
|
||||
|
||||
std::string result;
|
||||
result.reserve(60);
|
||||
|
||||
uint64_t data = 0;
|
||||
uint64_t bit_size = 0;
|
||||
|
||||
for (size_t i = 0; i < HASH_SIZE + 1; ++i) {
|
||||
data = (data << 8) | buf[i];
|
||||
bit_size += 8;
|
||||
|
||||
while (bit_size >= 5) {
|
||||
bit_size -= 5;
|
||||
result += "abcdefghijklmnopqrstuvwxyz234567"[(data >> bit_size) & 31];
|
||||
}
|
||||
}
|
||||
|
||||
result.append(".b32.i2p");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2026 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2026 jpk68
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include <string>
|
||||
#include <uv.h>
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
static FORCEINLINE constexpr hash from_i2p_b32_const(const char* dest_hash)
|
||||
{
|
||||
uint8_t buf[HASH_SIZE + 4] = {};
|
||||
uint8_t* p = buf;
|
||||
|
||||
uint64_t data = 0;
|
||||
uint64_t bit_size = 0;
|
||||
|
||||
for (size_t i = 0; i < 52; ++i) {
|
||||
const char c = dest_hash[i];
|
||||
uint64_t digit = 0;
|
||||
|
||||
if ('a' <= c && c <= 'z') {
|
||||
digit = static_cast<uint64_t>(c - 'a');
|
||||
}
|
||||
else if ('A' <= c && c <= 'Z') {
|
||||
digit = static_cast<uint64_t>(c - 'A');
|
||||
}
|
||||
else if ('2' <= c && c <= '7') {
|
||||
digit = static_cast<uint64_t>(c - '2') + 26;
|
||||
}
|
||||
else {
|
||||
return {};
|
||||
}
|
||||
|
||||
data = (data << 5) | digit;
|
||||
bit_size += 5;
|
||||
|
||||
while (bit_size >= 8) {
|
||||
bit_size -= 8;
|
||||
*(p++) = static_cast<uint8_t>(data >> bit_size);
|
||||
}
|
||||
}
|
||||
|
||||
hash result;
|
||||
|
||||
for (size_t i = 0; i < HASH_SIZE; ++i) {
|
||||
result.h[i] = buf[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
hash from_i2p_b32(const std::string& address);
|
||||
std::string to_i2p_b32(const hash& dest_hash);
|
||||
|
||||
} // namespace p2pool
|
||||
@@ -25,14 +25,14 @@ namespace ConstexprKeccak
|
||||
template<int ROUNDS>
|
||||
static FORCEINLINE constexpr void keccakf(std::array<uint64_t, 25>& st)
|
||||
{
|
||||
constexpr uint64_t round_constants[24] =
|
||||
constexpr uint64_t round_constants[24] =
|
||||
{
|
||||
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
|
||||
0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
|
||||
0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
|
||||
0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
|
||||
0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
|
||||
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
|
||||
0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
|
||||
0x8000000000008080, 0x0000000080000001, 0x8000000080008008
|
||||
};
|
||||
@@ -107,6 +107,7 @@ static constexpr hash keccak(const char (&input)[len])
|
||||
constexpr hash keccak_0x00 = keccak("\0");
|
||||
constexpr hash keccak_subaddress_viewpub = keccak("subaddress_viewpub");
|
||||
constexpr hash keccak_onion_address_v3 = keccak("onion_address_v3");
|
||||
constexpr hash keccak_i2p_b32_address = keccak("i2p_b32_address");
|
||||
|
||||
static_assert(keccak_0x00.u64<0>() == 0x14281E7A9E7836BCULL, "constexpr keccak code check failed");
|
||||
|
||||
|
||||
+3
-1
@@ -64,6 +64,7 @@ void p2pool_usage()
|
||||
"--host IP address of your Monero node, default is 127.0.0.1\n"
|
||||
"--rpc-port monerod RPC API port number, default is 18081\n"
|
||||
"--zmq-port monerod ZMQ pub port number, default is 18083 (same port as in monerod's \"--zmq-pub\" command line parameter)\n"
|
||||
"--sam-port I2P router SAM bridge port number, default is 7656\n"
|
||||
"--stratum Comma-separated list of IP:port for stratum server to listen on\n"
|
||||
"--p2p Comma-separated list of IP:port for p2p server to listen on\n"
|
||||
"--addpeers Comma-separated list of IP:port of other p2pool nodes to connect to\n"
|
||||
@@ -89,7 +90,7 @@ void p2pool_usage()
|
||||
"--no-autodiff Disable automatic difficulty adjustment for miners connected to stratum (WARNING: incompatible with Nicehash and MRR)\n"
|
||||
"--rpc-login Specify username[:password] required for Monero RPC server\n"
|
||||
"--socks5 Specify IP:port of a SOCKS5 proxy to use for outgoing connections\n"
|
||||
"--socks5-proxy-type The type of SOCKS5 proxy. Can be one of the following values: auto, plain, tor. Default is auto (auto-detect by the port number)\n"
|
||||
"--socks5-proxy-type The type of SOCKS5 proxy. Can be one of the following values: auto, plain, tor, i2p. Default is auto (auto-detected by the port number)\n"
|
||||
"--no-dns Disable DNS queries, use only IP addresses to connect to peers (seed node DNS will be unavailable too)\n"
|
||||
"--p2p-external-port Port number that your router uses for mapping to your local p2p port. Use it if you are behind a NAT and still want to accept incoming connections\n"
|
||||
#ifdef WITH_UPNP
|
||||
@@ -110,6 +111,7 @@ void p2pool_usage()
|
||||
"--no-stratum-http Disable HTTP on Stratum ports\n"
|
||||
"--full-validation Enables full share validation / increases CPU usage\n"
|
||||
"--onion-address Tell other peers to use this .onion address to connect to this node through TOR\n"
|
||||
"--i2p-address Tell other peers to use this .b32.i2p address to connect to this node through I2P\n"
|
||||
"--no-clearnet-p2p Forces P2P server to listen on 127.0.0.1 and to not connect to clearnet IPs\n"
|
||||
"--params-file File name to load parameters from. It can't be used together with any other command line parameters\n"
|
||||
"--help Show this help message\n\n"
|
||||
|
||||
@@ -89,7 +89,7 @@ MergeMiningClientTari::MergeMiningClientTari(p2pool* pool, std::string host, con
|
||||
s << "127.0.0.1:" << m_server->external_listen_port();
|
||||
|
||||
m_channelArgs.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 1000);
|
||||
|
||||
|
||||
m_channelArgs.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 1000);
|
||||
m_channelArgs.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 10000);
|
||||
|
||||
@@ -248,7 +248,7 @@ void MergeMiningClientTari::on_external_block(const PoolBlock& block)
|
||||
|
||||
for (const auto& i : block.m_mergeMiningExtra) {
|
||||
// Filter aux chain data only
|
||||
if ((i.first == keccak_subaddress_viewpub) || (i.first == keccak_onion_address_v3)) {
|
||||
if ((i.first == keccak_subaddress_viewpub) || (i.first == keccak_onion_address_v3) || (i.first == keccak_i2p_b32_address)) {
|
||||
continue;
|
||||
}
|
||||
++mm_extra_size;
|
||||
@@ -352,7 +352,7 @@ void MergeMiningClientTari::on_external_block(const PoolBlock& block)
|
||||
|
||||
std::vector<uint8_t> coinbase_merkle_proof;
|
||||
coinbase_merkle_proof.reserve(proof.size() * HASH_SIZE);
|
||||
|
||||
|
||||
for (const hash& h : proof) {
|
||||
coinbase_merkle_proof.insert(coinbase_merkle_proof.end(), h.h, h.h + HASH_SIZE);
|
||||
}
|
||||
|
||||
+98
-8
@@ -33,6 +33,7 @@
|
||||
#include "rapidjson_wrapper.h"
|
||||
#include "merge_mining_client.h"
|
||||
#include "sha256.h"
|
||||
#include "i2p.h"
|
||||
|
||||
#ifdef WITH_TLS
|
||||
#include <openssl/curve25519.h>
|
||||
@@ -48,6 +49,7 @@ LOG_CATEGORY(P2PServer)
|
||||
|
||||
static constexpr char saved_peer_list_file_name[] = "p2pool_peers.txt";
|
||||
static constexpr char saved_onion_peer_list_file_name[] = "p2pool_onion_peers.txt";
|
||||
static constexpr char saved_i2p_peer_list_file_name[] = "p2pool_i2p_peers.txt";
|
||||
static const char* seed_nodes[] = { "seeds.p2pool.io", "main.p2poolpeers.net", "" };
|
||||
static const char* seed_nodes_mini[] = { "seeds-mini.p2pool.io", "mini.p2poolpeers.net", "" };
|
||||
static const char* seed_nodes_nano[] = { "seeds-nano.p2pool.io", "nano.p2poolpeers.net", ""};
|
||||
@@ -63,6 +65,10 @@ static constexpr hash seed_onion_nodes[] = {
|
||||
from_onion_v3_const("p2pseedtwyepi4crkf4akceen4twejcptnsbm6gjmzdfgxua57hiijid.onion")
|
||||
};
|
||||
|
||||
static constexpr hash seed_i2p_nodes[] = {
|
||||
from_i2p_b32_const("mwrwtarc2x6ea2qrzo737nnxv2gg5mo5atk24f5omy3j74xtwkqa")
|
||||
};
|
||||
|
||||
P2PServer::P2PServer(p2pool* pool)
|
||||
: TCPServer(DEFAULT_BACKLOG, P2PClient::allocate, pool->params().m_socks5Proxy, pool->params().m_socks5ProxyType, pool->params().m_p2pProxyProtocol)
|
||||
, m_pool(pool)
|
||||
@@ -79,6 +85,8 @@ P2PServer::P2PServer(p2pool* pool)
|
||||
, m_seenGoodPeers(false)
|
||||
, m_peerListLastSaved(0)
|
||||
, m_numOnionConnections(0)
|
||||
, m_numI2PConnections(0)
|
||||
, m_isI2P(pool->params().m_socks5ProxyType == Params::ProxyType::I2P)
|
||||
, m_lookForMissingBlocks(true)
|
||||
, m_fastestPeer(nullptr)
|
||||
, m_newP2PoolVersionDetected(false)
|
||||
@@ -459,6 +467,39 @@ void P2PServer::update_peer_connections()
|
||||
}
|
||||
}
|
||||
|
||||
// Try to have at least N/2 (or N if clearnet P2P is disabled) outgoing I2P connections
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == Params::ProxyType::I2P)) {
|
||||
std::vector<hash> dest_hashes = m_pool->side_chain().seen_i2p_dest_hashes();
|
||||
|
||||
// Add seed nodes
|
||||
dest_hashes.insert(dest_hashes.end(), seed_i2p_nodes, seed_i2p_nodes + array_size(seed_i2p_nodes));
|
||||
|
||||
const uint32_t n = m_pool->params().m_noClearnetP2P ? N : (N / 2);
|
||||
|
||||
for (uint32_t i = m_numI2PConnections; (i < n) && !dest_hashes.empty();) {
|
||||
const uint64_t k = get_random64() % dest_hashes.size();
|
||||
const std::string addr = to_i2p_b32(dest_hashes[k]);
|
||||
|
||||
int port = DEFAULT_P2P_PORT_I2P;
|
||||
|
||||
for (const hash& seed_i2p : seed_i2p_nodes) {
|
||||
if (dest_hashes[k] == seed_i2p) {
|
||||
const SideChain& s = m_pool->side_chain();
|
||||
port = s.is_mini() ? DEFAULT_P2P_PORT_MINI : (s.is_nano() ? DEFAULT_P2P_PORT_NANO : DEFAULT_P2P_PORT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((connected_clients_domain.find(addr) == connected_clients_domain.end()) && connect_to_peer(addr, port)) {
|
||||
++i;
|
||||
++num_outgoing;
|
||||
}
|
||||
|
||||
dest_hashes[k] = dest_hashes.back();
|
||||
dest_hashes.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
// Try to have at least N outgoing connections (N defaults to 10, can be set via --out-peers command line parameter)
|
||||
if (!m_pool->params().m_noClearnetP2P) {
|
||||
while ((num_outgoing < N) && !peer_list.empty()) {
|
||||
@@ -631,6 +672,28 @@ void P2PServer::save_peer_list()
|
||||
}
|
||||
}
|
||||
|
||||
if (s.i2p_dest_hashes_count() > 0) {
|
||||
const std::string i2p_path = params.m_dataDir + saved_i2p_peer_list_file_name;
|
||||
|
||||
f.open(i2p_path, std::ios::binary);
|
||||
|
||||
if (!f.is_open()) {
|
||||
LOGERR(1, "failed to save I2P peer list " << i2p_path << ": error " << errno);
|
||||
}
|
||||
else {
|
||||
const std::vector<hash> dest_hashes = s.seen_i2p_dest_hashes();
|
||||
|
||||
for (const hash& h : dest_hashes) {
|
||||
f << to_i2p_b32(h) << '\n';
|
||||
}
|
||||
|
||||
f.flush();
|
||||
f.close();
|
||||
|
||||
LOGINFO(5, "I2P peer list saved (" << dest_hashes.size() << " peers)");
|
||||
}
|
||||
}
|
||||
|
||||
m_peerListLastSaved = seconds_since_epoch();
|
||||
}
|
||||
|
||||
@@ -738,6 +801,10 @@ void P2PServer::load_peer_list()
|
||||
paths[Params::ProxyType::TOR] = saved_onion_peer_list_file_name;
|
||||
}
|
||||
|
||||
if (!m_socks5Proxy.empty() && (m_socks5ProxyType == Params::ProxyType::I2P)) {
|
||||
paths[Params::ProxyType::I2P] = saved_i2p_peer_list_file_name;
|
||||
}
|
||||
|
||||
for (int i = Params::ProxyType::PLAIN; i < Params::ProxyType::MAX; ++i) {
|
||||
const std::string& path = paths[i];
|
||||
|
||||
@@ -761,6 +828,12 @@ void P2PServer::load_peer_list()
|
||||
pubkeys.emplace_back(h);
|
||||
}
|
||||
}
|
||||
else if (i == Params::ProxyType::I2P) {
|
||||
const hash h = from_i2p_b32(address);
|
||||
if (!h.empty()) {
|
||||
pubkeys.emplace_back(h);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!saved_list.empty()) {
|
||||
saved_list += ',';
|
||||
@@ -774,6 +847,9 @@ void P2PServer::load_peer_list()
|
||||
if (i == Params::ProxyType::TOR) {
|
||||
s.add_onion_pubkeys(pubkeys);
|
||||
}
|
||||
else if (i == Params::ProxyType::I2P) {
|
||||
s.add_i2p_dest_hashes(pubkeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1214,13 +1290,17 @@ uint64_t P2PServer::get_random64()
|
||||
void P2PServer::print_status()
|
||||
{
|
||||
const uint64_t onion_list_size = m_pool->side_chain().onion_pubkeys_count();
|
||||
const uint64_t i2p_list_size = m_pool->side_chain().i2p_dest_hashes_count();
|
||||
|
||||
MutexLock lock(m_peerListLock);
|
||||
|
||||
LOGINFO(0, "status" <<
|
||||
"\nConnections = " << m_numConnections.load() << " (" << m_numIncomingConnections.load() << " incoming, " << m_numOnionConnections.load() << " onion)"
|
||||
"\nConnections = " << m_numConnections.load() <<
|
||||
" (" << m_numIncomingConnections.load() <<
|
||||
" incoming, " << m_numOnionConnections.load() << " onion, " << m_numI2PConnections.load() << " I2P)" <<
|
||||
"\nPeer list size = " << m_peerList.size() <<
|
||||
"\nOnion list size = " << onion_list_size <<
|
||||
"\nI2P list size = " << i2p_list_size <<
|
||||
"\nUptime = " << log::Duration(seconds_since_epoch() - m_pool->start_time())
|
||||
);
|
||||
}
|
||||
@@ -1911,7 +1991,13 @@ void P2PServer::P2PClient::reset()
|
||||
server->m_fastestPeer = nullptr;
|
||||
}
|
||||
if ((m_addressType == AddressType::DomainName) && m_connectedTime) {
|
||||
--server->m_numOnionConnections;
|
||||
if (m_addressType == AddressType::DomainName) {
|
||||
if (server->m_isI2P == true) {
|
||||
--server->m_numI2PConnections;
|
||||
} else {
|
||||
--server->m_numOnionConnections;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1971,7 +2057,11 @@ bool P2PServer::P2PClient::on_connect()
|
||||
}
|
||||
|
||||
if (m_addressType == AddressType::DomainName) {
|
||||
++server->m_numOnionConnections;
|
||||
if (server->m_isI2P == true) {
|
||||
++server->m_numI2PConnections;
|
||||
} else {
|
||||
++server->m_numOnionConnections;
|
||||
}
|
||||
}
|
||||
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
@@ -3043,7 +3133,7 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
|
||||
const time_t cur_time = time(nullptr);
|
||||
|
||||
// Layout of the message:
|
||||
//
|
||||
//
|
||||
// 32 bytes | Secondary public key
|
||||
// 8 bytes | Secondary public key's expiration timestamp
|
||||
// 64 bytes | Master key signature signing the above 40 bytes
|
||||
@@ -3062,11 +3152,11 @@ bool P2PServer::P2PClient::on_aux_job_donation(const uint8_t* buf, uint32_t size
|
||||
}
|
||||
|
||||
// Layout of the data:
|
||||
//
|
||||
//
|
||||
// 8 bytes | timestamp
|
||||
//
|
||||
//
|
||||
// Next come one or multiple data entries:
|
||||
//
|
||||
//
|
||||
// 32 bytes | aux_id
|
||||
// 32 bytes | aux_hash
|
||||
// 16 bytes | aux_diff
|
||||
@@ -3262,7 +3352,7 @@ bool P2PServer::P2PClient::on_monero_block_broadcast(const uint8_t* buf, uint32_
|
||||
|
||||
std::vector<uint8_t> blob;
|
||||
blob.reserve(data.header_size + HASH_SIZE + 2);
|
||||
|
||||
|
||||
blob.insert(blob.end(), buf, buf + data.header_size);
|
||||
blob.insert(blob.end(), root.h, root.h + HASH_SIZE);
|
||||
writeVarint(num_transactions + 1, blob);
|
||||
|
||||
+5
-2
@@ -37,6 +37,7 @@ static constexpr int DEFAULT_P2P_PORT_MINI = 37888;
|
||||
static constexpr int DEFAULT_P2P_PORT_NANO = 37890;
|
||||
|
||||
static constexpr int DEFAULT_P2P_PORT_ONION = 28722;
|
||||
static constexpr int DEFAULT_P2P_PORT_I2P = 28723;
|
||||
|
||||
static constexpr uint32_t PROTOCOL_VERSION_1_0 = 0x00010000UL;
|
||||
static constexpr uint32_t PROTOCOL_VERSION_1_1 = 0x00010001UL;
|
||||
@@ -95,9 +96,9 @@ public:
|
||||
// Both peers send handshake challenge immediately after a connection is established
|
||||
// Both peers must have the same consensus ID for handshake to succeed
|
||||
// Consensus ID is never sent over the network
|
||||
//
|
||||
//
|
||||
// Handshake sequence:
|
||||
//
|
||||
//
|
||||
// - Both peers send 8-byte random challenges (and 8 bytes of peer ID) to each other
|
||||
// - Each peer receives 8-byte challenge, chooses 8-byte random SALT and calculates H = KECCAK(CHALLENGE|CONSENSUS_ID|SALT)
|
||||
// - Both peers send their H and SALT, calculate H of the other peer and check if it matches with what other peer calculated
|
||||
@@ -291,6 +292,8 @@ private:
|
||||
std::atomic<uint64_t> m_peerListLastSaved;
|
||||
|
||||
std::atomic<uint32_t> m_numOnionConnections;
|
||||
std::atomic<uint32_t> m_numI2PConnections;
|
||||
bool m_isI2P;
|
||||
|
||||
uv_mutex_t m_broadcastLock;
|
||||
uv_async_t m_broadcastAsync;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "params.h"
|
||||
#include "stratum_server.h"
|
||||
#include "p2p_server.h"
|
||||
#include "i2p.h"
|
||||
#include <fstream>
|
||||
|
||||
#ifdef WITH_GRPC
|
||||
@@ -59,6 +60,15 @@ Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_i2pAddress.empty()) {
|
||||
m_i2pDestinationHash = from_i2p_b32(m_i2pAddress);
|
||||
|
||||
if (m_i2pDestinationHash.empty()) {
|
||||
LOGERR(1, "Failed to parse \"" << m_i2pAddress << '"');
|
||||
throw std::exception();
|
||||
}
|
||||
}
|
||||
|
||||
auto invalid_host = [](const Host& h)
|
||||
{
|
||||
if (!h.valid()) {
|
||||
@@ -180,6 +190,10 @@ Params::Params(const std::vector<std::vector<std::string>>& args)
|
||||
m_socks5ProxyType = ProxyType::TOR;
|
||||
break;
|
||||
|
||||
case 4447:
|
||||
m_socks5ProxyType = ProxyType::I2P;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_socks5ProxyType = ProxyType::PLAIN;
|
||||
break;
|
||||
@@ -460,6 +474,16 @@ bool Params::process_arg(const std::vector<std::string>& arg)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "i2p-address") && has1(arg)) {
|
||||
m_i2pAddress = arg[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((arg[0] == "sam-port") && has1(arg)) {
|
||||
m_samPort = static_cast<int32_t>(std::min(std::max(strtoul(arg[1].c_str(), nullptr, 10), 1UL), 65535UL));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg[0] == "no-clearnet-p2p") {
|
||||
m_noClearnetP2P = true;
|
||||
return true;
|
||||
|
||||
+10
-1
@@ -116,7 +116,8 @@ struct Params
|
||||
AUTO = 0,
|
||||
PLAIN = 1,
|
||||
TOR = 2,
|
||||
MAX = 3,
|
||||
I2P = 3,
|
||||
MAX = 4,
|
||||
} m_socks5ProxyType = ProxyType::AUTO;
|
||||
|
||||
bool m_dns = true;
|
||||
@@ -148,6 +149,14 @@ struct Params
|
||||
|
||||
std::string m_onionAddress;
|
||||
hash m_onionPubkey;
|
||||
|
||||
// Hidden service address provided by the user
|
||||
std::string m_i2pAddress;
|
||||
// Raw hash of the destination info; decoded Base32 address with suffix removed
|
||||
hash m_i2pDestinationHash;
|
||||
|
||||
uint16_t m_samPort = 7656;
|
||||
|
||||
bool m_noClearnetP2P = false;
|
||||
bool m_stratumProxyProtocol = false;
|
||||
bool m_p2pProxyProtocol = false;
|
||||
|
||||
+42
-2
@@ -702,6 +702,13 @@ bool SideChain::add_block(const PoolBlock& block)
|
||||
m_seenOnionPubkeys[h] = new_block->m_localTimestamp;
|
||||
}
|
||||
|
||||
auto it2 = new_block->m_mergeMiningExtra.find(keccak_i2p_b32_address);
|
||||
if ((it2 != new_block->m_mergeMiningExtra.end()) && (it2->second.size() >= HASH_SIZE)) {
|
||||
hash h;
|
||||
memcpy(h.h, it2->second.data(), HASH_SIZE);
|
||||
m_seenI2PDestHashes[h] = new_block->m_localTimestamp;
|
||||
}
|
||||
|
||||
prune_seen_data();
|
||||
}
|
||||
|
||||
@@ -1156,7 +1163,7 @@ void SideChain::prune_seen_data()
|
||||
{
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
// Every 5 minutes, delete wallets that weren't seen for more than 72 hours and onion pubkeys that weren't seen for more than 12 hours
|
||||
// Every 5 minutes, delete wallets that haven't been seen for more than 72 hours and onion/I2P identifiers that haven't been seen for more than 12 hours
|
||||
if (m_seenWalletsLastPruneTime + 5ul * 60ul <= cur_time) {
|
||||
auto prune = [cur_time](auto& data, uint64_t timeout) {
|
||||
for (auto it = data.begin(); it != data.end();) {
|
||||
@@ -1173,6 +1180,7 @@ void SideChain::prune_seen_data()
|
||||
|
||||
prune(m_seenWallets, 72 * hour);
|
||||
prune(m_seenOnionPubkeys, 12 * hour);
|
||||
prune(m_seenI2PDestHashes, 12 * hour);
|
||||
|
||||
m_seenWalletsLastPruneTime = cur_time;
|
||||
}
|
||||
@@ -1401,6 +1409,38 @@ void SideChain::add_onion_pubkeys(const std::vector<hash>& pubkeys)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<hash> SideChain::seen_i2p_dest_hashes() const
|
||||
{
|
||||
std::vector<hash> result;
|
||||
|
||||
ReadLock lock(m_seenDataLock);
|
||||
|
||||
result.reserve(m_seenI2PDestHashes.size());
|
||||
|
||||
for (const auto& it : m_seenI2PDestHashes) {
|
||||
result.push_back(it.first);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void SideChain::add_i2p_dest_hashes(const std::vector<hash>& dest_hashes)
|
||||
{
|
||||
if (dest_hashes.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
WriteLock lock(m_seenDataLock);
|
||||
|
||||
for (const hash& h : dest_hashes) {
|
||||
if (!h.empty()) {
|
||||
m_seenI2PDestHashes[h] = cur_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SideChain::verify_loop(PoolBlock* block)
|
||||
{
|
||||
// PoW is already checked at this point
|
||||
@@ -2445,7 +2485,7 @@ void SideChain::precalc_worker()
|
||||
|
||||
do {
|
||||
const PoolBlock* job;
|
||||
|
||||
|
||||
{
|
||||
MutexLock lock(m_precalcJobsMutex);
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
[[nodiscard]] uint64_t block_time() const { return m_targetBlockTime; }
|
||||
[[nodiscard]] FORCEINLINE uint64_t miner_count() const { ReadLock lock(m_seenDataLock); return m_seenWallets.size(); }
|
||||
[[nodiscard]] FORCEINLINE uint64_t onion_pubkeys_count() const { ReadLock lock(m_seenDataLock); return m_seenOnionPubkeys.size(); }
|
||||
[[nodiscard]] FORCEINLINE uint64_t i2p_dest_hashes_count() const { ReadLock lock(m_seenDataLock); return m_seenI2PDestHashes.size(); }
|
||||
[[nodiscard]] uint64_t last_updated() const;
|
||||
[[nodiscard]] bool is_default() const;
|
||||
[[nodiscard]] bool is_mini() const;
|
||||
@@ -90,6 +91,9 @@ public:
|
||||
[[nodiscard]] std::vector<hash> seen_onion_pubkeys() const;
|
||||
void add_onion_pubkeys(const std::vector<hash>& pubkeys);
|
||||
|
||||
[[nodiscard]] std::vector<hash> seen_i2p_dest_hashes() const;
|
||||
void add_i2p_dest_hashes(const std::vector<hash>& dest_hashes);
|
||||
|
||||
#ifdef P2POOL_UNIT_TESTS
|
||||
difficulty_type m_testMainChainDiff;
|
||||
const unordered_map<hash, PoolBlock*>& blocksById() const { return m_blocksById; }
|
||||
@@ -129,6 +133,7 @@ private:
|
||||
mutable ReadWriteLock m_seenDataLock;
|
||||
unordered_map<hash, uint64_t> m_seenWallets;
|
||||
unordered_map<hash, uint64_t> m_seenOnionPubkeys;
|
||||
unordered_map<hash, uint64_t> m_seenI2PDestHashes;
|
||||
uint64_t m_seenWalletsLastPruneTime;
|
||||
|
||||
// Used to quickly cut off multiple broadcasts of the same block by different peers. Only the first broadcast will be processed.
|
||||
|
||||
@@ -15,7 +15,7 @@ endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "3.5.2")
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "3.5.2")
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT p2pool_tests)
|
||||
endif()
|
||||
|
||||
@@ -60,6 +60,7 @@ set(SOURCES
|
||||
src/sha256_tests.cpp
|
||||
src/util_tests.cpp
|
||||
src/wallet_tests.cpp
|
||||
src/i2p_tests.cpp
|
||||
../external/src/crypto/sha256.c
|
||||
../external/src/cryptonote/crypto-ops-data.c
|
||||
../external/src/cryptonote/crypto-ops.c
|
||||
@@ -84,6 +85,7 @@ set(SOURCES
|
||||
../src/tcp_server.cpp
|
||||
../src/util.cpp
|
||||
../src/wallet.cpp
|
||||
../src/i2p.cpp
|
||||
)
|
||||
|
||||
if (WITH_INDEXED_HASHES)
|
||||
@@ -185,7 +187,9 @@ endif()
|
||||
add_definitions("-DRAPIDJSON_PARSE_DEFAULT_FLAGS=kParseTrailingCommasFlag")
|
||||
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES})
|
||||
find_package(CURL REQUIRED)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} debug ${ZMQ_LIBRARY_DEBUG} debug ${UV_LIBRARY_DEBUG} optimized ${ZMQ_LIBRARY} optimized ${UV_LIBRARY} ${LIBS})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} ${CURL_LIBRARIES})
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/crypto_tests.txt" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/block.dat" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/src/sidechain_dump.dat.xz" $<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>)
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
|
||||
* Copyright (c) 2021-2024 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2026 jpk68
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include "gtest/gtest.h"
|
||||
#include "i2p.h"
|
||||
#include "common.h"
|
||||
|
||||
namespace p2pool {
|
||||
|
||||
TEST(i2p, decode_encode)
|
||||
{
|
||||
const std::string addr1 = "vxghq7uoi3m5juvfk2otmxlh4qhwb42xdbytehtahqeksoclcetq.b32.i2p";
|
||||
const hash result1 = from_i2p_b32(addr1);
|
||||
|
||||
const hash expected1{
|
||||
0xad, 0xcc, 0x78, 0x7e, 0x8e, 0x46, 0xd9, 0xd4,
|
||||
0xd2, 0xa5, 0x56, 0x9d, 0x36, 0x5d, 0x67, 0xe4,
|
||||
0x0f, 0x60, 0xf3, 0x57, 0x18, 0x71, 0x32, 0x1e,
|
||||
0x60, 0x3c, 0x08, 0xa9, 0x38, 0x4b, 0x11, 0x27
|
||||
};
|
||||
EXPECT_EQ(result1, expected1);
|
||||
|
||||
const std::string result2 = to_i2p_b32(result1);
|
||||
EXPECT_EQ(result2, addr1);
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
Reference in New Issue
Block a user