Skip to content

Commit

Permalink
3.5.8.4-leisure
Browse files Browse the repository at this point in the history
Gridcoin Research 3.5.8.4/MSI=41.9
Leisure Upgrade

- Catch HTTP error on Diagnostics page
- Add checkpoints up to 770000
- Remove unused functions (cryptolottery, options trading)
- Merge in Denravonska #158 - CPU-Usage-Fix:  This fix prevents GRC from
copying memory structs and is designed to lower CPU usage
  • Loading branch information
gridcoin committed Dec 31, 2016
1 parent 2ed693f commit 41add47
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 239 deletions.
2 changes: 1 addition & 1 deletion Makefile.Debug
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: gridcoinresearch
# Generated by qmake (2.01a) (Qt 4.8.4) on: Mon Nov 21 07:13:32 2016
# Generated by qmake (2.01a) (Qt 4.8.4) on: Sat Dec 31 17:22:56 2016
# Project: gridcoinresearch.pro
# Template: app
#############################################################################
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Release
@@ -1,6 +1,6 @@
#############################################################################
# Makefile for building: gridcoinresearch
# Generated by qmake (2.01a) (Qt 4.8.4) on: Mon Nov 21 07:13:34 2016
# Generated by qmake (2.01a) (Qt 4.8.4) on: Sat Dec 31 17:22:57 2016
# Project: gridcoinresearch.pro
# Template: app
#############################################################################
Expand Down
8 changes: 4 additions & 4 deletions contrib/Installer/GridcoinInstaller/GridcoinResearch.vdproj
Expand Up @@ -1120,19 +1120,19 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Gridcoin Research"
"ProductCode" = "8:{30AAD9EB-F91F-466F-AAC5-E4A0CE7BC53A}"
"PackageCode" = "8:{B6424258-604A-40D5-BEE0-640A2CAEC4C5}"
"ProductCode" = "8:{050C56BD-D556-4E95-BBD8-C7CE5E01FBDC}"
"PackageCode" = "8:{10C9F1E4-30DB-436D-A28D-79FB7577F00F}"
"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.7"
"ProductVersion" = "8:41.9"
"Manufacturer" = "8:GridcoinResearch"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:"
"Title" = "8:Gridcoin Research 41.8"
"Title" = "8:Gridcoin Research 41.9"
"Subject" = "8:"
"ARPCONTACT" = "8:The Gridcoin Developers"
"Keywords" = "8:Gridcoin Research"
Expand Down
23 changes: 20 additions & 3 deletions contrib/Installer/boinc/boinc/modGRC.vb
Expand Up @@ -209,8 +209,14 @@ Module modGRC
Dim BJ As New BatchJob
Dim myWebClient As New MyWebClient()
Dim sFullURL As String = sProjectURL + "am_set_info.php?account_key=" + sAccountKey + "&teamid=" + sTeamID
Dim sHttp As String

Dim sHTTP As String = myWebClient.DownloadString(sFullURL)
Try
sHttp = myWebClient.DownloadString(sFullURL)

Catch ex As Exception

End Try
If sHTTP.Contains("success") Then
BJ.Status = True
Else
Expand Down Expand Up @@ -335,8 +341,14 @@ Module modGRC
Try

Dim sFullURL As String = sProjectURL + "team_lookup.php?team_name=gridcoin&format=xml"
Dim sHTTP As String = myWebClient.DownloadString(sFullURL)
Dim sHTTP As String
Try
sHTTP = myWebClient.DownloadString(sFullURL)

Catch ex As Exception

End Try

Dim sTeamID As String
sTeamID = ExtractXML(sHTTP, "<id>", "</id>")
Return sTeamID
Expand Down Expand Up @@ -443,7 +455,12 @@ Module modGRC
Dim sURL As String = RACURL + "get_user.php?cpid=" + sCPID
Dim w As New MyWebClient
Dim sRAC As String
sRAC = w.DownloadString(sURL)
Try
sRAC = w.DownloadString(sURL)

Catch ex As Exception

End Try
Dim vRAC() As String
vRAC = Split(sRAC, "<project>")
dProjectByteLength = Len(sRAC)
Expand Down
14 changes: 12 additions & 2 deletions contrib/Installer/boinc/boinc/modPersistedDataSystem.vb
Expand Up @@ -1109,7 +1109,11 @@ ThreadStarted:
sData = ""
Dim sURL As String = "http://boinc.netsoft-online.com/get_user.php?cpid=" + sCPID
Dim w As New MyWebClient2
sData = w.DownloadString(sURL)
Try
sData = w.DownloadString(sURL)
Catch ex As Exception

