mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
Sync test: added merge mining
This commit is contained in:
parent
d1fee33482
commit
5aff5f5796
5 changed files with 89 additions and 19 deletions
44
.github/workflows/test-sync.yml
vendored
44
.github/workflows/test-sync.yml
vendored
|
@ -1,6 +1,13 @@
|
|||
name: Sync test
|
||||
|
||||
on: workflow_dispatch
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'docker-compose/**'
|
||||
- 'docs/**'
|
||||
- 'README.md'
|
||||
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
sync-test-ubuntu-tsan:
|
||||
|
@ -57,7 +64,10 @@ jobs:
|
|||
python ../tests/src/stratum_dummy.py 1 &
|
||||
python ../tests/src/stratum_dummy.py 2 &
|
||||
python ../tests/src/stratum_dummy.py 3 &
|
||||
TSAN_OPTIONS="suppressions=../tests/src/tsan_sup.txt halt_on_error=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
python ../tests/src/mm_server.py 8000 id0 data0 &
|
||||
python ../tests/src/mm_server.py 8001 id1 data1 &
|
||||
python ../tests/src/mm_server.py 8002 id2 data2 &
|
||||
TSAN_OPTIONS="suppressions=../tests/src/tsan_sup.txt halt_on_error=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
@ -142,7 +152,10 @@ jobs:
|
|||
python ../tests/src/stratum_dummy.py 1 &
|
||||
python ../tests/src/stratum_dummy.py 2 &
|
||||
python ../tests/src/stratum_dummy.py 3 &
|
||||
MSAN_OPTIONS="halt_on_error=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
python ../tests/src/mm_server.py 8000 id0 data0 &
|
||||
python ../tests/src/mm_server.py 8001 id1 data1 &
|
||||
python ../tests/src/mm_server.py 8002 id2 data2 &
|
||||
MSAN_OPTIONS="halt_on_error=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
@ -188,7 +201,10 @@ jobs:
|
|||
python ../tests/src/stratum_dummy.py 1 &
|
||||
python ../tests/src/stratum_dummy.py 2 &
|
||||
python ../tests/src/stratum_dummy.py 3 &
|
||||
UBSAN_OPTIONS="suppressions=../tests/src/ubsan_sup.txt halt_on_error=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
python ../tests/src/mm_server.py 8000 id0 data0 &
|
||||
python ../tests/src/mm_server.py 8001 id1 data1 &
|
||||
python ../tests/src/mm_server.py 8002 id2 data2 &
|
||||
UBSAN_OPTIONS="suppressions=../tests/src/ubsan_sup.txt halt_on_error=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
@ -234,7 +250,10 @@ jobs:
|
|||
python ../tests/src/stratum_dummy.py 1 &
|
||||
python ../tests/src/stratum_dummy.py 2 &
|
||||
python ../tests/src/stratum_dummy.py 3 &
|
||||
ASAN_OPTIONS="detect_stack_use_after_return=1 atexit=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
python ../tests/src/mm_server.py 8000 id0 data0 &
|
||||
python ../tests/src/mm_server.py 8001 id1 data1 &
|
||||
python ../tests/src/mm_server.py 8002 id2 data2 &
|
||||
ASAN_OPTIONS="detect_stack_use_after_return=1 atexit=1" ./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
@ -302,7 +321,10 @@ jobs:
|
|||
python3 ../tests/src/stratum_dummy.py 1 &
|
||||
python3 ../tests/src/stratum_dummy.py 2 &
|
||||
python3 ../tests/src/stratum_dummy.py 3 &
|
||||
./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
python3 ../tests/src/mm_server.py 8000 id0 data0 &
|
||||
python3 ../tests/src/mm_server.py 8001 id1 data1 &
|
||||
python3 ../tests/src/mm_server.py 8002 id2 data2 &
|
||||
./p2pool --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
@ -347,7 +369,10 @@ jobs:
|
|||
start python ../../tests/src/stratum_dummy.py 1
|
||||
start python ../../tests/src/stratum_dummy.py 2
|
||||
start python ../../tests/src/stratum_dummy.py 3
|
||||
p2pool.exe --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
start python ../../tests/src/mm_server.py 8000 id0 data0 &
|
||||
start python ../../tests/src/mm_server.py 8001 id1 data1 &
|
||||
start python ../../tests/src/mm_server.py 8002 id2 data2 &
|
||||
p2pool.exe --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
@ -390,7 +415,10 @@ jobs:
|
|||
Start-Process python -ArgumentList "../../tests/src/stratum_dummy.py 1"
|
||||
Start-Process python -ArgumentList "../../tests/src/stratum_dummy.py 2"
|
||||
Start-Process python -ArgumentList "../../tests/src/stratum_dummy.py 3"
|
||||
./p2pool.exe --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --loglevel 6
|
||||
Start-Process python -ArgumentList "../../tests/src/mm_server.py 8000 id0 data0"
|
||||
Start-Process python -ArgumentList "../../tests/src/mm_server.py 8001 id1 data1"
|
||||
Start-Process python -ArgumentList "../../tests/src/mm_server.py 8002 id2 data2"
|
||||
./p2pool.exe --host xmrnode.facspro.net --rpc-port 18089 --zmq-port 18084 --host xmr2.rs.me --wallet 44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg --mini --out-peers 200 --data-api data --local-api --merge-mine 127.0.0.1:8000 test0 --merge-mine 127.0.0.1:8001 test1 --merge-mine 127.0.0.1:8002 test2 --loglevel 6
|
||||
|
||||
- name: Check p2pool.log
|
||||
run: |
|
||||
|
|
|
@ -37,6 +37,9 @@ MergeMiningClient::MergeMiningClient(p2pool* pool, const std::string& host, cons
|
|||
, m_loopThread{}
|
||||
, m_timer{}
|
||||
, m_getJobRunning(false)
|
||||
#ifdef DEV_TEST_SYNC
|
||||
, m_getJobCounter(0)
|
||||
#endif
|
||||
, m_shutdownAsync{}
|
||||
{
|
||||
const size_t k = host.find_last_of(':');
|
||||
|
@ -110,6 +113,9 @@ void MergeMiningClient::merge_mining_get_chain_id()
|
|||
m_ping = ping;
|
||||
}
|
||||
|
||||
LOGINFO(1, m_host << ':' << m_port << " uses chain_id " << log::LightCyan() << m_chainID);
|
||||
LOGINFO(1, m_host << ':' << m_port << " ping is " << m_ping << " ms");
|
||||
|
||||
// Chain ID received successfully, we can start polling for new mining jobs now
|
||||
const int err = uv_timer_start(&m_timer, on_timer, 0, 500);
|
||||
if (err) {
|
||||
|
@ -117,9 +123,9 @@ void MergeMiningClient::merge_mining_get_chain_id()
|
|||
}
|
||||
}
|
||||
},
|
||||
[](const char* data, size_t size, double) {
|
||||
[this](const char* data, size_t size, double) {
|
||||
if (size > 0) {
|
||||
LOGERR(1, "couldn't get merge mining id, error " << log::const_buf(data, size));
|
||||
LOGERR(1, "couldn't get merge mining id from " << m_host << ':' << m_port << ", error " << log::const_buf(data, size));
|
||||
}
|
||||
}, &m_loop);
|
||||
}
|
||||
|
@ -160,6 +166,14 @@ bool MergeMiningClient::parse_merge_mining_get_chain_id(const char* data, size_t
|
|||
|
||||
void MergeMiningClient::merge_mining_get_job(uint64_t height, const hash& prev_id, const std::string& wallet, const hash& aux_hash)
|
||||
{
|
||||
#ifdef DEV_TEST_SYNC
|
||||
if (++m_getJobCounter > 100) {
|
||||
LOGINFO(0, log::LightGreen() << "[DEV] Synchronization finished successfully, stopping P2Pool now");
|
||||
m_pool->stop();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_getJobRunning) {
|
||||
return;
|
||||
}
|
||||
|
@ -182,7 +196,7 @@ void MergeMiningClient::merge_mining_get_job(uint64_t height, const hash& prev_i
|
|||
},
|
||||
[this](const char* data, size_t size, double) {
|
||||
if (size > 0) {
|
||||
LOGERR(1, "couldn't get merge mining job, error " << log::const_buf(data, size));
|
||||
LOGERR(1, "couldn't get merge mining job from " << m_host << ':' << m_port << ", error " << log::const_buf(data, size));
|
||||
}
|
||||
m_getJobRunning = false;
|
||||
}, &m_loop);
|
||||
|
@ -268,9 +282,9 @@ void MergeMiningClient::merge_mining_submit_solution(const std::vector<uint8_t>&
|
|||
[this](const char* data, size_t size, double) {
|
||||
parse_merge_mining_submit_solution(data, size);
|
||||
},
|
||||
[](const char* data, size_t size, double) {
|
||||
[this](const char* data, size_t size, double) {
|
||||
if (size > 0) {
|
||||
LOGERR(1, "couldn't submit merge mining solution, error " << log::const_buf(data, size));
|
||||
LOGERR(1, "couldn't submit merge mining solution to " << m_host << ':' << m_port << ", error " << log::const_buf(data, size));
|
||||
}
|
||||
}, &m_loop);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,10 @@ private:
|
|||
|
||||
bool m_getJobRunning;
|
||||
|
||||
#ifdef DEV_TEST_SYNC
|
||||
uint32_t m_getJobCounter;
|
||||
#endif
|
||||
|
||||
uv_async_t m_shutdownAsync;
|
||||
|
||||
static void on_shutdown(uv_async_t* async)
|
||||
|
|
|
@ -346,13 +346,15 @@ void p2pool::handle_miner_data(MinerData& data)
|
|||
data.aux_chains.reserve(m_mergeMiningClients.size());
|
||||
|
||||
std::vector<hash> tmp;
|
||||
tmp.reserve(m_mergeMiningClients.size());
|
||||
tmp.reserve(m_mergeMiningClients.size() + 1);
|
||||
|
||||
for (const MergeMiningClient* c : m_mergeMiningClients) {
|
||||
data.aux_chains.emplace_back(c->aux_id(), c->aux_data(), c->aux_diff());
|
||||
tmp.emplace_back(c->aux_data());
|
||||
tmp.emplace_back(c->aux_id());
|
||||
}
|
||||
|
||||
tmp.emplace_back(m_sideChain->consensus_hash());
|
||||
|
||||
if (!find_aux_nonce(tmp, data.aux_nonce)) {
|
||||
LOGERR(1, "Failed to find the aux nonce for merge mining. Merge mining will be off this round.");
|
||||
data.aux_chains.clear();
|
||||
|
|
|
@ -2,6 +2,13 @@ import http.server
|
|||
import socketserver
|
||||
import json
|
||||
|
||||
chain_id = ''
|
||||
aux_blob = ''
|
||||
aux_diff = 1000
|
||||
aux_hash = ''
|
||||
|
||||
counter = 0
|
||||
|
||||
class Server(http.server.BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
length = int(self.headers['content-length'])
|
||||
|
@ -16,9 +23,16 @@ class Server(http.server.BaseHTTPRequestHandler):
|
|||
response = {'jsonrpc':'2.0','id':'0'}
|
||||
|
||||
if request['method'] == 'merge_mining_get_chain_id':
|
||||
response['result'] = {'chain_id':'0f28c4960d96647e77e7ab6d13b85bd16c7ca56f45df802cdc763a5e5c0c7863'}
|
||||
response['result'] = {'chain_id':chain_id}
|
||||
elif request['method'] == 'merge_mining_get_job':
|
||||
response['result'] = {'aux_blob':'4c6f72656d20697073756d','aux_diff':123456,'aux_hash':'f6952d6eef555ddd87aca66e56b91530222d6e318414816f3ba7cf5bf694bf0f'}
|
||||
global counter
|
||||
counter += 1
|
||||
s = aux_blob + '_' + str(counter // 10)
|
||||
aux_hash = hashlib.sha256(s.encode('utf-8')).hexdigest()
|
||||
if aux_hash != request['params']['aux_hash']:
|
||||
response['result'] = {'aux_blob':s.encode('utf-8').hex(),'aux_diff':aux_diff,'aux_hash':aux_hash}
|
||||
else:
|
||||
response['result'] = {}
|
||||
elif request['method'] == 'merge_mining_submit_solution':
|
||||
response['result'] = {'status':'accepted'}
|
||||
|
||||
|
@ -26,5 +40,13 @@ class Server(http.server.BaseHTTPRequestHandler):
|
|||
print(response)
|
||||
self.wfile.write(response.encode('utf-8'))
|
||||
|
||||
httpd = socketserver.TCPServer(('', 8000), Server)
|
||||
httpd.serve_forever()
|
||||
if __name__ == "__main__":
|
||||
from sys import argv
|
||||
import hashlib
|
||||
|
||||
port = int(argv[1])
|
||||
chain_id = hashlib.sha256(argv[2].encode('utf-8')).hexdigest()
|
||||
aux_blob = argv[3];
|
||||
|
||||
httpd = socketserver.TCPServer(('', port), Server)
|
||||
httpd.serve_forever()
|
||||
|
|
Loading…
Reference in a new issue