Skip to content

Commit

Permalink
1.1.8.9 - Mandatory Upgrade (for Entire Network)
Browse files Browse the repository at this point in the history
- Prevent crash in POG Leaderboard when chain not synced (MIP)
- Prevent POG illegal tithes, Fix POG pool bug, make POG more exact
- Enhance exec pogaudit, and exec istithelegal
- Allow users to pay prayer_threshhold_amount to send a public prayer
  • Loading branch information
biblepay committed Feb 19, 2019
1 parent 6c781f2 commit 17375d5
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 53 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_REVISION, 8)
define(_CLIENT_VERSION_BUILD, 8)
define(_CLIENT_VERSION_BUILD, 9)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
AC_INIT([biblepay Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/biblepaypay/biblepay/issues],[biblepaycore])
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const std::string CLIENT_NAME("Biblepay Core");
const int BIBLEPAY_VERSION_MAJOR = 1;
const int BIBLEPAY_VERSION_MINOR = 1;
const int BIBLEPAY_VERSION_REVISION = 8;
const int BIBLEPAY_VERSION_BUILD = 8;
const int BIBLEPAY_VERSION_BUILD = 9;


const int BIBLE_VERSION = 1000000 * BIBLEPAY_VERSION_MAJOR
Expand Down
101 changes: 80 additions & 21 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,23 +1705,49 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C
int nTitheCount = pool.getTitheCount();
double dPogDiff = GetPOGDifficulty(chainActive.Tip());
std::string sRecipient = PubKeyToAddress(tx.vout[0].scriptPubKey);
bool bIsTithe = (sRecipient == chainparams.GetConsensus().FoundationAddress);
if (bIsTithe && dPogDiff < LOW_POG_DIFF && nTitheCount > TITHE_OVERFLOW)
CAmount nTitheAmount = GetTitheTotal(tx);
if (nTitheAmount > 0)
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type I; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (bIsTithe && nTitheCount > (TITHE_OVERFLOW * 2))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type II; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (bIsTithe && dPogDiff < LOW_POG_DIFF && chainActive.Height() < POG_V2_CUTOVER_HEIGHT_PROD && nTitheCount > (TITHE_OVERFLOW / 15))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type III; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
if (dPogDiff < LOW_POG_DIFF && nTitheCount > TITHE_OVERFLOW)
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type I; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (nTitheCount > (TITHE_OVERFLOW))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type II; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (dPogDiff < LOW_POG_DIFF && chainActive.Height() < POG_V2_CUTOVER_HEIGHT_PROD && nTitheCount > (TITHE_OVERFLOW / 15))
{
LogPrintf("AcceptToMemPool::Tithe Overflow Type III; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
else if (chainActive.Height() < POG_V3_CUTOVER_HEIGHT_PROD && fProd && nTitheAmount > (10 * COIN) && chainActive.Height() > POG_V2_CUTOVER_HEIGHT_PROD)
{
LogPrintf("AcceptToMemPool::Tithe Too Large; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}

/*
TitheDifficultyParams tdp = GetTitheParams(chainActive.Tip());
else if (nTitheAmount > (10 * COIN))
{
LogPrintf("AcceptToMemPool::Tithe Too Large; Tithe Rejected; Tithe Count %f, Pog Diff %f ", nTitheCount, dPogDiff);
return false;
}
CTitheObject oTithe = TxToTithe(tx, chainActive.Tip());
int iLegal = IsTitheLegal3(oTithe, tdp);
if (iLegal != 1)
{
std::string sErr = TitheErrorToString(iLegal);
LogPrintf("AcceptToMemPool::Illegal Tithe; Tithe Rejected; Status %s, TitheCount %f, Pog Diff %f", sErr.c_str(), nTitheCount, dPogDiff);
return false;
}
LogPrintf("Tithe Count %f, Diff %f ",(double)nTitheCount, dPogDiff);
*/
}
LogPrintf("Tithe Count %f, Diff %f ",(double)nTitheCount, dPogDiff);
}

// If we aren't going to actually accept it but just were verifying it, we are fine already
Expand Down Expand Up @@ -4607,19 +4633,37 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn

// Rob A., Biblepay, 3/7/2018, Kick Off BotNet Rules
double dBlockVersion = GetBlockVersion(block.vtx[0]);
if (fProd && nHeight > F11000_CUTOVER_HEIGHT_PROD && dBlockVersion < 1101)
if (fProd && nHeight > POG_V3_CUTOVER_HEIGHT_PROD && dBlockVersion < 1189)
{
LogPrintf("ContextualCheckBlock::ERROR Rejecting block version %f at height %f \n",(double)dBlockVersion,(double)nHeight);
return false;
}
return state.DoS(10, error("%s: Rejecting pog block version < 1189", __func__), REJECT_INVALID, "bad-block-version");
}

if (!fProd && nHeight > FPOG_CUTOVER_HEIGHT_TESTNET && dBlockVersion < 1179)
{
if (false) LogPrintf("ContextualCheckBlock::ERROR Rejecting testnet block version %f at height %f \n",(double)dBlockVersion,(double)nHeight);
return state.DoS(10, error("%s: Rejecting testnet block version < 1179", __func__), REJECT_INVALID, "bad-testnet-block-version");
}

// Rob A. - BiblePay - 12/3/2018
// Rob A. - BiblePay - 12/3/2018, 2/18/2019
/* // We are doing this in IsTitheLegal3 in the induction phase for safety
if (nHeight > POG_V3_CUTOVER_HEIGHT_PROD && fProd)
{
int iTitheCount = 0;
BOOST_FOREACH(const CTransaction& tx, block.vtx)
{
CAmount nTitheAmount = GetTitheTotal(tx);
if (nTitheAmount > 0) iTitheCount++;
if (nTitheAmount > (10 * COIN))
return state.DoS(10, error("%s: POG amount too high", __func__), REJECT_INVALID, "pog-tithe-too-high");
}
if (iTitheCount > TITHE_OVERFLOW)
{
return state.DoS(10, error("%s: POG quantity too high", __func__), REJECT_INVALID, "pog-qty-too-high");
}
}
*/

if (POGEnabled(nHeight, block.GetBlockTime()) && !fReindex)
{
bool fIsPogSuperblock = CSuperblock::IsPOGSuperblock(nHeight);
Expand Down Expand Up @@ -7896,12 +7940,27 @@ TxMessage GetTxMessage(std::string sMessage, int64_t nTime, int iPosition, std::
t.fPrayersMustBeSigned = (GetSporkDouble("prayersmustbesigned", 0) == 1);

if (t.sMessageType == "PRAYER" && (!(Contains(t.sMessageKey, "(") ))) t.sMessageKey += " (" + t.sTimestamp + ")";
if (t.sMessageType == "SPORK" || (t.sMessageType == "PRAYER" && t.fPrayersMustBeSigned))
if (t.sMessageType == "SPORK")
{
t.fSporkSigValid = CheckSporkSig(t);
if (!t.fSporkSigValid) t.sMessageValue = "";
t.fPassedSecurityCheck = t.fSporkSigValid;
}
else if (t.sMessageType == "PRAYER" && t.fPrayersMustBeSigned)
{
double dMinimumUnsignedPrayerDonation = GetSporkDouble("minimumunsignedprayerdonationamount", 3000);
// If donation is to Foundation and meets minimum amount and is not signed
if (dFoundationDonation >= dMinimumUnsignedPrayerDonation)
{
t.fPassedSecurityCheck = true;
}
else
{
t.fSporkSigValid = CheckSporkSig(t);
if (!t.fSporkSigValid) t.sMessageValue = "";
t.fPassedSecurityCheck = t.fSporkSigValid;
}
}
else if (t.sMessageType == "PRAYER" && !t.fPrayersMustBeSigned)
{
// We allow unsigned prayers, as long as abusers don't deface the system (if they do, we set the spork requiring signed prayers and we manually remove the offensive prayers using a signed update)
Expand Down
1 change: 1 addition & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static const int FPOG_CUTOVER_HEIGHT_PROD = 100001; // Feb 7th, 2019 (100,001)
static const int PODC_LAST_BLOCK_PROD = 107000; // March 13th, 2019
static const int PODC_LAST_BLOCK_TESTNET = 126150;
static const int POG_V2_CUTOVER_HEIGHT_PROD = 102025;
static const int POG_V3_CUTOVER_HEIGHT_PROD = 103175;
static const int LOW_POG_DIFF = 5000;
static const int TITHE_OVERFLOW = 75;
static const int MINIMUM_EMAIL_LENGTH = 5; // 3 character domain + . + 1 character name
Expand Down
6 changes: 6 additions & 0 deletions src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class CTitheObject
double Age;
std::string TXID;
int Ordinal;
CAmount CoinAmount;
int SpentHeight;

CTitheObject(std::string xAddress, CAmount xAmount, double xWeight) :
Address(xAddress), Amount(xAmount), Weight(xWeight)
Expand All @@ -100,13 +102,17 @@ class CTitheObject
LastBlockHash = uint256S("0x0");
Age = 0;
Ordinal = 0;
CoinAmount = 0;
SpentHeight = 0;
}

CTitheObject() : Address(""), Amount(0), Weight(0), PaymentTier(0), Height(0), HeightLast(0)
{
LastBlockHash = uint256S("0x0");
Age = 0;
Ordinal = 0;
CoinAmount = 0;
SpentHeight = 0;
}

uint256 GetHash() const;
Expand Down
7 changes: 4 additions & 3 deletions src/qt/businessobjectlist.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "businessobjectlist.h"
#include "bitcoinunits.h"
#include "ui_businessobjectlist.h"
#include "masternode-sync.h"
#include "secdialog.h"
#include "ui_secdialog.h"
#include "writeorphan.h"
Expand Down Expand Up @@ -66,12 +67,12 @@ void BusinessObjectList::UpdateObject(std::string objType)
std::string sFields;
QString pString;

if (objType == "pog_leaderboard")
if (objType == "pog_leaderboard" && masternodeSync.IsBlockchainSynced())
{
sFields = "id,nickname,address,height,amount,weight";
pString = GUIUtil::TOQS(GetPOGBusinessObjectList(ObjectType, sFields));
// Update once per minute
QTimer::singleShot(60000, this, SLOT(RefreshPogLeaderboard()));
// Update once per two minutes
QTimer::singleShot(120000, this, SLOT(RefreshPogLeaderboard()));
}
else
{
Expand Down
7 changes: 6 additions & 1 deletion src/qt/sendcoinsentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,16 @@ void SendCoinsEntry::updateFoundationAddress()
bool bCheckedF = (ui->chkForceTithe->checkState() == Qt::Checked);
bool bCheckedD = (ui->checkboxFoundation->checkState() == Qt::Checked);

if (bCheckedF || bCheckedD)
if (bCheckedD)
{
ui->payTo->setText(GUIUtil::TOQS(chainparams.GetConsensus().FoundationAddress));
ui->payAmount->setFocus();
}
else if (bCheckedF)
{
ui->payTo->setText(GUIUtil::TOQS(chainparams.GetConsensus().FoundationPODSAddress));
ui->payAmount->setFocus();
}
initPOGDifficulty();
}

Expand Down
42 changes: 27 additions & 15 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ UniValue exec(const UniValue& params, bool fHelp)
if (sType.empty() || sPrimaryKey.empty() || sValue.empty())
throw runtime_error(sError);
sError = "";
std::string sResult = SendBlockchainMessage(sType, sPrimaryKey, sValue, 1, true, sError);
std::string sResult = SendBlockchainMessage(sType, sPrimaryKey, sValue, .24, true, sError);
results.push_back(Pair("Sent", sValue));
results.push_back(Pair("TXID", sResult));
if (!sError.empty()) results.push_back(Pair("Error", sError));
Expand Down Expand Up @@ -3089,11 +3089,11 @@ UniValue exec(const UniValue& params, bool fHelp)
BOOST_FOREACH(const PAIRTYPE(std::string, CTitheObject)& item, pindex->mapTithes)
{
CTitheObject oTithe = item.second;
int iLegal = IsTitheLegal2(oTithe, tdp);
int iLegal = IsTitheLegal3(oTithe, tdp);
std::string sErr = TitheErrorToString(iLegal);

std::string sRow = "Legal: " + RoundToString(iLegal, 0) + " [" + sErr + "], Amount: " + RoundToString((double)(oTithe.Amount/COIN),2)
+ ", Height: " + RoundToString(oTithe.Height, 0)
std::string sRow = "Legal: " + RoundToString(iLegal, 0) + " [" + sErr + "], Amount: " + RoundToString((double)oTithe.Amount/COIN, 2)
+ ", Height: " + RoundToString(oTithe.Height, 0) + ", Spent_Coin_Value: " + RoundToString((double)oTithe.CoinAmount/COIN, 2)
+ ", " + oTithe.TXID + "-" + RoundToString(oTithe.Ordinal, 0)
+ ", Age: " + RoundToString(oTithe.Age, 2) + ", NickName: " + oTithe.NickName;
results.push_back(Pair(oTithe.Address, sRow));
Expand Down Expand Up @@ -3140,7 +3140,7 @@ UniValue exec(const UniValue& params, bool fHelp)
else if (sItem == "istithelegal")
{
if (params.size() != 2)
throw runtime_error("You must specify txid.");
throw runtime_error("You must specify a txid.");
std::string sTxId = params[1].get_str();
CTransaction txTithe;
uint256 hashBlockTithe;
Expand All @@ -3152,21 +3152,33 @@ UniValue exec(const UniValue& params, bool fHelp)
int hashInputOrdinal = txTithe.vin[0].prevout.n;
int64_t nTxTime = 0;
CAmount caAmount = 0;
GetTxTimeAndAmount(hashInput, hashInputOrdinal, nTxTime, caAmount);
int iHeight = 0;
GetTxTimeAndAmountAndHeight(hashInput, hashInputOrdinal, nTxTime, caAmount, iHeight);
if (mapBlockIndex.count(hashBlockTithe) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found");
CBlockIndex* pindex = mapBlockIndex[hashBlockTithe];
double nTitheAge = (double)((pindex->GetBlockTime() - nTxTime) / 86400);
CAmount nTotal = GetTitheTotal(txTithe);
bool bTitheLegal = (nTitheAge >= pindex->pprev->nMinCoinAge && caAmount >= pindex->pprev->nMinCoinAmount && nTotal <= pindex->pprev->nMaxTitheAmount);
CTitheObject oTithe = TxToTithe(txTithe, pindex);
TitheDifficultyParams tdp = GetTitheParams(pindex);
int iLegal = IsTitheLegal3(oTithe, tdp);
std::string sErr = TitheErrorToString(iLegal);
if (iLegal == 1) sErr = "VALID";

results.push_back(Pair("Tithe_Legal", iLegal));
results.push_back(Pair("Tithe_Legal_Result", sErr));

results.push_back(Pair("Tx_Time", pindex->GetBlockTime()));
results.push_back(Pair("Tithed_Height", pindex->nHeight));

results.push_back(Pair("Spent_Time", nTxTime));
results.push_back(Pair("Spent_Height", oTithe.SpentHeight));
results.push_back(Pair("Spent_Coin_Amount", (double)oTithe.CoinAmount / COIN));

results.push_back(Pair("Tithe_Age", (double)oTithe.Age));
results.push_back(Pair("Tithe_Amount", (double)oTithe.Amount / COIN));

results.push_back(Pair("Tithe_Legal", bTitheLegal));
results.push_back(Pair("Tithe_Age", nTitheAge));
results.push_back(Pair("Tithe_Spent_Coin_Amount", (double)(caAmount/COIN)));
results.push_back(Pair("Tithe_Amount", (double)(nTotal/COIN)));
results.push_back(Pair("Block_diff_min_coin_age", pindex->nMinCoinAge));
results.push_back(Pair("Block_diff_min_coin_amt", (double)(pindex->nMinCoinAmount/COIN)));
results.push_back(Pair("Block_diff_max_tithe_amt", (double)(pindex->nMaxTitheAmount/COIN)));
results.push_back(Pair("Tithed_Height", pindex->nHeight));
results.push_back(Pair("Block_diff_min_coin_amt", (double)(pindex->nMinCoinAmount / COIN)));
results.push_back(Pair("Block_diff_max_tithe_amt", (double)(pindex->nMaxTitheAmount / COIN)));
}
else
{
Expand Down
Loading

0 comments on commit 17375d5

Please sign in to comment.