Compare commits

...

6 Commits

Author SHA1 Message Date
Jay D Dee
13563e2598 v3.14.1 2020-05-21 13:00:29 -04:00
Jay D Dee
9571f85d53 v3.14.0 2020-05-20 13:56:35 -04:00
Jay D Dee
0e69756634 v3.13.2-segwit-test 2020-05-18 18:17:27 -04:00
Jay D Dee
9653bca1e2 v3.13.1.1 2020-05-17 19:21:37 -04:00
Jay D Dee
1c0719e8a4 v3.13.1 2020-05-10 21:34:55 -04:00
Jay D Dee
8b4b4dc613 v3.13.0.1 2020-05-07 17:57:04 -04:00
31 changed files with 645 additions and 242 deletions

View File

@@ -257,6 +257,7 @@ cpuminer_SOURCES = \
algo/x16/hex.c \
algo/x16/x21s-4way.c \
algo/x16/x21s.c \
algo/x16/minotaur.c \
algo/x17/x17-gate.c \
algo/x17/x17.c \
algo/x17/x17-4way.c \

View File

@@ -93,6 +93,7 @@ Supported Algorithms
lyra2z
lyra2z330 Lyra2 330 rows, Zoin (ZOI)
m7m Magi (XMG)
minotaur Ringcoin (RNG)
myr-gr Myriad-Groestl
neoscrypt NeoScrypt(128, 2, 1)
nist5 Nist5

View File

@@ -46,6 +46,15 @@ Icelake is only available on some laptops. Mining with a laptop is not
recommended. The icelake build is included in anticipation of Intel eventually
releasing a desktop CPU with a microarchitecture newer than Skylake.
Notes about included DLL files:
Downloading DLL files from alternative sources presents an inherent
security risk if their source is unknown. All DLL files included have
been copied from the Ubuntu-20.04 instalation or compiled by me from
source code obtained from the author's official repository. The exact
procedure is documented in the build instructions for Windows:
https://github.com/JayDDee/cpuminer-opt/wiki/Compiling-from-source
If you like this software feel free to donate:
BTC: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT

View File

@@ -65,6 +65,43 @@ If not what makes it happen or not happen?
Change Log
----------
v3.14.1
GBT and getwork log changes:
fixed missing TTF in New Block log,
ntime no longer byte-swapped for display in New Work log,
fixed zero effective hash rate in Periodic Report log,
deleted "Current block is..." log.
Renamed stratum "New Job" log to "New Work" to be consistent with the solo
version of the log. Added more data to both versions.
v3.14.0
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.
Fixed BUG log mining sha256d.
v3.13.1.1
Fixed Windows crash mining minotaur algo.
Fixed GCC 10 compile again.
Added -fno-common to testing to be consistent with GCC 10 default.
v3.13.1
Added minotaur algo for Ringcoin.
v3.13.0.1
Issue #262: Fixed xevan AVX2 invalid shares.
v3.13.0
Updated Windows binaries compiled with GCC 9. Included DLLs also updated.

View File

