Skip to content

Commit

Permalink
1.4.5.0-Leisure Upgrade
Browse files Browse the repository at this point in the history
- Add getblockforstratum rpc call to help support external cpu miner
(bbpminer.exe)
- Add exec pobh call for dev use (this allows us to test bible hashes
manually)
-  Fix instantsend GUI confirmation for signed/accepted IXs
- Add icon for decentralized network
- Increase IX timeout for locks and sigs
- Decrease memory consumption for votes and decrease network utilization
(Remove duplicate votes)
  • Loading branch information
biblepay committed Oct 11, 2019
1 parent 9754bfd commit e4b1391
Show file tree
Hide file tree
Showing 26 changed files with 248 additions and 22 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 4)
define(_CLIENT_VERSION_REVISION, 4)
define(_CLIENT_VERSION_BUILD, 9)
define(_CLIENT_VERSION_REVISION, 5)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const std::string CLIENT_NAME("BiblePay Core");

const int BIBLEPAY_VERSION_MAJOR = 1;
const int BIBLEPAY_VERSION_MINOR = 4;
const int BIBLEPAY_VERSION_REVISION = 4;
const int BIBLEPAY_VERSION_BUILD = 9;
const int BIBLEPAY_VERSION_REVISION = 5;
const int BIBLEPAY_VERSION_BUILD = 0;


const int BIBLE_VERSION = 1000000 * BIBLEPAY_VERSION_MAJOR
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//! These need to be macros, as clientversion.cpp's and biblepay*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 4
#define CLIENT_VERSION_REVISION 4
#define CLIENT_VERSION_BUILD 9
#define CLIENT_VERSION_REVISION 5
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
123 changes: 116 additions & 7 deletions src/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,30 +409,87 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
DBG(std::cout << "CGovernanceManager::AddGovernanceObject END" << std::endl;);
}

std::vector<CGovernanceVote> GetVoteByHash(uint256 governanceHash, uint256 voteHash, int& out_iPos)
{
out_iPos = -1;
std::vector<CGovernanceVote> vecVotes = governance.GetMatchingVotes(governanceHash);
for (int i = 0; i < vecVotes.size(); i++)
{
if (vecVotes[i].GetHash() == voteHash)
{
out_iPos = i;
return vecVotes;
}
}
return vecVotes;
}

int GetVoteCountByOutpointAndGovernanceHashAndSignal(uint256 governanceHash, COutPoint cOutpoint, std::string sVoteSignal, uint256 voteHash)
{
int iFound = 0;
std::vector<CGovernanceVote> vecVotes = governance.GetMatchingVotes(governanceHash);
for (int i = 0; i < vecVotes.size(); i++)
{
std::string sLocSig = CGovernanceVoting::ConvertSignalToString(vecVotes[i].GetSignal());
if (vecVotes[i].GetMasternodeOutpoint() == cOutpoint && sLocSig == sVoteSignal)
{
iFound++;
if (iFound == 1 && vecVotes[i].GetHash() == voteHash)
return 0;
}
}
return iFound;
}

UniValue CGovernanceManager::VoteCleanup1()
{
std::map<std::string, double> mvOutpointCount;
mvOutpointCount.clear();
UniValue results(UniValue::VOBJ);
const object_ref_cm_t::list_t& listItems = cmapVoteToObject.GetItemList();
object_ref_cm_t::list_cit lit = listItems.begin();
//results.push_back(Pair("VoteCleanup", cmapVoteToObject.size()));
int iTotal = 0;
int iInvVotes = 0;
while (lit != listItems.end())
{
uint256 nKey = lit->key;
CGovernanceObject* pGovobj = nullptr;
cmapVoteToObject.Get(nKey, pGovobj);
if (pGovobj != nullptr)
{
results.push_back(Pair(nKey.GetHex(), pGovobj->GetHash().GetHex()));
iTotal++;
}
else
{
results.push_back(Pair(nKey.GetHex(), "00000"));
int iPos = 0;
std::vector<CGovernanceVote> myVoteVec = GetVoteByHash(pGovobj->GetHash(), nKey, iPos);
if (iPos > -1)
{
// Who is the signing masternode on this vote?
if (cmapInvalidVotes.HasKey(nKey))
iInvVotes++;
mvOutpointCount[myVoteVec[iPos].GetMasternodeOutpoint().ToStringShort()]++;
iTotal++;
std::string sOP = myVoteVec[iPos].GetMasternodeOutpoint().ToStringShort();
if (true)
{
// Audit individual sanctuary
std::string sSignal = CGovernanceVoting::ConvertSignalToString(myVoteVec[iPos].GetSignal());
std::string sVote = "T:"+ RoundToString(pGovobj->GetObjectType(), 0) + "SIG:" + sSignal;
int iCt = GetVoteCountByOutpointAndGovernanceHashAndSignal(pGovobj->GetHash(), myVoteVec[iPos].GetMasternodeOutpoint(), sSignal, myVoteVec[iPos].GetHash());
std::string sRow = "SANC:" + myVoteVec[iPos].GetMasternodeOutpoint().ToStringShort() + ", gobj: " + pGovobj->GetHash().GetHex() + ", Vote:" + sVote + ", PriorVoteCount: " + RoundToString(iCt, 0);
results.push_back(Pair(nKey.GetHex(), sRow));
}
}
}
++lit;
}
results.push_back(Pair("Total", iTotal));
results.push_back(Pair("Invalid Votes", iInvVotes));

for (auto ii : mvOutpointCount)
{
double nCount = mvOutpointCount[ii.first];
std::string sOutpoint = ii.first;
results.push_back(Pair("SANC " + sOutpoint, nCount));
}

return results;
}

