From 941eb66862134292f342fd1bf0c0b0ed370874dd Mon Sep 17 00:00:00 2001 From: Gridcoin Date: Sun, 12 Feb 2017 19:38:27 -0600 Subject: [PATCH] 3.5.8.6-leisure Gridcoin Research 3.5.8.6/MSI=42.0 Leisure Upgrade - Removed the dependency on Netsoft to test a new CPID - Modified 'list cpids' to detect the users projects and CPID without a call to Netsoft - Modified 'execute proveownership' to work in a decentralized fashion - Tested 'execute advertisebeacon' to ensure it works with a valid new CPID with 0 rac - Note: New users must have boinc installed with at least one project mounted in order to advertise a beacon and the Gridcoin e-mail setting must match the project server e-mail address value. --- Makefile.Debug | 1 - Makefile.Release | 1 - .../GridcoinInstaller/GridcoinResearch.vdproj | 71 +++---- src/clientversion.h | 3 +- src/kernel.cpp | 24 ++- src/main.cpp | 187 ++++++++---------- src/net.cpp | 6 +- src/rpcblockchain.cpp | 155 +-------------- 8 files changed, 146 insertions(+), 302 deletions(-) diff --git a/Makefile.Debug b/Makefile.Debug index 0b4194fba6..dd0e627e11 100644 --- a/Makefile.Debug +++ b/Makefile.Debug @@ -1,6 +1,5 @@ ############################################################################# # Makefile for building: gridcoinresearch -# Generated by qmake (2.01a) (Qt 4.8.4) on: Thu Jan 5 19:45:15 2017 # Project: gridcoinresearch.pro # Template: app ############################################################################# diff --git a/Makefile.Release b/Makefile.Release index fb92660a23..823894a95c 100644 --- a/Makefile.Release +++ b/Makefile.Release @@ -1,6 +1,5 @@ ############################################################################# # Makefile for building: gridcoinresearch -# Generated by qmake (2.01a) (Qt 4.8.4) on: Thu Jan 5 19:45:15 2017 # Project: gridcoinresearch.pro # Template: app ############################################################################# diff --git a/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj b/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj index 44e77604e8..8a5f6f787d 100644 --- a/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj +++ b/contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj @@ -27,12 +27,6 @@ } "Entry" { - "MsmKey" = "8:_1F7D757BF031E15D44C47B631F994972" - "OwnerKey" = "8:_7A0EA93E644A4D9E8037FBB3C062DD65" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { "MsmKey" = "8:_2C7D9AF4C6E04C06A26314A95B1FF010" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -117,6 +111,12 @@ } "Entry" { + "MsmKey" = "8:_7EFEAD66FF864CE6AB4AE36FCBA65659" + "OwnerKey" = "8:_7A0EA93E644A4D9E8037FBB3C062DD65" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { "MsmKey" = "8:_86404F6E19794F8A9F8C0ED67F7ADBFC" "OwnerKey" = "8:_UNDEFINED" "MsmSig" = "8:_UNDEFINED" @@ -232,12 +232,6 @@ "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_D0966638AB084779AFD69795C33FC8EB" - "MsmSig" = "8:_UNDEFINED" - } - "Entry" - { - "MsmKey" = "8:_UNDEFINED" "OwnerKey" = "8:_7A0EA93E644A4D9E8037FBB3C062DD65" "MsmSig" = "8:_UNDEFINED" } @@ -416,26 +410,6 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } - "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1F7D757BF031E15D44C47B631F994972" - { - "SourcePath" = "8:BoincStake.tlb" - "TargetName" = "8:BoincStake.tlb" - "Tag" = "8:" - "Folder" = "8:_A31B68165F144F3EBC3FF86D68C9E31B" - "Condition" = "8:" - "Transitive" = "11:FALSE" - "Vital" = "11:TRUE" - "ReadOnly" = "11:FALSE" - "Hidden" = "11:FALSE" - "System" = "11:FALSE" - "Permanent" = "11:FALSE" - "SharedLegacy" = "11:FALSE" - "PackageAs" = "3:1" - "Register" = "3:2" - "Exclude" = "11:FALSE" - "IsDependency" = "11:TRUE" - "IsolateTo" = "8:" - } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2C7D9AF4C6E04C06A26314A95B1FF010" { "SourcePath" = "8:..\\..\\..\\share\\pixmaps\\GrcInstallBanner.jpg" @@ -711,6 +685,26 @@ "IsDependency" = "11:FALSE" "IsolateTo" = "8:" } + "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_7EFEAD66FF864CE6AB4AE36FCBA65659" + { + "SourcePath" = "8:BoincStake.tlb" + "TargetName" = "8:BoincStake.tlb" + "Tag" = "8:" + "Folder" = "8:_A31B68165F144F3EBC3FF86D68C9E31B" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:2" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_88C4C520DC26489AAE9A79AE2F7F22EB" { "SourcePath" = "8:..\\..\\..\\share\\pixmaps\\nsis-header.bmp" @@ -838,11 +832,6 @@ "AssemblyAsmDisplayName" = "8:OpenPop, Version=2.0.5.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_D0966638AB084779AFD69795C33FC8EB" - { - "Name" = "8:OpenPop.dll" - "Attributes" = "3:512" - } } "SourcePath" = "8:A:\\release\\OpenPop.dll" "TargetName" = "8:" @@ -1120,19 +1109,19 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Gridcoin Research" - "ProductCode" = "8:{050C56BD-D556-4E95-BBD8-C7CE5E01FBDC}" - "PackageCode" = "8:{10C9F1E4-30DB-436D-A28D-79FB7577F00F}" + "ProductCode" = "8:{99640ABC-1BE5-4E04-B0D9-47AAD10FB404}" + "PackageCode" = "8:{BFB1DB38-B968-4E50-9221-9918143CECEA}" "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.9" + "ProductVersion" = "8:42.0" "Manufacturer" = "8:GridcoinResearch" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" - "Title" = "8:Gridcoin Research 41.9" + "Title" = "8:Gridcoin Research 42.0" "Subject" = "8:" "ARPCONTACT" = "8:The Gridcoin Developers" "Keywords" = "8:Gridcoin Research" diff --git a/src/clientversion.h b/src/clientversion.h index 6f54395c51..8dc51d7628 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 5 +#define CLIENT_VERSION_BUILD 6 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! @@ -17,3 +17,4 @@ #define DO_STRINGIZE(X) #X #endif // CLIENTVERSION_H + \ No newline at end of file diff --git a/src/kernel.cpp b/src/kernel.cpp index 822410a074..b4cc92f932 100755 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -22,7 +22,7 @@ extern double OwedByAddress(std::string address); std::string ExtractXML(std::string XMLdata, std::string key, std::string key_end); double cdbl(std::string s, int place); extern int DetermineCPIDType(std::string cpid); -std::string GetHttpPage(std::string cpid, bool usedns, bool clearcache); +std::string GetHttpPageFromCreditServerRetired(std::string cpid, bool usedns, bool clearcache); extern int64_t GetRSAWeightByCPIDWithRA(std::string cpid); double MintLimiter(double PORDiff,int64_t RSA_WEIGHT,std::string cpid,int64_t locktime); double GetBlockDifficulty(unsigned int nBits); @@ -30,7 +30,7 @@ extern double GetLastPaymentTimeByCPID(std::string cpid); extern double GetUntrustedMagnitude(std::string cpid, double& out_owed); bool LessVerbose(int iMax1000); StructCPID GetInitializedStructCPID2(std::string name,std::map& vRef); -extern double ReturnTotalRacByCPID(std::string cpid); +extern double ReturnTotalRacByCPIDRetired(std::string cpid); typedef std::map MapModifierCheckpoints; /* @@ -293,10 +293,9 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64_t& nStakeModifi // a proof-of-work situation. // -double ReturnTotalRacByCPID(std::string cpid) +double ReturnTotalRacByCPIDRetired(std::string cpid) { - std::string result = GetHttpPage(cpid,true,true); - //std::vector vRAC = split(result.c_str(),""); + std::string result = GetHttpPageFromCreditServerRetired(cpid,true,true); std::string sRAC = ExtractXML(result,"",""); double dRAC = cdbl(sRAC,0); return dRAC; @@ -307,15 +306,22 @@ int DetermineCPIDType(std::string cpid) // -1 = Invalid CPID // 1 = Valid CPID with RAC // 2 = Investor or Pool Miner + printf("\r\nCPID Length %f\r\n",(double)cpid.length()); + if (cpid.empty()) return -1; if (cpid=="INVESTOR") return 2; StructCPID h = mvMagnitudes[cpid]; if (h.Magnitude > 0) return 1; // If magnitude is 0 in the current superblock, try to get magnitude from netsoft before failing - double dRAC = ReturnTotalRacByCPID(cpid); - if (dRAC > 0) return 1; - // At this point, they have no RAC in the superblock, and no RAC in Netsoft, so we assume they are an investor (or pool miner) - return 2; + if (cpid.length()==32) + { + return 1; + } + else + { + // CPID is not 32 chars long- return Investor + return 2; + } } diff --git a/src/main.cpp b/src/main.cpp index bc1a2f7a69..10ae26c469 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -339,7 +339,7 @@ extern enum Checkpoints::CPMode CheckpointsMode; // Gridcoin - Rob Halford -extern std::string GetHttpPage(std::string cpid, bool usedns, bool clearcache); +extern std::string GetHttpPageFromCreditServerRetired(std::string cpid, bool usedns, bool clearcache); extern std::string RetrieveMd5(std::string s1); extern std::string aes_complex_hash(uint256 scrypt_hash); @@ -381,7 +381,7 @@ extern bool AESSkeinHash(unsigned int diffbytes, double rac, uint256 scrypthash, std::string DefaultGetblocksCommand(); CClientUIInterface uiDog; void ExecuteCode(); -extern void CreditCheck(std::string cpid, bool clearcache); +extern void CreditCheckRetired(std::string cpid, bool clearcache); extern void ThreadCPIDs(); extern std::string GetGlobalStatus(); @@ -989,7 +989,7 @@ MiningCPID GetNextProject(bool bForce) { StructCPID structcpid = mvCPIDs[(*ii).first]; if ( msPrimaryCPID == structcpid.cpid && - structcpid.initialized && structcpid.Iscpidvalid && structcpid.rac > 10) iValidProjects++; + structcpid.initialized && structcpid.Iscpidvalid) iValidProjects++; } // Find next available CPU project: @@ -1008,14 +1008,12 @@ MiningCPID GetNextProject(bool bForce) for(map::iterator ii=mvCPIDs.begin(); ii!=mvCPIDs.end(); ++ii) { - StructCPID structcpid = mvCPIDs[(*ii).first]; - if (GetArg("-fullbore", "false") != "true") MilliSleep(1); if (structcpid.initialized) { if (msPrimaryCPID == structcpid.cpid && - structcpid.Iscpidvalid && structcpid.projectname.length() > 1 && structcpid.rac > 10) + structcpid.Iscpidvalid && structcpid.projectname.length() > 1) { iRow++; if (i==4 || iDistributedProject == iRow) @@ -1033,48 +1031,50 @@ MiningCPID GetNextProject(bool bForce) if (checkcpid) { - GlobalCPUMiningCPID.email = email; + GlobalCPUMiningCPID.email = email; + + if (LessVerbose(1) || fDebug || fDebug3) printf("Ready to CPU Mine project %s with CPID %s, RAC(%f) \r\n", + structcpid.projectname.c_str(),structcpid.cpid.c_str(), + structcpid.rac); + //Required for project to be mined in a block: + GlobalCPUMiningCPID.cpid=structcpid.cpid; + GlobalCPUMiningCPID.projectname = structcpid.projectname; + GlobalCPUMiningCPID.rac=structcpid.rac; + GlobalCPUMiningCPID.encboincpublickey = structcpid.boincpublickey; + GlobalCPUMiningCPID.encaes = structcpid.boincpublickey; - if (LessVerbose(1) || fDebug) printf("Ready to CPU Mine project %s with CPID %s, RAC(%f) \r\n", - structcpid.projectname.c_str(),structcpid.cpid.c_str(), - structcpid.rac); - //Required for project to be mined in a block: - GlobalCPUMiningCPID.cpid=structcpid.cpid; - GlobalCPUMiningCPID.projectname = structcpid.projectname; - GlobalCPUMiningCPID.rac=structcpid.rac; - GlobalCPUMiningCPID.encboincpublickey = structcpid.boincpublickey; - GlobalCPUMiningCPID.encaes = structcpid.boincpublickey; - - - GlobalCPUMiningCPID.boincruntimepublickey = structcpid.cpidhash; - uint256 pbh = 1; - GlobalCPUMiningCPID.cpidv2 = ComputeCPIDv2(GlobalCPUMiningCPID.email,GlobalCPUMiningCPID.boincruntimepublickey, pbh); - GlobalCPUMiningCPID.lastblockhash = "0"; - // Sign the block - GlobalCPUMiningCPID.BoincSignature = SignBlockWithCPID(GlobalCPUMiningCPID.cpid,GlobalCPUMiningCPID.lastblockhash); + + GlobalCPUMiningCPID.boincruntimepublickey = structcpid.cpidhash; + printf("\r\n GNP: Setting bpk to %s\r\n",structcpid.cpidhash.c_str()); + + uint256 pbh = 1; + GlobalCPUMiningCPID.cpidv2 = ComputeCPIDv2(GlobalCPUMiningCPID.email,GlobalCPUMiningCPID.boincruntimepublickey, pbh); + GlobalCPUMiningCPID.lastblockhash = "0"; + // Sign the block + GlobalCPUMiningCPID.BoincSignature = SignBlockWithCPID(GlobalCPUMiningCPID.cpid,GlobalCPUMiningCPID.lastblockhash); - if (!IsCPIDValidv2(GlobalCPUMiningCPID,1)) - { - printf("CPID INVALID (GetNextProject) %s, %s ",GlobalCPUMiningCPID.cpid.c_str(),GlobalCPUMiningCPID.cpidv2.c_str()); - continue; - } + if (!IsCPIDValidv2(GlobalCPUMiningCPID,1)) + { + printf("CPID INVALID (GetNextProject) %s, %s ",GlobalCPUMiningCPID.cpid.c_str(),GlobalCPUMiningCPID.cpidv2.c_str()); + continue; + } - //Only used for global status: - msMiningProject = structcpid.projectname; - msMiningCPID = structcpid.cpid; - mdMiningRAC = structcpid.rac; - - double ProjectRAC = GetNetworkAvgByProject(GlobalCPUMiningCPID.projectname); - GlobalCPUMiningCPID.NetworkRAC = ProjectRAC; - mdMiningNetworkRAC = GlobalCPUMiningCPID.NetworkRAC; - GlobalCPUMiningCPID.Magnitude = CalculatedMagnitude(GetAdjustedTime(),false); - if (fDebug && LessVerbose(2)) printf("For CPID %s Verified Magnitude = %f",GlobalCPUMiningCPID.cpid.c_str(),GlobalCPUMiningCPID.Magnitude); - //Reserved for GRC Speech Synthesis - msMiningErrors = (msMiningCPID == "INVESTOR" || msPrimaryCPID=="INVESTOR" || msMiningCPID.empty() || msPrimaryCPID.empty()) ? "Staking Interest" : "Boinc Mining"; - GlobalCPUMiningCPID.RSAWeight = GetRSAWeightByCPID(GlobalCPUMiningCPID.cpid); - GlobalCPUMiningCPID.LastPaymentTime = GetLastPaymentTimeByCPID(GlobalCPUMiningCPID.cpid); - return GlobalCPUMiningCPID; + //Only used for global status: + msMiningProject = structcpid.projectname; + msMiningCPID = structcpid.cpid; + mdMiningRAC = structcpid.rac; + + double ProjectRAC = GetNetworkAvgByProject(GlobalCPUMiningCPID.projectname); + GlobalCPUMiningCPID.NetworkRAC = ProjectRAC; + mdMiningNetworkRAC = GlobalCPUMiningCPID.NetworkRAC; + GlobalCPUMiningCPID.Magnitude = CalculatedMagnitude(GetAdjustedTime(),false); + if (fDebug && LessVerbose(2)) printf("For CPID %s Verified Magnitude = %f",GlobalCPUMiningCPID.cpid.c_str(),GlobalCPUMiningCPID.Magnitude); + //Reserved for GRC Speech Synthesis + msMiningErrors = (msMiningCPID == "INVESTOR" || msPrimaryCPID=="INVESTOR" || msMiningCPID.empty() || msPrimaryCPID.empty()) ? "Staking Interest" : "Boinc Mining"; + GlobalCPUMiningCPID.RSAWeight = GetRSAWeightByCPID(GlobalCPUMiningCPID.cpid); + GlobalCPUMiningCPID.LastPaymentTime = GetLastPaymentTimeByCPID(GlobalCPUMiningCPID.cpid); + return GlobalCPUMiningCPID; } } } @@ -4349,14 +4349,7 @@ bool CBlock::CheckBlock(std::string sCaller, int height1, int64_t Mint, bool fCh if (fDebug3) printf("CheckBlock[ResearchAge] : Researchers Reward Pays too much : Interest %f and Research %f and StakeReward %f, OUT_POR %f, with Out_Interest %f for CPID %s ", (double)bb.InterestSubsidy,(double)bb.ResearchSubsidy,CoinToDouble(nCalculatedResearch),(double)OUT_POR,(double)OUT_INTEREST,bb.cpid.c_str()); - /* - if (msPrimaryCPID == bb.cpid) - { - //bStakeMinerOutOfSyncWithNetwork=true; - //return false; - } - */ - + return DoS(10,error("CheckBlock[ResearchAge] : Researchers Reward Pays too much : Interest %f and Research %f and StakeReward %f, OUT_POR %f, with Out_Interest %f for CPID %s ", (double)bb.InterestSubsidy,(double)bb.ResearchSubsidy,CoinToDouble(nCalculatedResearch),(double)OUT_POR,(double)OUT_INTEREST,bb.cpid.c_str())); // Reserved for future use. @@ -8748,7 +8741,7 @@ void InitializeProjectStruct(StructCPID& project) std::string GetNetsoftProjects(std::string cpid) { - std::string cc = GetHttpPage(cpid,true,true); + std::string cc = GetHttpPageFromCreditServerRetired(cpid,true,true); if (cc.length() < 10) { if (fDebug10) printf("Note: HTTP Page returned blank from netsoft for %s\r\n",cpid.c_str()); @@ -8791,11 +8784,11 @@ std::string GetNetsoftProjects(std::string cpid) -void CreditCheck(std::string cpid, bool clearcache) +void CreditCheckRetired(std::string cpid, bool clearcache) { try { - std::string cc = GetHttpPage(cpid,true,clearcache); + std::string cc = GetHttpPageFromCreditServerRetired(cpid,true,clearcache); if (cc.length() < 50) { if (fDebug10) printf("Note: HTTP Page returned blank from netsoft for %s\r\n",cpid.c_str()); @@ -8820,7 +8813,6 @@ void CreditCheck(std::string cpid, bool clearcache) if (sProj.length() > 3 && !proj_id.empty()) { - //7-16-2015 StructCPID structcc = GetInitializedStructCPID2(sProj,mvCPIDs); iRow++; structcc.cpid = cpid; @@ -9016,7 +9008,6 @@ void HarvestCPIDs(bool cleardata) } GlobalCPUMiningCPID.email = GlobalCPUMiningCPID.aesskein; - //GlobalCPUMiningCPID.boincruntimepublickey = GlobalCPUMiningCPID.lastblockhash; printf("Using Serialized Boinc CPID %s with orig email of %s and bpk of %s with cpidhash of %s \r\n",GlobalCPUMiningCPID.cpid.c_str(), GlobalCPUMiningCPID.email.c_str(), GlobalCPUMiningCPID.boincruntimepublickey.c_str(),GlobalCPUMiningCPID.cpidhash.c_str()); GlobalCPUMiningCPID.cpidhash = GlobalCPUMiningCPID.boincruntimepublickey; printf("Using Serialized Boinc CPID %s with orig email of %s and bpk of %s with cpidhash of %s \r\n",GlobalCPUMiningCPID.cpid.c_str(), GlobalCPUMiningCPID.email.c_str(), GlobalCPUMiningCPID.boincruntimepublickey.c_str(),GlobalCPUMiningCPID.cpidhash.c_str()); @@ -9040,8 +9031,7 @@ void HarvestCPIDs(bool cleardata) structcpid.link = "http://boinc.netsoft-online.com/e107_plugins/boinc/get_user.php?cpid=" + structcpid.cpid; structcpid.Iscpidvalid = true; mvCPIDs.insert(map::value_type(structcpid.projectname,structcpid)); - //11-12-2015 - CreditCheck(structcpid.cpid,false); + // CreditCheck(structcpid.cpid,false); GetNextProject(false); if (fDebug10) printf("GCMCPI %s",GlobalCPUMiningCPID.cpid.c_str()); if (fDebug10) printf("Finished getting first remote boinc project\r\n"); @@ -9087,27 +9077,19 @@ void HarvestCPIDs(bool cleardata) else { - if (vCPID.size() > 0) { - for (unsigned int i = 0; i < vCPID.size(); i++) { std::string email_hash = ExtractXML(vCPID[i],"",""); std::string cpidhash = ExtractXML(vCPID[i],"",""); std::string externalcpid = ExtractXML(vCPID[i],"",""); - std::string utc=ExtractXML(vCPID[i],"",""); std::string rac=ExtractXML(vCPID[i],"",""); std::string proj=ExtractXML(vCPID[i],"",""); std::string team=ExtractXML(vCPID[i],"",""); std::string rectime = ExtractXML(vCPID[i],"",""); - if (Contains(vCPID[i],"") && externalcpid.empty()) - { - //externalcpid="?"; - } - boost::to_lower(proj); proj = ToOfficialName(proj); ProjectIsValid(proj); @@ -9127,10 +9109,18 @@ void HarvestCPIDs(bool cleardata) if (fDebug3) printf("Enumerating boinc local project %s cpid %s valid %s, elapsed %f ",structcpid.projectname.c_str(),structcpid.cpid.c_str(),YesNo(structcpid.Iscpidvalid).c_str(),(double)elapsed); structcpid.rac = cdbl(rac,0); structcpid.verifiedrac = cdbl(rac,0); + std::string sLocalClientEmailHash = RetrieveMd5(email); + + if (email_hash != sLocalClientEmailHash) + { + structcpid.errors = "Gridcoin Email setting does not match project Email. Check Gridcoin e-mail address setting or boinc project e-mail setting."; + structcpid.Iscpidvalid=false; + } + if (!structcpid.Iscpidvalid) { - structcpid.errors = "CPID calculation invalid. Check e-mail + reset project."; + structcpid.errors = "CPID calculation invalid. Check e-mail address and try resetting the boinc project."; } structcpid.utc = cdbl(utc,0); @@ -9138,51 +9128,49 @@ void HarvestCPIDs(bool cleardata) double currenttime = GetAdjustedTime(); double nActualTimespan = currenttime - structcpid.rectime; structcpid.age = nActualTimespan; - //Have credits been verified yet? - //If not, Call out to credit check node: std::string sKey = structcpid.cpid + ":" + proj; mvCPIDs[proj] = structcpid; - //structcpid = mvCPIDs[proj]; - + if (!structcpid.Iscpidvalid) { structcpid.errors = "CPID invalid. Check E-mail address."; } - - if (structcpid.rac < 10) - { - structcpid.Iscpidvalid = false; - structcpid.errors = "RAC too low"; - } - - if (structcpid.verifiedrac < 10) - { - structcpid.Iscpidvalid = false; - structcpid.errors="Verified RAC too low"; - } - + if (structcpid.team != "gridcoin") { structcpid.Iscpidvalid = false; structcpid.errors = "Team invalid"; } - bool bAcid = true; + bool bTestExternal = true; + bool bTestInternal = true; if (!externalcpid.empty()) { - bAcid = CPIDAcidTest2(cpidhash,externalcpid); - if (!bAcid) + printf("\r\n** External CPID not empty %s **\r\n",externalcpid.c_str()); + + bTestExternal = CPIDAcidTest2(cpidhash,externalcpid); + bTestInternal = CPIDAcidTest2(cpidhash,structcpid.cpid); + if (bTestExternal) + { + structcpid.cpid = externalcpid; + printf(" Setting CPID to %s ",structcpid.cpid.c_str()); + } + else + { + printf("External test failed."); + } + + + if (!bTestExternal && !bTestInternal) { structcpid.Iscpidvalid = false; - structcpid.errors = "CPID corrupted (ext cpid) "; - printf("Primary cpid corrupted %s \r\n",externalcpid.c_str()); + structcpid.errors = "CPID corrupted Internal: %s, External: %s" + structcpid.cpid + "," + externalcpid.c_str(); + printf("CPID corrupted Internal: %s, External: %s \r\n",structcpid.cpid.c_str(),externalcpid.c_str()); } mvCPIDs[proj] = structcpid; - } - + } - //12-21-2015 - if (structcpid.Iscpidvalid && bAcid) + if (structcpid.Iscpidvalid) { // Verify the CPID has magnitude > 0, otherwise set the user as an investor: int iCPIDType = DetermineCPIDType(structcpid.cpid); @@ -9194,8 +9182,9 @@ void HarvestCPIDs(bool cleardata) GlobalCPUMiningCPID.cpidhash = cpidhash; GlobalCPUMiningCPID.email = email; GlobalCPUMiningCPID.boincruntimepublickey = cpidhash; - - if (structcpid.rac > 10 && structcpid.team=="gridcoin") + printf("\r\nSetting bpk to %s\r\n",cpidhash.c_str()); + + if (structcpid.team=="gridcoin") { msPrimaryCPID = structcpid.cpid; #if defined(WIN32) && defined(QT_GUI) @@ -9203,7 +9192,7 @@ void HarvestCPIDs(bool cleardata) std::string sXML = "PrimaryCPID" + msPrimaryCPID + ""; std::string sData = qtExecuteDotNetStringFunction("WriteKey",sXML); #endif - //Try to get a neural RAC report 7-25-2015 + //Try to get a neural RAC report AsyncNeuralRequest("explainmag",msPrimaryCPID,5); } } @@ -9243,9 +9232,7 @@ void ThreadCPIDs() bCPIDsLoaded = false; HarvestCPIDs(true); bCPIDsLoaded = true; - //Reloads maglevel: - printf("Performing 1st credit check (%s)",GlobalCPUMiningCPID.cpid.c_str()); - CreditCheck(GlobalCPUMiningCPID.cpid,false); + //CreditCheck(GlobalCPUMiningCPID.cpid,false); printf("Getting first project"); GetNextProject(false); printf("Finished getting first project"); diff --git a/src/net.cpp b/src/net.cpp index c73abd75ec..7f84d44770 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -61,7 +61,7 @@ extern int nMaxConnections; MiningCPID GetNextProject(bool bForce); void HarvestCPIDs(bool cleardata); bool IsCPIDValid_Retired(std::string cpid, std::string ENCboincpubkey); -extern std::string GetHttpPage(std::string cpid, bool UseDNS, bool ClearCache); +extern std::string GetHttpPageFromCreditServerRetired(std::string cpid, bool UseDNS, bool ClearCache); std::string ExtractXML(std::string XMLdata, std::string key, std::string key_end); std::string cached_boinchash_args = ""; void WriteAppCache(std::string key, std::string value); @@ -770,9 +770,7 @@ std::string GetHttpPage(std::string url) - - -std::string GetHttpPage(std::string cpid, bool UseDNS, bool ClearCache) +std::string GetHttpPageFromCreditServerRetired(std::string cpid, bool UseDNS, bool ClearCache) { try diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 29fb9f927a..df71512ec7 100755 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -87,13 +87,11 @@ int64_t GetMaximumBoincSubsidy(int64_t nTime); double GRCMagnitudeUnit(int64_t locktime); std::string ExtractXML(std::string XMLdata, std::string key, std::string key_end); extern std::string GetTeamURLs(bool bMissingOnly, bool bReturnProjectNames); -extern bool InsertSmartContract(std::string URL,std::string Name); std::string ExtractHTML(std::string HTMLdata, std::string tagstartprefix, std::string tagstart_suffix, std::string tag_end); extern std::string GetNetsoftProjects(std::string cpid); std::string NeuralRequest(std::string MyNeuralRequest); extern bool AdvertiseBeacon(bool bFromService, std::string &sOutPrivKey, std::string &sOutPubKey, std::string &sError, std::string &sMessage); - double Round(double d, int place); bool UnusualActivityReport(); extern double GetCountOf(std::string datatype); @@ -144,8 +142,6 @@ extern Array GetJSONBeaconReport(); void GatherNeuralHashes(); extern std::string GetListOf(std::string datatype); void qtSyncWithDPORNodes(std::string data); - -extern bool SynchronizeRacForDPOR(bool SyncEntireCoin); std::string qtGetNeuralHash(std::string data); std::string qtGetNeuralContract(std::string data); @@ -209,14 +205,13 @@ MiningCPID DeserializeBoincBlock(std::string block); std::string GridcoinHttpPost(std::string msg, std::string boincauth, std::string urlPage, bool bUseDNS); extern double GetNetworkAvgByProject(std::string projectname); void HarvestCPIDs(bool cleardata); -std::string GetHttpPage(std::string cpid); std::string GetHttpPage(std::string cpid, bool usedns, bool clearcache); bool GridDecrypt(const std::vector& vchCiphertext,std::vector& vchPlaintext); bool GridEncrypt(std::vector vchPlaintext, std::vector &vchCiphertext); uint256 GridcoinMultipleAlgoHash(std::string t1); void ExecuteCode(); -void CreditCheck(std::string cpid, bool clearcache); +void CreditCheckRetired(std::string cpid, bool clearcache); double CalculatedMagnitude(int64_t locktime,bool bUseLederstrumpf); @@ -1198,43 +1193,6 @@ bool TallyMagnitudesInSuperblock() - -bool SynchronizeRacForDPOR(bool SyncEntireCoin) -{ - - //Only do this if user is not an investor (6-2-2015) - if (GlobalCPUMiningCPID.cpid=="INVESTOR") return false; - - std::string teams = GetTeamURLs(true,false); - std::string projs = GetTeamURLs(true,true); - //This list contains projects that have not been synced for 24+ hours in Gridcoin: - std::vector vTeams = split(teams.c_str(),""); - std::vector vProjs = split(projs.c_str(),""); - bool result = false; - - for (unsigned int i = 0; i < vTeams.size(); i++) - { - if (vTeams[i].length() > 5) - { - printf("Inserting smart contract for team project %s",vTeams[i].c_str()); - if (vProjs[i]=="world_community_grid") - { - - if (!SyncEntireCoin) break; - } - else - { - result = InsertSmartContract(vTeams[i],vProjs[i]); - if (result && !SyncEntireCoin) break; - } - - } - } - - return true; - -} - std::string GetTeamURLs(bool bMissingOnly, bool bReturnProjectNames) { @@ -1269,44 +1227,6 @@ std::string GetTeamURLs(bool bMissingOnly, bool bReturnProjectNames) -bool InsertSmartContract(std::string URL, std::string name) -{ - - std::string results = GetHttpPage(URL); - double total_rac = 0; - //printf("Querying DPOR RAC for project %s response %s\r\n",URL.c_str(),results.c_str()); - //int iRow = 0; - std::vector vUsers = split(results.c_str(),""); - std::string contract = ""; - for (unsigned int i = 0; i < vUsers.size(); i++) - { - std::string cpid = ExtractXML(vUsers[i],"",""); - std::string rac = ExtractXML(vUsers[i],"",""); - //if (fDebug10) printf("Cpid %s rac %s , ",cpid.c_str(),rac.c_str()); - - double dRac = cdbl(rac,0); - if (dRac > 10) - { - contract += cpid + "," + RoundToString(dRac,0) + ";"; - total_rac++; - } - } - - std::string sAction = "add"; - std::string sType = "contract"; - std::string sPass = ""; - sPass = (sType=="project" || sType=="projectmapping" || sType=="smart_contract") ? GetArgument("masterprojectkey", msMasterMessagePrivateKey) : msMasterMessagePrivateKey; - std::string sName = "" + name; - std::string sValue = contract; - - if (vUsers.size() > 1 && total_rac > 10) - { - std::string result = AddMessage(true,sType,sName,sValue,sPass,AmountFromValue(2500),.00001,""); - } - return (vUsers.size() > 1 && total_rac > 10) ? true : false; -} - - double GetCountOf(std::string datatype) { std::string data = GetListOf(datatype); @@ -1484,15 +1404,6 @@ bool AdvertiseBeacon(bool bFromService, std::string &sOutPrivKey, std::string &s std::string sName = GlobalCPUMiningCPID.cpid; try { - /* - if (bUseNeuralNetwork) - { - std::string payload = GlobalCPUMiningCPID.cpid + "|" + sBase + "|" + GlobalCPUMiningCPID.cpidv2 + "|" + hashRand.GetHex(); - AsyncNeuralRequest("addbeacon",payload,10); - sError = "Advertising Beacon on Neural Network for " + payload; - return true; - } - */ // Store the key sMessage = AddContract(sType,sName,sBase); return true; @@ -2001,6 +1912,11 @@ Value execute(const Array& params, bool fHelp) entry.push_back(Pair("CPID",GlobalCPUMiningCPID.cpid)); std::string sLongCPID = ComputeCPIDv2(email,GlobalCPUMiningCPID.boincruntimepublickey,1); std::string sShortCPID = RetrieveMd5(GlobalCPUMiningCPID.boincruntimepublickey + email); + std::string sEmailMD5 = RetrieveMd5(email); + std::string sBPKMD5 = RetrieveMd5(GlobalCPUMiningCPID.boincruntimepublickey); + entry.push_back(Pair("Computed Email Hash",sEmailMD5)); + entry.push_back(Pair("Computed BPK",sBPKMD5)); + entry.push_back(Pair("Computed CPID",sLongCPID)); entry.push_back(Pair("Computed Short CPID", sShortCPID)); bool fResult = CPID_IsCPIDValid(sShortCPID,sLongCPID,1); @@ -2197,19 +2113,6 @@ Value execute(const Array& params, bool fHelp) } else if (sItem == "advertisebeacon") { - // std::string optional = params[1].get_str(); - // boost::to_lower(optional); - // if (optional != "force" && optional != "neural") - /* - if (optional=="neural") - { - std::string sResult = AdvertiseBeacon(true,true); - entry.push_back(Pair("CPID",GlobalCPUMiningCPID.cpid.c_str())); - entry.push_back(Pair("Send Neural Beacon",sResult)); - results.push_back(entry); - } - else - */ std::string sOutPubKey = ""; std::string sOutPrivKey = ""; std::string sError = ""; @@ -2224,7 +2127,7 @@ Value execute(const Array& params, bool fHelp) if (!fResult) { - entry.push_back(Pair("FAILURE","Note: if your wallet is locked this command will fail; to solve that unlock the wallet: 'walletpassphrase <240>' without <>.")); + entry.push_back(Pair("FAILURE","Note: if your wallet is locked this command will fail; to solve that unlock the wallet: 'walletpassphrase <240>'.")); } if (fResult) { @@ -3158,14 +3061,6 @@ Value execute(const Array& params, bool fHelp) } - } - else if (sItem == "contract") - { - - InsertSmartContract("http://milkyway.cs.rpi.edu/milkyway/team_email_list.php?teamid=6566&xml=1","milkyway"); - entry.push_back(Pair("Done","Done")); - results.push_back(entry); - } else if (sItem == "wcgtest") { @@ -3174,13 +3069,6 @@ Value execute(const Array& params, bool fHelp) results.push_back(entry); } - else if (sItem == "syncrac") - { - - SynchronizeRacForDPOR(true); - entry.push_back(Pair("Done","Done")); - results.push_back(entry); - } else if (sItem == "dportally") { TallyMagnitudesInSuperblock(); @@ -3535,6 +3423,8 @@ Value execute(const Array& params, bool fHelp) } else if (sItem == "resetcpids") { + //Reload the config file + ReadConfigFile(mapArgs, mapMultiArgs); mvCPIDCache.clear(); HarvestCPIDs(true); GetNextProject(true); @@ -3559,30 +3449,6 @@ Value execute(const Array& params, bool fHelp) entry.push_back(Pair("Resending unsent wallet transactions...",1)); results.push_back(entry); } - else if (sItem == "postcpid") - { - std::string result = GetHttpPage("859038ff4a9",true,true); - entry.push_back(Pair("POST Result",result)); - results.push_back(entry); - } - else if (sItem == "netsoft") - { - std::string cpid = "784afb35d92503160125feb183157378"; - std::string result = GetHttpPage(cpid,true,true); - entry.push_back(Pair("POST Result",result)); - StructCPID h = mvMagnitudes[cpid]; - entry.push_back(Pair("Mag",h.Magnitude)); - int iType = DetermineCPIDType(cpid); - entry.push_back(Pair("Type",iType)); - iType=DetermineCPIDType("INVESTOR"); - entry.push_back(Pair("Type For Investor",iType)); - iType=DetermineCPIDType("invalid_cpid"); - entry.push_back(Pair("Type For Invalid",iType)); - double RAC = ReturnTotalRacByCPID(cpid); - entry.push_back(Pair("RAC for CPID",RAC)); - results.push_back(entry); - - } else if (sItem == "encrypt_deprecated") { std::string s1 = "1234"; @@ -5239,14 +5105,13 @@ Value listitem(const Array& params, bool fHelp) || structcpid.cpid=="INVESTOR" || GlobalCPUMiningCPID.cpid=="INVESTOR" || GlobalCPUMiningCPID.cpid.length()==0) { Object entry; - entry.push_back(Pair("Project",structcpid.projectname)); entry.push_back(Pair("CPID",structcpid.cpid)); entry.push_back(Pair("RAC",structcpid.rac)); entry.push_back(Pair("Team",structcpid.team)); - //entry.push_back(Pair("Is my CPID Valid?",structcpid.Iscpidvalid)); entry.push_back(Pair("CPID Link",structcpid.link)); entry.push_back(Pair("Debug Info",structcpid.errors)); + entry.push_back(Pair("Project Settings Valid for Gridcoin",structcpid.Iscpidvalid)); results.push_back(entry); }