From 57809c56b5ddd8dea8c3fa4657ce281e7adffe0c Mon Sep 17 00:00:00 2001 From: "Dr.Elias" Date: Fri, 19 Nov 2021 04:48:45 +0300 Subject: [PATCH 1/4] instant hashes computed fix --- crypto/util/cuda/credits.cu | 4 ++-- crypto/util/opencl/sha256.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crypto/util/cuda/credits.cu b/crypto/util/cuda/credits.cu index ca0fb900..7e9e0364 100644 --- a/crypto/util/cuda/credits.cu +++ b/crypto/util/cuda/credits.cu @@ -49,6 +49,7 @@ extern "C" int scanhash_credits(int gpu_id, int cpu_id, ton::HDataEnv H, const t expired = (uint32_t)td::Clocks::system() + 900; td::Timestamp instant_start_at = td::Timestamp::now(); HashResult foundNonce = bitcredit_cpu_hash(gpu_id, cpu_id, options.gpu_threads, throughput, i, expired); + *options.instant_passed = td::Timestamp::now().at() - instant_start_at.at(); if (foundNonce.nonce != UINT64_MAX && foundNonce.vcpu != UINT64_MAX) { pdata[0] = foundNonce.nonce; pdata[1] = foundNonce.vcpu; @@ -57,11 +58,10 @@ extern "C" int scanhash_credits(int gpu_id, int cpu_id, ton::HDataEnv H, const t *options.hashes_computed += foundNonce.nonce * foundNonce.vcpu; } if (options.instant_hashes_computed) { - *options.instant_hashes_computed += foundNonce.nonce * foundNonce.vcpu; + *options.instant_hashes_computed = foundNonce.nonce * foundNonce.vcpu; } return 1; } - *options.instant_passed = td::Timestamp::now().at() - instant_start_at.at(); i += throughput; if (options.hashes_computed) { *options.hashes_computed += throughput; diff --git a/crypto/util/opencl/sha256.cpp b/crypto/util/opencl/sha256.cpp index 6d5753bd..ac89005b 100644 --- a/crypto/util/opencl/sha256.cpp +++ b/crypto/util/opencl/sha256.cpp @@ -44,6 +44,7 @@ td::optional SHA256::run(ton::HDataEnv H, unsigned char *rdata, con expired = (uint32_t)td::Clocks::system() + 900; td::Timestamp instant_start_at = td::Timestamp::now(); HashResult foundNonce = opencl.scan_hash(cpu_id, options.gpu_threads, throughput, i, expired); + *options.instant_passed = td::Timestamp::now().at() - instant_start_at.at(); if (foundNonce.nonce != UINT64_MAX && foundNonce.vcpu != UINT64_MAX) { if (options.hashes_computed) { *options.hashes_computed += foundNonce.nonce * foundNonce.vcpu; @@ -57,7 +58,6 @@ td::optional SHA256::run(ton::HDataEnv H, unsigned char *rdata, con return result; } } - *options.instant_passed = td::Timestamp::now().at() - instant_start_at.at(); i += throughput; if (options.hashes_computed) { *options.hashes_computed += throughput; From c182c77f5ccbc1e5998030019bd930d3ede8f9ec Mon Sep 17 00:00:00 2001 From: "Dr.Elias" Date: Fri, 19 Nov 2021 11:33:40 +0300 Subject: [PATCH 2/4] hashes computed fix --- tonlib/tonlib/tonlib-cli.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tonlib/tonlib/tonlib-cli.cpp b/tonlib/tonlib/tonlib-cli.cpp index 62e51b9e..e26355ab 100644 --- a/tonlib/tonlib/tonlib-cli.cpp +++ b/tonlib/tonlib/tonlib-cli.cpp @@ -685,6 +685,7 @@ class TonlibCli : public td::actor::Actor { if (miner_options_ && threads_.empty() && need_run_miners_) { LOG(INFO) << "pminer: start workers"; + hashes_computed_.store(0); need_run_miners_ = false; miner_options_copy_ = miner_options_.value(); miner_options_copy_.hashes_computed = &hashes_computed_; From 013165399c834c74bfbc92b8e9dc11279b55f37e Mon Sep 17 00:00:00 2001 From: "Dr.Elias" Date: Fri, 19 Nov 2021 11:35:08 +0300 Subject: [PATCH 3/4] overclock detected --- crypto/util/Miner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto/util/Miner.cpp b/crypto/util/Miner.cpp index e9caa3c8..88d7d7df 100644 --- a/crypto/util/Miner.cpp +++ b/crypto/util/Miner.cpp @@ -194,6 +194,8 @@ td::optional build_mine_result(int cpu_id, ton::HDataEnv H, const t if (memcmp(hash.data(), options.complexity.data(), 32) < 0) { LOG(ERROR) << "FOUND! GPU ID: " << options.gpu_id << ", nonce=" << nonce << ", expired=" << expired; return H.body.as_slice().str(); + } else { + LOG(ERROR) << "OVERCLOCK DETECTED! GPU ID: " << options.gpu_id; } return {}; } From 10660f493be489c47968710dc49deb36f0f4df2f Mon Sep 17 00:00:00 2001 From: "Dr.Elias" Date: Fri, 19 Nov 2021 11:38:31 +0300 Subject: [PATCH 4/4] Revert "cuda sm_11" --- crypto/CMakeLists.txt | 2 +- tonlib/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 7f9d8ed9..02d3c7b3 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -320,7 +320,7 @@ if(MINERCUDA) target_link_libraries(pow-miner-cuda-lib PUBLIC ton_crypto ton_block ${CUDA_LIBRARIES}) add_executable(pow-miner-cuda util/pow-miner.cpp) - target_compile_definitions(pow-miner-cuda PRIVATE MINERCUDA=${MINERCUDA} $<$:-gencode arch=compute_11,code=sm_11>) + target_compile_definitions(pow-miner-cuda PRIVATE MINERCUDA=${MINERCUDA}) target_link_libraries(pow-miner-cuda PRIVATE ton_crypto ton_block pow-miner-cuda-lib git) endif() diff --git a/tonlib/CMakeLists.txt b/tonlib/CMakeLists.txt index f320ed57..90cd8d9e 100644 --- a/tonlib/CMakeLists.txt +++ b/tonlib/CMakeLists.txt @@ -79,8 +79,7 @@ if(MINERCUDA) include_directories("${CUDA_INCLUDE_DIRS}") add_executable(tonlib-cuda-cli tonlib/tonlib-cli.cpp) - target_compile_definitions(tonlib-cuda-cli PRIVATE MINERCUDA=${MINERCUDA} $<$:-gencode arch=compute_11,code=sm_11>) - + target_compile_definitions(tonlib-cuda-cli PRIVATE MINERCUDA=${MINERCUDA}) target_link_libraries(tonlib-cuda-cli tonlib tdactor tdutils terminal pow-miner-cuda-lib git ${CUDA_LIBRARIES}) endif()