From 4fd5fa2d55efa169a2477436d486addff4e15b9c Mon Sep 17 00:00:00 2001 From: Gridcoin Date: Tue, 1 Nov 2016 19:04:22 -0500 Subject: [PATCH] 3.5.8.2-Mandatory Gridcoin Research 3.5.8.2/MSI=41.7 Mandatory Upgrade - At block 725000 we require blocks to be signed with keypairs. - Enable binary superblocks at block 725000. - When keys expire at the 6 month interval, check the keypair by signing a Test block, and if good, renew the keypair, otherwise generate a new keypair and a new beacon and save the new keypair automatically. (The wallet will repair the keypair if one of two keys are missing). - Note: execute beaconstatus to find the status of your Prod keypair. --- Makefile.Debug | 2 +- Makefile.Release | 2 +- .../GridcoinInstaller/GridcoinResearch.vdproj | 8 ++++---- src/clientversion.h | 2 +- src/kernel.cpp | 4 +--- src/main.cpp | 19 +++++++++++++------ src/main.h | 7 ++++++- src/rpcblockchain.cpp | 14 +++++++++++++- src/wallet.cpp | 2 -- 9 files changed, 40 insertions(+), 20 deletions(-) diff --git a/Makefile.Debug b/Makefile.Debug index 1b227feab0..c32f2dcfdc 100644 --- a/Makefile.Debug +++ b/Makefile.Debug @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: gridcoinresearch -# Generated by qmake (2.01a) (Qt 4.8.4) on: Sat Oct 15 14:29:26 2016 +# Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Nov 1 19:00:49 2016 # Project: gridcoinresearch.pro # Template: app ############################################################################# diff --git a/Makefile.Release b/Makefile.Release index 0e12dd6536..0914522f31 100644 --- a/Makefile.Release +++ b/Makefile.Release @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: gridcoinresearch -# Generated by qmake (2.01a) (Qt 4.8.4) on: Sat Oct 15 14:29:26 2016 +# Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Nov 1 19:00:49 2016 # Project: gridcoinresearch.pro # Template: app ############################################################################# diff --git a/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj b/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj index 51395adba1..370957b743 100644 --- a/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj +++ b/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj @@ -1120,19 +1120,19 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Gridcoin Research" - "ProductCode" = "8:{F2C51C09-E622-4259-BF15-F6D5BFAA777A}" - "PackageCode" = "8:{EA9810E9-3C35-42D0-8118-DB23C6DA3AE0}" + "ProductCode" = "8:{30AAD9EB-F91F-466F-AAC5-E4A0CE7BC53A}" + "PackageCode" = "8:{B6424258-604A-40D5-BEE0-640A2CAEC4C5}" "UpgradeCode" = "8:{9617E9EA-252F-43CE-B53E-B48C85F71192}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:TRUE" "DetectNewerInstalledVersion" = "11:FALSE" "InstallAllUsers" = "11:TRUE" - "ProductVersion" = "8:41.6" + "ProductVersion" = "8:41.7" "Manufacturer" = "8:GridcoinResearch" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" - "Title" = "8:Gridcoin Research 41.6" + "Title" = "8:Gridcoin Research 41.7" "Subject" = "8:" "ARPCONTACT" = "8:The Gridcoin Developers" "Keywords" = "8:Gridcoin Research" diff --git a/src/clientversion.h b/src/clientversion.h index 653f1f9890..0a3827e554 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -9,7 +9,7 @@ #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 5 #define CLIENT_VERSION_REVISION 8 -#define CLIENT_VERSION_BUILD 1 +#define CLIENT_VERSION_BUILD 2 // 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 f9de4f10d5..d794dbe89d 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -394,7 +394,7 @@ int64_t GetRSAWeightByCPIDWithRA(std::string cpid) int64_t GetRSAWeightByCPID(std::string cpid) { - if (IsResearchAgeEnabled(pindexBest->nHeight) && bNewbieFeatureEnabled) + if (IsResearchAgeEnabled(pindexBest->nHeight) && AreBinarySuperblocksEnabled(pindexBest->nHeight)) { return GetRSAWeightByCPIDWithRA(cpid); //ToDo : During next mandatory, retire this old function. @@ -421,8 +421,6 @@ int64_t GetRSAWeightByCPID(std::string cpid) if (IsResearchAgeEnabled(pindexBest->nHeight) && weight < 0) weight=0; } - //if (IsResearchAgeEnabled(pindexBest->nHeight) && !bNewbieFeatureEnabled) weight = UntrustedHost.Magnitude; - } else { diff --git a/src/main.cpp b/src/main.cpp index 18c907f08c..508569fcc7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -304,7 +304,6 @@ unsigned int nStakeMaxAge = -1; // unlimited unsigned int nModifierInterval = 10 * 60; // time to elapse before new modifier is computed bool bCryptoLotteryEnabled = true; bool bRemotePaymentsEnabled = false; -bool bNewbieFeatureEnabled = false; bool bOPReturnEnabled = true; bool bOptionPaymentsEnabled = false; @@ -481,7 +480,7 @@ extern void FlushGridcoinBlockFile(bool fFinalize); std::string msHDDSerial = ""; //When syncing, we grandfather block rejection rules up to this block, as rules became stricter over time and fields changed - int nGrandfather = 677500; + int nGrandfather = 714999; int nNewIndex = 271625; int nNewIndex2 = 364500; @@ -5544,7 +5543,6 @@ bool LoadBlockIndex(bool fAllowNew) nNewIndex = 10; nNewIndex2 = 36500; bRemotePaymentsEnabled = false; - bNewbieFeatureEnabled = true; bOPReturnEnabled = false; bOptionPaymentsEnabled = false; //1-24-2016 @@ -8662,7 +8660,7 @@ std::string GetNeuralNetworkSuperBlock() #if defined(WIN32) && defined(QT_GUI) contract = qtGetNeuralContract(""); if (fDebug2 && LessVerbose(5)) printf("Appending SuperBlock %f\r\n",(double)contract.length()); - if (bNewbieFeatureEnabled) + if (AreBinarySuperblocksEnabled(nBestHeight)) { // 12-21-2015 : Stake a binary superblock contract = PackBinarySuperblock(contract); @@ -10297,7 +10295,7 @@ double GRCMagnitudeUnit(int64_t locktime) double Kitty = MaximumEmission - (network.payments/14); if (Kitty < 1) Kitty = 1; double MagnitudeUnit = 0; - if (bNewbieFeatureEnabled) + if (AreBinarySuperblocksEnabled(nBestHeight)) { MagnitudeUnit = (Kitty/TotalNetworkMagnitude)*1.25; } @@ -10318,7 +10316,7 @@ int64_t ComputeResearchAccrual(int64_t nTime, std::string cpid, std::string oper if (pHistorical->nHeight <= nNewIndex || pHistorical->nMagnitude==0 || pHistorical->nTime == 0) { //No prior block exists... Newbies get .01 age to bootstrap the CPID (otherwise they will not have any prior block to refer to, thus cannot get started): - if (!bNewbieFeatureEnabled) + if (!AreBinarySuperblocksEnabled(pindexLast->nHeight)) { return dCurrentMagnitude > 0 ? ((dCurrentMagnitude/100)*COIN) : 0; } @@ -10331,9 +10329,18 @@ int64_t ComputeResearchAccrual(int64_t nTime, std::string cpid, std::string oper { double dNewbieAccrualAge = ((double)nTime - (double)iBeaconTimestamp) / 86400; int64_t iAccrual = (int64_t)((dNewbieAccrualAge*dCurrentMagnitude*dMagnitudeUnit*COIN) + (1*COIN)); + if ((dNewbieAccrualAge*dCurrentMagnitude*dMagnitudeUnit) > 500) + { + printf("Newbie special stake too high, reward=500GRC"); + return (500*COIN); + } if (fDebug3) printf("\r\n Newbie Special First Stake for CPID %s, Age %f, Accrual %f \r\n",cpid.c_str(),dNewbieAccrualAge,(double)iAccrual); return iAccrual; } + else + { + return dCurrentMagnitude > 0 ? (((dCurrentMagnitude/100)*COIN) + (1*COIN)): 0; + } } } // To prevent reorgs and checkblock errors, ensure the research age is > 10 blocks wide: diff --git a/src/main.h b/src/main.h index ece0d94d6e..d0be0cc323 100644 --- a/src/main.h +++ b/src/main.h @@ -103,6 +103,12 @@ inline int GetSuperblockAgeSpacing(int nHeight) return (fTestNet ? 86400 : (nHeight > 364500) ? 86400 : 43200); } +inline bool AreBinarySuperblocksEnabled(int nHeight) +{ + return (fTestNet ? nHeight > 10000 : nHeight > 725000); +} + + inline int64_t PastDrift(int64_t nTime, int nHeight) { return IsProtocolV2(nHeight) ? nTime - 20 * 60 : nTime - 20 * 60; } inline int64_t FutureDrift(int64_t nTime, int nHeight) { return IsProtocolV2(nHeight) ? nTime + 20 * 60 : nTime + 20 * 60; } inline unsigned int GetTargetSpacing(int nHeight) { return IsProtocolV2(nHeight) ? 90 : 60; } @@ -151,7 +157,6 @@ extern std::map mapOrphanBlocks; extern int64_t COIN_YEAR_REWARD; extern bool bCryptoLotteryEnabled; extern bool bRemotePaymentsEnabled; -extern bool bNewbieFeatureEnabled; extern bool bOPReturnEnabled; extern bool bOptionPaymentsEnabled; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 624fa96b9d..e245514798 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -1404,7 +1404,19 @@ int GenerateNewKeyPair(std::string sIndex, std::string &sOutPubKey, std::string std::string sSuffix = fTestNet ? "testnet" : ""; sOutPrivKey = GetArgument("PrivateKey" + sIndex + sSuffix, ""); sOutPubKey = GetArgument("PublicKey" + sIndex + sSuffix, ""); - if (!sOutPrivKey.empty() && !sOutPubKey.empty()) return 1; + // If current keypair is not empty, but is invalid, allow the new keys to be stored, otherwise return 1: (10-25-2016) + + if (!sOutPrivKey.empty() && !sOutPubKey.empty()) + { + uint256 hashBlock = GetRandHash(); + std::string sSignature = SignBlockWithCPID(sIndex,hashBlock.GetHex()); + bool fResult = VerifyCPIDSignature(sIndex, hashBlock.GetHex(), sSignature); + if (fResult) + { + printf("\r\nGenerateNewKeyPair::Current keypair is valid.\r\n"); + return 1; + } + } // Generate the Keypair CKey key; key.MakeNewKey(false); diff --git a/src/wallet.cpp b/src/wallet.cpp index 0183da0c5c..31bc0c7ab2 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1884,13 +1884,11 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (!GlobalCPUMiningCPID.initialized) { printf("Global Mining CPID not initialized yet.. Unable to stake\r\n"); - msMiningErrors7="No Global CPID;"; return false; } if (GlobalCPUMiningCPID.cpid == "") { printf("Global Mining CPID not initialized yet.. Unable to stake\r\n"); - msMiningErrors7="No Global CPID"; return false; }