Auto merge of #1863 - str4d:1795-config-flag-disable-miner, r=bitcartel
Add compile flag to disable compilation of mining code Closes #1795
This commit is contained in:
commit
80a32b2845
17
configure.ac
17
configure.ac
|
@ -82,6 +82,12 @@ AC_ARG_ENABLE([wallet],
|
||||||
[enable_wallet=$enableval],
|
[enable_wallet=$enableval],
|
||||||
[enable_wallet=yes])
|
[enable_wallet=yes])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([mining],
|
||||||
|
[AS_HELP_STRING([--enable-mining],
|
||||||
|
[enable mining (default is yes)])],
|
||||||
|
[enable_mining=$enableval],
|
||||||
|
[enable_mining=yes])
|
||||||
|
|
||||||
AC_ARG_WITH([miniupnpc],
|
AC_ARG_WITH([miniupnpc],
|
||||||
[AS_HELP_STRING([--with-miniupnpc],
|
[AS_HELP_STRING([--with-miniupnpc],
|
||||||
[enable UPNP (default is yes if libminiupnpc is found)])],
|
[enable UPNP (default is yes if libminiupnpc is found)])],
|
||||||
|
@ -790,6 +796,16 @@ else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl enable mining
|
||||||
|
AC_MSG_CHECKING([if mining should be enabled])
|
||||||
|
if test x$enable_mining != xno; then
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(ENABLE_MINING, 1, [Define to 1 to enable mining functions])
|
||||||
|
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
|
||||||
dnl enable upnp support
|
dnl enable upnp support
|
||||||
AC_MSG_CHECKING([whether to build with support for UPnP])
|
AC_MSG_CHECKING([whether to build with support for UPnP])
|
||||||
if test x$have_miniupnpc = xno; then
|
if test x$have_miniupnpc = xno; then
|
||||||
|
@ -881,6 +897,7 @@ AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])
|
||||||
AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
|
AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
|
||||||
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
|
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
|
||||||
AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
|
AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
|
||||||
|
AM_CONDITIONAL([ENABLE_MINING],[test x$enable_mining = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
|
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
|
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
|
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
|
||||||
|
|
|
@ -248,13 +248,8 @@ libbitcoin_wallet_a_SOURCES = \
|
||||||
$(BITCOIN_CORE_H) \
|
$(BITCOIN_CORE_H) \
|
||||||
$(LIBZCASH_H)
|
$(LIBZCASH_H)
|
||||||
|
|
||||||
EQUIHASH_TROMP_SOURCES = \
|
|
||||||
pow/tromp/equi_miner.h \
|
|
||||||
pow/tromp/equi.h \
|
|
||||||
pow/tromp/osx_barrier.h
|
|
||||||
|
|
||||||
# crypto primitives library
|
# crypto primitives library
|
||||||
crypto_libbitcoin_crypto_a_CPPFLAGS = $(BITCOIN_CONFIG_INCLUDES) -DEQUIHASH_TROMP_ATOMIC
|
crypto_libbitcoin_crypto_a_CPPFLAGS = $(BITCOIN_CONFIG_INCLUDES)
|
||||||
crypto_libbitcoin_crypto_a_SOURCES = \
|
crypto_libbitcoin_crypto_a_SOURCES = \
|
||||||
crypto/common.h \
|
crypto/common.h \
|
||||||
crypto/equihash.cpp \
|
crypto/equihash.cpp \
|
||||||
|
@ -271,8 +266,19 @@ crypto_libbitcoin_crypto_a_SOURCES = \
|
||||||
crypto/sha256.cpp \
|
crypto/sha256.cpp \
|
||||||
crypto/sha256.h \
|
crypto/sha256.h \
|
||||||
crypto/sha512.cpp \
|
crypto/sha512.cpp \
|
||||||
crypto/sha512.h \
|
crypto/sha512.h
|
||||||
|
|
||||||
|
if ENABLE_MINING
|
||||||
|
EQUIHASH_TROMP_SOURCES = \
|
||||||
|
pow/tromp/equi_miner.h \
|
||||||
|
pow/tromp/equi.h \
|
||||||
|
pow/tromp/osx_barrier.h
|
||||||
|
|
||||||
|
crypto_libbitcoin_crypto_a_CPPFLAGS += \
|
||||||
|
-DEQUIHASH_TROMP_ATOMIC
|
||||||
|
crypto_libbitcoin_crypto_a_SOURCES += \
|
||||||
${EQUIHASH_TROMP_SOURCES}
|
${EQUIHASH_TROMP_SOURCES}
|
||||||
|
endif
|
||||||
|
|
||||||
# univalue JSON library
|
# univalue JSON library
|
||||||
univalue_libbitcoin_univalue_a_SOURCES = \
|
univalue_libbitcoin_univalue_a_SOURCES = \
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
// NDSS ’16, 21-24 February 2016, San Diego, CA, USA
|
// NDSS ’16, 21-24 February 2016, San Diego, CA, USA
|
||||||
// https://www.internetsociety.org/sites/default/files/blogs-media/equihash-asymmetric-proof-of-work-based-generalized-birthday-problem.pdf
|
// https://www.internetsociety.org/sites/default/files/blogs-media/equihash-asymmetric-proof-of-work-based-generalized-birthday-problem.pdf
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include "config/bitcoin-config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "crypto/equihash.h"
|
#include "crypto/equihash.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
@ -319,6 +323,7 @@ std::shared_ptr<eh_trunc> TruncatedStepRow<WIDTH>::GetTruncatedIndices(size_t le
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
template<unsigned int N, unsigned int K>
|
template<unsigned int N, unsigned int K>
|
||||||
bool Equihash<N,K>::BasicSolve(const eh_HashState& base_state,
|
bool Equihash<N,K>::BasicSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
|
@ -711,6 +716,7 @@ invalidsolution:
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MINING
|
||||||
|
|
||||||
template<unsigned int N, unsigned int K>
|
template<unsigned int N, unsigned int K>
|
||||||
bool Equihash<N,K>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln)
|
bool Equihash<N,K>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln)
|
||||||
|
@ -762,40 +768,48 @@ bool Equihash<N,K>::IsValidSolution(const eh_HashState& base_state, std::vector<
|
||||||
|
|
||||||
// Explicit instantiations for Equihash<96,3>
|
// Explicit instantiations for Equihash<96,3>
|
||||||
template int Equihash<96,3>::InitialiseState(eh_HashState& base_state);
|
template int Equihash<96,3>::InitialiseState(eh_HashState& base_state);
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
template bool Equihash<96,3>::BasicSolve(const eh_HashState& base_state,
|
template bool Equihash<96,3>::BasicSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
template bool Equihash<96,3>::OptimisedSolve(const eh_HashState& base_state,
|
template bool Equihash<96,3>::OptimisedSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
|
#endif
|
||||||
template bool Equihash<96,3>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
template bool Equihash<96,3>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
||||||
|
|
||||||
// Explicit instantiations for Equihash<200,9>
|
// Explicit instantiations for Equihash<200,9>
|
||||||
template int Equihash<200,9>::InitialiseState(eh_HashState& base_state);
|
template int Equihash<200,9>::InitialiseState(eh_HashState& base_state);
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
template bool Equihash<200,9>::BasicSolve(const eh_HashState& base_state,
|
template bool Equihash<200,9>::BasicSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
template bool Equihash<200,9>::OptimisedSolve(const eh_HashState& base_state,
|
template bool Equihash<200,9>::OptimisedSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
|
#endif
|
||||||
template bool Equihash<200,9>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
template bool Equihash<200,9>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
||||||
|
|
||||||
// Explicit instantiations for Equihash<96,5>
|
// Explicit instantiations for Equihash<96,5>
|
||||||
template int Equihash<96,5>::InitialiseState(eh_HashState& base_state);
|
template int Equihash<96,5>::InitialiseState(eh_HashState& base_state);
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
template bool Equihash<96,5>::BasicSolve(const eh_HashState& base_state,
|
template bool Equihash<96,5>::BasicSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
template bool Equihash<96,5>::OptimisedSolve(const eh_HashState& base_state,
|
template bool Equihash<96,5>::OptimisedSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
|
#endif
|
||||||
template bool Equihash<96,5>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
template bool Equihash<96,5>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
||||||
|
|
||||||
// Explicit instantiations for Equihash<48,5>
|
// Explicit instantiations for Equihash<48,5>
|
||||||
template int Equihash<48,5>::InitialiseState(eh_HashState& base_state);
|
template int Equihash<48,5>::InitialiseState(eh_HashState& base_state);
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
template bool Equihash<48,5>::BasicSolve(const eh_HashState& base_state,
|
template bool Equihash<48,5>::BasicSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
template bool Equihash<48,5>::OptimisedSolve(const eh_HashState& base_state,
|
template bool Equihash<48,5>::OptimisedSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
|
#endif
|
||||||
template bool Equihash<48,5>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
template bool Equihash<48,5>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
||||||
|
|
|
@ -182,12 +182,14 @@ public:
|
||||||
Equihash() { }
|
Equihash() { }
|
||||||
|
|
||||||
int InitialiseState(eh_HashState& base_state);
|
int InitialiseState(eh_HashState& base_state);
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
bool BasicSolve(const eh_HashState& base_state,
|
bool BasicSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
bool OptimisedSolve(const eh_HashState& base_state,
|
bool OptimisedSolve(const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
const std::function<bool(EhSolverCancelCheck)> cancelled);
|
||||||
|
#endif
|
||||||
bool IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
bool IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -211,6 +213,7 @@ static Equihash<48,5> Eh48_5;
|
||||||
throw std::invalid_argument("Unsupported Equihash parameters"); \
|
throw std::invalid_argument("Unsupported Equihash parameters"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
inline bool EhBasicSolve(unsigned int n, unsigned int k, const eh_HashState& base_state,
|
inline bool EhBasicSolve(unsigned int n, unsigned int k, const eh_HashState& base_state,
|
||||||
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
const std::function<bool(std::vector<unsigned char>)> validBlock,
|
||||||
const std::function<bool(EhSolverCancelCheck)> cancelled)
|
const std::function<bool(EhSolverCancelCheck)> cancelled)
|
||||||
|
@ -258,6 +261,7 @@ inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const
|
||||||
return EhOptimisedSolve(n, k, base_state, validBlock,
|
return EhOptimisedSolve(n, k, base_state, validBlock,
|
||||||
[](EhSolverCancelCheck pos) { return false; });
|
[](EhSolverCancelCheck pos) { return false; });
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MINING
|
||||||
|
|
||||||
#define EhIsValidSolution(n, k, base_state, soln, ret) \
|
#define EhIsValidSolution(n, k, base_state, soln, ret) \
|
||||||
if (n == 96 && k == 3) { \
|
if (n == 96 && k == 3) { \
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include "config/bitcoin-config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
|
|
||||||
|
@ -76,6 +80,7 @@ TEST(equihash_tests, is_probably_duplicate) {
|
||||||
ASSERT_TRUE(IsProbablyDuplicate<4>(p3, 4));
|
ASSERT_TRUE(IsProbablyDuplicate<4>(p3, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
TEST(equihash_tests, check_basic_solver_cancelled) {
|
TEST(equihash_tests, check_basic_solver_cancelled) {
|
||||||
Equihash<48,5> Eh48_5;
|
Equihash<48,5> Eh48_5;
|
||||||
crypto_generichash_blake2b_state state;
|
crypto_generichash_blake2b_state state;
|
||||||
|
@ -283,3 +288,4 @@ TEST(equihash_tests, check_optimised_solver_cancelled) {
|
||||||
}), EhSolverCancelledException);
|
}), EhSolverCancelledException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MINING
|
||||||
|
|
|
@ -163,7 +163,9 @@ void Shutdown()
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (pwalletMain)
|
if (pwalletMain)
|
||||||
pwalletMain->Flush(false);
|
pwalletMain->Flush(false);
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
GenerateBitcoins(false, NULL, 0);
|
GenerateBitcoins(false, NULL, 0);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
StopNode();
|
StopNode();
|
||||||
UnregisterNodeSignals(GetNodeSignals());
|
UnregisterNodeSignals(GetNodeSignals());
|
||||||
|
@ -1505,7 +1507,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
boost::ref(cs_main), boost::cref(pindexBestHeader), nPowTargetSpacing);
|
boost::ref(cs_main), boost::cref(pindexBestHeader), nPowTargetSpacing);
|
||||||
scheduler.scheduleEvery(f, nPowTargetSpacing);
|
scheduler.scheduleEvery(f, nPowTargetSpacing);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
|
||||||
// Generate coins in the background
|
// Generate coins in the background
|
||||||
if (pwalletMain)
|
if (pwalletMain)
|
||||||
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
|
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
|
||||||
|
|
|
@ -128,6 +128,7 @@ int printNetworkStats()
|
||||||
|
|
||||||
int printMiningStatus(bool mining)
|
int printMiningStatus(bool mining)
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
// Number of lines that are always displayed
|
// Number of lines that are always displayed
|
||||||
int lines = 1;
|
int lines = 1;
|
||||||
|
|
||||||
|
@ -151,6 +152,9 @@ int printMiningStatus(bool mining)
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
|
#else // ENABLE_MINING
|
||||||
|
return 0;
|
||||||
|
#endif // !ENABLE_MINING
|
||||||
}
|
}
|
||||||
|
|
||||||
int printMetrics(size_t cols, bool mining)
|
int printMetrics(size_t cols, bool mining)
|
||||||
|
@ -342,7 +346,11 @@ void ThreadShowMetricsScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Miner status
|
// Miner status
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
bool mining = GetBoolArg("-gen", false);
|
bool mining = GetBoolArg("-gen", false);
|
||||||
|
#else
|
||||||
|
bool mining = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
lines += printNetworkStats();
|
lines += printNetworkStats();
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "miner.h"
|
#include "miner.h"
|
||||||
|
#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
|
||||||
#include "pow/tromp/equi_miner.h"
|
#include "pow/tromp/equi_miner.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
|
@ -21,7 +23,9 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "utilmoneystr.h"
|
#include "utilmoneystr.h"
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
#include "crypto/equihash.h"
|
#include "crypto/equihash.h"
|
||||||
|
#endif
|
||||||
#include "wallet/wallet.h"
|
#include "wallet/wallet.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#endif
|
#endif
|
||||||
|
@ -414,6 +418,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||||
return CreateNewBlock(scriptPubKey);
|
return CreateNewBlock(scriptPubKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||||
{
|
{
|
||||||
LogPrintf("%s\n", pblock->ToString());
|
LogPrintf("%s\n", pblock->ToString());
|
||||||
|
@ -687,4 +692,5 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
|
||||||
minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet));
|
minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // ENABLE_MINING
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
|
@ -23,8 +23,10 @@ struct CBlockTemplate
|
||||||
std::vector<int64_t> vTxSigOps;
|
std::vector<int64_t> vTxSigOps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
/** Run the miner threads */
|
/** Run the miner threads */
|
||||||
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads);
|
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads);
|
||||||
|
#endif
|
||||||
/** Generate a new block, without valid proof-of-work */
|
/** Generate a new block, without valid proof-of-work */
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
|
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
|
||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
|
||||||
|
|
|
@ -137,7 +137,7 @@ Value getnetworkhashps(const Array& params, bool fHelp)
|
||||||
return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120, params.size() > 1 ? params[1].get_int() : -1);
|
return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120, params.size() > 1 ? params[1].get_int() : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
|
||||||
Value getgenerate(const Array& params, bool fHelp)
|
Value getgenerate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
if (fHelp || params.size() != 0)
|
if (fHelp || params.size() != 0)
|
||||||
|
@ -343,7 +343,7 @@ Value getmininginfo(const Array& params, bool fHelp)
|
||||||
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
|
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
|
||||||
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
|
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
|
||||||
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||||
#ifdef ENABLE_WALLET
|
#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
|
||||||
obj.push_back(Pair("generate", getgenerate(params, false)));
|
obj.push_back(Pair("generate", getgenerate(params, false)));
|
||||||
#endif
|
#endif
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -466,9 +466,10 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
|
#ifdef ENABLE_WALLET
|
||||||
// Wallet is required because we support coinbasetxn
|
// Wallet is required because we support coinbasetxn
|
||||||
if (pwalletMain == NULL) {
|
if (pwalletMain == NULL) {
|
||||||
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (wallet disabled)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strMode = "template";
|
std::string strMode = "template";
|
||||||
|
@ -694,6 +695,10 @@ Value getblocktemplate(const Array& params, bool fHelp)
|
||||||
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
|
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#else // ENABLE_WALLET
|
||||||
|
// Wallet is required because we support coinbasetxn
|
||||||
|
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (wallet support not built)");
|
||||||
|
#endif // !ENABLE_WALLET
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||||
{ "mining", "submitblock", &submitblock, true },
|
{ "mining", "submitblock", &submitblock, true },
|
||||||
{ "mining", "getblocksubsidy", &getblocksubsidy, true },
|
{ "mining", "getblocksubsidy", &getblocksubsidy, true },
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
|
||||||
/* Coin generation */
|
/* Coin generation */
|
||||||
{ "generating", "getgenerate", &getgenerate, true },
|
{ "generating", "getgenerate", &getgenerate, true },
|
||||||
{ "generating", "setgenerate", &setgenerate, true },
|
{ "generating", "setgenerate", &setgenerate, true },
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include "config/bitcoin-config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "arith_uint256.h"
|
#include "arith_uint256.h"
|
||||||
#include "crypto/sha256.h"
|
#include "crypto/sha256.h"
|
||||||
#include "crypto/equihash.h"
|
#include "crypto/equihash.h"
|
||||||
|
@ -40,6 +44,7 @@ void PrintSolutions(std::stringstream &strm, std::set<std::vector<uint32_t>> sol
|
||||||
strm << "\n}";
|
strm << "\n}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
void TestEquihashSolvers(unsigned int n, unsigned int k, const std::string &I, const arith_uint256 &nonce, const std::set<std::vector<uint32_t>> &solns) {
|
void TestEquihashSolvers(unsigned int n, unsigned int k, const std::string &I, const arith_uint256 &nonce, const std::set<std::vector<uint32_t>> &solns) {
|
||||||
size_t cBitLen { n/(k+1) };
|
size_t cBitLen { n/(k+1) };
|
||||||
crypto_generichash_blake2b_state state;
|
crypto_generichash_blake2b_state state;
|
||||||
|
@ -78,6 +83,7 @@ void TestEquihashSolvers(unsigned int n, unsigned int k, const std::string &I, c
|
||||||
BOOST_CHECK(retOpt == solns);
|
BOOST_CHECK(retOpt == solns);
|
||||||
BOOST_CHECK(retOpt == ret);
|
BOOST_CHECK(retOpt == ret);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void TestEquihashValidator(unsigned int n, unsigned int k, const std::string &I, const arith_uint256 &nonce, std::vector<uint32_t> soln, bool expected) {
|
void TestEquihashValidator(unsigned int n, unsigned int k, const std::string &I, const arith_uint256 &nonce, std::vector<uint32_t> soln, bool expected) {
|
||||||
size_t cBitLen { n/(k+1) };
|
size_t cBitLen { n/(k+1) };
|
||||||
|
@ -95,6 +101,7 @@ void TestEquihashValidator(unsigned int n, unsigned int k, const std::string &I,
|
||||||
BOOST_CHECK(isValid == expected);
|
BOOST_CHECK(isValid == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
BOOST_AUTO_TEST_CASE(solver_testvectors) {
|
BOOST_AUTO_TEST_CASE(solver_testvectors) {
|
||||||
TestEquihashSolvers(96, 5, "block header", 0, {
|
TestEquihashSolvers(96, 5, "block header", 0, {
|
||||||
{976, 126621, 100174, 123328, 38477, 105390, 38834, 90500, 6411, 116489, 51107, 129167, 25557, 92292, 38525, 56514, 1110, 98024, 15426, 74455, 3185, 84007, 24328, 36473, 17427, 129451, 27556, 119967, 31704, 62448, 110460, 117894},
|
{976, 126621, 100174, 123328, 38477, 105390, 38834, 90500, 6411, 116489, 51107, 129167, 25557, 92292, 38525, 56514, 1110, 98024, 15426, 74455, 3185, 84007, 24328, 36473, 17427, 129451, 27556, 119967, 31704, 62448, 110460, 117894},
|
||||||
|
@ -147,6 +154,7 @@ BOOST_AUTO_TEST_CASE(solver_testvectors) {
|
||||||
{8144, 33053, 33933, 77498, 21356, 110495, 42805, 116575, 27360, 48574, 100682, 102629, 50754, 64608, 96899, 120978, 11924, 74422, 49240, 106822, 12787, 68290, 44314, 50005, 38056, 49716, 83299, 95307, 41798, 82309, 94504, 96161}
|
{8144, 33053, 33933, 77498, 21356, 110495, 42805, 116575, 27360, 48574, 100682, 102629, 50754, 64608, 96899, 120978, 11924, 74422, 49240, 106822, 12787, 68290, 44314, 50005, 38056, 49716, 83299, 95307, 41798, 82309, 94504, 96161}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(validator_testvectors) {
|
BOOST_AUTO_TEST_CASE(validator_testvectors) {
|
||||||
// Original valid solution
|
// Original valid solution
|
||||||
|
|
|
@ -2498,6 +2498,7 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp)
|
||||||
}
|
}
|
||||||
} else if (benchmarktype == "verifyjoinsplit") {
|
} else if (benchmarktype == "verifyjoinsplit") {
|
||||||
sample_times.push_back(benchmark_verify_joinsplit(samplejoinsplit));
|
sample_times.push_back(benchmark_verify_joinsplit(samplejoinsplit));
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
} else if (benchmarktype == "solveequihash") {
|
} else if (benchmarktype == "solveequihash") {
|
||||||
if (params.size() < 3) {
|
if (params.size() < 3) {
|
||||||
sample_times.push_back(benchmark_solve_equihash());
|
sample_times.push_back(benchmark_solve_equihash());
|
||||||
|
@ -2506,6 +2507,7 @@ Value zc_benchmark(const json_spirit::Array& params, bool fHelp)
|
||||||
std::vector<double> vals = benchmark_solve_equihash_threaded(nThreads);
|
std::vector<double> vals = benchmark_solve_equihash_threaded(nThreads);
|
||||||
sample_times.insert(sample_times.end(), vals.begin(), vals.end());
|
sample_times.insert(sample_times.end(), vals.begin(), vals.end());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if (benchmarktype == "verifyequihash") {
|
} else if (benchmarktype == "verifyequihash") {
|
||||||
sample_times.push_back(benchmark_verify_equihash());
|
sample_times.push_back(benchmark_verify_equihash());
|
||||||
} else if (benchmarktype == "validatelargetx") {
|
} else if (benchmarktype == "validatelargetx") {
|
||||||
|
|
|
@ -126,6 +126,7 @@ double benchmark_verify_joinsplit(const JSDescription &joinsplit)
|
||||||
return timer_stop(tv_start);
|
return timer_stop(tv_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_MINING
|
||||||
double benchmark_solve_equihash()
|
double benchmark_solve_equihash()
|
||||||
{
|
{
|
||||||
CBlock pblock;
|
CBlock pblock;
|
||||||
|
@ -173,6 +174,7 @@ std::vector<double> benchmark_solve_equihash_threaded(int nThreads)
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_MINING
|
||||||
|
|
||||||
double benchmark_verify_equihash()
|
double benchmark_verify_equihash()
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,13 +33,16 @@ Usage:
|
||||||
$0 --help
|
$0 --help
|
||||||
Show this help message and exit.
|
Show this help message and exit.
|
||||||
|
|
||||||
$0 [ --enable-lcov || --disable-tests ] [ MAKEARGS... ]
|
$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ MAKEARGS... ]
|
||||||
Build Zcash and most of its transitive dependencies from
|
Build Zcash and most of its transitive dependencies from
|
||||||
source. MAKEARGS are applied to both dependencies and Zcash itself.
|
source. MAKEARGS are applied to both dependencies and Zcash itself.
|
||||||
|
|
||||||
If --enable-lcov is passed, Zcash is configured to add coverage
|
If --enable-lcov is passed, Zcash is configured to add coverage
|
||||||
instrumentation, thus enabling "make cov" to work.
|
instrumentation, thus enabling "make cov" to work.
|
||||||
If --disable-tests is passed instead, the Zcash tests are not built.
|
If --disable-tests is passed instead, the Zcash tests are not built.
|
||||||
|
|
||||||
|
If --disable-mining is passed, Zcash is configured to not build any mining
|
||||||
|
code. It must be passed after the test arguments, if present.
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -62,9 +65,17 @@ then
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If --disable-mining is the next argument, disable mining code:
|
||||||
|
MINING_ARG=''
|
||||||
|
if [ "x${1:-}" = 'x--disable-mining' ]
|
||||||
|
then
|
||||||
|
MINING_ARG='--enable-mining=no'
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
PREFIX="$(pwd)/depends/$BUILD/"
|
PREFIX="$(pwd)/depends/$BUILD/"
|
||||||
|
|
||||||
HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1 NO_QT=1
|
HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1 NO_QT=1
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" CXXFLAGS='-fwrapv -fno-strict-aliasing -Werror -g'
|
CC="$CC" CXX="$CXX" ./configure --prefix="${PREFIX}" --host="$HOST" --build="$BUILD" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" CXXFLAGS='-fwrapv -fno-strict-aliasing -Werror -g'
|
||||||
"$MAKE" "$@" V=1
|
"$MAKE" "$@" V=1
|
||||||
|
|
Loading…
Reference in New Issue