This commit is contained in:
Jay D Dee
2020-03-01 13:18:17 -05:00
parent 720610cce5
commit 3da149418a
8 changed files with 122 additions and 117 deletions

View File

@@ -152,6 +152,27 @@ Supported Algorithms
yespower-b2b generic yespower + blake2b
zr5 Ziftr
Many variations of scrypt based algos can be mine by specifying their
parameters:
scryptn2: --algo scrypt --param-n 1048576
cpupower: --algo yespower --param-key "CPUpower: The number of CPU working or available for proof-of-work mining"
power2b: --algo yespower-b2b --param-n 2048 --param-r 32 --param-key "Now I am become Death, the destroyer of worlds"
sugarchain: --algo yespower --param-n 2048 -param-r 32 --param-key "Satoshi Nakamoto 31/Oct/2008 Proof-of-work is essentially one-CPU-one-vote"
yespoweriots: --a yespower --param-n 2048 --param-key "Iots is committed to the development of IOT"
yespowerlitb: --algo yespower --param-n 2048 --param-r 32 --param-key "LITBpower: The number of LITB working or available for proof-of-work mini"
yespoweric: --algo yespower --param-n 2048 --param-r 32 --param-key "IsotopeC"
yespowerurx: --algo yespower --param-n 2048 --param-r 32 --param-key "UraniumX"
yespowerltncg: --algo yespower --param-n 2048 --param-r 32 --param-key "LTNCGYES"
Errata
------

View File

@@ -65,6 +65,19 @@ If not what makes it happen or not happen?
Change Log
----------
v3.12.5
Issues #246 & #251: fixed incorrect share diff for stratum and getwork,
fixed incorrect target diff for getwork. Stats should now be correct for
getwork as well as stratum.
Getwork: reduce stale blocks, faster response to new work.
Added ntime to new job/work logs.
README.md now lists the parameters for yespower variations that don't have
a specific algo name.
v3.12.4.6
Issue #246: fixed getwork repeated new block logs with same height. New work

View File

@@ -706,12 +706,12 @@ extern int scanhash_scrypt( struct work *work, uint32_t max_nonce,
if ( rc )
for ( i = 0; i < throughput; i++ )
{
if ( unlikely( valid_hash( hash + i * 8, ptarget ) ) )
if ( unlikely( valid_hash( hash + i * 8, ptarget ) ) )
{
pdata[19] = data[i * 20 + 19];
submit_lane_solution( work, hash, mythr, i );
submit_solution( work, hash + i * 8, mythr );
}
}
}
} while ( likely( ( n < ( max_nonce - throughput ) ) && !(*restart) ) );
*hashes_done = n - pdata[19];

20
configure vendored
View File