Expand Down Expand Up @@ -724,6 +781,9 @@ void CGovernanceManager::DoMaintenance(CConnman& connman)
ClearPreDIP3Votes();
RemoveInvalidProposalVotes();
}
// BiblePay
RemoveDuplicateVotes();
// End of BiblePay

// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES

Expand Down Expand Up @@ -1531,6 +1591,55 @@ void CGovernanceManager::CleanOrphanObjects()
}
}

void CGovernanceManager::RemoveDuplicateVotes()
{
LOCK(cs);
LogPrintf("\nRemoveDuplicateVotes %f", 1);

std::vector<uint256> duplicateVotes;
int iTotal = 0;
int iDeleted = 0;
int iMarked = 0;
const object_ref_cm_t::list_t& listItems = cmapVoteToObject.GetItemList();
object_ref_cm_t::list_cit lit = listItems.begin();
while (lit != listItems.end())
{
uint256 nKey = lit->key;
CGovernanceObject* pGovobj = nullptr;
cmapVoteToObject.Get(nKey, pGovobj);
if (pGovobj != nullptr)
{
int iPos = 0;
std::vector<CGovernanceVote> myVoteVec = GetVoteByHash(pGovobj->GetHash(), nKey, iPos);
if (iPos > -1)
{
iTotal++;
std::string sSignal = CGovernanceVoting::ConvertSignalToString(myVoteVec[iPos].GetSignal());
std::string sVote = "T:"+ RoundToString(pGovobj->GetObjectType(), 0) + "SIG:" + sSignal;
int iCt = GetVoteCountByOutpointAndGovernanceHashAndSignal(pGovobj->GetHash(), myVoteVec[iPos].GetMasternodeOutpoint(), sSignal, nKey);
if (iCt >= 7)
{
// This sanc has voted at least 7 times for the same object with the same signal (IE causing many duplicate votes to be transmitted around the network)
// Delete most of the duplicates, but leave the first vote
duplicateVotes.emplace_back(nKey);
iMarked++;
}
}
}
++lit;
}

LogPrintf("\nMarked %f out of %f", iMarked, iTotal);

for (const auto& uVote : duplicateVotes)
{
}

LogPrintf("\nBiblePay::RemoveDuplicates::Removed %f out of %f ", iDeleted, iTotal);
}



