Merge pull request #374 from gavinbarnard/gavinbarnard/fullvalidationoption
full share validation via cmdline option
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
--rpc-ssl Enable SSL on RPC connections to the Monero node
|
--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)
|
--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
|
--no-stratum-http Disable HTTP on Stratum ports
|
||||||
|
--full-validation Enables full share validation / increases CPU usage
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example command line
|
### 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.
|
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.
|
||||||
@@ -100,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"
|
"--rpc-ssl-fingerprint base64-encoded fingerprint of the Monero node's certificate (optional, use it for certificate pinning)\n"
|
||||||
#endif
|
#endif
|
||||||
"--no-stratum-http Disable HTTP on Stratum ports\n"
|
"--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"
|
"--help Show this help message\n\n"
|
||||||
"Example command line:\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",
|
"%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",
|
||||||
|
|||||||
@@ -258,6 +258,11 @@ Params::Params(int argc, char* const argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "--full-validation") == 0) {
|
||||||
|
m_enableFullValidation = true;
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
// Wait to avoid log messages overlapping with printf() calls and making a mess on screen
|
// Wait to avoid log messages overlapping with printf() calls and making a mess on screen
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ struct Params
|
|||||||
uint8_t priv_key[64];
|
uint8_t priv_key[64];
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
bool m_enableFullValidation = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace p2pool
|
} // namespace p2pool
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ StratumServer::StratumServer(p2pool* pool)
|
|||||||
: TCPServer(DEFAULT_BACKLOG, StratumClient::allocate, std::string())
|
: TCPServer(DEFAULT_BACKLOG, StratumClient::allocate, std::string())
|
||||||
, m_pool(pool)
|
, m_pool(pool)
|
||||||
, m_autoDiff(pool->params().m_autoDiff)
|
, m_autoDiff(pool->params().m_autoDiff)
|
||||||
|
, m_enableFullValidation(pool->params().m_enableFullValidation)
|
||||||
, m_rng(RandomDeviceSeed::instance)
|
, m_rng(RandomDeviceSeed::instance)
|
||||||
, m_cumulativeHashes(0)
|
, m_cumulativeHashes(0)
|
||||||
, m_cumulativeHashesAtLastShare(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);
|
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 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_share_found(&share.m_req);
|
||||||
on_after_share_found(&share.m_req, 0);
|
on_after_share_found(&share.m_req, 0);
|
||||||
return true;
|
return true;
|
||||||
@@ -951,7 +952,7 @@ void StratumServer::on_share_found(uv_work_t* req)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (share->m_highEnoughDifficulty) {
|
if (share->m_highEnoughDifficulty || server->m_enableFullValidation) {
|
||||||
BACKGROUND_JOB_START(StratumServer::on_share_found);
|
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 target = share->m_target;
|
||||||
const uint64_t hashes = share->m_hashes;
|
const uint64_t hashes = share->m_hashes;
|
||||||
|
|
||||||
if (share->m_highEnoughDifficulty) {
|
if (share->m_highEnoughDifficulty || server->m_enableFullValidation) {
|
||||||
if (pool->stopped()) {
|
if (pool->stopped()) {
|
||||||
LOGWARN(0, "p2pool is shutting down, but a share was found. Trying to process it anyway!");
|
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;
|
prev_time = server->m_lastSidechainShareFoundTime;
|
||||||
server->m_lastSidechainShareFoundTime = cur_time;
|
server->m_lastSidechainShareFoundTime = cur_time;
|
||||||
}
|
}
|
||||||
|
if (share->m_highEnoughDifficulty && !pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
|
||||||
if (!pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
|
|
||||||
WriteLock lock(server->m_hashrateDataLock);
|
WriteLock lock(server->m_hashrateDataLock);
|
||||||
|
|
||||||
if (server->m_totalFoundSidechainShares > 0) {
|
if (server->m_totalFoundSidechainShares > 0) {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ private:
|
|||||||
|
|
||||||
p2pool* m_pool;
|
p2pool* m_pool;
|
||||||
bool m_autoDiff;
|
bool m_autoDiff;
|
||||||
|
bool m_enableFullValidation;
|
||||||
struct BlobsData
|
struct BlobsData
|
||||||
{
|
{
|
||||||
uint32_t m_extraNonceStart;
|
uint32_t m_extraNonceStart;
|
||||||
|
|||||||
Reference in New Issue
Block a user