@@ -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.12.4.6.
# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.12.5.
#
#
# 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.12.4.6'
PACKAGE_STRING='cpuminer-opt 3.12.4.6'
PACKAGE_VERSION='3.12.5'
PACKAGE_STRING='cpuminer-opt 3.12.5'
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.12.4.6 to adapt to many kinds of systems.
\`configure' configures cpuminer-opt 3.12.5 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.12.4.6:";;
short | recursive ) echo "Configuration of cpuminer-opt 3.12.5:";;
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.12.4.6
cpuminer-opt configure 3.12.5
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.12.4.6, which was
It was created by cpuminer-opt $as_me 3.12.5, 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.12.4.6'
VERSION='3.12.5'
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.12.4.6, which was
This file was extended by cpuminer-opt $as_me 3.12.5, 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.12.4.6
cpuminer-opt config.status 3.12.5
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@@ -1,4 +1,4 @@
AC_INIT([cpuminer-opt], [3.12.4.6])
AC_INIT([cpuminer-opt], [3.12.5])
AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM

View File

@@ -102,6 +102,7 @@ static int opt_fail_pause = 10;
static int opt_time_limit = 0;
int opt_timeout = 300;
static int opt_scantime = 5;
const int min_scantime = 1;
//static const bool opt_time = true;
enum algos opt_algo = ALGO_NULL;
char* opt_param_key = NULL;
@@ -159,6 +160,7 @@ uint32_t accepted_share_count = 0;
uint32_t rejected_share_count = 0;
uint32_t stale_share_count = 0;
uint32_t solved_block_count = 0;
uint64_t new_work_count = 0;
double *thr_hashrates;
double global_hashrate = 0;
double stratum_diff = 0.;
@@ -436,9 +438,6 @@ static bool work_decode( const json_t *val, struct work *work )
if ( !allow_mininginfo )
net_diff = algo_gate.calc_network_diff( work );
work->targetdiff = target_to_diff( work->target );
// for api stats, on longpoll pools
// This needs cleanup, stratum_diff doean't apply solo mining
// and targetdiff is redundant, same as net_diff.
stratum_diff = last_targetdiff = work->targetdiff;
work->sharediff = 0;
algo_gate.decode_extra_data( work, &net_blocks );
@@ -939,6 +938,8 @@ void report_summary_log( bool force )
uint64_t accepts = accept_sum; accept_sum = 0;
uint64_t rejects = reject_sum; reject_sum = 0;
uint64_t stales = stale_sum; stale_sum = 0;
// uint64_t new_work = new_work_count; new_work_count = 0;
memcpy( &start_time, &five_min_start, sizeof start_time );
memcpy( &five_min_start, &now, sizeof now );
@@ -949,12 +950,10 @@ void report_summary_log( bool force )
double share_time = (double)et.tv_sec + (double)et.tv_usec / 1e6;
double ghrate = global_hashrate;
double shrate = share_time == 0. ? 0. : exp32 * last_targetdiff
* (double)(accepts) / share_time;
double sess_hrate = uptime.tv_sec == 0. ? 0. : exp32 * norm_diff_sum
/ (double)uptime.tv_sec;
double submit_rate = share_time == 0. ? 0. : (double)submits*60. / share_time;
char shr_units[4] = {0};
char ghr_units[4] = {0};
@@ -962,6 +961,21 @@ void report_summary_log( bool force )
char et_str[24];
char upt_str[24];
/*
uint64_t work_time = new_work ? et.tv_sec / new_work : 15;
// Adjust scantime for frequent new work to prevent stales.
if ( work_time < 2 * opt_scantime )
{
if ( opt_scantime > min_scantime )
{
opt_scantime--;
if ( !opt_quiet )
applog( LOG_BLUE, "Getwork scan time reduced to %d seconds",
opt_scantime );
}
}
*/
scale_hash_for_display( &shrate, shr_units );
scale_hash_for_display( &ghrate, ghr_units );
scale_hash_for_display( &sess_hrate, sess_hr_units );
@@ -1095,7 +1109,7 @@ static int share_result( int result, struct work *work,
rejected_share_count++;
sprintf( sres, "S%d", stale_share_count );
sprintf( rres, "Rejected %d" , rejected_share_count );
lowdiff_debug = true;
// lowdiff_debug = true;
}
}
@@ -1323,6 +1337,7 @@ char* std_malloc_txs_request( struct work *work )
static bool submit_upstream_work( CURL *curl, struct work *work )
{
work->stale = false;
/*
// Submit anyway, discardring here messes up the stats
if ( !have_stratum && allow_mininginfo )
{
@@ -1334,16 +1349,19 @@ static bool submit_upstream_work( CURL *curl, struct work *work )
applog( LOG_WARNING, "Block %u already solved, current block %d",
work->height, mining_info.height );
work->stale = true;
// g_work_time = 0;
}
}
*/
/* pass if the previous hash is not the current previous hash */
if ( !( work->stale || submit_old )
&& memcmp( &work->data[1], &g_work.data[1], 32 ) )
if ( !submit_old && ( work->data[ algo_gate.ntime_index ]
!= g_work.data[ algo_gate.ntime_index] ) )
{
if ( !opt_quiet )
if ( !opt_debug )
applog( LOG_WARNING, "Stale work detected, submitting anyway" );
work->stale = true;
g_work_time = 0;
}
if ( have_stratum )
@@ -1481,9 +1499,11 @@ start:
if ( work->height > last_block_height )
{
new_work_count++;
last_block_height = work->height;
applog( LOG_BLUE, "New block %d, net diff %.5g, target diff %.5g",
work->height, net_diff, work->targetdiff );
applog( LOG_BLUE, "New block %d, net diff %.5g, target diff %.5g, ntime %08x",
work->height, net_diff, work->targetdiff,
bswap_32( work->data[ algo_gate.ntime_index ] ) );
if ( !opt_quiet && net_diff && net_hashrate )
{
@@ -1517,7 +1537,9 @@ start:
} // work->height > last_block_height
else if ( memcmp( &work->data[1], &g_work.data[1], 32 ) )
{
applog( LOG_BLUE, "New work" );
new_work_count++;
applog( LOG_BLUE, "New work, ntime %08lx",
bswap_32( work->data[ algo_gate.ntime_index ] ) );
if ( opt_debug )
{
uint32_t *old = g_work.data;
@@ -1588,8 +1610,6 @@ static bool workio_get_work( struct workio_cmd *wc, CURL *curl )
if ( !tq_push(wc->thr->q, ret_work ) )
free( ret_work );
report_summary_log( false );
return true;
}
@@ -1732,17 +1752,13 @@ err_out:
// double precision floating point with 15 decimal digits precision.
static inline double u256_to_double( const uint64_t *u )
{
const double exp64 = 4294967296.0 * 4294967296.0; // 2**64
return ( ( u[3] * exp64 + u[2] ) * exp64 + u[1] ) * exp64 + u[0];
}
*/
static void update_submit_stats( struct work *work, const void *hash )
{
// Workaround until problems with target_to_diff are resolved.
work->sharediff = work->targetdiff * (double)( ((uint64_t*)hash)[3] )
/ (double)( ((uint64_t*)work->target)[3] );
// work->sharediff = likely( hash ) ? target_to_diff( (uint32_t*)hash ) : 0.;
work->sharediff = hash ? exp32 / ( (uint64_t*)hash )[3] : 0.;
pthread_mutex_lock( &stats_lock );
@@ -1760,6 +1776,7 @@ static void update_submit_stats( struct work *work, const void *hash )
pthread_mutex_unlock( &stats_lock );
}
/*
//deprecated
void work_set_target_ratio( struct work* work, const void *hash )
{
@@ -1786,6 +1803,7 @@ void work_set_target_ratio( struct work* work, const void *hash )
pthread_mutex_unlock( &stats_lock );
}
*/
bool submit_solution( struct work *work, const void *hash,
struct thr_info *thr )
@@ -1857,49 +1875,6 @@ bool submit_lane_solution( struct work *work, const void *hash,
return false;
}
// The new way, replaces fulltest and submit_solution
bool test_hash_and_submit( struct work *work, const void *hash,
struct thr_info *thr )
{
work->sharediff = work->targetdiff * (double)( ((uint64_t*)hash)[3] )
/ (double)( ((uint64_t*)work->target)[3] );
if ( work->sharediff >= work->targetdiff )
{
if ( likely( submit_work( thr, work ) ) )
{
update_submit_stats( work, hash );
if ( !opt_quiet )
{
if ( have_stratum )
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d, job %s",
submitted_share_count, work->sharediff, work->height,
work->job_id );
else
applog( LOG_NOTICE, "%d Submit diff %.5g, block %d",
submitted_share_count, work->sharediff, work->height );
}
if ( lowdiff_debug )
{
uint32_t* h = (uint32_t*)hash;
uint32_t* t = (uint32_t*)work->target;
applog(LOG_INFO,"Hash[7:0]: %08x %08x %08x %08x %08x %08x %08x %08x",
h[7],h[6],h[5],h[4],h[3],h[2],h[1],h[0]);
applog(LOG_INFO,"Targ[7:0]: %08x %08x %08x %08x %08x %08x %08x %08x",
t[7],t[6],t[5],t[4],t[3],t[2],t[1],t[0]);
}
return true;
}
else
applog( LOG_WARNING, "%d failed to submit share, thread %d",
submitted_share_count, thr->id );
}
return false;
}
static bool wanna_mine(int thr_id)
{
bool state = true;
@@ -2146,13 +2121,14 @@ static void *miner_thread( void *userdata )
}
else
{
int min_scantime = have_longpoll ? LP_SCANTIME : opt_scantime;
int scantime = have_longpoll ? LP_SCANTIME : opt_scantime;
pthread_mutex_lock( &g_work_lock );
if ( time(NULL) - g_work_time >= min_scantime
if ( time(NULL) - g_work_time >= scantime
|| *nonceptr >= end_nonce )
{
if ( unlikely( !get_work( mythr, &g_work ) ) )
report_summary_log( false );
if ( unlikely( !get_work( mythr, &g_work ) ) )
{
applog( LOG_ERR, "work retrieval failed, exiting "
"mining thread %d", thr_id );
@@ -2160,7 +2136,8 @@ static void *miner_thread( void *userdata )
goto out;
}
g_work_time = time(NULL);
}
restart_threads();
}
algo_gate.get_new_work( &work, &g_work, thr_id, &end_nonce );
pthread_mutex_unlock( &g_work_lock );
@@ -2627,10 +2604,8 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
algo_gate.set_work_data_endian( g_work );
g_work->height = sctx->block_height;
g_work->targetdiff = sctx->job.diff
/ ( opt_target_factor * opt_diff_factor );
/ ( opt_target_factor * opt_diff_factor );
diff_to_target( g_work->target, g_work->targetdiff );
// work_set_target( g_work, sctx->job.diff
// / ( opt_target_factor * opt_diff_factor ) );
pthread_mutex_unlock( &sctx->work_lock );
@@ -2654,13 +2629,16 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
pthread_mutex_unlock( &stats_lock );
if ( stratum_diff != sctx->job.diff )
applog( LOG_BLUE, "New stratum diff %g, block %d, job %s",
sctx->job.diff, sctx->block_height, g_work->job_id );
applog( LOG_BLUE, "New diff %g, block %d, job %s, ntime %08x",
sctx->job.diff, sctx->block_height, g_work->job_id,
bswap_32( g_work->data[ algo_gate.ntime_index ] ) );
else if ( last_block_height != sctx->block_height )
applog( LOG_BLUE, "New block %d, job %s",
sctx->block_height, g_work->job_id );
applog( LOG_BLUE, "New block %d, job %si, ntime %08x",
sctx->block_height, g_work->job_id,
bswap_32( g_work->data[ algo_gate.ntime_index ] ) );
else if ( g_work->job_id )
applog( LOG_BLUE,"New job %s", g_work->job_id );
applog( LOG_BLUE,"New job %s, ntime %08x", g_work->job_id,
bswap_32( g_work->data[ algo_gate.ntime_index ] ) );
// Update data and calculate new estimates.
if ( ( stratum_diff != sctx->job.diff )
@@ -2677,7 +2655,7 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
if ( !opt_quiet )
{
applog2( LOG_INFO, "Diff: Net %.5g, Stratum %.5g, Target %.5g",
net_diff, stratum_diff, last_targetdiff );
net_diff, stratum_diff, g_work->targetdiff );
if ( likely( hr > 0. ) )
{
@@ -2686,7 +2664,7 @@ void std_stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
char share_ttf[32];
sprintf_et( block_ttf, ( net_diff * exp32 ) / hr );
sprintf_et( share_ttf, last_targetdiff * exp32 / hr );
sprintf_et( share_ttf, g_work->targetdiff * exp32 / hr );
scale_hash_for_display ( &hr, hr_units );
applog2( LOG_INFO, "TTF @ %.2f %sh/s: block %s, share %s",
hr, hr_units, block_ttf, share_ttf );

View File

@@ -347,11 +347,11 @@ struct thr_info {
bool submit_solution( struct work *work, const void *hash,
struct thr_info *thr );
// deprecated
bool submit_lane_solution( struct work *work, const void *hash,
struct thr_info *thr, const int lane );
bool test_hash_and_submit( struct work*, const void*, struct thr_info* );
bool submit_work( struct thr_info *thr, const struct work *work_in );
@@ -869,7 +869,7 @@ Options:\n\
zr5 Ziftr\n\
-N, --param-n N parameter for scrypt based algos\n\
-R, --patam-r R parameter for scrypt based algos\n\
-K, --param-key Key parameter for algos that use it\n\
-K, --param-key Key (pers) parameter for algos that use it\n\
-o, --url=URL URL of mining server\n\
-O, --userpass=U:P username:password pair for mining server\n\
-u, --user=USERNAME username for mining server\n\

41
util.c
View File

@@ -1041,16 +1041,19 @@ bool fulltest( const uint32_t *hash, const uint32_t *target )
return rc;
}
/*
void diff_to_target(uint32_t *target, double diff)
{
uint64_t m;
int k;
for (k = 6; k > 0 && diff > 1.0; k--)
diff /= 4294967296.0;
diff /= exp32;
m = (uint64_t)(4294901760.0 / diff);
// diff /= 4294967296.0;
// m = (uint64_t)(4294901760.0 / diff);
m = (uint64_t)(exp32 / diff);
if (m == 0 && k == 6)
memset(target, 0xff, 32);
@@ -1060,29 +1063,8 @@ void diff_to_target(uint32_t *target, double diff)
target[k + 1] = (uint32_t)(m >> 32);
}
}
*/
void diff_to_target(uint32_t *target, double diff)
{
uint64_t *t = (uint64_t*)target;
uint64_t m;
int k;
for ( k = 3; k > 0 && diff > 1.0; k-- )
diff /= exp64;
m = (uint64_t)( 0xffff0000 / diff );
if unlikely( m == 0 && k == 3 )
memset( t, 0xff, 32 );
else
{
memset( t, 0, 32 );
t[k] = m;
}
}
// deprecated
void work_set_target(struct work* work, double diff)
{
@@ -1090,6 +1072,16 @@ void work_set_target(struct work* work, double diff)
work->targetdiff = diff;
}
double target_to_diff( uint32_t* target )
{
uint64_t *targ = (uint64_t*)target;
return target ? 1. / ( ( (double)targ[3] / exp32 )
+ ( (double)targ[2] )
+ ( (double)targ[1] * exp32 )
+ ( (double)targ[0] * exp64 ) )
: 0.;
}
/*
double target_to_diff(uint32_t* target)
{
uchar* tgt = (uchar*) target;
@@ -1108,6 +1100,7 @@ double target_to_diff(uint32_t* target)
else
return (double)0x0000ffff00000000/m;
}
*/
#ifdef WIN32
#define socket_blocks() (WSAGetLastError() == WSAEWOULDBLOCK)