void CGovernanceManager::RemoveInvalidProposalVotes()
{
auto curMNList = deterministicMNManager->GetListAtChainTip();
Expand Down
1 change: 1 addition & 0 deletions src/governance.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ class CGovernanceManager
void RequestOrphanObjects(CConnman& connman);

void CleanOrphanObjects();
void RemoveDuplicateVotes();

void RemoveInvalidProposalVotes();

Expand Down
8 changes: 4 additions & 4 deletions src/instantx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ static const int MIN_INSTANTSEND_PROTO_VERSION = 70210;

/// For how long we are going to accept votes/locks
/// after we saw the first one for a specific transaction
static const int INSTANTSEND_LOCK_TIMEOUT_SECONDS = 15;
static const int INSTANTSEND_LOCK_TIMEOUT_SECONDS = 60;
/// For how long we are going to keep invalid votes and votes for failed lock attempts,
/// must be greater than INSTANTSEND_LOCK_TIMEOUT_SECONDS
static const int INSTANTSEND_FAILED_TIMEOUT_SECONDS = 60;
static const int INSTANTSEND_FAILED_TIMEOUT_SECONDS = 180;

extern bool fEnableInstantSend;
extern int nCompleteTXLocks;
Expand Down Expand Up @@ -313,8 +313,8 @@ class COutPointLock
bool fAttacked = false;

public:
static const int SIGNATURES_REQUIRED = 6;
static const int SIGNATURES_TOTAL = 10;
static const int SIGNATURES_REQUIRED = 3;
static const int SIGNATURES_TOTAL = 5;

COutPointLock() {}

Expand Down
25 changes: 25 additions & 0 deletions src/kjv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31463,6 +31463,31 @@ uint256 BibleHashV2(uint256 hash, int64_t nBlockTime, int64_t nPrevBlockTime, bo
return ArithToUint256(bnHash);
}

uint256 BibleHashDebug(uint256 hash, bool fLate)
{
std::vector<unsigned char> vchPlaintext = vector<unsigned char>(hash.begin(), hash.end());
std::vector<unsigned char> vchCiphertext;
BibleEncrypt(vchPlaintext, vchCiphertext);
std::string s64 = EncodeBase64(VectorToString(vchCiphertext));
std::string sMd5Hash = BibleMD5(EncodeBase64(VectorToString(vchCiphertext)));
std::string sVerses = GVFromHash(sMd5Hash, false);
std::string smd1 = BibleMD5(sVerses);
std::vector<unsigned char> vchVerses = vector<unsigned char>(smd1.begin(), smd1.end());
uint256 h = SerializeHash(vchVerses);

arith_uint256 bnHash = UintToArith256(h);
// Make compatible with DGW 7 minute blocks
int64_t nDivisor = fLate ? 8400 : 1777;
bnHash *= 420;
bnHash /= nDivisor;
uint256 nBH = ArithToUint256(bnHash);
LogPrintf("\nBibleHashDebug: BASE64 %s, Md5Enc %s, md5Verses %s, Sha256Hash %s, POBHash %s ",
s64, sMd5Hash, smd1, h.GetHex(), nBH.GetHex());

return nBH;
}


uint256 BibleHashClassic(uint256 hash, int64_t nBlockTime, int64_t nPrevBlockTime, bool bMining, int nPrevHeight, const CBlockIndex* pindexLast, bool bRequireTxIndex,
bool f7000, bool f8000, bool f9000, bool fTitheBlocksActive, unsigned int nNonce, const Consensus::Params& params)
{
Expand Down
1 change: 1 addition & 0 deletions src/kjv.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ bool BibleEncryptE(std::vector<unsigned char> vchPlaintext, std::vector<unsigned
extern std::string GetBibleHashVerses(uint256 hash, uint64_t nBlockTime, uint64_t nPrevBlockTime, int nPrevHeight, CBlockIndex* pindexPrev);
std::string GetBibleHashVerseNumber(uint256 hash, uint64_t nBlockTime, uint64_t nPrevBlockTime, int nPrevHeight, CBlockIndex* pindexPrev, int iVerseNumber);
std::string GetVerseML(std::string sLanguage, std::string sBook, int iChapter, int iVerse, int iBookStart, int iBookEnd);
uint256 BibleHashDebug(uint256 hash, bool fLate);

#endif
34 changes: 34 additions & 0 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,40 @@ bool IsMyABNSufficient(CBlock block, CBlockIndex* pindexPrev, int nHeight)
return true;
}

std::string CreateBlockForStratum(std::string& sError, std::string& sHexDifficulty)
{
// Create Evo block
bool fFunded = false;
std::string sPoolMiningAddress;
std::string sMinerGuid;
int iThreadID = 0;
boost::shared_ptr<CReserveScript> coinbaseScript;
GetMainSignals().ScriptForMining(coinbaseScript);

std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler(Params()).CreateNewBlock(coinbaseScript->reserveScript,
sPoolMiningAddress, sMinerGuid, iThreadID, fFunded));
if (!pblocktemplate.get())
{
LogPrint("miner", "CreateBlockForStratum::No block to mine %f", iThreadID);
sError = "Wallet Locked/ABN Required";
SpendABN();
return "";
}

CBlock *pblock = &pblocktemplate->block;
unsigned int nExtraNonce = 7;
CBlockIndex* pindexPrev = chainActive.Tip();

IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION);
CBlock block1 = const_cast<CBlock&>(*pblock);
ssBlock << block1;
std::string sBlockHex1 = HexStr(ssBlock.begin(), ssBlock.end());
arith_uint256 hashTarget = arith_uint256().SetCompact(pblock->nBits);
sHexDifficulty = hashTarget.GetHex();
return sBlockHex1;
}

void static BibleMiner(const CChainParams& chainparams, int iThreadID, int iFeatureSet)
{
LogPrintf("BibleMiner -- started thread %f \n", (double)iThreadID);
Expand Down
1 change: 1 addition & 0 deletions src/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Consensus { struct Params; };
static const bool DEFAULT_PRINTPRIORITY = false;

void GenerateBiblecoins(bool fGenerate, int nThreads, const CChainParams& chainparams);
std::string CreateBlockForStratum(std::string& sError, std::string& sTarget);

struct CBlockTemplate
{
Expand Down
Binary file added src/qt/res/icons/bezaleel/account256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/qt/res/icons/bezaleel/account32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/qt/res/icons/bezaleel/account32_legacy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/qt/res/icons/drkblue/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added src/qt/res/icons/drkblue/account256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/qt/res/icons/drkblue/account32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/qt/res/icons/light-retro/account256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/qt/res/icons/light-retro/account32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/qt/res/icons/light/account256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/qt/res/icons/light/account32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/qt/res/icons/trad/account256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/qt/res/icons/trad/account32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
else
{
status.lockedByInstantSend = wtx.IsLockedByInstantSend();
if (wtx.IsABN())
if (instantsend.IsLockedInstantSendTransaction(wtx.GetHash()))
{
status.status = TransactionStatus::Confirmed;
}
else if (wtx.IsABN())
{
status.status = TransactionStatus::Abandoned;
}
Expand Down
Loading

0 comments on commit e4b1391

Please sign in to comment.