From 4efa648c4cacba1311523e50acc7778d0f974467 Mon Sep 17 00:00:00 2001 From: R4SAS Date: Thu, 6 Jun 2019 22:17:09 +0300 Subject: [PATCH] 2.3.1, separate gostd and gostcoin algos --- Makefile.am | 6 +++++- README.txt | 22 +++++++++++++++++++++- algos.h | 4 ++++ api.cpp | 7 ++++--- ccminer.cpp | 24 ++++++++++++++++++------ compat/ccminer-config.h | 2 +- configure.ac | 2 +- miner.h | 2 +- res/ccminer.rc | 16 ++++++++-------- util.cpp | 33 +++++++++++++-------------------- 10 files changed, 76 insertions(+), 42 deletions(-) diff --git a/Makefile.am b/Makefile.am index 5228789..6af46ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,9 +38,13 @@ ccminer_LDFLAGS = $(PTHREAD_FLAGS) @CUDA_LDFLAGS@ ccminer_LDADD = @LIBCURL@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@ @CUDA_LIBS@ @OPENMP_CFLAGS@ @LIBS@ $(nvml_libs) ccminer_CPPFLAGS = @LIBCURL_CPPFLAGS@ @OPENMP_CFLAGS@ $(CPPFLAGS) $(PTHREAD_FLAGS) -fno-strict-aliasing $(JANSSON_INCLUDES) $(DEF_INCLUDES) $(nvml_defs) -nvcc_ARCH = -gencode=arch=compute_50,code=\"sm_50,compute_50\" +nvcc_ARCH := +#nvcc_ARCH += -gencode=arch=compute_75,code=\"sm_75,compute_75\" # CUDA 10 req. +#nvcc_ARCH += -gencode=arch=compute_70,code=\"sm_70,compute_70\" # CUDA 9.1 +#nvcc_ARCH += -gencode=arch=compute_61,code=\"sm_61,compute_61\" # CUDA 8 #nvcc_ARCH += -gencode=arch=compute_52,code=\"sm_52,compute_52\" +nvcc_ARCH += -gencode=arch=compute_50,code=\"sm_50,compute_50\" #nvcc_ARCH += -gencode=arch=compute_35,code=\"sm_35,compute_35\" #nvcc_ARCH += -gencode=arch=compute_30,code=\"sm_30,compute_30\" #nvcc_ARCH += -gencode=arch=compute_20,code=\"sm_21,compute_20\" diff --git a/README.txt b/README.txt index 327ce31..502052e 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ -ccminer 2.2.4 (Jan. 2018) "lyra2v2 and keccak improvements" +ccminer 2.3.1 (Jan. 2018) "lyra2v2 and keccak improvements" --------------------------------------------------------------- *************************************************************** @@ -277,6 +277,26 @@ so we can more efficiently implement new algorithms using the latest hardware features. >>> RELEASE HISTORY <<< + Jan. 30th 2019 v2.3.1 + Handle Lyra2v3 algo + Handle sha256q algo + Handle exosis algo + Handle blake2b standard algo + + June 23th 2018 v2.3 + Handle phi2 header variation for smart contracts + Handle monero, stellite, graft and cryptolight variants + Handle SonoA algo + + June 10th 2018 v2.2.6 + New phi2 algo for LUX + New allium algo for Garlic + + Apr. 02nd 2018 v2.2.5 + New x16r algo for Raven + New x16s algo for Pigeon and Eden + New x12 algo for Galaxycash + Equihash (SIMT) sync issues for the Volta generation Jan. 04th 2017 v2.2.4 Improve lyra2v2 Higher keccak default intensity diff --git a/algos.h b/algos.h index 3f6a5c1..54a7cb6 100644 --- a/algos.h +++ b/algos.h @@ -6,6 +6,7 @@ enum sha_algos { ALGO_GOSTD = 0, + ALGO_GOSTCOIN, ALGO_AUTO, ALGO_COUNT }; @@ -14,6 +15,7 @@ extern volatile enum sha_algos opt_algo; static const char *algo_names[] = { "gostd", + "gostcoin", "auto", /* reserved for multi algo */ "" }; @@ -35,6 +37,8 @@ static inline int algo_to_int(char* arg) i = ALGO_AUTO; else if (!strcasecmp("gost", arg)) i = ALGO_GOSTD; + else if (!strcasecmp("gostcoin", arg)) + i = ALGO_GOSTCOIN; else i = -1; } diff --git a/api.cpp b/api.cpp index 74ec4a1..b7832e3 100644 --- a/api.cpp +++ b/api.cpp @@ -250,7 +250,7 @@ static char *getpoolnfo(char *params) static void gpuhwinfos(int gpu_id) { - char buf[256]; + char buf[512]; char pstate[8]; char* card; struct cgpu_info *cgpu = NULL; @@ -1245,7 +1245,7 @@ static void api() char *wskey = NULL; n = recv(c, &buf[0], SOCK_REC_BUFSZ, 0); - fail = SOCKETFAIL(n); + fail = SOCKETFAIL(n) || n < 0; if (fail) buf[0] = '\0'; else if (n > 0 && buf[n-1] == '\n') { @@ -1254,7 +1254,8 @@ static void api() if (n > 0 && buf[n-1] == '\r') buf[n-1] = '\0'; } - buf[n] = '\0'; + else + buf[n] = '\0'; //if (opt_debug && opt_protocol && n > 0) // applog(LOG_DEBUG, "API: recv command: (%d) '%s'+char(%x)", n, buf, buf[n-1]); diff --git a/ccminer.cpp b/ccminer.cpp index 309201e..80586fa 100644 --- a/ccminer.cpp +++ b/ccminer.cpp @@ -231,7 +231,8 @@ static char const usage[] = "\ Usage: " PROGRAM_NAME " [OPTIONS]\n\ Options:\n\ -a, --algo=ALGO specify the hash algorithm to use\n\ - gostd GOSTcoin\n\ + gostd Double GOST R 34.11\n\ + gostcoin GOSTcoin\n\ -d, --devices Comma separated list of CUDA devices to use.\n\ Device IDs start counting from 0! Alternatively takes\n\ string names of your cards like gtx780ti or gt640#2\n\ @@ -1297,13 +1298,23 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work) work->pooln = sctx->pooln; /* Generate merkle root */ - gostd(merkle_root, sctx->job.coinbase, (int)sctx->job.coinbase_size); + switch (opt_algo) { + case ALGO_GOSTCOIN: + gostd(merkle_root, sctx->job.coinbase, (int)sctx->job.coinbase_size); + break; + default: + sha256d(merkle_root, sctx->job.coinbase, (int)sctx->job.coinbase_size); + } for (i = 0; i < sctx->job.merkle_count; i++) { memcpy(merkle_root + 32, sctx->job.merkle[i], 32); - //GOSTCoin - memcpy(merkle_root + 32, merkle_root, 32); - gostd(merkle_root, merkle_root, 64); + + if (opt_algo == ALGO_GOSTCOIN) + { + memcpy(merkle_root + 32, merkle_root, 32); + gostd(merkle_root, merkle_root, 64); + } else + sha256d(merkle_root, merkle_root, 64); } /* Increment extranonce2 */ @@ -1736,7 +1747,7 @@ static void *miner_thread(void *userdata) max64 *= (uint32_t)thr_hashrates[thr_id]; /* on start, max64 should not be 0, - * before hashrate is computed */ + * before hashrate is computed */ if (max64 < minmax) { minmax = 0x400000; max64 = max(minmax-1, max64); @@ -2344,6 +2355,7 @@ void parse_arg(int key, char *arg) if (v < 1 || v > 65535) // sanity check show_usage_and_exit(1); opt_api_mcast_port = v; + break; case 'B': opt_background = true; break; diff --git a/compat/ccminer-config.h b/compat/ccminer-config.h index 932effb..92f2900 100644 --- a/compat/ccminer-config.h +++ b/compat/ccminer-config.h @@ -164,7 +164,7 @@ #define PACKAGE_URL "https://github.com/GOSTSec/ccminer-gostd-lite" /* Define to the version of this package. */ -#define PACKAGE_VERSION "2.2.4-gostd-lite" +#define PACKAGE_VERSION "2.3.1-gostd-lite" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be diff --git a/configure.ac b/configure.ac index d9b614a..f67344e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([ccminer], [2.2.4-gostd-lite], [], [ccminer], [https://github.com/GOSTSec/ccminer-gostd-lite]) +AC_INIT([ccminer], [2.3.1-gostd-lite], [], [ccminer], [https://github.com/GOSTSec/ccminer-gostd-lite]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/miner.h b/miner.h index 7b078b3..8c8ff62 100644 --- a/miner.h +++ b/miner.h @@ -542,7 +542,7 @@ struct stratum_job { unsigned char version[4]; unsigned char nbits[4]; unsigned char ntime[4]; - unsigned char claim[32]; // lbry + unsigned char extra[64]; bool clean; unsigned char nreward[2]; uint32_t height; diff --git a/res/ccminer.rc b/res/ccminer.rc index 832e7be..9313df9 100644 --- a/res/ccminer.rc +++ b/res/ccminer.rc @@ -13,7 +13,7 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// Anglais (États-Unis) resources +// English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US @@ -60,8 +60,8 @@ IDI_ICON1 ICON "ccminer.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,2,4,0 - PRODUCTVERSION 2,2,4,0 + FILEVERSION 2,3,1,0 + PRODUCTVERSION 2,3,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x21L @@ -76,10 +76,10 @@ BEGIN BEGIN BLOCK "040904e4" BEGIN - VALUE "FileVersion", "2.2.4" - VALUE "LegalCopyright", "Copyright (C) 2018" - VALUE "ProductName", "ccminer" - VALUE "ProductVersion", "2.2.4" + VALUE "FileVersion", "2.3.1" + VALUE "LegalCopyright", "Copyright (C) 2019" + VALUE "ProductName", "ccminer-gostd-lite" + VALUE "ProductVersion", "2.3.1" END END BLOCK "VarFileInfo" @@ -88,7 +88,7 @@ BEGIN END END -#endif // Anglais (États-Unis) resources +#endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/util.cpp b/util.cpp index 5ed2fa8..2b1c8de 100644 --- a/util.cpp +++ b/util.cpp @@ -614,7 +614,7 @@ err_out: json_t *json_rpc_call_pool(CURL *curl, struct pool_infos *pool, const char *req, bool longpoll_scan, bool longpoll, int *curl_err) { - char userpass[512]; + char userpass[768]; // todo, malloc and store that in pool array snprintf(userpass, sizeof(userpass), "%s%c%s", pool->user, strlen(pool->pass)?':':'\0', pool->pass); @@ -625,7 +625,7 @@ json_t *json_rpc_call_pool(CURL *curl, struct pool_infos *pool, const char *req, /* called only from longpoll thread, we have the lp_url */ json_t *json_rpc_longpoll(CURL *curl, char *lp_url, struct pool_infos *pool, const char *req, int *curl_err) { - char userpass[512]; + char userpass[768]; snprintf(userpass, sizeof(userpass), "%s%c%s", pool->user, strlen(pool->pass)?':':'\0', pool->pass); @@ -1346,8 +1346,12 @@ bool stratum_authorize(struct stratum_ctx *sctx, const char *user, const char *p err_val = json_object_get(val, "error"); if (!res_val || json_is_false(res_val) || - (err_val && !json_is_null(err_val))) { - applog(LOG_ERR, "Stratum authentication failed"); + (err_val && !json_is_null(err_val))) { + if (err_val && json_is_array(err_val)) { + const char* reason = json_string_value(json_array_get(err_val, 1)); + applog(LOG_ERR, "Stratum authentication failed (%s)", reason); + } + else applog(LOG_ERR, "Stratum authentication failed"); goto out; } @@ -1431,7 +1435,7 @@ static uint32_t getblocheight(struct stratum_ctx *sctx) static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) { const char *job_id, *prevhash, *coinb1, *coinb2, *version, *nbits, *stime; - const char *claim = NULL, *nreward = NULL; + const char *extradata = NULL, *nreward = NULL; size_t coinb1_size, coinb2_size; bool clean, ret = false; int merkle_count, i, p=0; @@ -1439,19 +1443,9 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) uchar **merkle = NULL; // uchar(*merkle_tree)[32] = { 0 }; int ntime; - char algo[64] = { 0 }; - get_currentalgo(algo, sizeof(algo)); - bool has_claim = !strcasecmp(algo, "lbry"); job_id = json_string_value(json_array_get(params, p++)); prevhash = json_string_value(json_array_get(params, p++)); - if (has_claim) { - claim = json_string_value(json_array_get(params, p++)); - if (!claim || strlen(claim) != 64) { - applog(LOG_ERR, "Stratum notify: invalid claim parameter"); - goto out; - } - } coinb1 = json_string_value(json_array_get(params, p++)); coinb2 = json_string_value(json_array_get(params, p++)); merkle_arr = json_array_get(params, p++); @@ -1465,8 +1459,8 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) nreward = json_string_value(json_array_get(params, p++)); if (!job_id || !prevhash || !coinb1 || !coinb2 || !version || !nbits || !stime || - strlen(prevhash) != 64 || strlen(version) != 8 || - strlen(nbits) != 8 || strlen(stime) != 8) { + strlen(prevhash) != 64 || strlen(version) != 8 || + strlen(nbits) != 8 || strlen(stime) != 8) { applog(LOG_ERR, "Stratum notify: invalid parameters"); goto out; } @@ -1500,7 +1494,7 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) coinb1_size = strlen(coinb1) / 2; coinb2_size = strlen(coinb2) / 2; sctx->job.coinbase_size = coinb1_size + sctx->xnonce1_size + - sctx->xnonce2_size + coinb2_size; + sctx->xnonce2_size + coinb2_size; sctx->job.coinbase = (uchar*) realloc(sctx->job.coinbase, sctx->job.coinbase_size); sctx->job.xnonce2 = sctx->job.coinbase + coinb1_size + sctx->xnonce1_size; @@ -1514,7 +1508,6 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) free(sctx->job.job_id); sctx->job.job_id = strdup(job_id); hex2bin(sctx->job.prevhash, prevhash, 32); - if (has_claim) hex2bin(sctx->job.claim, claim, 32); sctx->job.height = getblocheight(sctx); @@ -2138,7 +2131,7 @@ void print_hash_tests(void) printf(CL_WHT "CPU HASH ON EMPTY BUFFER RESULTS:" CL_N "\n"); gostd_hash(&hash[0], &buf[0]); - printpfx("gost", hash); + printpfx("gostd", hash); printf("\n");