diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 9e733f7e..4611be1f 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -65,13 +65,16 @@ If not what makes it happen or not happen? Change Log ---------- -v3.13.2-segwit-test +v3.14.0 -Added support for SegWit. +Changes to solo mining: + - segwit is supported by getblocktemplate, + - longpolling is not working and is disabled, + - Periodic Report log is output, + - New Block log includes TTF estimates, + - Stratum thread no longer created when using getwork or GBT. -This is a test release, it may contain bugs and additional debug logging. -Solo miners are invited to test it and report their results. Other users -may want to wait for the next general release before upgrading. +Fixed BUG log mining sha256d. v3.13.1.1 diff --git a/algo/sha/sha2.c b/algo/sha/sha2.c index 30feeaf2..2b0c5706 100644 --- a/algo/sha/sha2.c +++ b/algo/sha/sha2.c @@ -479,8 +479,8 @@ static inline void sha256d_ms(uint32_t *hash, uint32_t *W, void sha256d_ms_4way(uint32_t *hash, uint32_t *data, const uint32_t *midstate, const uint32_t *prehash); -static inline int scanhash_sha256d_4way(int thr_id, struct work *work, - uint32_t max_nonce, uint64_t *hashes_done) +static inline int scanhash_sha256d_4way( struct work *work, + uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) { uint32_t *pdata = work->data; uint32_t *ptarget = work->target; @@ -492,6 +492,7 @@ static inline int scanhash_sha256d_4way(int thr_id, struct work *work, uint32_t n = pdata[19] - 1; const uint32_t first_nonce = pdata[19]; const uint32_t Htarg = ptarget[7]; + int thr_id = mythr->id; int i, j; memcpy(data, pdata + 16, 64); @@ -521,10 +522,8 @@ static inline int scanhash_sha256d_4way(int thr_id, struct work *work, if (swab32(hash[4 * 7 + i]) <= Htarg) { pdata[19] = data[4 * 3 + i]; sha256d_80_swap(hash, pdata); - if (fulltest(hash, ptarget)) { - *hashes_done = n - first_nonce + 1; - return 1; - } + if ( fulltest( hash, ptarget ) && !opt_benchmark ) + submit_solution( work, hash, mythr ); } } } while (n < max_nonce && !work_restart[thr_id].restart); @@ -541,8 +540,8 @@ static inline int scanhash_sha256d_4way(int thr_id, struct work *work, void sha256d_ms_8way(uint32_t *hash, uint32_t *data, const uint32_t *midstate, const uint32_t *prehash); -static inline int scanhash_sha256d_8way(int thr_id, struct work *work, - uint32_t max_nonce, uint64_t *hashes_done) +static inline int scanhash_sha256d_8way( struct work *work, + uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) { uint32_t *pdata = work->data; uint32_t *ptarget = work->target; @@ -554,6 +553,7 @@ static inline int scanhash_sha256d_8way(int thr_id, struct work *work, uint32_t n = pdata[19] - 1; const uint32_t first_nonce = pdata[19]; const uint32_t Htarg = ptarget[7]; + int thr_id = mythr->id; int i, j; memcpy(data, pdata + 16, 64); @@ -583,10 +583,8 @@ static inline int scanhash_sha256d_8way(int thr_id, struct work *work, if (swab32(hash[8 * 7 + i]) <= Htarg) { pdata[19] = data[8 * 3 + i]; sha256d_80_swap(hash, pdata); - if (fulltest(hash, ptarget)) { - *hashes_done = n - first_nonce + 1; - return 1; - } + if ( fulltest( hash, ptarget ) && !opt_benchmark ) + submit_solution( work, hash, mythr ); } } } while (n < max_nonce && !work_restart[thr_id].restart); @@ -614,13 +612,11 @@ int scanhash_sha256d( struct work *work, #ifdef HAVE_SHA256_8WAY if (sha256_use_8way()) - return scanhash_sha256d_8way(thr_id, work, - max_nonce, hashes_done); + return scanhash_sha256d_8way( work, max_nonce, hashes_done, mythr ); #endif #ifdef HAVE_SHA256_4WAY if (sha256_use_4way()) - return scanhash_sha256d_4way(thr_id, work, - max_nonce, hashes_done); + return scanhash_sha256d_4way( work, max_nonce, hashes_done, mythr ); #endif memcpy(data, pdata + 16, 64); @@ -657,7 +653,7 @@ int scanhash_SHA256d( struct work *work, const uint32_t max_nonce, uint32_t n = pdata[19] - 1; const uint32_t first_nonce = pdata[19]; const uint32_t Htarg = ptarget[7]; - int thr_id = mythr->id; // thr_id arg is deprecated + int thr_id = mythr->id; memcpy( data, pdata, 80 ); diff --git a/configure b/configure index 978402f9..26cbd429 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.13.2-segwit-test. +# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.14.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='cpuminer-opt' PACKAGE_TARNAME='cpuminer-opt' -PACKAGE_VERSION='3.13.2-segwit-test' -PACKAGE_STRING='cpuminer-opt 3.13.2-segwit-test' +PACKAGE_VERSION='3.14.0' +PACKAGE_STRING='cpuminer-opt 3.14.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1332,7 +1332,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures cpuminer-opt 3.13.2-segwit-test to adapt to many kinds of systems. +\`configure' configures cpuminer-opt 3.14.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1404,7 +1404,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of cpuminer-opt 3.13.2-segwit-test:";; + short | recursive ) echo "Configuration of cpuminer-opt 3.14.0:";; esac cat <<\_ACEOF @@ -1509,7 +1509,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -cpuminer-opt configure 3.13.2-segwit-test +cpuminer-opt configure 3.14.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2012,7 +2012,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by cpuminer-opt $as_me 3.13.2-segwit-test, which was +It was created by cpuminer-opt $as_me 3.14.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2993,7 +2993,7 @@ fi # Define the identity of the package. PACKAGE='cpuminer-opt' - VERSION='3.13.2-segwit-test' + VERSION='3.14.0' cat >>confdefs.h <<_ACEOF @@ -6690,7 +6690,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by cpuminer-opt $as_me 3.13.2-segwit-test, which was +This file was extended by cpuminer-opt $as_me 3.14.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6756,7 +6756,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -cpuminer-opt config.status 3.13.2-segwit-test +cpuminer-opt config.status 3.14.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index e05eb159..bad99665 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([cpuminer-opt], [3.13.2-segwit-test]) +AC_INIT([cpuminer-opt], [3.14.0]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpu-miner.c b/cpu-miner.c index c82eb2d9..d558be8b 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -88,7 +88,7 @@ bool opt_protocol = false; bool opt_benchmark = false; bool opt_redirect = true; bool opt_extranonce = true; -bool want_longpoll = true; +bool want_longpoll = false; bool have_longpoll = false; bool have_gbt = true; bool allow_getwork = true; @@ -494,7 +494,7 @@ static bool get_mininginfo( CURL *curl, struct work *work ) if ( json_is_object( key ) ) key = json_object_get( key, "proof-of-work" ); if ( json_is_real( key ) ) - net_diff = json_real_value( key ); + net_diff = work->targetdiff = json_real_value( key ); } key = json_object_get( res, "networkhashps" ); @@ -565,21 +565,21 @@ static bool gbt_work_decode( const json_t *val, struct work *work ) // Segwit BEGIN bool segwit = false; - tmp = json_object_get(val, "rules"); - if (tmp && json_is_array(tmp)) { - n = json_array_size(tmp); - for (i = 0; i < n; i++) { - const char *s = json_string_value(json_array_get(tmp, i)); - if (!s) + tmp = json_object_get( val, "rules" ); + if ( tmp && json_is_array( tmp ) ) + { + n = json_array_size( tmp ); + for ( i = 0; i < n; i++ ) + { + const char *s = json_string_value( json_array_get( tmp, i ) ); + if ( !s ) continue; - if (!strcmp(s, "segwit") || !strcmp(s, "!segwit")) + if ( !strcmp( s, "segwit" ) || !strcmp( s, "!segwit" ) ) segwit = true; } } // Segwit END -if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled"); - tmp = json_object_get( val, "mutable" ); if ( tmp && json_is_array( tmp ) ) { @@ -612,9 +612,6 @@ if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled"); goto out; } version = (uint32_t) json_integer_value( tmp ); - - applog( LOG_INFO, "SEGWIT test, block version= %d", version ); - // yescryptr8g uses block version 5 and sapling. if ( opt_sapling ) work->sapling = true; @@ -754,10 +751,8 @@ if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled"); cbtx_size += (int) pk_script_size; // Segwit BEGIN - if (segwit) { - -applog( LOG_INFO, "SEGWIT test: add segwit to tx"); - + if ( segwit ) + { unsigned char (*wtree)[32] = calloc(tx_count + 2, 32); memset(cbtx+cbtx_size, 0, 8); /* value */ cbtx_size += 8; @@ -768,28 +763,32 @@ applog( LOG_INFO, "SEGWIT test: add segwit to tx"); cbtx[cbtx_size++] = 0x21; cbtx[cbtx_size++] = 0xa9; cbtx[cbtx_size++] = 0xed; - for (i = 0; i < tx_count; i++) { - const json_t *tx = json_array_get(txa, i); - const json_t *hash = json_object_get(tx, "hash"); - if (!hash || !hex2bin(wtree[1+i], json_string_value(hash), 32)) { + for ( i = 0; i < tx_count; i++ ) + { + const json_t *tx = json_array_get( txa, i ); + const json_t *hash = json_object_get(tx, "hash" ); + if ( !hash || !hex2bin( wtree[1+i], + json_string_value( hash ), 32 ) ) + { applog(LOG_ERR, "JSON invalid transaction hash"); free(wtree); goto out; } - memrev(wtree[1+i], 32); + memrev( wtree[1+i], 32 ); } n = tx_count + 1; - while (n > 1) { - if (n % 2) - memcpy(wtree[n], wtree[n-1], 32); - n = (n + 1) / 2; - for (i = 0; i < n; i++) - sha256d(wtree[i], wtree[2*i], 64); + while ( n > 1 ) + { + if ( n % 2 ) + memcpy( wtree[n], wtree[n-1], 32 ); + n = ( n + 1 ) / 2; + for ( i = 0; i < n; i++ ) + sha256d( wtree[i], wtree[2*i], 64 ); } - memset(wtree[1], 0, 32); /* witness reserved value = 0 */ - sha256d(cbtx+cbtx_size, wtree[0], 64); + memset( wtree[1], 0, 32 ); /* witness reserved value = 0 */ + sha256d( cbtx+cbtx_size, wtree[0], 64 ); cbtx_size += 32; - free(wtree); + free( wtree ); } // Segwit END @@ -860,8 +859,8 @@ applog( LOG_INFO, "SEGWIT test: add segwit to tx"); bin2hex( work->txs + 2*n, cbtx, cbtx_size ); /* generate merkle root */ - merkle_tree = (uchar(*)[32]) calloc(((1 + tx_count + 1) & ~1), 32); - sha256d(merkle_tree[0], cbtx, cbtx_size); + merkle_tree = (uchar(*)[32]) calloc( ( (1 + tx_count + 1) & ~1 ), 32 ); + sha256d( merkle_tree[0], cbtx, cbtx_size ); for ( i = 0; i < tx_count; i++ ) { tmp = json_array_get( txa, i ); @@ -871,13 +870,13 @@ applog( LOG_INFO, "SEGWIT test: add segwit to tx"); // Segwit BEGIN if ( segwit ) { - const char *txid = json_string_value(json_object_get(tmp, "txid")); - if (!txid || !hex2bin(merkle_tree[1 + i], txid, 32)) + const char *txid = json_string_value( json_object_get( tmp, "txid" ) ); + if ( !txid || !hex2bin( merkle_tree[1 + i], txid, 32 ) ) { applog(LOG_ERR, "JSON invalid transaction txid"); goto out; } - memrev(merkle_tree[1 + i], 32); + memrev( merkle_tree[1 + i], 32 ); } else { @@ -1567,25 +1566,27 @@ static bool get_upstream_work( CURL *curl, struct work *work ) if ( rc ) { - if ( opt_protocol ) + json_decref( val ); + + get_mininginfo( curl, work ); + report_summary_log( false ); + + if ( opt_protocol | opt_debug ) { timeval_subtract( &diff, &tv_end, &tv_start ); - applog( LOG_DEBUG, "got new work in %.2f ms", + applog( LOG_INFO, "%s new work received in %.2f ms", + ( have_gbt ? "GBT" : "GetWork" ), ( 1000.0 * diff.tv_sec ) + ( 0.001 * diff.tv_usec ) ); } - json_decref( val ); - // store work height in solo - get_mininginfo(curl, work); - if ( work->height > last_block_height ) { last_block_height = work->height; - applog( LOG_BLUE, "New Block %d, Net Diff %.5g, Target Diff %.5g, Ntime %08x", - work->height, net_diff, work->targetdiff, + applog( LOG_BLUE, "New Block %d, Net Diff %.5g, Ntime %08x", + work->height, net_diff, bswap_32( work->data[ algo_gate.ntime_index ] ) ); - if ( !opt_quiet && net_diff && net_hashrate ) + if ( !opt_quiet && net_diff && ( net_hashrate > 0. ) ) { double miner_hr = 0.; pthread_mutex_lock( &stats_lock ); @@ -1596,7 +1597,7 @@ static bool get_upstream_work( CURL *curl, struct work *work ) pthread_mutex_unlock( &stats_lock ); - if ( miner_hr ) + if ( miner_hr > 0. ) { double net_hr = net_hashrate; char net_hr_units[4] = {0}; @@ -1604,8 +1605,8 @@ static bool get_upstream_work( CURL *curl, struct work *work ) char net_ttf[32]; char miner_ttf[32]; - sprintf_et( net_ttf, ( work->targetdiff * exp32 ) / net_hr ); - sprintf_et( miner_ttf, ( work->targetdiff * exp32 ) / miner_hr ); + sprintf_et( net_ttf, ( net_diff * exp32 ) / net_hr ); + sprintf_et( miner_ttf, ( net_diff * exp32 ) / miner_hr ); scale_hash_for_display ( &miner_hr, miner_hr_units ); scale_hash_for_display ( &net_hr, net_hr_units ); applog2( LOG_INFO, @@ -3316,15 +3317,8 @@ static void show_credits() { printf("\n ********** "PACKAGE_NAME" "PACKAGE_VERSION" *********** \n"); printf(" A CPU miner with multi algo support and optimized for CPUs\n"); - printf(" with AVX512, SHA and VAES extensions.\n"); + printf(" with AVX512, SHA and VAES extensions by JayDDee.\n"); printf(" BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT\n\n"); - -printf("/nWarning: this is a test release, it may contain bugs and aditional\n"); -printf("debug log output. Users who solo mine using getwork or GBT are invited\n\n"); -printf("to use it for testing purposes. Please report any regressions. Other\n"); -printf("users may prefer to continue using the latest general release.\n\n"); - - } bool check_cpu_capability ()