v3.13.2-segwit-test

This commit is contained in:
Jay D Dee
2020-05-18 18:17:27 -04:00
parent 9653bca1e2
commit 0e69756634
6 changed files with 149 additions and 18 deletions

View File

@@ -65,6 +65,14 @@ If not what makes it happen or not happen?
Change Log Change Log
---------- ----------
v3.13.2-segwit-test
Added support for SegWit.
This is a test release, it may contain bugs and additional debug logging.
Solo miners are invited to test it and report their results. Other users
may want to wait for the next general release before upgrading.
v3.13.1.1 v3.13.1.1
Fixed Windows crash mining minotaur algo. Fixed Windows crash mining minotaur algo.

20
configure vendored
View File

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

View File

@@ -1,4 +1,4 @@
AC_INIT([cpuminer-opt], [3.13.1.1]) AC_INIT([cpuminer-opt], [3.13.2-segwit-test])
AC_PREREQ([2.59c]) AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM

View File

@@ -563,6 +563,23 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
json_t *tmp, *txa; json_t *tmp, *txa;
bool rc = false; 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
if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled");
tmp = json_object_get( val, "mutable" ); tmp = json_object_get( val, "mutable" );
if ( tmp && json_is_array( tmp ) ) if ( tmp && json_is_array( tmp ) )
{ {
@@ -596,6 +613,8 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
} }
version = (uint32_t) json_integer_value( tmp ); version = (uint32_t) json_integer_value( tmp );
applog( LOG_INFO, "SEGWIT test, block version= %d", version );
// yescryptr8g uses block version 5 and sapling. // yescryptr8g uses block version 5 and sapling.
if ( opt_sapling ) if ( opt_sapling )
work->sapling = true; work->sapling = true;
@@ -721,13 +740,59 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
cbtx[41] = cbtx_size - 42; /* scriptsig length */ cbtx[41] = cbtx_size - 42; /* scriptsig length */
le32enc( (uint32_t *)( cbtx+cbtx_size ), 0xffffffff ); /* sequence */ le32enc( (uint32_t *)( cbtx+cbtx_size ), 0xffffffff ); /* sequence */
cbtx_size += 4; 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) , (uint32_t)cbvalue ); /* value */
le32enc( (uint32_t *)( cbtx+cbtx_size+4 ), cbvalue >> 32 ); le32enc( (uint32_t *)( cbtx+cbtx_size+4 ), cbvalue >> 32 );
cbtx_size += 8; cbtx_size += 8;
cbtx[ cbtx_size++ ] = (uint8_t) pk_script_size; /* txout-script length */ cbtx[ cbtx_size++ ] = (uint8_t) pk_script_size; /* txout-script length */
memcpy( cbtx+cbtx_size, pk_script, pk_script_size ); memcpy( cbtx+cbtx_size, pk_script, pk_script_size );
cbtx_size += (int) pk_script_size; cbtx_size += (int) pk_script_size;
// Segwit BEGIN
if (segwit) {
applog( LOG_INFO, "SEGWIT test: add segwit to tx");
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 */ le32enc( (uint32_t *)( cbtx+cbtx_size ), 0 ); /* lock time */
cbtx_size += 4; cbtx_size += 4;
coinbase_append = true; coinbase_append = true;
@@ -802,14 +867,36 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
tmp = json_array_get( txa, i ); tmp = json_array_get( txa, i );
const char *tx_hex = json_string_value( json_object_get( tmp, "data" ) ); const char *tx_hex = json_string_value( json_object_get( tmp, "data" ) );
const int tx_size = tx_hex ? (int) ( strlen( tx_hex ) / 2 ) : 0; 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" ); const char *txid = json_string_value(json_object_get(tmp, "txid"));
free( tx ); if (!txid || !hex2bin(merkle_tree[1 + i], txid, 32))
goto out; {
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 ) if ( !submit_coinbase )
strcat( work->txs, tx_hex ); strcat( work->txs, tx_hex );
} }
@@ -1405,12 +1492,24 @@ const char *getwork_req =
#define GBT_CAPABILITIES "[\"coinbasetxn\", \"coinbasevalue\", \"longpoll\", \"workid\"]" #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 = static const char *gbt_req =
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": " "{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
GBT_CAPABILITIES "}], \"id\":0}\r\n"; GBT_CAPABILITIES "}], \"id\":0}\r\n";
const char *gbt_lp_req = const char *gbt_lp_req =
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": " "{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
GBT_CAPABILITIES ", \"longpollid\": \"%s\"}], \"id\":0}\r\n"; GBT_CAPABILITIES ", \"longpollid\": \"%s\"}], \"id\":0}\r\n";
*/
// Segwit END
static bool get_upstream_work( CURL *curl, struct work *work ) static bool get_upstream_work( CURL *curl, struct work *work )
{ {
@@ -3219,6 +3318,13 @@ static void show_credits()
printf(" A CPU miner with multi algo support and optimized for CPUs\n"); printf(" A CPU miner with multi algo support and optimized for CPUs\n");
printf(" with AVX512, SHA and VAES extensions.\n"); printf(" with AVX512, SHA and VAES extensions.\n");
printf(" BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT\n\n"); printf(" BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT\n\n");
printf("/nWarning: this is a test release, it may contain bugs and aditional\n");
printf("debug log output. Users who solo mine using getwork or GBT are invited\n\n");
printf("to use it for testing purposes. Please report any regressions. Other\n");
printf("users may prefer to continue using the latest general release.\n\n");
} }
bool check_cpu_capability () bool check_cpu_capability ()

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, int timeval_subtract( struct timeval *result, struct timeval *x,
struct timeval *y); struct timeval *y);
// Segwit BEGIN
extern void memrev(unsigned char *p, size_t len);
// Segwit END
// Bitcoin formula for converting difficulty to an equivalent // Bitcoin formula for converting difficulty to an equivalent
// number of hashes. // number of hashes.
// //

13
util.c
View File

@@ -747,6 +747,19 @@ err_out:
return cfg; 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) void cbin2hex(char *out, const char *in, size_t len)
{ {
if (out) { if (out) {