Skip to content

Commit

Permalink
v1.1 Fork
Browse files Browse the repository at this point in the history
Forking at 1423836000; // Fri, 13 Feb 2015 14:00:00 GMT
to reign in timedrift to 60 seconds.
  • Loading branch information
presstab committed Feb 13, 2015
1 parent be434ee commit e998e8e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
16 changes: 4 additions & 12 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ CBlockIndex* pindexBest = NULL;
int64 nTimeBestReceived = 0;
bool fHaveGUI = false;


CMedianFilter<int> cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have

map<uint256, CBlock*> mapOrphanBlocks;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4642,4 +4641,4 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet)
Sleep(10);
}
}
}
}
9 changes: 8 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/qt/res/bitcoin-qt.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class CWallet : public CCryptoKeyStore
fStakeRequirement = false;

// Stake Settings
nHashDrift = 300;
nHashDrift = 60;
nStakeSplitThreshold = 2000;

//MultiSend
Expand Down Expand Up @@ -161,7 +161,7 @@ class CWallet : public CCryptoKeyStore
fStakeRequirement = false;

// Stake Settings
nHashDrift = 300;
nHashDrift = 60;
nStakeSplitThreshold = 2000;

//MultiSend
Expand Down

0 comments on commit e998e8e

Please sign in to comment.