Browse Source

fixed faux GPU failures

cl-refactor
Genoil 9 years ago
parent
commit
def718be57
  1. 17
      ethminer/MinerAux.h
  2. 2
      libethcore/EthashCUDAMiner.cpp
  3. 30
      libstratum/EthStratumClient.cpp
  4. 3
      libstratum/EthStratumClient.h

17
ethminer/MinerAux.h

@ -881,7 +881,7 @@ private:
f.start("opencl");
else if (_m == MinerType::CUDA)
f.start("cuda");
EthashProofOfWork::WorkPackage current;
EthashProofOfWork::WorkPackage current, solved;
EthashAux::FullType dag;
while (m_running)
try
@ -891,6 +891,9 @@ private:
f.onSolutionFound([&](EthashProofOfWork::Solution sol)
{
solution = sol;
solved.headerHash = current.headerHash;
solved.boundary = current.boundary;
solved.seedHash = current.seedHash;
return completed = true;
});
for (unsigned i = 0; !completed; ++i)
@ -939,13 +942,13 @@ private:
cnote << "Solution found; Submitting to" << _remote << "...";
cnote << " Nonce:" << solution.nonce.hex();
cnote << " Mixhash:" << solution.mixHash.hex();
cnote << " Header-hash:" << current.headerHash.hex();
cnote << " Seedhash:" << current.seedHash.hex();
cnote << " Target: " << h256(current.boundary).hex();
cnote << " Ethash: " << h256(EthashAux::eval(current.seedHash, current.headerHash, solution.nonce).value).hex();
if (EthashAux::eval(current.seedHash, current.headerHash, solution.nonce).value < current.boundary)
cnote << " Header-hash:" << solved.headerHash.hex();
cnote << " Seedhash:" << solved.seedHash.hex();
cnote << " Target: " << h256(solved.boundary).hex();
cnote << " Ethash: " << h256(EthashAux::eval(solved.seedHash, solved.headerHash, solution.nonce).value).hex();
if (EthashAux::eval(solved.seedHash, solved.headerHash, solution.nonce).value < solved.boundary)
{
bool ok = prpc->eth_submitWork("0x" + toString(solution.nonce), "0x" + toString(current.headerHash), "0x" + toString(solution.mixHash));
bool ok = prpc->eth_submitWork("0x" + toString(solution.nonce), "0x" + toString(solved.headerHash), "0x" + toString(solution.mixHash));
if (ok) {
cnote << "B-) Submitted and accepted.";
f.acceptedSolution();

2
libethcore/EthashCUDAMiner.cpp

@ -149,7 +149,7 @@ void EthashCUDAMiner::workLoop()
// take local copy of work since it may end up being overwritten by kickOff/pause.
try {
WorkPackage w = work();
cnote << "workLoop" << !!m_miner << m_minerSeed << w.seedHash;
cnote << "seedhash" << "#" + m_minerSeed.hex().substr(0, 16);
if (!m_miner || m_minerSeed != w.seedHash)
{
cnote << "Initialising miner...";

30
libstratum/EthStratumClient.cpp

@ -176,7 +176,7 @@ void EthStratumClient::connect_handler(const boost::system::error_code& ec, tcp:
}
void EthStratumClient::readline() {
m_mtx.lock();
x_pending.lock();
if (m_pending == 0) {
async_read_until(m_socket, m_responseBuffer, "\n",
boost::bind(&EthStratumClient::readResponse, this,
@ -185,7 +185,7 @@ void EthStratumClient::readline() {
m_pending++;
}
m_mtx.unlock();
x_pending.unlock();
}
void EthStratumClient::handleResponse(const boost::system::error_code& ec) {
@ -203,9 +203,9 @@ void EthStratumClient::handleResponse(const boost::system::error_code& ec) {
void EthStratumClient::readResponse(const boost::system::error_code& ec, std::size_t bytes_transferred)
{
dev::setThreadName("stratum");
m_mtx.lock();
x_pending.lock();
m_pending = m_pending > 0 ? m_pending - 1 : 0;
m_mtx.unlock();
x_pending.unlock();
if (!ec)
{
@ -321,15 +321,18 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
EthashAux::computeFull(sha3(seedHash), true);
if (headerHash != m_current.headerHash)
{
x_current.lock();
if (p_worktimer)
p_worktimer->cancel();
m_current.headerHash = h256(sHeaderHash);
m_current.seedHash = seedHash;
m_current.boundary = h256(sShareTarget);// , h256::AlignRight);
p_farm->setWork(m_current);
x_current.unlock();
p_worktimer = new boost::asio::deadline_timer(m_io_service, boost::posix_time::seconds(m_worktimeout));
p_worktimer->async_wait(boost::bind(&EthStratumClient::work_timeout_handler, this, boost::asio::placeholders::error));
}
}
}
@ -358,29 +361,32 @@ void EthStratumClient::work_timeout_handler(const boost::system::error_code& ec)
}
bool EthStratumClient::submit(EthashProofOfWork::Solution solution) {
x_current.lock();
cnote << "Solution found; Submitting to" << p_active->host << "...";
cnote << " Nonce:" << "0x"+solution.nonce.hex();
cnote << " Mixhash:" << "0x" + solution.mixHash.hex();
cnote << " Header-hash:" << "0x" + m_current.headerHash.hex();
cnote << " Seedhash:" << "0x" + m_current.seedHash.hex();
cnote << " Target: " << "0x" + h256(m_current.boundary).hex();
cnote << " Ethash: " << "0x" + h256(EthashAux::eval(m_current.seedHash, m_current.headerHash, solution.nonce).value).hex();
//cnote << " Mixhash:" << "0x" + solution.mixHash.hex();
//cnote << " Header-hash:" << "0x" + m_current.headerHash.hex();
//cnote << " Seedhash:" << "0x" + m_current.seedHash.hex();
//cnote << " Target: " << "0x" + h256(m_current.boundary).hex();
//cnote << " Ethash: " << "0x" + h256(EthashAux::eval(m_current.seedHash, m_current.headerHash, solution.nonce).value).hex();
if (EthashAux::eval(m_current.seedHash, m_current.headerHash, solution.nonce).value < m_current.boundary)
{
string json = "{\"id\": 4, \"method\": \"mining.submit\", \"params\": [\"" + p_active->user + "\",\"" + m_job + "\",\"0x" + solution.nonce.hex() + "\",\"0x" + m_current.headerHash.hex() + "\",\"0x" + solution.mixHash.hex() + "\"]}\n";
std::ostream os(&m_requestBuffer);
os << json;
x_current.unlock();
async_write(m_socket, m_requestBuffer,
boost::bind(&EthStratumClient::handleResponse, this,
boost::asio::placeholders::error));
return true;
}
else {
x_current.unlock();
cwarn << "FAILURE: GPU gave incorrect result!";
p_farm->rejectedSolution();
}
return false;
}

3
libstratum/EthStratumClient.h

@ -67,11 +67,12 @@ private:
int m_maxRetries;
int m_worktimeout = 60;
boost::mutex m_mtx;
boost::mutex x_pending;
int m_pending;
string m_response;
GenericFarm<EthashProofOfWork> * p_farm;
boost::mutex x_current;
EthashProofOfWork::WorkPackage m_current;
string m_job;
EthashAux::FullType m_dag;

Loading…
Cancel
Save