End Try
Return sData
End Function
Public Function GetRAC_Resilient(sCPID As String) As Boolean
Expand Down Expand Up @@ -1629,7 +1633,13 @@ Retry:
End If
Dim sURL As String = "https://c-cex.com/t/" + ccxPage
Dim w As New MyWebClient
Dim sJSON As String = w.DownloadString(sURL)
Dim sJSON As String = String.Empty
Try
sJSON = w.DownloadString(sURL)

Catch ex As Exception

End Try
Dim sLast As String = ExtractValue(sJSON, "lastprice", "updated")
sLast = Replace(sLast, ",", ".")

Expand Down
3 changes: 3 additions & 0 deletions src/checkpoints.cpp
Expand Up @@ -50,6 +50,9 @@ namespace Checkpoints
(145000, uint256("0x99f5d7166ad55d6d0e1ac5c7fffaee1d1dd1ff1409738e0d4f13ac1ae38234cc") )
(278000, uint256("0x8066e63198c44b9840f664e795b0315d9b752773b267d6212f35593bc0e3b6f4") )
(361800, uint256("0x801981d8a8f5809e34a2881ea97600259e1d9d778fa21752a5f6cff4defcd08d") )
(500000, uint256("0x3916b53eaa0eb392ce5d7e4eaf7db4f745187743f167539ffa4dc1a30c06acbd") )
(700000, uint256("0x2e45c8a834675b505b96792d198c2dc970f560429c635479c347204044acc59b") )
(770000, uint256("0xfc13a63162bc0a5a09acc3f284cf959d6812a027bb54b342a0e1ccaaca8627ce") )
;

// TestNet has no checkpoints
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Expand Up @@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 5
#define CLIENT_VERSION_REVISION 8
#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!
Expand Down
21 changes: 0 additions & 21 deletions src/kernel.cpp
Expand Up @@ -14,7 +14,6 @@ bool IsCPIDValidv2(MiningCPID& mc,int height);
using namespace std;
MiningCPID DeserializeBoincBlock(std::string block);
std::string RetrieveMd5(std::string s1);
extern std::string CPIDByAddress(std::string address);
bool IsCPIDValid_Retired(std::string cpid, std::string ENCboincpubkey);
MiningCPID GetMiningCPID();
StructCPID GetStructCPID();
Expand Down Expand Up @@ -336,26 +335,6 @@ double GetMagnitudeByHashBoinc(std::string hashBoinc, int height)
}


std::string CPIDByAddress(std::string address)
{
//CryptoLottery
for(map<string,StructCPID>::iterator ii=mvMagnitudes.begin(); ii!=mvMagnitudes.end(); ++ii)
{
StructCPID structMag = GetStructCPID();
structMag = mvMagnitudes[(*ii).first];
if (structMag.initialized && structMag.cpid.length() > 2 && structMag.cpid != "INVESTOR" && structMag.GRCAddress.length() > 5)
{
if (structMag.GRCAddress==address)
{
return structMag.cpid;
}
}
}
return "";

}



