Skip to content

Commit

Permalink
2.3.1, separate gostd and gostcoin algos
Browse files Browse the repository at this point in the history
  • Loading branch information
r4sas committed Jun 6, 2019
1 parent b8a6425 commit 4efa648
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 42 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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\"
Expand Down
22 changes: 21 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

ccminer 2.2.4 (Jan. 2018) "lyra2v2 and keccak improvements"
ccminer 2.3.1 (Jan. 2018) "lyra2v2 and keccak improvements"
---------------------------------------------------------------

***************************************************************
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions algos.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

enum sha_algos {
ALGO_GOSTD = 0,
ALGO_GOSTCOIN,
ALGO_AUTO,
ALGO_COUNT
};
Expand All @@ -14,6 +15,7 @@ extern volatile enum sha_algos opt_algo;

static const char *algo_names[] = {
"gostd",
"gostcoin",
"auto", /* reserved for multi algo */
""
};
Expand All @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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') {
Expand All @@ -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]);
Expand Down
24 changes: 18 additions & 6 deletions ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion compat/ccminer-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions res/ccminer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -88,7 +88,7 @@ BEGIN
END
END

#endif // Anglais (�tats-Unis) resources
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////


Expand Down
33 changes: 13 additions & 20 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
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);
Expand All @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1431,27 +1435,17 @@ 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;
json_t *merkle_arr;
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++);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 4efa648

Please sign in to comment.