Permalink
Browse files

Proof of Work Limits

From Block 5.6m PoW will only be accepted after a Stake block, or 10
minutes with no block
From Block 6.0m PoW will only be accepted after 10 mins with no block
Bump to version 1.5.3.0 and update Proto Version, will send alerts
Bump back down the DB version , as LevelDB1.9 "should" work fine as a
drop in with LevelDB 1.7
  • Loading branch information...
Tranz5 committed Jul 8, 2017
1 parent 166baec commit e14a28cce0967110327f758066c11922af94aa5e
Showing with 70 additions and 10 deletions.
  1. +1 −1 HoboNickels-qt.pro
  2. +3 −2 src/checkpoints.cpp
  3. +1 −0 src/checkpoints.h
  4. +2 −2 src/clientversion.h
  5. +14 −2 src/main.cpp
  6. +12 −1 src/main.h
  7. +35 −0 src/rpcmining.cpp
  8. +2 −2 src/version.h
View
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = HoboNickels-qt
VERSION = 1.5.2.5
VERSION = 1.5.3.0
QT += core gui network
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES
View
@@ -215,7 +215,6 @@ namespace Checkpoints
// Check against synchronized checkpoint
bool CheckSync(const uint256& hashBlock, const CBlockIndex* pindexPrev)
{
if (fTestNet) return true; // Testnet has no checkpoints
int nHeight = pindexPrev->nHeight + 1;
LOCK(cs_hashSyncCheckpoint);
@@ -369,15 +368,17 @@ namespace Checkpoints
}
// sync-checkpoint master key
const std::string CSyncCheckpoint::strMasterPubKey = "04bdd7aa319f16d2682afab4d0d807141be59caac0291802ba7467f0288eaf54db9d144f8c78231d61746bb7b5f1ef70f92c62d4b18c5488ab39118e38460304dd";
const std::string CSyncCheckpoint::strMasterPubKeyTestNet = "04d22e393d8500b017d0d3df9ef961321df12748bbd39a9f18b4cc47002717ad4d2f0ba87d1d81b83fff61472fad51ce11677b55b4f0861b4272ca3c6b001f8b1e";
std::string CSyncCheckpoint::strMasterPrivKey = "";
// verify signature of sync-checkpoint message
bool CSyncCheckpoint::CheckSignature()
{
CKey key;
if (!key.SetPubKey(ParseHex(CSyncCheckpoint::strMasterPubKey)))
if (!key.SetPubKey(ParseHex((fTestNet ? CSyncCheckpoint::strMasterPubKeyTestNet : CSyncCheckpoint::strMasterPubKey))))
return error("CSyncCheckpoint::CheckSignature() : SetPubKey failed");
if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
return error("CSyncCheckpoint::CheckSignature() : verify signature failed");
View
@@ -100,6 +100,7 @@ class CSyncCheckpoint : public CUnsignedSyncCheckpoint
{
public:
static const std::string strMasterPubKey;
static const std::string strMasterPubKeyTestNet;
static std::string strMasterPrivKey;
std::vector<unsigned char> vchMsg;
View
@@ -8,8 +8,8 @@
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 5
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 5
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
View
@@ -2359,6 +2359,18 @@ bool CBlock::AcceptBlock()
CBlockIndex* pindexPrev = (*mi).second;
int nHeight = pindexPrev->nHeight+1;
// Code to effectivly turn off PoW, except for emergency need.
if (IsProofOfWork() && nHeight > (fTestNet ? POW_STOP_HEIGHT_TESTNET : POW_STOP_HEIGHT)
&& (GetBlockTime() - FutureDrift(pindexPrev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT)))
return DoS(10, error("AcceptBlock() : PoW is only allowed after 10 mins of no block found"));
// Code to prevent flash mining.
if (IsProofOfWork() && nHeight > (fTestNet ? POW_LIMIT_HEIGHT_TESTNET : POW_LIMIT_HEIGHT) && pindexPrev->IsProofOfWork())
{
if (GetBlockTime() - FutureDrift(pindexPrev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT))
return DoS(10, error("AcceptBlock() : PoW must come afer PoS only or after 10 mins"));
}
// Check proof-of-work or proof-of-stake
if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake()))
return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake"));
@@ -2909,11 +2921,11 @@ bool LoadBlockIndex(bool fAllowNew)
{
CTxDB txdb;
string strPubKey = "";
if (!txdb.ReadCheckpointPubKey(strPubKey) || strPubKey != CSyncCheckpoint::strMasterPubKey)
if (!txdb.ReadCheckpointPubKey(strPubKey) || strPubKey != (fTestNet ? CSyncCheckpoint::strMasterPubKeyTestNet : CSyncCheckpoint::strMasterPubKey))
{
// write checkpoint master key to db
txdb.TxnBegin();
if (!txdb.WriteCheckpointPubKey(CSyncCheckpoint::strMasterPubKey))
if (!txdb.WriteCheckpointPubKey((fTestNet ? CSyncCheckpoint::strMasterPubKeyTestNet : CSyncCheckpoint::strMasterPubKey)))
return error("LoadBlockIndex() : failed to write new checkpoint master key to db");
if (!txdb.TxnCommit())
return error("LoadBlockIndex() : failed to commit new checkpoint master key to db");
View
@@ -67,7 +67,18 @@ static const unsigned int POS_REWARD_SWITCH_TIME = 1378684800; // 9 SEP 2013 00:
static const unsigned int POS_REWARD_FIX_TIME = 1383177600; // 31 OCT 2013 00:00:00
static const unsigned int POS_REWARD_FIX_TIME2 = 1383606000; // 04 Nov 2013 23:00:00
static const unsigned int VERSION1_5_SWITCH_TIME = 1421489410; // Sat, 17 Jan 2015 10:10:10 GMT
static const unsigned int VERSION1_5_SWITCH_BLOCK = 1600000; // Block 1.6 million, approx same time
static const int VERSION1_5_SWITCH_BLOCK = 1600000; // Block 1.6 million, approx same time
static const int POW_LIMIT_HEIGHT_TESTNET = 4500; // Limit Flash PoW Mining TestNet.
static const int POW_STOP_HEIGHT_TESTNET = 4600; // Limit PoW Mining TestNet
static const int64_t POW_TIME_LIMIT_TESTNET = 60; // Time for PoW to wait to find block TestNet
static const int POW_LIMIT_HEIGHT = 5600000 ; // Limit Flash PoW Mining.
static const int POW_STOP_HEIGHT = 6000000; // Limit PoW Mining.
static const int64_t POW_TIME_LIMIT = 60 * 10; // Time for PoW to wait to find block
inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
View
@@ -73,6 +73,17 @@ Value getworkex(CWallet* pWallet, const Array& params, bool fHelp)
if (IsInitialBlockDownload())
throw JSONRPCError(-10, "HoboNickels is downloading blocks...");
// Code to effectivly turn off PoW, except for emergency need.
if (pindexBest->nHeight >= (fTestNet ? POW_STOP_HEIGHT_TESTNET : POW_STOP_HEIGHT)
&& (GetAdjustedTime() - FutureDrift(pindexBest->pprev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT)))
throw JSONRPCError(RPC_MISC_ERROR, "PoW is only allowed after 10 mins of no block found");
// Code to prevent flash mining.
if (pindexBest->IsProofOfWork() && pindexBest->nHeight >= (fTestNet ? POW_LIMIT_HEIGHT_TESTNET : POW_LIMIT_HEIGHT))
{
if (GetAdjustedTime() - FutureDrift(pindexBest->pprev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT))
throw JSONRPCError(RPC_MISC_ERROR, "PoW must wait for PoS block or 10 min with no block");
}
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock;
static vector<CBlock*> vNewBlock;
@@ -207,6 +218,18 @@ Value getwork(CWallet* pWallet, const Array& params, bool fHelp)
if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "HoboNickels is downloading blocks...");
// Code to effectivly turn off PoW, except for emergency need.
if (pindexBest->nHeight >= (fTestNet ? POW_STOP_HEIGHT_TESTNET : POW_STOP_HEIGHT)
&& (GetAdjustedTime() - FutureDrift(pindexBest->pprev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT)))
throw JSONRPCError(RPC_MISC_ERROR, "PoW is only allowed after 10 mins of no block found");
// Code to prevent flash mining.
if (pindexBest->IsProofOfWork() && pindexBest->nHeight >= (fTestNet ? POW_LIMIT_HEIGHT_TESTNET : POW_LIMIT_HEIGHT))
{
if (GetAdjustedTime() - FutureDrift(pindexBest->pprev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT))
throw JSONRPCError(RPC_MISC_ERROR, "PoW must wait for PoS block or 10 min with no block");
}
typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t;
static mapNewBlock_t mapNewBlock; // FIXME: thread safety
static vector<CBlock*> vNewBlock;
@@ -352,6 +375,18 @@ Value getblocktemplate(CWallet* pWallet, const Array& params, bool fHelp)
if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "HoboNickels is downloading blocks...");
// Code to effectivly turn off PoW, except for emergency need.
if (pindexBest->nHeight >= (fTestNet ? POW_STOP_HEIGHT_TESTNET : POW_STOP_HEIGHT )
&& (GetAdjustedTime() - FutureDrift(pindexBest->pprev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT)))
throw JSONRPCError(RPC_MISC_ERROR, "PoW is only allowed after 10 mins of no block found");
// Code to prevent flash mining.
if (pindexBest->IsProofOfWork() && pindexBest->nHeight >= (fTestNet ? POW_LIMIT_HEIGHT_TESTNET : POW_LIMIT_HEIGHT))
{
if (GetAdjustedTime() - FutureDrift(pindexBest->pprev->GetBlockTime()) < (fTestNet ? POW_TIME_LIMIT_TESTNET : POW_TIME_LIMIT))
throw JSONRPCError(RPC_MISC_ERROR, "PoW must wait for PoS block or 10 min with no block");
}
static CReserveKey reservekey(pWallet);
// Update block
View
@@ -22,10 +22,10 @@ extern const std::string CLIENT_BUILD;
extern const std::string CLIENT_DATE;
// database version
static const int DATABASE_VERSION = 70600;
static const int DATABASE_VERSION = 70501;
// network protocol versioning
static const int PROTOCOL_VERSION = 70007;
static const int PROTOCOL_VERSION = 70008;
// intial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;

0 comments on commit e14a28c

Please sign in to comment.