double OwedByAddress(std::string address)
{
Expand Down
6 changes: 1 addition & 5 deletions src/main.cpp
Expand Up @@ -153,13 +153,11 @@ void qtSyncWithDPORNodes(std::string data);
std::string qtGetNeuralHash(std::string data);
std::string GetListOf(std::string datatype);

std::string CryptoLottery(int64_t locktime);
std::string GetCommandNonce(std::string command);
std::string DefaultBlockKey(int key_length);
void InitializeBoincProjects();

extern double Cap(double dAmt, double Ceiling);
std::string CPIDByAddress(std::string address);
extern std::string ToOfficialNameNew(std::string proj);
double OwedByAddress(std::string address);

Expand Down Expand Up @@ -288,7 +286,6 @@ CBigNum bnProofOfWorkLimitTestNet(~uint256(0) >> 16);
unsigned int nStakeMinAge = 16 * 60 * 60; // 16 hours
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 bOPReturnEnabled = true;
bool bOptionPaymentsEnabled = false;
Expand Down Expand Up @@ -4434,8 +4431,7 @@ bool CBlock::CheckBlock(std::string sCaller, int height1, int64_t Mint, bool fCh

if (IsProofOfStake())
{
//4-2-2015 Verify each POR recipient is owed > paid - CryptoLottery
// Coinbase output should be empty if proof-of-stake block
// Coinbase output should be empty if proof-of-stake block
if (vtx[0].vout.size() != 1 || !vtx[0].vout[0].IsEmpty())
return DoS(100, error("CheckBlock[] : coinbase output not empty for proof-of-stake block"));

Expand Down
1 change: 0 additions & 1 deletion src/main.h
Expand Up @@ -153,7 +153,6 @@ extern unsigned char pchMessageStart[4];
extern std::map<uint256, CBlock*> mapOrphanBlocks;

extern int64_t COIN_YEAR_REWARD;
extern bool bCryptoLotteryEnabled;
extern bool bRemotePaymentsEnabled;
extern bool bOPReturnEnabled;
extern bool bOptionPaymentsEnabled;
Expand Down
122 changes: 2 additions & 120 deletions src/rpcblockchain.cpp
Expand Up @@ -36,7 +36,6 @@ extern std::string GetBeaconPrivateKey(std::string cpid);
extern std::string SuccessFail(bool f);
extern Array GetUpgradedBeaconReport();
extern Array MagnitudeReport(std::string cpid);
extern bool UserAcknowledgedHoldHarmlessClause(std::string sAddress);
std::string ConvertBinToHex(std::string a);
std::string ConvertHexToBin(std::string a);
bool TallyResearchAverages(bool Forcefully);
Expand Down Expand Up @@ -83,8 +82,6 @@ void WriteCache(std::string section, std::string key, std::string value, int64_t
extern std::string MyBeaconExists(std::string cpid);
int64_t GetEarliestWalletTransaction();
extern bool CheckMessageSignature(std::string sAction,std::string messagetype, std::string sMsg, std::string sSig, std::string opt_pubkey);
extern std::string CryptoLottery(int64_t locktime);
std::string CPIDByAddress(std::string address);
bool LoadAdminMessages(bool bFullTableScan,std::string& out_errors);
int64_t GetMaximumBoincSubsidy(int64_t nTime);
double GRCMagnitudeUnit(int64_t locktime);
Expand All @@ -110,7 +107,6 @@ void TestScan2();
bool AsyncNeuralRequest(std::string command_name,std::string cpid,int NodeLimit);
bool FullSyncWithDPORNodes();
bool LoadSuperblock(std::string data, int64_t nTime, double height);

StructCPID GetInitializedStructCPID2(std::string name,std::map<std::string, StructCPID>& vRef);

std::string GetNeuralNetworkSupermajorityHash(double& out_popularity);
Expand Down Expand Up @@ -1520,19 +1516,6 @@ bool AdvertiseBeacon(bool bFromService, std::string &sOutPrivKey, std::string &s
}



std::string AcknowledgeHoldHarmlessClause()
{
std::string GRCAddress = DefaultWalletAddress();
bool bHarmlessClauseAcknowledged = UserAcknowledgedHoldHarmlessClause(GRCAddress);
if (bHarmlessClauseAcknowledged) return "SUCCESS";
std::string contract = GRCAddress;
std::string sAction = "add";
std::string sType = "holdharmless";
std::string result = AddContract(sType,GRCAddress,contract);
return result;
}

std::string ExecuteRPCCommand(std::string method, std::string arg1, std::string arg2, std::string arg3, std::string arg4, std::string arg5, std::string arg6)
{
Array params;
Expand Down Expand Up @@ -3939,78 +3922,6 @@ double GetMagnitudeByCpidFromLastSuperblock(std::string sCPID)
return 0;
}

std::string CryptoLottery(int64_t locktime)
{
std::string sOut = "";
std::string row = "";
int rows = 0;

if (!bRemotePaymentsEnabled) return "";

double max_subsidy = (double)GetMaximumBoincSubsidy(locktime);
vector<CPIDOwed> vCPIDSOwed;

//int iRecord = 0;
for(map<string,StructCPID>::iterator ii=mvMagnitudes.begin(); ii!=mvMagnitudes.end(); ++ii)
{
StructCPID structMag = mvMagnitudes[(*ii).first];
if (structMag.initialized && structMag.cpid.length() > 2 && structMag.cpid != "INVESTOR" && structMag.GRCAddress.length() > 5)
{
CPIDOwed c;
c.owed = structMag.totalowed-structMag.payments;
c.GRCAddress = structMag.GRCAddress;
c.cpid = structMag.cpid;
c.initialized = true;
vCPIDSOwed.push_back(c);
}
}
// Sort by Max Owed descending:
std::sort(vCPIDSOwed.begin(), vCPIDSOwed.end(), SortByOwed);

int nLastTally = (nBestHeight-CONSENSUS_LOOKBACK) - ( (nBestHeight-CONSENSUS_LOOKBACK) % BLOCK_GRANULARITY);
int height_since_last_tally = nBestHeight - CONSENSUS_LOOKBACK - nLastTally;
if (height_since_last_tally < 0) height_since_last_tally=0;
int iSkip = 0;
for(std::vector<CPIDOwed>::iterator it = vCPIDSOwed.begin(); it != vCPIDSOwed.end(); it++)
{
StructCPID structMag = mvMagnitudes[it->cpid];
if (structMag.initialized && structMag.cpid.length() > 2 && structMag.cpid != "INVESTOR" && structMag.GRCAddress.length() > 5)
{
double Owed = OwedByAddress(structMag.GRCAddress);
//Reverse Check, ensure Address resolves to cpid:
std::string reverse_cpid_lookup = CPIDByAddress(structMag.GRCAddress);
iSkip++;
if (reverse_cpid_lookup == structMag.cpid && Owed > (max_subsidy*4) && sOut.find(structMag.GRCAddress) == std::string::npos && iSkip > height_since_last_tally)
{
// Gather the owed amount, grc address, and cpid.
// During block verification we will verify owed <> block_paid, grcaddress belongs to cpid, and cpid is owed > purported_owed
std::string row = "";
double tbp = Owed / 2;
if (tbp > max_subsidy) tbp=max_subsidy;
row = structMag.cpid + ";" + structMag.GRCAddress + ";" + RoundToString(tbp,2);
sOut += row + "<COL>";
rows++;
if (rows >= 20) break;
}
}

}



if (sOut.length() > 10) sOut = sOut.substr(0,sOut.length()-5); //Remove last delimiter
if (fDebug3) printf("CryptoLottery %s",sOut.c_str());
if (rows < 15) sOut = "";
return sOut;
}



bool UserAcknowledgedHoldHarmlessClause(std::string sAddress)
{
std::string sHarmless = mvApplicationCache["holdharmless;" + sAddress];
return (!sHarmless.empty());
}

bool IsContractSettled(std::string sContractType, std::string sOpra)
{
Expand Down Expand Up @@ -4953,7 +4864,7 @@ Value listitem(const Array& params, bool fHelp)

Object entry;
entry.push_back(Pair("RSA Weight",RSAWEIGHT));
entry.push_back(Pair("Remote Magnitude",out_magnitude));
entry.push_back(Pair("Magnitude",out_magnitude));
entry.push_back(Pair("RSA Owed",out_owed));
results.push_back(entry);

Expand Down Expand Up @@ -4983,36 +4894,7 @@ Value listitem(const Array& params, bool fHelp)
entry.push_back(Pair("Bad CPID with missing beacon",fResult));
results.push_back(entry);
}
else if (sitem == "lottery")
{

Object entry;
std::string recipients = CryptoLottery(GetAdjustedTime());
entry.push_back(Pair("Recipients",recipients));
std::vector<std::string> vRecipients = split(recipients.c_str(),"<COL>");
if (vRecipients.size() > 0)
{
for (unsigned int i=0;i < vRecipients.size(); i++)
{
std::vector<std::string> vPayments = split(vRecipients[i].c_str(),";");
//0=script Pub Key, 1=negative amount, 2=coinstake
if (vPayments.size() == 3)
{
std::string cpid = vPayments[0];
std::string grc_address = vPayments[1];
double amt = cdbl(vPayments[2],2);
std::string CLcpid = CPIDByAddress(grc_address);
entry.push_back(Pair("CPID",cpid));
entry.push_back(Pair("CPID_VERIFY",CLcpid));
entry.push_back(Pair("GRC_ADDRESS",grc_address));
entry.push_back(Pair("Amount To Be Paid",amt));
}
}
}

results.push_back(entry);
}
else if (sitem == "debugexplainmagnitude")
else if (sitem == "debugexplainmagnitude")
{
double dMag = ExtractMagnitudeFromExplainMagnitude();
Object entry;
Expand Down

0 comments on commit 41add47

Please sign in to comment.