@@ -90,13 +90,44 @@ void algo_not_implemented()
}
// default null functions
// deprecated, use generic as default
int null_scanhash()
{
applog(LOG_WARNING,"SWERR: undefined scanhash function in algo_gate");
return 0;
}
// Default generic scanhash can be used in many cases.
int scanhash_generic( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr )
{
uint32_t edata[20] __attribute__((aligned(64)));
uint32_t hash[8] __attribute__((aligned(64)));
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
const uint32_t first_nonce = pdata[19];
const uint32_t last_nonce = max_nonce - 1;
uint32_t n = first_nonce;
const int thr_id = mythr->id;
const bool bench = opt_benchmark;
mm128_bswap32_80( edata, pdata );
do
{
edata[19] = n;
if ( likely( algo_gate.hash( hash, edata, thr_id ) ) )
if ( unlikely( valid_hash( hash, ptarget ) && !bench ) )
{
pdata[19] = bswap_32( n );
submit_solution( work, hash, mythr );
}
n++;
} while ( n < last_nonce && !work_restart[thr_id].restart );
*hashes_done = n - first_nonce;
pdata[19] = n;
return 0;
}
int null_hash()
{
applog(LOG_WARNING,"SWERR: null_hash unsafe null function");
@@ -106,7 +137,7 @@ int null_hash()
void init_algo_gate( algo_gate_t* gate )
{
gate->miner_thread_init = (void*)&return_true;
gate->scanhash = (void*)&null_scanhash;
gate->scanhash = (void*)&scanhash_generic;
gate->hash = (void*)&null_hash;
gate->get_new_work = (void*)&std_get_new_work;
gate->work_decode = (void*)&std_le_work_decode;
@@ -179,6 +210,7 @@ bool register_algo_gate( int algo, algo_gate_t *gate )
case ALGO_LYRA2Z: register_lyra2z_algo ( gate ); break;
case ALGO_LYRA2Z330: register_lyra2z330_algo ( gate ); break;
case ALGO_M7M: register_m7m_algo ( gate ); break;
case ALGO_MINOTAUR: register_minotaur_algo ( gate ); break;
case ALGO_MYR_GR: register_myriad_algo ( gate ); break;
case ALGO_NEOSCRYPT: register_neoscrypt_algo ( gate ); break;
case ALGO_NIST5: register_nist5_algo ( gate ); break;
@@ -251,7 +283,6 @@ bool register_algo_gate( int algo, algo_gate_t *gate )
// restore warnings
#pragma GCC diagnostic pop
// run the alternate hash function for a specific algo
void exec_hash_function( int algo, void *output, const void *pdata )
{
algo_gate_t gate;

View File

@@ -110,11 +110,13 @@ inline bool set_excl ( set_t a, set_t b ) { return (a & b) == 0; }
typedef struct
{
// mandatory function, must be overwritten
// Mandatory functions, one of these is mandatory. If the default scanhash
// is used a custom hash function must be registered, with a custom scanhash
// the hash function is not necessary.
int ( *scanhash ) ( struct work*, uint32_t, uint64_t*, struct thr_info* );
// Deprecated, will be removed
int ( *hash ) ( void*, const void*, uint32_t ) ;
//int ( *hash ) ( void*, const void*, uint32_t ) ;
int ( *hash ) ( void*, const void*, int );
//optional, safe to use default in most cases
@@ -207,9 +209,13 @@ void four_way_not_tested();
#define JR2_WORK_CMP_INDEX_2 43
#define JR2_WORK_CMP_SIZE_2 33
// allways returns failure
// deprecated, use generic instead
int null_scanhash();
// Default generic, may be used in many cases.
int scanhash_generic( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
// displays warning
int null_hash ();

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

View File

@@ -731,7 +731,7 @@ void skein512_8way_full( skein512_8way_context *sc, void *out, const void *data,
void
skein512_8way_prehash64( skein512_8way_context *sc, const void *data )
{
__m512i *vdata = (__m512*)data;
__m512i *vdata = (__m512i*)data;
__m512i *buf = sc->buf;
buf[0] = vdata[0];
buf[1] = vdata[1];

258
algo/x16/minotaur.c Normal file
View File

@@ -0,0 +1,258 @@
// Minotaur hash
#include "algo-gate-api.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "algo/blake/sph_blake.h"
#include "algo/bmw/sph_bmw.h"
#include "algo/jh/sph_jh.h"
#include "algo/keccak/sph_keccak.h"
#include "algo/skein/sph_skein.h"
#include "algo/shavite/sph_shavite.h"
#include "algo/luffa/luffa_for_sse2.h"
#include "algo/cubehash/cubehash_sse2.h"
#include "algo/simd/nist.h"
#include "algo/hamsi/sph_hamsi.h"
#include "algo/fugue/sph_fugue.h"
#include "algo/shabal/sph_shabal.h"
#include "algo/whirlpool/sph_whirlpool.h"
#include <openssl/sha.h>
#if defined(__AES__)
#include "algo/echo/aes_ni/hash_api.h"
#include "algo/groestl/aes_ni/hash-groestl.h"
#else
#include "algo/echo/sph_echo.h"
#include "algo/groestl/sph_groestl.h"
#endif
// Config
#define MINOTAUR_ALGO_COUNT 16
typedef struct TortureNode TortureNode;
typedef struct TortureGarden TortureGarden;
// Graph of hash algos plus SPH contexts
struct TortureGarden {
#if defined(__AES__)
hashState_echo echo;
hashState_groestl groestl;
#else
sph_echo512_context echo;
sph_groestl512_context groestl;
#endif
sph_blake512_context blake;
sph_bmw512_context bmw;
sph_skein512_context skein;
sph_jh512_context jh;
sph_keccak512_context keccak;
hashState_luffa luffa;
cubehashParam cube;
shavite512_context shavite;
hashState_sd simd;
sph_hamsi512_context hamsi;
sph_fugue512_context fugue;
sph_shabal512_context shabal;
sph_whirlpool_context whirlpool;
SHA512_CTX sha512;
struct TortureNode {
unsigned int algo;
TortureNode *childLeft;
TortureNode *childRight;
} nodes[22];
} __attribute__ ((aligned (64)));
// Get a 64-byte hash for given 64-byte input, using given TortureGarden contexts and given algo index
static void get_hash( void *output, const void *input, TortureGarden *garden,
unsigned int algo )
{
unsigned char hash[64] __attribute__ ((aligned (64)));
switch (algo) {
case 0:
sph_blake512_init(&garden->blake);
sph_blake512(&garden->blake, input, 64);
sph_blake512_close(&garden->blake, hash);
break;
case 1:
sph_bmw512_init(&garden->bmw);
sph_bmw512(&garden->bmw, input, 64);
sph_bmw512_close(&garden->bmw, hash);
break;
case 2:
cubehashInit( &garden->cube, 512, 16, 32 );
cubehashUpdateDigest( &garden->cube, (byte*)hash,
(const byte*)input, 64 );
break;
case 3:
#if defined(__AES__)
echo_full( &garden->echo, (BitSequence *)hash, 512,
(const BitSequence *)input, 64 );
#else
sph_echo512_init(&garden->echo);
sph_echo512(&garden->echo, input, 64);
sph_echo512_close(&garden->echo, hash);
#endif
break;
case 4:
sph_fugue512_init(&garden->fugue);
sph_fugue512(&garden->fugue, input, 64);
sph_fugue512_close(&garden->fugue, hash);
break;
case 5:
#if defined(__AES__)
groestl512_full( &garden->groestl, (char*)hash, (char*)input, 512 );
#else
sph_groestl512_init(&garden->groestl);
sph_groestl512(&garden->groestl, input, 64);
sph_groestl512_close(&garden->groestl, hash);
#endif
break;
case 6:
sph_hamsi512_init(&garden->hamsi);
sph_hamsi512(&garden->hamsi, input, 64);
sph_hamsi512_close(&garden->hamsi, hash);
break;
case 7:
SHA512_Init( &garden->sha512 );
SHA512_Update( &garden->sha512, input, 64 );
SHA512_Final( (unsigned char*)hash, &garden->sha512 );
break;
case 8:
sph_jh512_init(&garden->jh);
sph_jh512(&garden->jh, input, 64);
sph_jh512_close(&garden->jh, hash);
break;
case 9:
sph_keccak512_init(&garden->keccak);
sph_keccak512(&garden->keccak, input, 64);
sph_keccak512_close(&garden->keccak, hash);
break;
case 10:
init_luffa( &garden->luffa, 512 );
update_and_final_luffa( &garden->luffa, (BitSequence*)hash,
(const BitSequence*)input, 64 );
break;
case 11:
sph_shabal512_init(&garden->shabal);
sph_shabal512(&garden->shabal, input, 64);
sph_shabal512_close(&garden->shabal, hash);
break;
case 12:
sph_shavite512_init(&garden->shavite);
sph_shavite512(&garden->shavite, input, 64);
sph_shavite512_close(&garden->shavite, hash);
break;
case 13:
init_sd( &garden->simd, 512 );
update_final_sd( &garden->simd, (BitSequence *)hash,
(const BitSequence*)input, 512 );
break;
case 14:
sph_skein512_init(&garden->skein);
sph_skein512(&garden->skein, input, 64);
sph_skein512_close(&garden->skein, hash);
break;
case 15:
sph_whirlpool_init(&garden->whirlpool);
sph_whirlpool(&garden->whirlpool, input, 64);
sph_whirlpool_close(&garden->whirlpool, hash);
break;
}
// Output the hash
memcpy(output, hash, 64);
}
// Recursively traverse a given torture garden starting with a given hash and given node within the garden. The hash is overwritten with the final hash.
static void traverse_garden( TortureGarden *garden, void *hash,
TortureNode *node )
{
unsigned char partialHash[64] __attribute__ ((aligned (64)));
get_hash(partialHash, hash, garden, node->algo);
if ( partialHash[63] % 2 == 0 )
{ // Last byte of output hash is even
if ( node->childLeft != NULL )
traverse_garden( garden, partialHash, node->childLeft );
}
else
{ // Last byte of output hash is odd
if ( node->childRight != NULL )
traverse_garden( garden, partialHash, node->childRight );
}
memcpy( hash, partialHash, 64 );
}
// Associate child nodes with a parent node
static inline void link_nodes( TortureNode *parent, TortureNode *childLeft,
TortureNode *childRight )
{
parent->childLeft = childLeft;
parent->childRight = childRight;
}
static __thread TortureGarden garden;
bool initialize_torture_garden()
{
// Create torture garden nodes. Note that both sides of 19 and 20 lead to 21, and 21 has no children (to make traversal complete).
link_nodes(&garden.nodes[0], &garden.nodes[1], &garden.nodes[2]);
link_nodes(&garden.nodes[1], &garden.nodes[3], &garden.nodes[4]);
link_nodes(&garden.nodes[2], &garden.nodes[5], &garden.nodes[6]);
link_nodes(&garden.nodes[3], &garden.nodes[7], &garden.nodes[8]);
link_nodes(&garden.nodes[4], &garden.nodes[9], &garden.nodes[10]);
link_nodes(&garden.nodes[5], &garden.nodes[11], &garden.nodes[12]);
link_nodes(&garden.nodes[6], &garden.nodes[13], &garden.nodes[14]);
link_nodes(&garden.nodes[7], &garden.nodes[15], &garden.nodes[16]);
link_nodes(&garden.nodes[8], &garden.nodes[15], &garden.nodes[16]);
link_nodes(&garden.nodes[9], &garden.nodes[15], &garden.nodes[16]);
link_nodes(&garden.nodes[10], &garden.nodes[15], &garden.nodes[16]);
link_nodes(&garden.nodes[11], &garden.nodes[17], &garden.nodes[18]);
link_nodes(&garden.nodes[12], &garden.nodes[17], &garden.nodes[18]);
link_nodes(&garden.nodes[13], &garden.nodes[17], &garden.nodes[18]);
link_nodes(&garden.nodes[14], &garden.nodes[17], &garden.nodes[18]);
link_nodes(&garden.nodes[15], &garden.nodes[19], &garden.nodes[20]);
link_nodes(&garden.nodes[16], &garden.nodes[19], &garden.nodes[20]);
link_nodes(&garden.nodes[17], &garden.nodes[19], &garden.nodes[20]);
link_nodes(&garden.nodes[18], &garden.nodes[19], &garden.nodes[20]);
link_nodes(&garden.nodes[19], &garden.nodes[21], &garden.nodes[21]);
link_nodes(&garden.nodes[20], &garden.nodes[21], &garden.nodes[21]);
garden.nodes[21].childLeft = NULL;
garden.nodes[21].childRight = NULL;
return true;
}
// Produce a 32-byte hash from 80-byte input data
int minotaur_hash( void *output, const void *input )
{
unsigned char hash[64] __attribute__ ((aligned (64)));
// Find initial sha512 hash
SHA512_Init( &garden.sha512 );
SHA512_Update( &garden.sha512, input, 80 );
SHA512_Final( (unsigned char*) hash, &garden.sha512 );
// Assign algos to torture garden nodes based on initial hash
for ( int i = 0; i < 22; i++ )
garden.nodes[i].algo = hash[i] % MINOTAUR_ALGO_COUNT;
// Send the initial hash through the torture garden
traverse_garden( &garden, hash, &garden.nodes[0] );
memcpy( output, hash, 32 );
return 1;
}
bool register_minotaur_algo( algo_gate_t* gate )
{
gate->hash = (void*)&minotaur_hash;
gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT;
gate->miner_thread_init = (void*)&initialize_torture_garden;
return true;
};

View File

@@ -4,14 +4,14 @@ bool register_sonoa_algo( algo_gate_t* gate )
{
#if defined (SONOA_8WAY)
gate->scanhash = (void*)&scanhash_sonoa_8way;
// gate->hash = (void*)&sonoa_8way_hash;
gate->hash = (void*)&sonoa_8way_hash;
#elif defined (SONOA_4WAY)
gate->scanhash = (void*)&scanhash_sonoa_4way;
// gate->hash = (void*)&sonoa_4way_hash;
gate->hash = (void*)&sonoa_4way_hash;
#else
init_sonoa_ctx();
gate->scanhash = (void*)&scanhash_sonoa;
// gate->hash = (void*)&sonoa_hash;
// gate->scanhash = (void*)&scanhash_sonoa;
gate->hash = (void*)&sonoa_hash;
#endif
gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT;
return true;

View File

@@ -569,34 +569,4 @@ int sonoa_hash( void *state, const void *input, int thrid )
return 1;
}
int scanhash_sonoa( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr)
{
uint32_t edata[20] __attribute__((aligned(64)));
uint32_t hash64[8] __attribute__((aligned(64)));
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
uint32_t n = pdata[19];
const uint32_t first_nonce = pdata[19];
const int thr_id = mythr->id;
const bool bench = opt_benchmark;
mm128_bswap32_80( edata, pdata );
do
{
edata[19] = n;
if ( sonoa_hash( hash64, edata, thr_id ) )
if ( unlikely( valid_hash( hash64, ptarget ) && !bench ) )
{
pdata[19] = bswap_32( n );
submit_solution( work, hash64, mythr );
}
n++;
} while ( n < max_nonce && !work_restart[thr_id].restart );
*hashes_done = n - first_nonce;
pdata[19] = n;
return 0;
}
#endif

View File

@@ -57,7 +57,7 @@ union _x17_8way_context_overlay
} __attribute__ ((aligned (64)));
typedef union _x17_8way_context_overlay x17_8way_context_overlay;
void x17_8way_hash( void *state, const void *input )
int x17_8way_hash( void *state, const void *input )
{
uint64_t vhash[8*8] __attribute__ ((aligned (128)));
uint64_t vhashA[8*8] __attribute__ ((aligned (64)));
@@ -230,6 +230,8 @@ void x17_8way_hash( void *state, const void *input )
haval256_5_8way_init( &ctx.haval );
haval256_5_8way_update( &ctx.haval, vhashA, 64 );
haval256_5_8way_close( &ctx.haval, state );
return 1;
}
int scanhash_x17_8way( struct work *work, uint32_t max_nonce,
@@ -300,7 +302,7 @@ union _x17_4way_context_overlay
};
typedef union _x17_4way_context_overlay x17_4way_context_overlay;
void x17_4way_hash( void *state, const void *input )
int x17_4way_hash( void *state, const void *input )
{
uint64_t vhash[8*4] __attribute__ ((aligned (64)));
uint64_t vhashA[8*4] __attribute__ ((aligned (64)));
@@ -399,6 +401,8 @@ void x17_4way_hash( void *state, const void *input )
haval256_5_4way_init( &ctx.haval );
haval256_5_4way_update( &ctx.haval, vhashB, 64 );
haval256_5_4way_close( &ctx.haval, state );
return 1;
}
int scanhash_x17_4way( struct work *work, uint32_t max_nonce,

View File

@@ -9,7 +9,6 @@ bool register_x17_algo( algo_gate_t* gate )
gate->scanhash = (void*)&scanhash_x17_4way;
gate->hash = (void*)&x17_4way_hash;
#else
gate->scanhash = (void*)&scanhash_x17;
gate->hash = (void*)&x17_hash;
#endif
gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT;

View File

@@ -14,20 +14,18 @@ bool register_x17_algo( algo_gate_t* gate );
#if defined(X17_8WAY)
void x17_8way_hash( void *state, const void *input );
int x17_8way_hash( void *state, const void *input );
int scanhash_x17_8way( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
#elif defined(X17_4WAY)
void x17_4way_hash( void *state, const void *input );
int x17_4way_hash( void *state, const void *input );
int scanhash_x17_4way( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
#endif
void x17_hash( void *state, const void *input );
int scanhash_x17( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
int x17_hash( void *state, const void *input, int thr_id );
#endif

View File

@@ -56,7 +56,7 @@ union _x17_context_overlay
};
typedef union _x17_context_overlay x17_context_overlay;
void x17_hash(void *output, const void *input)
int x17_hash(void *output, const void *input, int thr_id )
{
// unsigned char hash[64 * 4] __attribute__((aligned(64))) = {0};
unsigned char hash[64] __attribute__((aligned(64)));
@@ -143,36 +143,8 @@ void x17_hash(void *output, const void *input)
sph_haval256_5_init(&ctx.haval);
sph_haval256_5( &ctx.haval, (const void*)hash, 64 );
sph_haval256_5_close( &ctx.haval, output );
}
int scanhash_x17( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr)
{
uint32_t edata[20] __attribute__((aligned(64)));
uint32_t hash64[8] __attribute__((aligned(64)));
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
uint32_t n = pdata[19] - 1;
const uint32_t first_nonce = pdata[19];
const int thr_id = mythr->id;
const bool bench = opt_benchmark;
mm128_bswap32_80( edata, pdata );
do
{
edata[19] = n;
x17_hash( hash64, edata );
if ( unlikely( valid_hash( hash64, ptarget ) && !bench ) )
{
pdata[19] = bswap_32( n );
submit_solution( work, hash64, mythr );
}
n++;
} while ( n < max_nonce && !work_restart[thr_id].restart );
*hashes_done = n - first_nonce;
pdata[19] = n;
return 0;
return 1;
}
#endif

View File

@@ -57,7 +57,7 @@ union _xevan_8way_context_overlay
} __attribute__ ((aligned (64)));
typedef union _xevan_8way_context_overlay xevan_8way_context_overlay;
void xevan_8way_hash( void *output, const void *input )
int xevan_8way_hash( void *output, const void *input )
{
uint64_t vhash[16<<3] __attribute__ ((aligned (128)));
uint64_t vhashA[16<<3] __attribute__ ((aligned (64)));
@@ -395,6 +395,8 @@ void xevan_8way_hash( void *output, const void *input )
haval256_5_8way_init( &ctx.haval );
haval256_5_8way_update( &ctx.haval, vhashA, dataLen );
haval256_5_8way_close( &ctx.haval, output );
return 1;
}
int scanhash_xevan_8way( struct work *work, uint32_t max_nonce,
@@ -465,7 +467,7 @@ union _xevan_4way_context_overlay
};
typedef union _xevan_4way_context_overlay xevan_4way_context_overlay;
void xevan_4way_hash( void *output, const void *input )
int xevan_4way_hash( void *output, const void *input )
{
uint64_t hash0[16] __attribute__ ((aligned (64)));
uint64_t hash1[16] __attribute__ ((aligned (64)));
@@ -540,10 +542,10 @@ void xevan_4way_hash( void *output, const void *input )
dintrlv_4x64( hash0, hash1, hash2, hash3, vhash, dataLen<<3 );
sph_fugue512_full( &ctx.fugue, hash0, hash0, 64 );
sph_fugue512_full( &ctx.fugue, hash1, hash1, 64 );
sph_fugue512_full( &ctx.fugue, hash2, hash2, 64 );
sph_fugue512_full( &ctx.fugue, hash3, hash3, 64 );
sph_fugue512_full( &ctx.fugue, hash0, hash0, dataLen );
sph_fugue512_full( &ctx.fugue, hash1, hash1, dataLen );
sph_fugue512_full( &ctx.fugue, hash2, hash2, dataLen );
sph_fugue512_full( &ctx.fugue, hash3, hash3, dataLen );
// Parallel 4way 32 bit
intrlv_4x32( vhash, hash0, hash1, hash2, hash3, dataLen<<3 );
@@ -637,10 +639,10 @@ void xevan_4way_hash( void *output, const void *input )
dintrlv_4x64( hash0, hash1, hash2, hash3, vhash, dataLen<<3 );
sph_fugue512_full( &ctx.fugue, hash0, hash0, 64 );
sph_fugue512_full( &ctx.fugue, hash1, hash1, 64 );
sph_fugue512_full( &ctx.fugue, hash2, hash2, 64 );
sph_fugue512_full( &ctx.fugue, hash3, hash3, 64 );
sph_fugue512_full( &ctx.fugue, hash0, hash0, dataLen );
sph_fugue512_full( &ctx.fugue, hash1, hash1, dataLen );
sph_fugue512_full( &ctx.fugue, hash2, hash2, dataLen );
sph_fugue512_full( &ctx.fugue, hash3, hash3, dataLen );
intrlv_4x32( vhash, hash0, hash1, hash2, hash3, dataLen<<3 );
@@ -666,6 +668,8 @@ void xevan_4way_hash( void *output, const void *input )
haval256_5_4way_init( &ctx.haval );
haval256_5_4way_update( &ctx.haval, vhashA, dataLen );
haval256_5_4way_close( &ctx.haval, output );
return 1;
}
int scanhash_xevan_4way( struct work *work, uint32_t max_nonce,

View File

@@ -10,7 +10,6 @@ bool register_xevan_algo( algo_gate_t* gate )
gate->hash = (void*)&xevan_4way_hash;
#else
init_xevan_ctx();
gate->scanhash = (void*)&scanhash_xevan;
gate->hash = (void*)&xevan_hash;
#endif
gate->optimizations = SSE2_OPT | AES_OPT | AVX2_OPT | AVX512_OPT | VAES_OPT;

View File

@@ -14,14 +14,12 @@ bool register_xevan_algo( algo_gate_t* gate );
#if defined(XEVAN_8WAY)
void xevan_8way_hash( void *state, const void *input );
int xevan_8way_hash( void *state, const void *input );
int scanhash_xevan_8way( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
#elif defined(XEVAN_4WAY)
void xevan_4way_hash( void *state, const void *input );
int xevan_4way_hash( void *state, const void *input );
int scanhash_xevan_4way( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
@@ -29,11 +27,7 @@ int scanhash_xevan_4way( struct work *work, uint32_t max_nonce,
#else
void xevan_hash( void *state, const void *input );
int scanhash_xevan( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );
int xevan_hash( void *state, const void *input, int trh_id );
void init_xevan_ctx();
#endif

View File

@@ -83,7 +83,7 @@ void init_xevan_ctx()
#endif
};
void xevan_hash(void *output, const void *input)
int xevan_hash(void *output, const void *input, int thr_id )
{
uint32_t _ALIGN(64) hash[32]; // 128 bytes required
const int dataLen = 128;
@@ -218,36 +218,8 @@ void xevan_hash(void *output, const void *input)
sph_haval256_5_close(&ctx.haval, hash);
memcpy(output, hash, 32);
}
int scanhash_xevan( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr)
{
uint32_t edata[20] __attribute__((aligned(64)));
uint32_t hash64[8] __attribute__((aligned(64)));
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
uint32_t n = pdata[19];
const uint32_t first_nonce = pdata[19];
const int thr_id = mythr->id;
const bool bench = opt_benchmark;
mm128_bswap32_80( edata, pdata );
do
{
edata[19] = n;
xevan_hash( hash64, edata );
if ( unlikely( valid_hash( hash64, ptarget ) && !bench ) )
{
pdata[19] = bswap_32( n );
submit_solution( work, hash64, mythr );
}
n++;
} while ( n < max_nonce && !work_restart[thr_id].restart );
pdata[19] = n;
*hashes_done = n - first_nonce;
return 0;
return 1;
}
#endif

View File

@@ -445,7 +445,7 @@ bool register_yescrypt_algo( algo_gate_t* gate )
YESCRYPT_P = 1;
applog( LOG_NOTICE,"Yescrypt parameters: N= %d, R= %d.", YESCRYPT_N,
applog( LOG_NOTICE,"Yescrypt parameters: N= %d, R= %d", YESCRYPT_N,
YESCRYPT_R );
if ( yescrypt_client_key )
applog( LOG_NOTICE,"Key= \"%s\"\n", yescrypt_client_key );

View File

@@ -139,7 +139,7 @@ bool register_yespower_algo( algo_gate_t* gate )
yespower_params.perslen = 0;
}
applog( LOG_NOTICE,"Yespower parameters: N= %d, R= %d.", yespower_params.N,
applog( LOG_NOTICE,"Yespower parameters: N= %d, R= %d", yespower_params.N,
yespower_params.r );
if ( yespower_params.pers )
applog( LOG_NOTICE,"Key= \"%s\"\n", yespower_params.pers );
@@ -264,7 +264,7 @@ bool register_power2b_algo( algo_gate_t* gate )
yespower_params.pers = "Now I am become Death, the destroyer of worlds";
yespower_params.perslen = 46;
applog( LOG_NOTICE,"yespower-b2b parameters: N= %d, R= %d.", yespower_params.N,
applog( LOG_NOTICE,"yespower-b2b parameters: N= %d, R= %d", yespower_params.N,
yespower_params.r );
applog( LOG_NOTICE,"Key= \"%s\"", yespower_params.pers );
applog( LOG_NOTICE,"Key length= %d\n", yespower_params.perslen );

View File

@@ -76,7 +76,7 @@ typedef struct {
unsigned char uc[32];
} yespower_binary_t __attribute__ ((aligned (64)));
yespower_params_t yespower_params;
extern yespower_params_t yespower_params;
//SHA256_CTX sha256_prehash_ctx;
extern __thread SHA256_CTX sha256_prehash_ctx;

View File

@@ -9,15 +9,15 @@ rm cpuminer-avx512-sha-vaes cpuminer-avx512 cpuminer-avx2 cpuminer-aes-avx cpumi
make distclean || echo clean
rm -f config.status
./autogen.sh || echo done
CFLAGS="-O3 -march=icelake-client -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -march=icelake-client -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-avx512-sha-vaes.exe
strip -s cpuminer
mv cpuminer cpuminer-avx512-sha-vaes
CFLAGS="-O3 -march=skylake-avx512 -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -march=skylake-avx512 -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-avx512.exe
strip -s cpuminer
@@ -26,8 +26,8 @@ mv cpuminer cpuminer-avx512
make clean || echo clean
rm -f config.status
# GCC 9 doesn't include AES with core-avx2
CFLAGS="-O3 -march=core-avx2 -maes -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -march=core-avx2 -maes -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-avx2.exe
strip -s cpuminer
@@ -35,17 +35,17 @@ mv cpuminer cpuminer-avx2
make clean || echo clean
rm -f config.status
CFLAGS="-O3 -march=corei7-avx -maes -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -march=corei7-avx -maes -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-avx.exe
strip -s cpuminer
mv cpuminer cpuminer-aes-avx
mv cpuminer cpuminer-avx
make clean || echo clean
rm -f config.status
CFLAGS="-O3 -maes -msse4.2 -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -maes -msse4.2 -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-aes-sse42.exe
strip -s cpuminer
@@ -53,8 +53,8 @@ mv cpuminer cpuminer-aes-sse42
#make clean || echo clean
#rm -f config.status
#CFLAGS="-O3 -march=corei7 -Wall" ./configure --with-curl
#make -j 16
#CFLAGS="-O3 -march=corei7 -Wall -fno-common" ./configure --with-curl
#make -j 8
#strip -s cpuminer.exe
#mv cpuminer.exe cpuminer-sse42.exe
#strip -s cpuminer
@@ -62,8 +62,8 @@ mv cpuminer cpuminer-aes-sse42
#make clean || echo clean
#rm -f config.status
#CFLAGS="-O3 -march=core2 -Wall" ./configure --with-curl
#make -j 16
#CFLAGS="-O3 -march=core2 -Wall -fno-common" ./configure --with-curl
#make -j 8
#strip -s cpuminer.exe
#mv cpuminer.exe cpuminer-ssse3.exe
#strip -s cpuminer
@@ -71,8 +71,8 @@ mv cpuminer cpuminer-aes-sse42
make clean || echo clean
rm -f config.status
CFLAGS="-O3 -msse2 -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -msse2 -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-sse2.exe
strip -s cpuminer
@@ -80,8 +80,8 @@ mv cpuminer cpuminer-sse2
make clean || echo done
rm -f config.status
CFLAGS="-O3 -march=znver1 -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -march=znver1 -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe cpuminer-zen.exe
strip -s cpuminer
@@ -89,8 +89,8 @@ mv cpuminer cpuminer-zen
make clean || echo done
rm -f config.status
CFLAGS="-O3 -march=native -Wall" ./configure --with-curl
make -j 16
CFLAGS="-O3 -march=native -Wall -fno-common" ./configure --with-curl
make -j 8
strip -s cpuminer.exe
strip -s cpuminer

27
build-no-common.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
#if [ "$OS" = "Windows_NT" ]; then
# ./mingw64.sh
# exit 0
#fi
# Linux build
make distclean || echo clean
rm -f config.status
./autogen.sh || echo done
# Ubuntu 10.04 (gcc 4.4)
# extracflags="-O3 -march=native -Wall -D_REENTRANT -funroll-loops -fvariable-expansion-in-unroller -fmerge-all-constants -fbranch-target-load-optimize2 -fsched2-use-superblocks -falign-loops=16 -falign-functions=16 -falign-jumps=16 -falign-labels=16"
# Debian 7.7 / Ubuntu 14.04 (gcc 4.7+)
#extracflags="$extracflags -Ofast -flto -fuse-linker-plugin -ftree-loop-if-convert-stores"
#CFLAGS="-O3 -march=native -Wall" ./configure --with-curl --with-crypto=$HOME/usr
CFLAGS="-O3 -march=native -Wall -fno-common" ./configure --with-curl
#CFLAGS="-O3 -march=native -Wall" CXXFLAGS="$CFLAGS -std=gnu++11" ./configure --with-curl
make -j 4
strip -s cpuminer

View File

@@ -3,8 +3,8 @@
# imake clean and rm all the targetted executables.
# tips to users.
rm cpuminer-avx512-sha-vaes cpuminer-avx512 cpuminer-avx2 cpuminer-aes-avx cpuminer-aes-sse42 cpuminer-sse2 cpuminer-zen > /dev/null
rm cpuminer-avx512-sha-vaes cpuminer-avx512 cpuminer-avx2 cpuminer-avx cpuminer-aes-sse42 cpuminer-sse2 cpuminer-zen > /dev/null
rm cpuminer-avx512-sha-vaes.exe cpuminer-avx512.exe cpuminer-avx2.exe cpuminer-aes-avx.exe cpuminer-aes-sse42.exe cpuminer-sse2.exe cpuminer-zen.exe > /dev/null
rm cpuminer-avx512-sha-vaes.exe cpuminer-avx512.exe cpuminer-avx2.exe cpuminer-avx.exe cpuminer-aes-sse42.exe cpuminer-sse2.exe cpuminer-zen.exe > /dev/null
make distclean > /dev/null

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.13.0.
# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.14.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.13.0'
PACKAGE_STRING='cpuminer-opt 3.13.0'
PACKAGE_VERSION='3.14.1'
PACKAGE_STRING='cpuminer-opt 3.14.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.13.0 to adapt to many kinds of systems.
\`configure' configures cpuminer-opt 3.14.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.13.0:";;
short | recursive ) echo "Configuration of cpuminer-opt 3.14.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.13.0
cpuminer-opt configure 3.14.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.13.0, which was
It was created by cpuminer-opt $as_me 3.14.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.13.0'
VERSION='3.14.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.13.0, which was
This file was extended by cpuminer-opt $as_me 3.14.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.13.0
cpuminer-opt config.status 3.14.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.13.0])
AC_INIT([cpuminer-opt], [3.14.1])
AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM

View File

@@ -2,8 +2,8 @@
* Copyright 2010 Jeff Garzik
* Copyright 2012-2014 pooler
* Copyright 2014 Lucas Jones
* Copyright 2014 Tanguy Pruvot
* Copyright 2016 Jay D Dee
* Copyright 2014-2016 Tanguy Pruvot
* Copyright 2016-2020 Jay D Dee
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@@ -55,9 +55,12 @@
#endif
// GCC 9 warning sysctl.h is deprecated
#if ( __GNUC__ < 9 )
#include <sys/sysctl.h>
#endif
#endif
#endif // HAVE_SYS_SYSCTL_H
#endif // _MSC_VER ELSE
#ifndef WIN32
#include <sys/resource.h>
@@ -85,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;
@@ -491,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" );
@@ -560,6 +563,23 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
json_t *tmp, *txa;
bool rc = false;
// 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 )
continue;
if ( !strcmp( s, "segwit" ) || !strcmp( s, "!segwit" ) )
segwit = true;
}
}
// Segwit END
tmp = json_object_get( val, "mutable" );
if ( tmp && json_is_array( tmp ) )
{
@@ -583,7 +603,6 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
goto out;
}
work->height = (int) json_integer_value( tmp );
applog( LOG_BLUE, "Current block is %d", work->height );
tmp = json_object_get(val, "version");
if ( !tmp || !json_is_integer( tmp ) )
@@ -592,7 +611,6 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
goto out;
}
version = (uint32_t) json_integer_value( tmp );
// yescryptr8g uses block version 5 and sapling.
if ( opt_sapling )
work->sapling = true;
@@ -718,13 +736,61 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
cbtx[41] = cbtx_size - 42; /* scriptsig length */
le32enc( (uint32_t *)( cbtx+cbtx_size ), 0xffffffff ); /* sequence */
cbtx_size += 4;
cbtx[ cbtx_size++ ] = 1; /* out-counter */
// Segwit BEGIN
//cbtx[cbtx_size++] = 1; /* out-counter */
cbtx[cbtx_size++] = segwit ? 2 : 1; /* out-counter */
// Segwit END
le32enc( (uint32_t *)( cbtx+cbtx_size) , (uint32_t)cbvalue ); /* value */
le32enc( (uint32_t *)( cbtx+cbtx_size+4 ), cbvalue >> 32 );
cbtx_size += 8;
cbtx[ cbtx_size++ ] = (uint8_t) pk_script_size; /* txout-script length */
memcpy( cbtx+cbtx_size, pk_script, pk_script_size );
cbtx_size += (int) pk_script_size;
// Segwit BEGIN
if ( segwit )
{
unsigned char (*wtree)[32] = calloc(tx_count + 2, 32);
memset(cbtx+cbtx_size, 0, 8); /* value */
cbtx_size += 8;
cbtx[cbtx_size++] = 38; /* txout-script length */
cbtx[cbtx_size++] = 0x6a; /* txout-script */
cbtx[cbtx_size++] = 0x24;
cbtx[cbtx_size++] = 0xaa;
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 ) )
{
applog(LOG_ERR, "JSON invalid transaction hash");
free(wtree);
goto out;
}
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 );
}
memset( wtree[1], 0, 32 ); /* witness reserved value = 0 */
sha256d( cbtx+cbtx_size, wtree[0], 64 );
cbtx_size += 32;
free( wtree );
}
// Segwit END
le32enc( (uint32_t *)( cbtx+cbtx_size ), 0 ); /* lock time */
cbtx_size += 4;
coinbase_append = true;
@@ -792,21 +858,43 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
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 );
const char *tx_hex = json_string_value( json_object_get( tmp, "data" ) );
const int tx_size = tx_hex ? (int) ( strlen( tx_hex ) / 2 ) : 0;
unsigned char *tx = (uchar*) malloc( tx_size );
if ( !tx_hex || !hex2bin( tx, tx_hex, tx_size ) )
// Segwit BEGIN
if ( segwit )
{
applog( LOG_ERR, "JSON invalid transactions" );
free( tx );
goto out;
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 );
}
sha256d( merkle_tree[1 + i], tx, tx_size );
else
{
// Segwit END
unsigned char *tx = (uchar*) malloc( tx_size );
if ( !tx_hex || !hex2bin( tx, tx_hex, tx_size ) )
{
applog( LOG_ERR, "JSON invalid transactions" );
free( tx );
goto out;
}
sha256d( merkle_tree[1 + i], tx, tx_size );
free( tx );
// Segwit BEGIN
}
// Segwit END
if ( !submit_coinbase )
strcat( work->txs, tx_hex );
}
@@ -1402,12 +1490,24 @@ const char *getwork_req =
#define GBT_CAPABILITIES "[\"coinbasetxn\", \"coinbasevalue\", \"longpoll\", \"workid\"]"
// Segwit BEGIN
#define GBT_RULES "[\"segwit\"]"
static const char *gbt_req =
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
GBT_CAPABILITIES ", \"rules\": " GBT_RULES "}], \"id\":0}\r\n";
const char *gbt_lp_req =
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
GBT_CAPABILITIES ", \"rules\": " GBT_RULES ", \"longpollid\": \"%s\"}], \"id\":0}\r\n";
/*
static const char *gbt_req =
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
GBT_CAPABILITIES "}], \"id\":0}\r\n";
const char *gbt_lp_req =
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
GBT_CAPABILITIES ", \"longpollid\": \"%s\"}], \"id\":0}\r\n";
*/
// Segwit END
static bool get_upstream_work( CURL *curl, struct work *work )
{
@@ -1465,27 +1565,32 @@ start:
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,
bswap_32( work->data[ algo_gate.ntime_index ] ) );
last_targetdiff = net_diff;
if ( !opt_quiet && net_diff && net_hashrate )
applog( LOG_BLUE, "New Block %d, Net Diff %.5g, Ntime %08x",
work->height, net_diff,
work->data[ algo_gate.ntime_index ] );
if ( !opt_quiet && ( net_diff > 0. ) && ( net_hashrate > 0. ) )
{
double miner_hr = 0.;
pthread_mutex_lock( &stats_lock );
for ( int i = 0; i < opt_n_threads; i++ )
@@ -1494,7 +1599,7 @@ start:
pthread_mutex_unlock( &stats_lock );
if ( miner_hr )
if ( miner_hr > 0. )
{
double net_hr = net_hashrate;
char net_hr_units[4] = {0};
@@ -1502,20 +1607,21 @@ start:
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,
"Miner TTF @ %.2f %sh/s %s, Net TTF @ %.2f %sh/s %s",
miner_hr, miner_hr_units, miner_ttf,
net_hr, net_hr_units, net_ttf );
miner_hr, miner_hr_units, miner_ttf, net_hr,
net_hr_units, net_ttf );
}
}
} // work->height > last_block_height
else if ( memcmp( &work->data[1], &g_work.data[1], 32 ) )
applog( LOG_BLUE, "New Work, Ntime %08lx",
bswap_32( work->data[ algo_gate.ntime_index ] ) );
applog( LOG_BLUE, "New Work: Block %d, Net Diff %.5g, Ntime %08x",
work->height, net_diff,
work->data[ algo_gate.ntime_index ] );
} // rc
return rc;
@@ -1915,13 +2021,14 @@ static void 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 Diff %g, Block %d, Job %s",
applog( LOG_BLUE, "New Stratum Diff %g, Block %d, Job %s",
sctx->job.diff, sctx->block_height, g_work->job_id );
else if ( last_block_height != sctx->block_height )
applog( LOG_BLUE, "New Block %d, Job %s",
sctx->block_height, g_work->job_id );
else if ( g_work->job_id )
applog( LOG_BLUE,"New Job %s", g_work->job_id );
applog( LOG_BLUE, "New Work: Block %d, Net diff %.5g, Job %s",
sctx->block_height, net_diff, g_work->job_id );
// Update data and calculate new estimates.
if ( ( stratum_diff != sctx->job.diff )
@@ -1965,10 +2072,8 @@ static void stratum_gen_work( struct stratum_ctx *sctx, struct work *g_work )
if ( net_diff && net_ttf )
{
double net_hr = net_diff * exp32 / net_ttf;
// char net_ttf_str[32];
char net_hr_units[4] = {0};
// sprintf_et( net_ttf_str, net_ttf );
scale_hash_for_display ( &net_hr, net_hr_units );
applog2( LOG_INFO, "Net hash rate (est) %.2f %sh/s",
net_hr, net_hr_units );
@@ -3214,7 +3319,7 @@ 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");
}

31
miner.h
View File

@@ -313,6 +313,10 @@ size_t address_to_script( unsigned char *out, size_t outsz, const char *addr );
int timeval_subtract( struct timeval *result, struct timeval *x,
struct timeval *y);
// Segwit BEGIN
extern void memrev(unsigned char *p, size_t len);
// Segwit END
// Bitcoin formula for converting difficulty to an equivalent
// number of hashes.
//
@@ -324,12 +328,12 @@ int timeval_subtract( struct timeval *result, struct timeval *x,
#define EXP16 65536.
#define EXP32 4294967296.
const long double exp32; // 2**32
const long double exp48; // 2**48
const long double exp64; // 2**64
const long double exp96; // 2**96
const long double exp128; // 2**128
const long double exp160; // 2**160
extern const long double exp32; // 2**32
extern const long double exp48; // 2**48
extern const long double exp64; // 2**64
extern const long double exp96; // 2**96
extern const long double exp128; // 2**128
extern const long double exp160; // 2**160
bool fulltest( const uint32_t *hash, const uint32_t *target );
bool valid_hash( const void*, const void* );
@@ -551,15 +555,16 @@ enum algos {
ALGO_LYRA2RE,
ALGO_LYRA2REV2,
ALGO_LYRA2REV3,
ALGO_LYRA2Z,
ALGO_LYRA2Z,
ALGO_LYRA2Z330,
ALGO_M7M,
ALGO_M7M,
ALGO_MINOTAUR,
ALGO_MYR_GR,
ALGO_NEOSCRYPT,
ALGO_NIST5,
ALGO_PENTABLAKE,
ALGO_PHI1612,
ALGO_PHI2,
ALGO_PHI2,
ALGO_POLYTIMOS,
ALGO_POWER2B,
ALGO_QUARK,
@@ -642,10 +647,11 @@ static const char* const algo_names[] = {
"lyra2re",
"lyra2rev2",
"lyra2rev3",
"lyra2z",
"lyra2z",
"lyra2z330",
"m7m",
"myr-gr",
"minotaur",
"myr-gr",
"neoscrypt",
"nist5",
"pentablake",
@@ -802,7 +808,8 @@ Options:\n\
lyra2z330 Lyra2 330 rows\n\
m7m Magi (XMG)\n\
myr-gr Myriad-Groestl\n\
neoscrypt NeoScrypt(128, 2, 1)\n\
minotaur Ringcoin (RNG)\n\
neoscrypt NeoScrypt(128, 2, 1)\n\
nist5 Nist5\n\
pentablake 5 x blake512\n\
phi1612 phi\n\

13
util.c
View File

@@ -747,6 +747,19 @@ err_out:
return cfg;
}
// Segwit BEGIN
void memrev(unsigned char *p, size_t len)
{
unsigned char c, *q;
for (q = p + len - 1; p < q; p++, q--) {
c = *p;
*p = *q;
*q = c;
}
}
// Segwit END
void cbin2hex(char *out, const char *in, size_t len)
{
if (out) {

View File

@@ -44,14 +44,14 @@ cp $LOCAL_LIB/curl/lib/.libs/libcurl-4.dll release/
rm -f config.status
./autogen.sh || echo done
CFLAGS="-O3 -march=icelake-client -Wall" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-avx512-sha-vaes.exe
make clean || echo clean
rm -f config.status
CFLAGS="-O3 -march=znver1 -Wall" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-zen.exe
@@ -60,7 +60,7 @@ make clean || echo clean
rm -f config.status
CFLAGS="-O3 -march=skylake-avx512 -Wall" ./configure $CONFIGURE_ARGS
#CFLAGS="-O3 -march=skylake-avx512 -Wall -fno-asynchronous-unwind-tables" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-avx512.exe
@@ -68,7 +68,7 @@ make clean || echo clean
rm -f config.status
# GCC 9 doesn't include AES in -march=core-avx2
CFLAGS="-O3 -march=core-avx2 -maes -Wall" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-avx2.exe
@@ -76,7 +76,7 @@ make clean || echo clean
rm -f config.status
# -march=corei7-avx still includes aes, but just in case
CFLAGS="-O3 -march=corei7-avx -maes -Wall" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-avx.exe
@@ -85,7 +85,7 @@ make clean || echo clean
rm -f config.status
CFLAGS="-O3 -march=westmere -Wall" ./configure $CONFIGURE_ARGS
#CFLAGS="-O3 -maes -msse4.2 -Wall" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-aes-sse42.exe
@@ -107,7 +107,7 @@ mv cpuminer.exe release/cpuminer-aes-sse42.exe
make clean || echo clean
rm -f config.status
CFLAGS="-O3 -msse2 -Wall" ./configure $CONFIGURE_ARGS
make -j 16
make -j 8
strip -s cpuminer.exe
mv cpuminer.exe release/cpuminer-sse2.exe
make clean || echo clean