[enable_wallet=$enableval],
[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],
[AS_HELP_STRING([--with-miniupnpc],
[enable UPNP (default is yes if libminiupnpc is found)])],
AC_MSG_RESULT(no)
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
AC_MSG_CHECKING([whether to build with support for UPnP])
if test x$have_miniupnpc = xno; then
AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin])
AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows])
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_QT],[test x$bitcoin_enable_qt = xyes])
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
$(BITCOIN_CORE_H) \
$(LIBZCASH_H)
-EQUIHASH_TROMP_SOURCES = \
- pow/tromp/equi_miner.h \
- pow/tromp/equi.h \
- pow/tromp/osx_barrier.h
-
# 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/common.h \
crypto/equihash.cpp \
crypto/sha256.cpp \
crypto/sha256.h \
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}
+endif
# univalue JSON library
univalue_libbitcoin_univalue_a_SOURCES = \
// 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
+#if defined(HAVE_CONFIG_H)
+#include "config/bitcoin-config.h"
+#endif
+
#include "crypto/equihash.h"
#include "util.h"
return p;
}
+#ifdef ENABLE_MINING
template<unsigned int N, unsigned int K>
bool Equihash<N,K>::BasicSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
return false;
}
+#endif // ENABLE_MINING
template<unsigned int N, unsigned int K>
bool Equihash<N,K>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln)
// Explicit instantiations for Equihash<96,3>
template int Equihash<96,3>::InitialiseState(eh_HashState& base_state);
+#ifdef ENABLE_MINING
template bool Equihash<96,3>::BasicSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
template bool Equihash<96,3>::OptimisedSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
+#endif
template bool Equihash<96,3>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
// Explicit instantiations for Equihash<200,9>
template int Equihash<200,9>::InitialiseState(eh_HashState& base_state);
+#ifdef ENABLE_MINING
template bool Equihash<200,9>::BasicSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
template bool Equihash<200,9>::OptimisedSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
+#endif
template bool Equihash<200,9>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
// Explicit instantiations for Equihash<96,5>
template int Equihash<96,5>::InitialiseState(eh_HashState& base_state);
+#ifdef ENABLE_MINING
template bool Equihash<96,5>::BasicSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
template bool Equihash<96,5>::OptimisedSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
+#endif
template bool Equihash<96,5>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
// Explicit instantiations for Equihash<48,5>
template int Equihash<48,5>::InitialiseState(eh_HashState& base_state);
+#ifdef ENABLE_MINING
template bool Equihash<48,5>::BasicSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
template bool Equihash<48,5>::OptimisedSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
+#endif
template bool Equihash<48,5>::IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
Equihash() { }
int InitialiseState(eh_HashState& base_state);
+#ifdef ENABLE_MINING
bool BasicSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
bool OptimisedSolve(const eh_HashState& base_state,
const std::function<bool(std::vector<unsigned char>)> validBlock,
const std::function<bool(EhSolverCancelCheck)> cancelled);
+#endif
bool IsValidSolution(const eh_HashState& base_state, std::vector<unsigned char> soln);
};
throw std::invalid_argument("Unsupported Equihash parameters"); \
}
+#ifdef ENABLE_MINING
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(EhSolverCancelCheck)> cancelled)
return EhOptimisedSolve(n, k, base_state, validBlock,
[](EhSolverCancelCheck pos) { return false; });
}
+#endif // ENABLE_MINING
#define EhIsValidSolution(n, k, base_state, soln, ret) \
if (n == 96 && k == 3) { \
+#if defined(HAVE_CONFIG_H)
+#include "config/bitcoin-config.h"
+#endif
+
#include <gtest/gtest.h>
#include <gmock/gmock.h>
ASSERT_TRUE(IsProbablyDuplicate<4>(p3, 4));
}
+#ifdef ENABLE_MINING
TEST(equihash_tests, check_basic_solver_cancelled) {
Equihash<48,5> Eh48_5;
crypto_generichash_blake2b_state state;
}), EhSolverCancelledException);
}
}
+#endif // ENABLE_MINING
#ifdef ENABLE_WALLET
if (pwalletMain)
pwalletMain->Flush(false);
+ #ifdef ENABLE_MINING
GenerateBitcoins(false, NULL, 0);
+ #endif
#endif
StopNode();
UnregisterNodeSignals(GetNodeSignals());
boost::ref(cs_main), boost::cref(pindexBestHeader), nPowTargetSpacing);
scheduler.scheduleEvery(f, nPowTargetSpacing);
-#ifdef ENABLE_WALLET
+#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
// Generate coins in the background
if (pwalletMain)
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
int printMiningStatus(bool mining)
{
+#ifdef ENABLE_MINING
// Number of lines that are always displayed
int lines = 1;
std::cout << std::endl;
return lines;
+#else // ENABLE_MINING
+ return 0;
+#endif // !ENABLE_MINING
}
int printMetrics(size_t cols, bool mining)
}
// Miner status
+#ifdef ENABLE_MINING
bool mining = GetBoolArg("-gen", false);
+#else
+ bool mining = false;
+#endif
if (loaded) {
lines += printNetworkStats();
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "miner.h"
+#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
#include "pow/tromp/equi_miner.h"
+#endif
#include "amount.h"
#include "chainparams.h"
#include "util.h"
#include "utilmoneystr.h"
#ifdef ENABLE_WALLET
+ #ifdef ENABLE_MINING
#include "crypto/equihash.h"
+ #endif
#include "wallet/wallet.h"
#include <functional>
#endif
return CreateNewBlock(scriptPubKey);
}
+#ifdef ENABLE_MINING
static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
{
LogPrintf("%s\n", pblock->ToString());
minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet));
}
+#endif // ENABLE_MINING
#endif // ENABLE_WALLET
std::vector<int64_t> vTxSigOps;
};
+#ifdef ENABLE_MINING
/** Run the miner threads */
void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads);
+#endif
/** Generate a new block, without valid proof-of-work */
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey);
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)
{
if (fHelp || params.size() != 0)
obj.push_back(Pair("pooledtx", (uint64_t)mempool.size()));
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
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)));
#endif
return obj;
LOCK(cs_main);
+#ifdef ENABLE_WALLET
// Wallet is required because we support coinbasetxn
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";
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
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
{ "mining", "submitblock", &submitblock, true },
{ "mining", "getblocksubsidy", &getblocksubsidy, true },
-#ifdef ENABLE_WALLET
+#if defined(ENABLE_WALLET) && defined(ENABLE_MINING)
/* Coin generation */
{ "generating", "getgenerate", &getgenerate, true },
{ "generating", "setgenerate", &setgenerate, true },
// Distributed under the MIT software license, see the accompanying
// 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 "crypto/sha256.h"
#include "crypto/equihash.h"
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) {
size_t cBitLen { n/(k+1) };
crypto_generichash_blake2b_state state;
BOOST_CHECK(retOpt == solns);
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) {
size_t cBitLen { n/(k+1) };
BOOST_CHECK(isValid == expected);
}
+#ifdef ENABLE_MINING
BOOST_AUTO_TEST_CASE(solver_testvectors) {
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},
{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) {
// Original valid solution
}
} else if (benchmarktype == "verifyjoinsplit") {
sample_times.push_back(benchmark_verify_joinsplit(samplejoinsplit));
+#ifdef ENABLE_MINING
} else if (benchmarktype == "solveequihash") {
if (params.size() < 3) {
sample_times.push_back(benchmark_solve_equihash());
std::vector<double> vals = benchmark_solve_equihash_threaded(nThreads);
sample_times.insert(sample_times.end(), vals.begin(), vals.end());
}
+#endif
} else if (benchmarktype == "verifyequihash") {
sample_times.push_back(benchmark_verify_equihash());
} else if (benchmarktype == "validatelargetx") {
return timer_stop(tv_start);
}
+#ifdef ENABLE_MINING
double benchmark_solve_equihash()
{
CBlock pblock;
}
return ret;
}
+#endif // ENABLE_MINING
double benchmark_verify_equihash()
{
$0 --help
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
source. MAKEARGS are applied to both dependencies and Zcash itself.
If --enable-lcov is passed, Zcash is configured to add coverage
instrumentation, thus enabling "make cov" to work.
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
exit 0
fi
shift
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/"
HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1 NO_QT=1
./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