From e998e8e9aa3f9e6cae7d02b3028890818e3788b2 Mon Sep 17 00:00:00 2001 From: presstab Date: Thu, 12 Feb 2015 20:01:09 -0700 Subject: [PATCH] v1.1 Fork Forking at 1423836000; // Fri, 13 Feb 2015 14:00:00 GMT to reign in timedrift to 60 seconds. --- src/kernel.cpp | 16 ++++------------ src/main.cpp | 13 ++++++------- src/main.h | 9 ++++++++- src/qt/res/bitcoin-qt.rc | 4 ++-- src/version.cpp | 2 +- src/version.h | 6 +++--- src/wallet.h | 4 ++-- 7 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/kernel.cpp b/src/kernel.cpp index 991bcc9cb..177e6cb66 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -297,21 +297,14 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier /** Presstab - HyperStake hashing I redesigned the hashing iteration in a few ways. - Code Reorginization - Instead of iterating the hashing in wallet.cpp, it is iterated in kernel.cpp inside of checkstakekernelhash, this allows the iteration to not need to initialize the variables for every iteration. This is also true for the stake modifier, which was previously calculated for each iteration. - liteStake - Previously the staking process would continuosly rehash the same hashes over and over, needlessly taking up valuable CPU power. I have added a std::map that tracks the block height and the last time the wallet hashed on this height. Depending on your staking settings, the wallet will not begin a new round of hashing until after a certain amount of time has passed, or a new block is accepted. This time delay -can be found in main.cpp bitcoinminer(). This means that there will be 1-5 seconds of heavier CPU use once every few minutes, compared to -continued heavy CPU use. - -Staking Modes - This allows the user to decide how much time they want to hash into the future and past. HYP has a max time drift of 15 minutes. -The aggressive mode allows the user to hash 10 minutes into the future and 10 into the past. This will affect the chains timing a bit, and also -might make difficulty more volatile in the short run. In my opinion it is more dangerous to allow a creative coder to do these same accepted -practices without letting general users do the same. +can be found in main.cpp bitcoinminer(). This means that there will be 1-5 seconds of hashing with the CPU once every few minutes, compared to +continued hashing with the CPU. **/ uint256 stakeHash(unsigned int nTimeTx, unsigned int nTxPrevTime, CDataStream ss, unsigned int prevoutIndex, unsigned int nTxPrevOffset, unsigned int nTimeBlockFrom) { @@ -367,14 +360,13 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned return stakeTargetHit(hashProofOfStake, (int64)nTimeTx - nTxPrevTime, nValueIn, bnTargetPerCoinDay); } - nHashDrift = min(nHashDrift, (unsigned int)(10*60)); // only allow 10 minutes of hashing in the future bool fSuccess = false; unsigned int nTryTime = 0; unsigned int i; - for(i = 0; i < (nHashDrift*2); i++) //iterate the hashing + for(i = 0; i < (nHashDrift); i++) //iterate the hashing { //hash this iteration - nTryTime = nTimeTx - nHashDrift + i; + nTryTime = nTimeTx + nHashDrift - i; hashProofOfStake = stakeHash(nTryTime, nTxPrevTime, ss, prevout.n, nTxPrevOffset, nTimeBlockFrom); // if stake hash does not meet the target then continue to next iteration diff --git a/src/main.cpp b/src/main.cpp index a4c122789..189ab4253 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,7 +59,6 @@ CBlockIndex* pindexBest = NULL; int64 nTimeBestReceived = 0; bool fHaveGUI = false; - CMedianFilter cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have map mapOrphanBlocks; @@ -2049,7 +2048,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot) const return DoS(50, error("CheckBlock() : proof of work failed")); // Check timestamp - if (GetBlockTime() > GetAdjustedTime() + nMaxClockDrift) + if (GetBlockTime() > GetAdjustedTime() + GetClockDrift(GetBlockTime())) return error("CheckBlock() : block timestamp too far in the future"); // First transaction must be coinbase, the rest must not be @@ -2069,7 +2068,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot) const return error("CheckBlock() : coinbase output not empty for proof-of-stake block"); // Check coinbase timestamp - if (GetBlockTime() > (int64)vtx[0].nTime + nMaxClockDrift) + if (GetBlockTime() > (int64)vtx[0].nTime + GetClockDrift(GetBlockTime())) return DoS(50, error("CheckBlock() : coinbase timestamp is too early")); // Check coinstake timestamp @@ -2140,7 +2139,7 @@ bool CBlock::AcceptBlock() return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake")); // Check timestamp against prev - if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + nMaxClockDrift < pindexPrev->GetBlockTime()) + if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + GetClockDrift(GetBlockTime()) < pindexPrev->GetBlockTime()) return error("AcceptBlock() : block's timestamp is too early"); // Check that all transactions are finalized @@ -4086,7 +4085,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) // printf(">>> OK1\n"); if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime-nLastCoinStakeSearchTime, txCoinStake)) { - if (txCoinStake.nTime >= max(pindexPrev->GetMedianTimePast()+1, pindexPrev->GetBlockTime() - nMaxClockDrift)) + if (txCoinStake.nTime >= max(pindexPrev->GetMedianTimePast()+1, pindexPrev->GetBlockTime() - GetClockDrift(pindexPrev->GetBlockTime()))) { // make sure coinstake would meet timestamp protocol // as it would be the same as the block timestamp pblock->vtx[0].vout[0].SetEmpty(); @@ -4301,7 +4300,7 @@ CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) if (pblock->IsProofOfStake()) pblock->nTime = pblock->vtx[1].nTime; //same as coinstake timestamp pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, pblock->GetMaxTransactionTime()); - pblock->nTime = max(pblock->GetBlockTime(), pindexPrev->GetBlockTime() - nMaxClockDrift); + pblock->nTime = max(pblock->GetBlockTime(), pindexPrev->GetBlockTime() - GetClockDrift(pindexPrev->GetBlockTime())); if (pblock->IsProofOfWork()) pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; @@ -4642,4 +4641,4 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet) Sleep(10); } } -} +} \ No newline at end of file diff --git a/src/main.h b/src/main.h index cafcfbfa8..4fc07b43c 100644 --- a/src/main.h +++ b/src/main.h @@ -41,6 +41,7 @@ static const int64 MAX_MONEY2 = 60000000 * COIN; // 60 mil static const int64 MAX_MINT_PROOF_OF_STAKE = 2.00 * COIN; // 200% annual interest static const int64 MAX_MINT_PROOF_OF_STAKEV2 = 7.50 * COIN; // 750% annual interest static const unsigned int FORK_TIME = 1404678625; // Sun, 06 Jul 2014 20:30:25 GMT +static const unsigned int FORK_TIME2 = 1423836000; // Fri, 13 Feb 2015 14:00:00 GMT static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE; inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } @@ -56,7 +57,13 @@ static const int fHaveUPnP = false; static const uint256 hashGenesisBlockOfficial("0x000005fe04e512585c3611369c7ce23f130958038c18a462577d002680dab4fc"); static const uint256 hashGenesisBlockTestNet ("0x0000076130e1a816bab8f26310839ab601305b2315dc3b8b1a250faa0cb1f9a8"); -static const int64 nMaxClockDrift = 15 * 60; // fifteen minutes +inline int64 GetClockDrift(int64 nTime) +{ + if(nTime < FORK_TIME2) + return 15 * 60; + else + return 60; +} static const int64 MAX_TIME_SINCE_BEST_BLOCK = 10; // how many seconds to wait before sending next PushGetBlocks() extern CScript COINBASE_FLAGS; diff --git a/src/qt/res/bitcoin-qt.rc b/src/qt/res/bitcoin-qt.rc index 7b2bf4e77..96c590179 100644 --- a/src/qt/res/bitcoin-qt.rc +++ b/src/qt/res/bitcoin-qt.rc @@ -16,13 +16,13 @@ BEGIN BEGIN VALUE "CompanyName", "HyperStake" VALUE "FileDescription", "HyperStake-Qt (OSS GUI client for HyperStake)" - VALUE "FileVersion", "1.0.9.3-BETA" + VALUE "FileVersion", "1.1" VALUE "InternalName", "HyperStake-qt" VALUE "LegalCopyright", "2009-2012 The Bitcoin developers, 2012-2013 The HyperStake & PPCoin developers" VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." VALUE "OriginalFilename", "HyperStake-qt.exe" VALUE "ProductName", "HyperStake-Qt" - VALUE "ProductVersion", "1.0.9.3-BETA" + VALUE "ProductVersion", "1.1" END END diff --git a/src/version.cpp b/src/version.cpp index 8b4914318..8c57c4eaf 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -11,7 +11,7 @@ const std::string CLIENT_NAME("HyperStake"); // Client version number -#define CLIENT_VERSION_SUFFIX "HyperStake-1.0.9.3-BETA" +#define CLIENT_VERSION_SUFFIX "HyperStake-1.1" // The following part of the code determines the CLIENT_BUILD variable. diff --git a/src/version.h b/src/version.h index c51450f41..e20ca3f59 100644 --- a/src/version.h +++ b/src/version.h @@ -32,8 +32,8 @@ static const int BIP0031_VERSION = 60000; static const int MEMPOOL_GD_VERSION = 60002; #define DISPLAY_VERSION_MAJOR 1 -#define DISPLAY_VERSION_MINOR 0 -#define DISPLAY_VERSION_REVISION 9 -#define DISPLAY_VERSION_BUILD 3 +#define DISPLAY_VERSION_MINOR 1 +#define DISPLAY_VERSION_REVISION 0 +#define DISPLAY_VERSION_BUILD 0 #endif diff --git a/src/wallet.h b/src/wallet.h index 4f49a3090..f6ae0853c 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -130,7 +130,7 @@ class CWallet : public CCryptoKeyStore fStakeRequirement = false; // Stake Settings - nHashDrift = 300; + nHashDrift = 60; nStakeSplitThreshold = 2000; //MultiSend @@ -161,7 +161,7 @@ class CWallet : public CCryptoKeyStore fStakeRequirement = false; // Stake Settings - nHashDrift = 300; + nHashDrift = 60; nStakeSplitThreshold = 2000; //MultiSend