From 972d4d70db92c95477a0dd5e19ad113a712313ec Mon Sep 17 00:00:00 2001 From: Jay D Dee Date: Fri, 17 Apr 2020 16:12:45 -0400 Subject: [PATCH] v3.12.8.1 --- .RELEASE_NOTES.swp | Bin 16384 -> 16384 bytes RELEASE_NOTES | 4 +++ algo/yespower/yescrypt-r8g.c | 20 +++-------- algo/yespower/yescrypt-r8g.h | 49 ++++++++++++++++++++++++++ algo/yespower/yespower-blake2b.c | 37 ++++++++++++++++++-- algo/yespower/yespower-gate.c | 46 +++++++++++------------- algo/yespower/yespower-opt.c | 26 ++++++++++++-- algo/yespower/yespower.h | 58 ++++++++++++++++++++++++++++--- configure | 20 +++++------ configure.ac | 2 +- cpu-miner.c | 4 +-- 11 files changed, 203 insertions(+), 63 deletions(-) create mode 100644 algo/yespower/yescrypt-r8g.h diff --git a/.RELEASE_NOTES.swp b/.RELEASE_NOTES.swp index 272c3f365905feac567dd95a33031048db2516a8..15e48b9a0bd60184890094936324aa924c70d95f 100644 GIT binary patch delta 1099 zcmZA0TWkzb7{Kvw^+IWDOM=jHT9>+Y+pSym!98?|TS-ZaWILU<%XVkY%!-xBmUFjiMcDht^ zRfBJ{s_|3_%`Fnm>D?D=oFH4aifBe4l<1q4Shrz{$6Kj|BOQT|ZdMp!yJC^YTkWaw zc>Atw%1V98D$938lSS_Gcpe}#eX{Sq!a&^eC1x|(o#i5-wO+-adTQ`LMFRZk(%g=ogFQ52CdMs7kf|* zFFxjqTtzP~-~jfc8GcO0vmBA9IFEDaK{xiG2`jMzU$R98@ElL@I9r+|PUkdys6#%+ z;bE4@1Drq?)?y86u^eB?;~IL}cw8dFzgYWNkw!0i(2W!5LOn7ymxmv$_B-_B{%j66a0zi7g9#1w z$ZXBF+>|T(W_Ie?Qg7Z-wr?@NB#Ws0p%xXel-;f?BNU7(D-sSHrcD8aO~W=cBj^#I zof#4`RL}^u>81+lnr>NsGpcMuSz%oZv@+2){dS~dfvtsWD=R6Pf6t7V!G$XDZ@!-r I>(E=|FD!rEw*UYD delta 937 zcmZA0Ur1AN6u|Lw-DX=l+lVN9=_Z9xy7{lAK@UBvb?yJ(oTRMMm0p?E2z?55IFczu&#T^Sk#Z5=tVWsO@E~ z^{3TpN0|^dk)LC?FZcp&vRo+=h;)RL)BBSrP8B%=Jy*Ir!lB;MNKdr1(otUFsCG8H z8{D-Xx4*He#qH4)W3543HWcM6v6S6bT+^SqBcWsmS>MRUkbeC~A2;j&^!h;RvTbjD zuU<9gWRuNVfAv{|dj0B_`r4MKtfoHMjwpW3ZeK019%WHQW&w@HG`qS}iH~d(8Aca6 zaR6U)MV9a$6L^CAxQ8>az>Ie$kwq+E9>chU0rcY_@{tDva`4J1@)9?2-6$S8N#e$D zgUBz;VHSh9hA8@Q2;bTJ0_HJQQ7x!C8>3X2*{+QZ_YIqqUxZ)qoUDt`S~H+Ik-9^(;4aTon)!#Ome5r9Q_KuA&tzdc$3TTRAbVbUFDYl(All$ diff --git a/RELEASE_NOTES b/RELEASE_NOTES index a831994..e807c27 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -65,6 +65,10 @@ If not what makes it happen or not happen? Change Log ---------- +v3.12.8.1 + +Issue #261: Fixed yescryptr8g invalid shares. + v3.12.8 Yespower sha256 prehash made thread safe. diff --git a/algo/yespower/yescrypt-r8g.c b/algo/yespower/yescrypt-r8g.c index 1670eb7..5ee79ea 100644 --- a/algo/yespower/yescrypt-r8g.c +++ b/algo/yespower/yescrypt-r8g.c @@ -19,12 +19,11 @@ */ #include "cpuminer-config.h" +#include "miner.h" #include #include #include -#include -#include "algo-gate-api.h" -#include "yespower.h" +#include "yescrypt-r8g.h" int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) @@ -38,17 +37,7 @@ int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce, const uint32_t last_nonce = max_nonce; const int thr_id = mythr->id; - static __thread int initialized = 0; - static __thread yespower_local_t local; - - if ( !initialized ) - { - if ( yespower_init_local( &local ) ) - return -1; - initialized = 1; - } - - yespower_params_t params = + yespower_params_t params = { .version = YESPOWER_0_5, .N = 2048, @@ -67,7 +56,7 @@ int scanhash_yespower_r8g( struct work *work, uint32_t max_nonce, SHA256_Update( &sha256_prehash_ctx, endiandata, 64 ); do { - yespower_hash( &local, (unsigned char *)endiandata, params.perslen, + yespower_tls( (unsigned char *)endiandata, params.perslen, ¶ms, (yespower_binary_t*)hash, thr_id ); if unlikely( valid_hash( hash, ptarget ) && !opt_benchmark ) @@ -87,6 +76,7 @@ bool register_yescryptr8g_algo( algo_gate_t* gate ) { gate->optimizations = SSE2_OPT | SHA_OPT; gate->scanhash = (void*)&scanhash_yespower_r8g; + gate->hash = (void*)&yespower_tls; pk_buffer_size = 26; opt_sapling = true; opt_target_factor = 65536.0; diff --git a/algo/yespower/yescrypt-r8g.h b/algo/yespower/yescrypt-r8g.h new file mode 100644 index 0000000..57f5cec --- /dev/null +++ b/algo/yespower/yescrypt-r8g.h @@ -0,0 +1,49 @@ +/*- + * Copyright 2009 Colin Percival + * Copyright 2013-2018 Alexander Peslyak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file was originally written by Colin Percival as part of the Tarsnap + * online backup system. + */ +#ifndef _YESPOWERR8G_H_ +#define _YESPOWERR8G_H_ + +#include +#include /* for size_t */ +#include "algo-gate-api.h" +#include "algo/yespower/yespower.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern int yespowerr8g_tls(const uint8_t *src, size_t srclen, + const yespower_params_t *params, yespower_binary_t *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* !_YESPOWERR8G_H_ */ diff --git a/algo/yespower/yespower-blake2b.c b/algo/yespower/yespower-blake2b.c index 4175a6e..4f54201 100644 --- a/algo/yespower/yespower-blake2b.c +++ b/algo/yespower/yespower-blake2b.c @@ -1112,10 +1112,10 @@ static void smix(uint8_t *B, size_t r, uint32_t N, * * Return 0 on success; or -1 on error. */ -int yespower_b2b_hash(yespower_local_t *local, +int yespower_b2b(yespower_local_t *local, const uint8_t *src, size_t srclen, const yespower_params_t *params, - void *dst, int thrid ) + yespower_binary_t *dst, int thrid ) { uint32_t N = params->N; uint32_t r = params->r; @@ -1191,4 +1191,37 @@ fail: return 0; } +/** + * yespower_tls(src, srclen, params, dst): + * Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target". + * The memory allocation is maintained internally using thread-local storage. + * + * Return 0 on success; or -1 on error. + */ +int yespower_b2b_tls(const uint8_t *src, size_t srclen, + const yespower_params_t *params, yespower_binary_t *dst, int thrid ) +{ + static __thread int initialized = 0; + static __thread yespower_local_t local; + + if (!initialized) { + init_region(&local); + initialized = 1; + } + + return yespower_b2b(&local, src, srclen, params, dst, thrid); +} +/* +int yespower_init_local(yespower_local_t *local) +{ + init_region(local); + return 0; +} + +int yespower_free_local(yespower_local_t *local) +{ + return free_region(local); +} +*/ + #endif diff --git a/algo/yespower/yespower-gate.c b/algo/yespower/yespower-gate.c index 7e6798c..603fcbf 100644 --- a/algo/yespower/yespower-gate.c +++ b/algo/yespower/yespower-gate.c @@ -23,17 +23,26 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * This file was originally written by Cryply team as part of the Cryply + * coin. */ #include "yespower.h" + #include "algo-gate-api.h" yespower_params_t yespower_params; -// Give each thread its own copy to avoid requiring mutex. +//SHA256_CTX sha256_prehash_ctx; __thread SHA256_CTX sha256_prehash_ctx; // YESPOWER +int yespower_hash( const char *input, char *output, uint32_t len, int thrid ) +{ + return yespower_tls( input, len, &yespower_params, + (yespower_binary_t*)output, thrid ); +} + int scanhash_yespower( struct work *work, uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) { @@ -46,16 +55,6 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce, uint32_t n = first_nonce; const int thr_id = mythr->id; - static __thread int initialized = 0; - static __thread yespower_local_t local; - - if ( !initialized ) - { - if ( yespower_init_local( &local ) ) - return -1; - initialized = 1; - } - for ( int k = 0; k < 19; k++ ) be32enc( &endiandata[k], pdata[k] ); endiandata[19] = n; @@ -65,8 +64,7 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce, SHA256_Update( &sha256_prehash_ctx, endiandata, 64 ); do { - if ( yespower_hash( &local, (char*)endiandata, 80, &yespower_params, - (char*)vhash, thr_id ) ) + if ( yespower_hash( (char*)endiandata, (char*)vhash, 80, thr_id ) ) if unlikely( valid_hash( vhash, ptarget ) && !opt_benchmark ) { be32enc( pdata+19, n ); @@ -81,6 +79,11 @@ int scanhash_yespower( struct work *work, uint32_t max_nonce, // YESPOWER-B2B +int yespower_b2b_hash( const char *input, char *output, uint32_t len, int thrid ) +{ + return yespower_b2b_tls( input, len, &yespower_params, (yespower_binary_t*)output, thrid ); +} + int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce, uint64_t *hashes_done, struct thr_info *mythr ) { @@ -93,16 +96,6 @@ int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce, const uint32_t last_nonce = max_nonce; const int thr_id = mythr->id; - static __thread int initialized = 0; - static __thread yespower_local_t local; - - if ( !initialized ) - { - if ( yespower_init_local( &local ) ) - return -1; - initialized = 1; - } - for ( int k = 0; k < 19; k++ ) be32enc( &endiandata[k], pdata[k] ); endiandata[19] = n; @@ -112,8 +105,7 @@ int scanhash_yespower_b2b( struct work *work, uint32_t max_nonce, SHA256_Update( &sha256_prehash_ctx, endiandata, 64 ); do { - if (yespower_b2b_hash( &local, (char*) endiandata, 80, &yespower_params, - (char*) vhash, thr_id ) ) + if (yespower_b2b_hash( (char*) endiandata, (char*) vhash, 80, thr_id ) ) if unlikely( valid_hash( vhash, ptarget ) && !opt_benchmark ) { be32enc( pdata+19, n ); @@ -154,6 +146,7 @@ bool register_yespower_algo( algo_gate_t* gate ) gate->optimizations = SSE2_OPT | SHA_OPT; gate->scanhash = (void*)&scanhash_yespower; + gate->hash = (void*)&yespower_hash; opt_target_factor = 65536.0; return true; }; @@ -167,6 +160,7 @@ bool register_yespowerr16_algo( algo_gate_t* gate ) yespower_params.perslen = 0; gate->optimizations = SSE2_OPT | SHA_OPT; gate->scanhash = (void*)&scanhash_yespower; + gate->hash = (void*)&yespower_hash; opt_target_factor = 65536.0; return true; }; @@ -277,6 +271,7 @@ bool register_power2b_algo( algo_gate_t* gate ) gate->optimizations = SSE2_OPT; gate->scanhash = (void*)&scanhash_yespower_b2b; + gate->hash = (void*)&yespower_b2b_hash; opt_target_factor = 65536.0; return true; }; @@ -316,6 +311,7 @@ bool register_yespower_b2b_algo( algo_gate_t* gate ) gate->optimizations = SSE2_OPT; gate->scanhash = (void*)&scanhash_yespower_b2b; + gate->hash = (void*)&yespower_b2b_hash; opt_target_factor = 65536.0; return true; }; diff --git a/algo/yespower/yespower-opt.c b/algo/yespower/yespower-opt.c index 3596027..f26de51 100644 --- a/algo/yespower/yespower-opt.c +++ b/algo/yespower/yespower-opt.c @@ -1024,10 +1024,10 @@ static void smix(uint8_t *B, size_t r, uint32_t N, * * Return 0 on success; or -1 on error. */ -int yespower_hash( yespower_local_t *local, +int yespower(yespower_local_t *local, const uint8_t *src, size_t srclen, const yespower_params_t *params, - void *dst, int thrid ) + yespower_binary_t *dst, int thrid ) { yespower_version_t version = params->version; uint32_t N = params->N; @@ -1158,6 +1158,27 @@ int yespower_hash( yespower_local_t *local, return 1; } +/** + * yespower_tls(src, srclen, params, dst): + * Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target". + * The memory allocation is maintained internally using thread-local storage. + * + * Return 0 on success; or -1 on error. + */ +int yespower_tls(const uint8_t *src, size_t srclen, + const yespower_params_t *params, yespower_binary_t *dst, int thrid ) +{ + static __thread int initialized = 0; + static __thread yespower_local_t local; + + if (!initialized) { + if (yespower_init_local(&local)) + return -1; + initialized = 1; + } + + return yespower( &local, src, srclen, params, dst, thrid ); +} int yespower_init_local(yespower_local_t *local) { @@ -1169,5 +1190,4 @@ int yespower_free_local(yespower_local_t *local) { return free_region(local); } - #endif diff --git a/algo/yespower/yespower.h b/algo/yespower/yespower.h index 9c37662..4a53b71 100644 --- a/algo/yespower/yespower.h +++ b/algo/yespower/yespower.h @@ -76,21 +76,68 @@ typedef struct { unsigned char uc[32]; } yespower_binary_t __attribute__ ((aligned (64))); -extern yespower_params_t yespower_params; +yespower_params_t yespower_params; +//SHA256_CTX sha256_prehash_ctx; extern __thread SHA256_CTX sha256_prehash_ctx; +/** + * yespower_init_local(local): + * Initialize the thread-local (RAM) data structure. Actual memory allocation + * is currently fully postponed until a call to yespower(). + * + * Return 0 on success; or -1 on error. + * + * MT-safe as long as local is local to the thread. + */ extern int yespower_init_local(yespower_local_t *local); +/** + * yespower_free_local(local): + * Free memory that may have been allocated for an initialized thread-local + * (RAM) data structure. + * + * Return 0 on success; or -1 on error. + * + * MT-safe as long as local is local to the thread. + */ extern int yespower_free_local(yespower_local_t *local); -extern int yespower_hash(yespower_local_t *local, +/** + * yespower(local, src, srclen, params, dst): + * Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target". + * local is the thread-local data structure, allowing to preserve and reuse a + * memory allocation across calls, thereby reducing processing overhead. + * + * Return 0 on success; or -1 on error. + * + * local must be initialized with yespower_init_local(). + * + * MT-safe as long as local and dst are local to the thread. + */ +extern int yespower(yespower_local_t *local, const uint8_t *src, size_t srclen, - const yespower_params_t *params, void *dst, int thrid); + const yespower_params_t *params, yespower_binary_t *dst, int thrid); -extern int yespower_b2b_hash(yespower_local_t *local, +extern int yespower_b2b(yespower_local_t *local, const uint8_t *src, size_t srclen, - const yespower_params_t *params, void *dst, int thrid ); + const yespower_params_t *params, yespower_binary_t *dst, int thrid ); + +/** + * yespower_tls(src, srclen, params, dst): + * Compute yespower(src[0 .. srclen - 1], N, r), to be checked for "< target". + * The memory allocation is maintained internally using thread-local storage. + * + * Return 0 on success; or -1 on error. + * + * MT-safe as long as dst is local to the thread. + */ +extern int yespower_tls(const uint8_t *src, size_t srclen, + const yespower_params_t *params, yespower_binary_t *dst, int thr_id); + +extern int yespower_b2b_tls(const uint8_t *src, size_t srclen, + const yespower_params_t *params, yespower_binary_t *dst, int thr_id); + #if defined(__AVX2__) @@ -103,6 +150,7 @@ extern int yespower_8way( yespower_local_t *local, const __m256i *src, size_t srclen, const yespower_params_t *params, yespower_8way_binary_t *dst, int thrid ); + extern int yespower_8way_tls( const __m256i *src, size_t srclen, const yespower_params_t *params, yespower_8way_binary_t *dst, int thr_id ); diff --git a/configure b/configure index f6854b0..b70cdf0 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.12.8. +# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.12.8.1. # # # 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.8' -PACKAGE_STRING='cpuminer-opt 3.12.8' +PACKAGE_VERSION='3.12.8.1' +PACKAGE_STRING='cpuminer-opt 3.12.8.1' 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.8 to adapt to many kinds of systems. +\`configure' configures cpuminer-opt 3.12.8.1 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.8:";; + short | recursive ) echo "Configuration of cpuminer-opt 3.12.8.1:";; 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.8 +cpuminer-opt configure 3.12.8.1 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.8, which was +It was created by cpuminer-opt $as_me 3.12.8.1, 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.8' + VERSION='3.12.8.1' 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.8, which was +This file was extended by cpuminer-opt $as_me 3.12.8.1, 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.8 +cpuminer-opt config.status 3.12.8.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index a8215a9..2ae9c94 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([cpuminer-opt], [3.12.8]) +AC_INIT([cpuminer-opt], [3.12.8.1]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpu-miner.c b/cpu-miner.c index 39feae3..23b31e5 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -3285,7 +3285,7 @@ bool check_cpu_capability () // #endif cpu_brand_string( cpu_brand ); - printf( "CPU: %s.\n", cpu_brand ); + printf( "CPU: %s\n", cpu_brand ); printf("SW built on " __DATE__ #ifdef _MSC_VER @@ -3294,7 +3294,7 @@ bool check_cpu_capability () " with GCC"); printf(" %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__); #else - printf(".\n"); + printf("\n"); #endif printf("CPU features: ");