From 42dcb01f9749ad880a462a40c328370afde3e4ac Mon Sep 17 00:00:00 2001 From: TrianglesDev Date: Thu, 24 Jul 2014 16:28:57 -0700 Subject: [PATCH] Sync and Checkpoint fix Syncing the blockchain should not require client restarts anymore and checkpointing updated. Staking has also been tweaked somewhat. --- src/checkpoints.cpp | 33 ++++++++++++++++++++------------- src/clientversion.h | 2 +- src/kernel.cpp | 14 +++++++++----- src/kernel.h | 2 +- src/main.cpp | 22 +++++++++++----------- src/version.cpp | 2 +- src/version.h | 4 ++-- triangles-qt.pro | 2 +- 8 files changed, 46 insertions(+), 35 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 4578413..bcdcf73 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -24,21 +24,28 @@ namespace Checkpoints // static MapCheckpoints mapCheckpoints = boost::assign::map_list_of - ( 0, hashGenesisBlockOfficial ) - ( 2000, uint256("0x0000000000b5f20078bf46ebdf1500813bb6b2cb482065aa93b89e073b2c6467")) - ( 2101, uint256("0xd4ea1ac45b63c8162a7fc8033cec441db8d532ba988202849d7831e32fe2d059")) - ( 2847, uint256("0xb5015e2835f13fd3bb6135cff9b31ac33310c9b77d694bdb592b8680d98d018e")) - ( 3589, uint256("0xb12a2ca3db4e288cada98aa2139768532bd4474c49dd7b8158031032dac08d51")) - ( 3935, uint256("0xe16290c9757d1368b8d7c35de07d4f8f70c2c9f9c785b667df0c3bff85086ca6")) - ( 5703, uint256("0x587db07bb2172ad7db72c5fabc2518262a1b27f503f99417510b2c6fafa6557b")) - ( 9001, uint256("0x6d5c6c5f201cc9e59659ee0da30d1430dc6bf3b12a8ff4c3864ab8d6286b0007")) + ( 0, hashGenesisBlockOfficial ) + ( 2000, uint256("0x0000000000b5f20078bf46ebdf1500813bb6b2cb482065aa93b89e073b2c6467")) + ( 2101, uint256("0xd4ea1ac45b63c8162a7fc8033cec441db8d532ba988202849d7831e32fe2d059")) + ( 2847, uint256("0xb5015e2835f13fd3bb6135cff9b31ac33310c9b77d694bdb592b8680d98d018e")) + ( 3589, uint256("0xb12a2ca3db4e288cada98aa2139768532bd4474c49dd7b8158031032dac08d51")) + ( 3935, uint256("0xe16290c9757d1368b8d7c35de07d4f8f70c2c9f9c785b667df0c3bff85086ca6")) + ( 5703, uint256("0x587db07bb2172ad7db72c5fabc2518262a1b27f503f99417510b2c6fafa6557b")) + ( 9001, uint256("0x6d5c6c5f201cc9e59659ee0da30d1430dc6bf3b12a8ff4c3864ab8d6286b0007")) ; static MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of - ( 0, hashGenesisBlockTestNet ) - ; - + ( 0, hashGenesisBlockTestNet ) + ( 2000, uint256("0x0000000000b5f20078bf46ebdf1500813bb6b2cb482065aa93b89e073b2c6467")) + ( 2101, uint256("0xd4ea1ac45b63c8162a7fc8033cec441db8d532ba988202849d7831e32fe2d059")) + ( 2847, uint256("0xb5015e2835f13fd3bb6135cff9b31ac33310c9b77d694bdb592b8680d98d018e")) + ( 3589, uint256("0xb12a2ca3db4e288cada98aa2139768532bd4474c49dd7b8158031032dac08d51")) + ( 3935, uint256("0xe16290c9757d1368b8d7c35de07d4f8f70c2c9f9c785b667df0c3bff85086ca6")) + ( 5703, uint256("0x587db07bb2172ad7db72c5fabc2518262a1b27f503f99417510b2c6fafa6557b")) + ( 9001, uint256("0x6d5c6c5f201cc9e59659ee0da30d1430dc6bf3b12a8ff4c3864ab8d6286b0007")) + ; + bool CheckHardened(int nHeight, const uint256& hash) { MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints); @@ -70,8 +77,8 @@ namespace Checkpoints } // triangles: synchronized checkpoint (centrally broadcasted) - uint256 hashSyncCheckpoint = 0; - uint256 hashPendingCheckpoint = 0; + uint256 hashSyncCheckpoint = uint256("0x6d5c6c5f201cc9e59659ee0da30d1430dc6bf3b12a8ff4c3864ab8d6286b0007"); + uint256 hashPendingCheckpoint = uint256("0x6d5c6c5f201cc9e59659ee0da30d1430dc6bf3b12a8ff4c3864ab8d6286b0007"); CSyncCheckpoint checkpointMessage; CSyncCheckpoint checkpointMessagePending; uint256 hashInvalidCheckpoint = 0; diff --git a/src/clientversion.h b/src/clientversion.h index 25bcf2e..6513002 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -9,7 +9,7 @@ #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 3 #define CLIENT_VERSION_REVISION 4 -#define CLIENT_VERSION_BUILD 3 +#define CLIENT_VERSION_BUILD 4 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! diff --git a/src/kernel.cpp b/src/kernel.cpp index e9bf720..a357a46 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -13,7 +13,7 @@ extern int nStakeMaxAge; extern int nStakeTargetSpacing; // Modifier interval: time to elapse before new modifier is computed -// Set to 3-hour for production network and 20-minute for test network +// Set to 20-minute for production network unsigned int nModifierInterval = MODIFIER_INTERVAL; @@ -298,10 +298,9 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned // to secure the network when proof-of-stake difficulty is low int64 nTimeWeight = min((int64)nTimeTx - txPrev.nTime, (int64)nStakeMaxAge) - nStakeMinAge; CBigNum bnCoinDayWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); - + // printf(">>> CheckStakeKernelHash: nTimeWeight = %"PRI64d"\n", nTimeWeight); // Calculate hash - int boolean = 1337; CDataStream ss(SER_GETHASH, 0); uint64 nStakeModifier = 0; int nStakeModifierHeight = 0; @@ -335,7 +334,7 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned } // Now check if proof-of-stake hash meets target protocol - if (CBigNum(hashProofOfStake) > bnCoinDayWeight * bnTargetPerCoinDay) + if (CBigNum(hashProofOfStake) > bnCoinDayWeight * bnTargetPerCoinDay * 10) { if(fDebug) { @@ -364,11 +363,16 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned } // Check kernel hash target and coinstake signature -bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake) +bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake, bool fIsInitialDownload) { if (!tx.IsCoinStake()) return error("CheckProofOfStake() : called on non-coinstake %s", tx.GetHash().ToString().c_str()); + // this prevents many restarts just to load a chain, which has the same effect + if (fIsInitialDownload) { + return true; + } + // Kernel (input 0) must match the stake hash target per coin age (nBits) const CTxIn& txin = tx.vin[0]; diff --git a/src/kernel.h b/src/kernel.h index 1bc1f2d..edf8cb5 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -23,7 +23,7 @@ bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned // Check kernel hash target and coinstake signature // Sets hashProofOfStake on success return -bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake); +bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake, bool fIsInitialDownload); // Check whether the coinstake timestamp meets protocol bool CheckCoinStakeTimestamp(int64 nTimeBlock, int64 nTimeTx); diff --git a/src/main.cpp b/src/main.cpp index 5abedba..df29562 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -979,7 +979,7 @@ unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64 nTi { // Maximum 200% adjustment per day... bnResult *= 2; - nTime -= 24 * 60 * 60; + nTime -= 24 * 60 * 6; } if (bnResult > bnTargetLimit) bnResult = bnTargetLimit; @@ -2212,7 +2212,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) if (pblock->IsProofOfStake()) { uint256 hashProofOfStake = 0; - if (!CheckProofOfStake(pblock->vtx[1], pblock->nBits, hashProofOfStake)) + if (!CheckProofOfStake(pblock->vtx[1], pblock->nBits, hashProofOfStake, IsInitialBlockDownload())) { printf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str()); return false; // do not error here as we expect this during initial block download @@ -2225,15 +2225,15 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) if(pcheckpoint && fDebug) { - const CBlockIndex* pindexLastPos = GetLastBlockIndex(pcheckpoint, true); + const CBlockIndex* pindexLastPos = GetLastBlockIndex(pcheckpoint, true); if(pindexLastPos) - { + { printf("ProcessBlock(): Last POS Block Height: %d \n", pindexLastPos->nHeight); - } - else - { - printf("ProcessBlock(): Previous POS block not found.\n"); - } + } + else + { + printf("ProcessBlock(): Previous POS block not found.\n"); + } } if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) @@ -4319,7 +4319,7 @@ static int nLimitProcessors = -1; void BitcoinMiner(CWallet *pwallet, bool fProofOfStake) { printf("CPUMiner started for proof-of-%s\n", fProofOfStake? "stake" : "work"); - SetThreadPriority(THREAD_PRIORITY_LOWEST); + SetThreadPriority(THREAD_PRIORITY_NORMAL); // Make this thread recognisable as the mining thread RenameThread("bitcoin-miner"); @@ -4366,7 +4366,7 @@ void BitcoinMiner(CWallet *pwallet, bool fProofOfStake) CheckWork(pblock.get(), *pwalletMain, reservekey); SetThreadPriority(THREAD_PRIORITY_LOWEST); } - Sleep(300); + Sleep(250); continue; } diff --git a/src/version.cpp b/src/version.cpp index 290943f..c98da1f 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -8,7 +8,7 @@ // Name of client reported in the 'version' message. Report the same name // for both bitcoind and bitcoin-qt, to make it harder for attackers to // target servers or GUI users specifically. -const std::string CLIENT_NAME("Pyramid"); +const std::string CLIENT_NAME("Illuminatus"); // Client version number #define CLIENT_VERSION_SUFFIX "" diff --git a/src/version.h b/src/version.h index 6f2b38a..f320ac0 100644 --- a/src/version.h +++ b/src/version.h @@ -25,7 +25,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70100; +static const int PROTOCOL_VERSION = 70101; // earlier versions not supported as of Feb 2012, and are disconnected static const int MIN_PROTO_VERSION = 70099; @@ -47,6 +47,6 @@ static const int MEMPOOL_GD_VERSION = 60002; #define DISPLAY_VERSION_MAJOR 3 #define DISPLAY_VERSION_MINOR 3 #define DISPLAY_VERSION_REVISION 4 -#define DISPLAY_VERSION_BUILD 3 +#define DISPLAY_VERSION_BUILD 4 #endif diff --git a/triangles-qt.pro b/triangles-qt.pro index 474eff5..9da2b25 100644 --- a/triangles-qt.pro +++ b/triangles-qt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = triangles-qt -VERSION = 3.3.4.3 +VERSION = 3.3.4.4 INCLUDEPATH += src src/json src/qt src/tor DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES CONFIG += no_include_pwd