This commit is contained in:
Jay D Dee
2020-05-20 13:56:35 -04:00
parent 0e69756634
commit 9571f85d53
5 changed files with 83 additions and 90 deletions

View File

@@ -65,13 +65,16 @@ If not what makes it happen or not happen?
Change Log 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. Fixed BUG log mining sha256d.
Solo miners are invited to test it and report their results. Other users
may want to wait for the next general release before upgrading.
v3.13.1.1 v3.13.1.1

View File

@@ -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, void sha256d_ms_4way(uint32_t *hash, uint32_t *data,
const uint32_t *midstate, const uint32_t *prehash); const uint32_t *midstate, const uint32_t *prehash);
static inline int scanhash_sha256d_4way(int thr_id, struct work *work, static inline int scanhash_sha256d_4way( struct work *work,
uint32_t max_nonce, uint64_t *hashes_done) uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr )
{ {
uint32_t *pdata = work->data; uint32_t *pdata = work->data;
uint32_t *ptarget = work->target; 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; uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7]; const uint32_t Htarg = ptarget[7];
int thr_id = mythr->id;
int i, j; int i, j;
memcpy(data, pdata + 16, 64); 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) { if (swab32(hash[4 * 7 + i]) <= Htarg) {
pdata[19] = data[4 * 3 + i]; pdata[19] = data[4 * 3 + i];
sha256d_80_swap(hash, pdata); sha256d_80_swap(hash, pdata);
if (fulltest(hash, ptarget)) { if ( fulltest( hash, ptarget ) && !opt_benchmark )
*hashes_done = n - first_nonce + 1; submit_solution( work, hash, mythr );
return 1;
}
} }
} }
} while (n < max_nonce && !work_restart[thr_id].restart); } 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, void sha256d_ms_8way(uint32_t *hash, uint32_t *data,
const uint32_t *midstate, const uint32_t *prehash); const uint32_t *midstate, const uint32_t *prehash);
static inline int scanhash_sha256d_8way(int thr_id, struct work *work, static inline int scanhash_sha256d_8way( struct work *work,
uint32_t max_nonce, uint64_t *hashes_done) uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr )
{ {
uint32_t *pdata = work->data; uint32_t *pdata = work->data;
uint32_t *ptarget = work->target; 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; uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7]; const uint32_t Htarg = ptarget[7];
int thr_id = mythr->id;
int i, j; int i, j;
memcpy(data, pdata + 16, 64); 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) { if (swab32(hash[8 * 7 + i]) <= Htarg) {
pdata[19] = data[8 * 3 + i]; pdata[19] = data[8 * 3 + i];
sha256d_80_swap(hash, pdata); sha256d_80_swap(hash, pdata);
if (fulltest(hash, ptarget)) { if ( fulltest( hash, ptarget ) && !opt_benchmark )
*hashes_done = n - first_nonce + 1; submit_solution( work, hash, mythr );
return 1;
}
} }
} }
} while (n < max_nonce && !work_restart[thr_id].restart); } while (n < max_nonce && !work_restart[thr_id].restart);
@@ -614,13 +612,11 @@ int scanhash_sha256d( struct work *work,
#ifdef HAVE_SHA256_8WAY #ifdef HAVE_SHA256_8WAY
if (sha256_use_8way()) if (sha256_use_8way())
return scanhash_sha256d_8way(thr_id, work, return scanhash_sha256d_8way( work, max_nonce, hashes_done, mythr );
max_nonce, hashes_done);
#endif #endif
#ifdef HAVE_SHA256_4WAY #ifdef HAVE_SHA256_4WAY
if (sha256_use_4way()) if (sha256_use_4way())
return scanhash_sha256d_4way(thr_id, work, return scanhash_sha256d_4way( work, max_nonce, hashes_done, mythr );
max_nonce, hashes_done);
#endif #endif
memcpy(data, pdata + 16, 64); 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; uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19]; const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7]; 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 ); memcpy( data, pdata, 80 );

20
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # 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. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='cpuminer-opt' PACKAGE_NAME='cpuminer-opt'
PACKAGE_TARNAME='cpuminer-opt' PACKAGE_TARNAME='cpuminer-opt'
PACKAGE_VERSION='3.13.2-segwit-test' PACKAGE_VERSION='3.14.0'
PACKAGE_STRING='cpuminer-opt 3.13.2-segwit-test' PACKAGE_STRING='cpuminer-opt 3.14.0'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
PACKAGE_URL='' 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. # 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. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF 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]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1404,7 +1404,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in 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 esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1509,7 +1509,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
cpuminer-opt configure 3.13.2-segwit-test cpuminer-opt configure 3.14.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2012,7 +2012,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. 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 generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@@ -2993,7 +2993,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='cpuminer-opt' PACKAGE='cpuminer-opt'
VERSION='3.13.2-segwit-test' VERSION='3.14.0'
cat >>confdefs.h <<_ACEOF 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 # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" 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 generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -6756,7 +6756,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ 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, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@@ -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_PREREQ([2.59c])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM

View File

@@ -88,7 +88,7 @@ bool opt_protocol = false;
bool opt_benchmark = false; bool opt_benchmark = false;
bool opt_redirect = true; bool opt_redirect = true;
bool opt_extranonce = true; bool opt_extranonce = true;
bool want_longpoll = true; bool want_longpoll = false;
bool have_longpoll = false; bool have_longpoll = false;
bool have_gbt = true; bool have_gbt = true;
bool allow_getwork = true; bool allow_getwork = true;
@@ -494,7 +494,7 @@ static bool get_mininginfo( CURL *curl, struct work *work )
if ( json_is_object( key ) ) if ( json_is_object( key ) )
key = json_object_get( key, "proof-of-work" ); key = json_object_get( key, "proof-of-work" );
if ( json_is_real( key ) ) 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" ); key = json_object_get( res, "networkhashps" );
@@ -565,21 +565,21 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
// Segwit BEGIN // Segwit BEGIN
bool segwit = false; bool segwit = false;
tmp = json_object_get(val, "rules"); tmp = json_object_get( val, "rules" );
if (tmp && json_is_array(tmp)) { if ( tmp && json_is_array( tmp ) )
n = json_array_size(tmp); {
for (i = 0; i < n; i++) { n = json_array_size( tmp );
const char *s = json_string_value(json_array_get(tmp, i)); for ( i = 0; i < n; i++ )
if (!s) {
const char *s = json_string_value( json_array_get( tmp, i ) );
if ( !s )
continue; continue;
if (!strcmp(s, "segwit") || !strcmp(s, "!segwit")) if ( !strcmp( s, "segwit" ) || !strcmp( s, "!segwit" ) )
segwit = true; segwit = true;
} }
} }
// Segwit END // Segwit END
if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled");
tmp = json_object_get( val, "mutable" ); tmp = json_object_get( val, "mutable" );
if ( tmp && json_is_array( tmp ) ) if ( tmp && json_is_array( tmp ) )
{ {
@@ -612,9 +612,6 @@ if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled");
goto out; goto out;
} }
version = (uint32_t) json_integer_value( tmp ); version = (uint32_t) json_integer_value( tmp );
applog( LOG_INFO, "SEGWIT test, block version= %d", version );
// yescryptr8g uses block version 5 and sapling. // yescryptr8g uses block version 5 and sapling.
if ( opt_sapling ) if ( opt_sapling )
work->sapling = true; work->sapling = true;
@@ -754,10 +751,8 @@ if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled");
cbtx_size += (int) pk_script_size; cbtx_size += (int) pk_script_size;
// Segwit BEGIN // Segwit BEGIN
if (segwit) { if ( segwit )
{
applog( LOG_INFO, "SEGWIT test: add segwit to tx");
unsigned char (*wtree)[32] = calloc(tx_count + 2, 32); unsigned char (*wtree)[32] = calloc(tx_count + 2, 32);
memset(cbtx+cbtx_size, 0, 8); /* value */ memset(cbtx+cbtx_size, 0, 8); /* value */
cbtx_size += 8; cbtx_size += 8;
@@ -768,28 +763,32 @@ applog( LOG_INFO, "SEGWIT test: add segwit to tx");
cbtx[cbtx_size++] = 0x21; cbtx[cbtx_size++] = 0x21;
cbtx[cbtx_size++] = 0xa9; cbtx[cbtx_size++] = 0xa9;
cbtx[cbtx_size++] = 0xed; cbtx[cbtx_size++] = 0xed;
for (i = 0; i < tx_count; i++) { 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"); const json_t *tx = json_array_get( txa, i );
if (!hash || !hex2bin(wtree[1+i], json_string_value(hash), 32)) { 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"); applog(LOG_ERR, "JSON invalid transaction hash");
free(wtree); free(wtree);
goto out; goto out;
} }
memrev(wtree[1+i], 32); memrev( wtree[1+i], 32 );
} }
n = tx_count + 1; n = tx_count + 1;
while (n > 1) { while ( n > 1 )
if (n % 2) {
memcpy(wtree[n], wtree[n-1], 32); if ( n % 2 )
n = (n + 1) / 2; memcpy( wtree[n], wtree[n-1], 32 );
for (i = 0; i < n; i++) n = ( n + 1 ) / 2;
sha256d(wtree[i], wtree[2*i], 64); for ( i = 0; i < n; i++ )
sha256d( wtree[i], wtree[2*i], 64 );
} }
memset(wtree[1], 0, 32); /* witness reserved value = 0 */ memset( wtree[1], 0, 32 ); /* witness reserved value = 0 */
sha256d(cbtx+cbtx_size, wtree[0], 64); sha256d( cbtx+cbtx_size, wtree[0], 64 );
cbtx_size += 32; cbtx_size += 32;
free(wtree); free( wtree );
} }
// Segwit END // Segwit END
@@ -860,8 +859,8 @@ applog( LOG_INFO, "SEGWIT test: add segwit to tx");
bin2hex( work->txs + 2*n, cbtx, cbtx_size ); bin2hex( work->txs + 2*n, cbtx, cbtx_size );
/* generate merkle root */ /* generate merkle root */
merkle_tree = (uchar(*)[32]) calloc(((1 + tx_count + 1) & ~1), 32); merkle_tree = (uchar(*)[32]) calloc( ( (1 + tx_count + 1) & ~1 ), 32 );
sha256d(merkle_tree[0], cbtx, cbtx_size); sha256d( merkle_tree[0], cbtx, cbtx_size );
for ( i = 0; i < tx_count; i++ ) for ( i = 0; i < tx_count; i++ )
{ {
tmp = json_array_get( txa, i ); tmp = json_array_get( txa, i );
@@ -871,13 +870,13 @@ applog( LOG_INFO, "SEGWIT test: add segwit to tx");
// Segwit BEGIN // Segwit BEGIN
if ( segwit ) if ( segwit )
{ {
const char *txid = json_string_value(json_object_get(tmp, "txid")); const char *txid = json_string_value( json_object_get( tmp, "txid" ) );
if (!txid || !hex2bin(merkle_tree[1 + i], txid, 32)) if ( !txid || !hex2bin( merkle_tree[1 + i], txid, 32 ) )
{ {
applog(LOG_ERR, "JSON invalid transaction txid"); applog(LOG_ERR, "JSON invalid transaction txid");
goto out; goto out;
} }
memrev(merkle_tree[1 + i], 32); memrev( merkle_tree[1 + i], 32 );
} }
else else
{ {
@@ -1567,25 +1566,27 @@ start:
if ( rc ) 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 ); 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 ) ); ( 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 ) if ( work->height > last_block_height )
{ {
last_block_height = work->height; last_block_height = work->height;
applog( LOG_BLUE, "New Block %d, Net Diff %.5g, Target Diff %.5g, Ntime %08x", applog( LOG_BLUE, "New Block %d, Net Diff %.5g, Ntime %08x",
work->height, net_diff, work->targetdiff, work->height, net_diff,
bswap_32( work->data[ algo_gate.ntime_index ] ) ); 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.; double miner_hr = 0.;
pthread_mutex_lock( &stats_lock ); pthread_mutex_lock( &stats_lock );
@@ -1596,7 +1597,7 @@ start:
pthread_mutex_unlock( &stats_lock ); pthread_mutex_unlock( &stats_lock );
if ( miner_hr ) if ( miner_hr > 0. )
{ {
double net_hr = net_hashrate; double net_hr = net_hashrate;
char net_hr_units[4] = {0}; char net_hr_units[4] = {0};
@@ -1604,8 +1605,8 @@ start:
char net_ttf[32]; char net_ttf[32];
char miner_ttf[32]; char miner_ttf[32];
sprintf_et( net_ttf, ( work->targetdiff * exp32 ) / net_hr ); sprintf_et( net_ttf, ( net_diff * exp32 ) / net_hr );
sprintf_et( miner_ttf, ( work->targetdiff * exp32 ) / miner_hr ); sprintf_et( miner_ttf, ( net_diff * exp32 ) / miner_hr );
scale_hash_for_display ( &miner_hr, miner_hr_units ); scale_hash_for_display ( &miner_hr, miner_hr_units );
scale_hash_for_display ( &net_hr, net_hr_units ); scale_hash_for_display ( &net_hr, net_hr_units );
applog2( LOG_INFO, applog2( LOG_INFO,
@@ -3316,15 +3317,8 @@ static void show_credits()
{ {
printf("\n ********** "PACKAGE_NAME" "PACKAGE_VERSION" *********** \n"); printf("\n ********** "PACKAGE_NAME" "PACKAGE_VERSION" *********** \n");
printf(" A CPU miner with multi algo support and optimized for CPUs\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(" 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 () bool check_cpu_capability ()