v3.12.8.1

This commit is contained in:
Jay D Dee
2020-04-17 16:12:45 -04:00
parent e96a6bd699
commit 972d4d70db
11 changed files with 203 additions and 63 deletions

Binary file not shown.

View File

@@ -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.

View File

@@ -19,12 +19,11 @@
*/
#include "cpuminer-config.h"
#include "miner.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#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,
&params, (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;

View File

@@ -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 <stdint.h>
#include <stdlib.h> /* 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_ */

View File

@@ -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

View File

@@ -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;
};

View File

@@ -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

View File

@@ -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 );

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.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\\"

View File

@@ -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

View File

@@ -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: ");