mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-11-28 11:53:53 +01:00
core code changes to implement yescrypt as relacement for qubit
This commit is contained in:
@@ -109,6 +109,7 @@ BITCOIN_CORE_H = \
|
||||
merkleblock.h \
|
||||
miner.h \
|
||||
mruset.h \
|
||||
myriad_params.h \
|
||||
net.h \
|
||||
netbase.h \
|
||||
noui.h \
|
||||
|
||||
+3
-3
@@ -408,7 +408,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-blockminsize=<n>", strprintf(_("Set minimum block size in bytes (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-blockmaxsize=<n>", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE));
|
||||
strUsage += HelpMessageOpt("-blockprioritysize=<n>", strprintf(_("Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"), DEFAULT_BLOCK_PRIORITY_SIZE));
|
||||
strUsage += HelpMessageOpt("-algo=<algo>", _("Mining algorithm: sha256d, scrypt, groestl, skein, qubit"));
|
||||
strUsage += HelpMessageOpt("-algo=<algo>", _("Mining algorithm: sha256d, scrypt, groestl, skein, qubit, yescrypt"));
|
||||
|
||||
strUsage += HelpMessageGroup(_("RPC server options:"));
|
||||
strUsage += HelpMessageOpt("-server", _("Accept command line and JSON-RPC commands"));
|
||||
@@ -740,8 +740,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
miningAlgo = ALGO_GROESTL;
|
||||
else if (strAlgo == "skein" || strAlgo == "skeinsha2")
|
||||
miningAlgo = ALGO_SKEIN;
|
||||
else if (strAlgo == "q2c" || strAlgo == "qubit")
|
||||
miningAlgo = ALGO_QUBIT;
|
||||
else if (strAlgo == "q2c" || strAlgo == "qubit" || strAlgo == "yescrypt")
|
||||
miningAlgo = ALGO_CPU;
|
||||
else
|
||||
miningAlgo = ALGO_SHA256D;
|
||||
|
||||
|
||||
+3
-2
@@ -2248,8 +2248,9 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
||||
nTimeBestReceived = GetTime();
|
||||
mempool.AddTransactionsUpdated(1);
|
||||
|
||||
LogPrintf("%s: new best=%s height=%d algo=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->GetAlgo(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
||||
LogPrintf("%s: new best=%s height=%d algo=%d (%s) log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), chainActive.Tip()->GetAlgo(), GetAlgoName(chainActive.Tip()->GetAlgo(), chainActive.Tip()->GetBlockTime()),
|
||||
log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
||||
Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.Tip()), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||
|
||||
|
||||
+12
-3
@@ -18,6 +18,7 @@
|
||||
#include "timedata.h"
|
||||
#include "util.h"
|
||||
#include "utilmoneystr.h"
|
||||
#include "myriad_params.h"
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "wallet/wallet.h"
|
||||
#endif
|
||||
@@ -810,9 +811,17 @@ void static ThreadMiner(CWallet *pwallet)
|
||||
LogPrintf("MyriadMiner[Skein] miner started\n");
|
||||
GenericMiner(pwallet, ALGO_SKEIN);
|
||||
break;
|
||||
case ALGO_QUBIT:
|
||||
LogPrintf("MyriadMiner[Qubit] miner started\n");
|
||||
GenericMiner(pwallet, ALGO_QUBIT);
|
||||
case ALGO_CPU:
|
||||
if(GetTime() >= nTimeYescryptStart)
|
||||
{
|
||||
LogPrintf("MyriadMiner[Yescrypt] miner started\n");
|
||||
GenericMiner(pwallet, ALGO_CPU); // could be replaced with a decent yescrypt miner in the style of scrypt, but how much need?
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrintf("MyriadMiner[Qubit] miner started\n");
|
||||
GenericMiner(pwallet, ALGO_CPU);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) 2016 The Myriad developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef MYRIAD_PARAMS_H
|
||||
#define MYRIAD_PARAMS_H
|
||||
|
||||
const uint32_t nTimeYescryptStart = 1466237700; // block time where Qubit hash is replaced with Yescrypt ** TODO CHANGE ME **
|
||||
|
||||
#endif // MYRIAD_PARAMS_H
|
||||
|
||||
+19
-1
@@ -12,6 +12,7 @@
|
||||
#include "uint256.h"
|
||||
#include "util.h"
|
||||
#include "bignum.h"
|
||||
#include "myriad_params.h"
|
||||
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params, int algo)
|
||||
{
|
||||
@@ -123,6 +124,23 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
}
|
||||
}
|
||||
|
||||
// change of algo from Qubit to Yescrypt
|
||||
// because the difficulty of qubit will be much higher than yescrypt on change, we will return the proof-of-work limit
|
||||
// once the changeover occurs, then start adjusting once nAveragingInterval blocks have occured. Will result in a short
|
||||
// insta-mine, but difficulty changes will quickly take care of this.
|
||||
|
||||
if(pindexLast->GetBlockTime() >= nTimeYescryptStart && algo == ALGO_CPU)
|
||||
{
|
||||
if(pindexFirst->GetBlockTime() < nTimeYescryptStart)
|
||||
{
|
||||
if(fDebug)
|
||||
{
|
||||
LogPrintf("nTimeYescryptStart has been passed, but insufficient blocks to calculate new target. Returning nProofOfWorkLimit\n");
|
||||
}
|
||||
return nProofOfWorkLimit.GetCompact();
|
||||
}
|
||||
}
|
||||
|
||||
int64_t nActualTimespan;
|
||||
|
||||
if (pindexLast->nHeight >= params.nBlockTimeWarpPreventStart3)
|
||||
@@ -307,7 +325,7 @@ int GetAlgoWorkFactor(int algo)
|
||||
return 64 * 8;
|
||||
case ALGO_SKEIN:
|
||||
return 4 * 6;
|
||||
case ALGO_QUBIT:
|
||||
case ALGO_CPU:
|
||||
return 128 * 8;
|
||||
default:
|
||||
return 1;
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
#include "crypto/hashqubit.h"
|
||||
#include "crypto/hashskein.h"
|
||||
#include "crypto/scrypt.h"
|
||||
#include "crypto/yescrypt.h"
|
||||
#include "hash.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "myriad_params.h"
|
||||
|
||||
uint256 CPureBlockHeader::GetHash() const
|
||||
{
|
||||
@@ -34,8 +36,17 @@ uint256 CPureBlockHeader::GetPoWHash(int algo) const
|
||||
return HashGroestl(BEGIN(nVersion), END(nNonce));
|
||||
case ALGO_SKEIN:
|
||||
return HashSkein(BEGIN(nVersion), END(nNonce));
|
||||
case ALGO_QUBIT:
|
||||
return HashQubit(BEGIN(nVersion), END(nNonce));
|
||||
case ALGO_CPU:
|
||||
if(nTime >= nTimeYescryptStart)
|
||||
{
|
||||
uint256 thash;
|
||||
yescrypt_hash(BEGIN(nVersion), BEGIN(thash));
|
||||
return thash;
|
||||
}
|
||||
else
|
||||
{
|
||||
return HashQubit(BEGIN(nVersion), END(nNonce));
|
||||
}
|
||||
}
|
||||
return GetHash();
|
||||
}
|
||||
@@ -52,13 +63,13 @@ int GetAlgo(int nVersion)
|
||||
return ALGO_GROESTL;
|
||||
case BLOCK_VERSION_SKEIN:
|
||||
return ALGO_SKEIN;
|
||||
case BLOCK_VERSION_QUBIT:
|
||||
return ALGO_QUBIT;
|
||||
case BLOCK_VERSION_CPU:
|
||||
return ALGO_CPU;
|
||||
}
|
||||
return ALGO_SHA256D;
|
||||
}
|
||||
|
||||
std::string GetAlgoName(int Algo)
|
||||
std::string GetAlgoName(int Algo, uint32_t time)
|
||||
{
|
||||
switch (Algo)
|
||||
{
|
||||
@@ -70,8 +81,15 @@ std::string GetAlgoName(int Algo)
|
||||
return std::string("groestl");
|
||||
case ALGO_SKEIN:
|
||||
return std::string("skein");
|
||||
case ALGO_QUBIT:
|
||||
return std::string("qubit");
|
||||
case ALGO_CPU:
|
||||
if(time >= nTimeYescryptStart)
|
||||
{
|
||||
return std::string("yescrypt");
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::string("qubit");
|
||||
}
|
||||
}
|
||||
return std::string("unknown");
|
||||
}
|
||||
@@ -14,7 +14,7 @@ enum {
|
||||
ALGO_SCRYPT = 1,
|
||||
ALGO_GROESTL = 2,
|
||||
ALGO_SKEIN = 3,
|
||||
ALGO_QUBIT = 4,
|
||||
ALGO_CPU = 4,
|
||||
NUM_ALGOS };
|
||||
|
||||
enum
|
||||
@@ -27,11 +27,11 @@ enum
|
||||
BLOCK_VERSION_SCRYPT = (1 << 9),
|
||||
BLOCK_VERSION_GROESTL = (2 << 9),
|
||||
BLOCK_VERSION_SKEIN = (3 << 9),
|
||||
BLOCK_VERSION_QUBIT = (4 << 9),
|
||||
BLOCK_VERSION_CPU = (4 << 9),
|
||||
};
|
||||
|
||||
int GetAlgo(int nVersion);
|
||||
std::string GetAlgoName(int Algo);
|
||||
std::string GetAlgoName(int Algo, uint32_t time);
|
||||
|
||||
/**
|
||||
* Encapsulate a block version. This takes care of building it up
|
||||
@@ -104,8 +104,8 @@ public:
|
||||
case ALGO_SKEIN:
|
||||
nVersion |= BLOCK_VERSION_SKEIN;
|
||||
break;
|
||||
case ALGO_QUBIT:
|
||||
nVersion |= BLOCK_VERSION_QUBIT;
|
||||
case ALGO_CPU:
|
||||
nVersion |= BLOCK_VERSION_CPU;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
+10
-2
@@ -12,6 +12,7 @@
|
||||
#include "rpcserver.h"
|
||||
#include "sync.h"
|
||||
#include "util.h"
|
||||
#include "myriad_params.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -108,7 +109,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDe
|
||||
result.push_back(Pair("version", block.nVersion.GetFullVersion()));
|
||||
int algo = block.GetAlgo();
|
||||
result.push_back(Pair("pow_algo_id", algo));
|
||||
result.push_back(Pair("pow_algo", GetAlgoName(algo)));
|
||||
result.push_back(Pair("pow_algo", GetAlgoName(algo, block.GetBlockTime())));
|
||||
result.push_back(Pair("pow_hash", block.GetPoWHash(algo).GetHex()));
|
||||
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
|
||||
Array txs;
|
||||
@@ -596,7 +597,14 @@ Value getblockchaininfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("difficulty_scrypt", (double)GetDifficulty(NULL, ALGO_SCRYPT)));
|
||||
obj.push_back(Pair("difficulty_groestl", (double)GetDifficulty(NULL, ALGO_GROESTL)));
|
||||
obj.push_back(Pair("difficulty_skein", (double)GetDifficulty(NULL, ALGO_SKEIN)));
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_QUBIT)));
|
||||
if(GetTime() >= nTimeYescryptStart)
|
||||
{
|
||||
obj.push_back(Pair("difficulty_yescrypt",(double)GetDifficulty(NULL, ALGO_CPU)));
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_CPU)));
|
||||
}
|
||||
obj.push_back(Pair("verificationprogress", Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.Tip())));
|
||||
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
|
||||
obj.push_back(Pair("pruned", fPruneMode));
|
||||
|
||||
+10
-2
@@ -16,6 +16,7 @@
|
||||
#include "rpcserver.h"
|
||||
#include "util.h"
|
||||
#include "validationinterface.h"
|
||||
#include "myriad_params.h"
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "wallet/wallet.h"
|
||||
#endif
|
||||
@@ -260,13 +261,20 @@ Value getmininginfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize));
|
||||
obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx));
|
||||
obj.push_back(Pair("pow_algo_id", miningAlgo));
|
||||
obj.push_back(Pair("pow_algo", GetAlgoName(miningAlgo)));
|
||||
obj.push_back(Pair("pow_algo", GetAlgoName(miningAlgo, GetTime())));
|
||||
obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL, miningAlgo)));
|
||||
obj.push_back(Pair("difficulty_sha256d", (double)GetDifficulty(NULL, ALGO_SHA256D)));
|
||||
obj.push_back(Pair("difficulty_scrypt", (double)GetDifficulty(NULL, ALGO_SCRYPT)));
|
||||
obj.push_back(Pair("difficulty_groestl", (double)GetDifficulty(NULL, ALGO_GROESTL)));
|
||||
obj.push_back(Pair("difficulty_skein", (double)GetDifficulty(NULL, ALGO_SKEIN)));
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_QUBIT)));
|
||||
if(GetTime() >= nTimeYescryptStart)
|
||||
{
|
||||
obj.push_back(Pair("difficulty_yescrypt",(double)GetDifficulty(NULL, ALGO_CPU)));
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_CPU)));
|
||||
}
|
||||
obj.push_back(Pair("errors", GetWarnings("statusbar")));
|
||||
obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
|
||||
// obj.push_back(Pair("networkhashps", getnetworkhashps(params, false)));
|
||||
|
||||
+11
-2
@@ -12,6 +12,7 @@
|
||||
#include "rpcserver.h"
|
||||
#include "timedata.h"
|
||||
#include "util.h"
|
||||
#include "myriad_params.h"
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "wallet/wallet.h"
|
||||
#include "wallet/walletdb.h"
|
||||
@@ -99,13 +100,21 @@ Value getinfo(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("connections", (int)vNodes.size()));
|
||||
obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string())));
|
||||
obj.push_back(Pair("pow_algo_id", miningAlgo));
|
||||
obj.push_back(Pair("pow_algo", GetAlgoName(miningAlgo)));
|
||||
obj.push_back(Pair("pow_algo", GetAlgoName(miningAlgo, GetTime())));
|
||||
obj.push_back(Pair("difficulty", (double)GetDifficulty(NULL, miningAlgo)));
|
||||
obj.push_back(Pair("difficulty_sha256d", (double)GetDifficulty(NULL, ALGO_SHA256D)));
|
||||
obj.push_back(Pair("difficulty_scrypt", (double)GetDifficulty(NULL, ALGO_SCRYPT)));
|
||||
obj.push_back(Pair("difficulty_groestl", (double)GetDifficulty(NULL, ALGO_GROESTL)));
|
||||
obj.push_back(Pair("difficulty_skein", (double)GetDifficulty(NULL, ALGO_SKEIN)));
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_QUBIT)));
|
||||
if(GetTime() >= nTimeYescryptStart)
|
||||
{
|
||||
obj.push_back(Pair("difficulty_yescrypt",(double)GetDifficulty(NULL, ALGO_CPU)));
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.push_back(Pair("difficulty_qubit", (double)GetDifficulty(NULL, ALGO_CPU)));
|
||||
}
|
||||
|
||||
obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC()));
|
||||
#ifdef ENABLE_WALLET
|
||||
if (pwalletMain) {
|
||||
|
||||
Reference in New Issue
Block a user