Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/LIMXTEC/BitCore into 0.9.8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
limxdev committed Apr 20, 2020
2 parents 173373c + 7613027 commit 9033c57
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 59 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, 0)
define(_CLIENT_VERSION_MINOR, 90)
define(_CLIENT_VERSION_REVISION, 8)
define(_CLIENT_VERSION_BUILD, 10)
define(_CLIENT_VERSION_BUILD, 11)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2020)
define(_COPYRIGHT_HOLDERS,[The %s developers])
Expand Down
12 changes: 3 additions & 9 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ class CMainParams : public CChainParams {
{ 200000, uint256S("0x65c89c662dbdad4aeeb4215076884be736a7512984741b353bbdef47478305e5")},
{ 215000, uint256S("0x18accc496518e6f3008eeaab7e04123939d66eb7f8a02f2fcb3d69093c1df38c")},
{ 356548, uint256S("0xf62b6c5645997d078d9cb130cfe96d64ec2c047bbceca3ae8ffc373eef80b866")},
{ 550000, uint256S("0xa901848fe9d22814dbb3e0f62892d3bd7a1e70f6a48a459e68ebaf24ea5d5867")},
}
};
// FXTC BEGIN
consensus.nlastValidPowHashHeight = 999999999;
// FXTC

chainTxData = ChainTxData{
// BTX: data as of block 0x8da1c7f79018fac8acac69a57b2f8b5d2743af67976a4525fdedc8c85a3a1418 (height 410476).
Expand Down Expand Up @@ -364,9 +362,7 @@ class CTestNetParams : public CChainParams {
{0, uint256S("0xe02c5d66e8edb49984eb743c798bca069466ce457b7febfa3c3a01b33353b7bc6")},
}
};
// FXTC BEGIN
consensus.nlastValidPowHashHeight = 99999999;;
// FXTC


chainTxData = ChainTxData{
// BTX: data as of block 0x8da1c7f79018fac8acac69a57b2f8b5d2743af67976a4525fdedc8c85a3a1418 (height 410476).
Expand Down Expand Up @@ -482,9 +478,7 @@ class CRegTestParams : public CChainParams {
{0, uint256S("0x604148281e5c4b7f2487e5d03cd60d8e6f69411d613f6448034508cea52e9574")},
}
};
// FXTC BEGIN
consensus.nlastValidPowHashHeight = 99999999;;
// FXTC


chainTxData = ChainTxData{
0,
Expand Down
3 changes: 0 additions & 3 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ struct Params {
int64_t DifficultyAdjustmentIntervalV2() const { return nPowTargetTimespanV2 / nPowTargetSpacing; }
uint256 nMinimumChainWork;
uint256 defaultAssumeValid;
// FXTC BEGIN
int nlastValidPowHashHeight;
// FXTC EMD
};
} // namespace Consensus

Expand Down
36 changes: 22 additions & 14 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool IsBlockPayeeValid(const CTransactionRef txNew, int nBlockHeight, CAmount bl
// we can only check masternode payments

const Consensus::Params& consensusParams = Params().GetConsensus();

//We should leave that here until we start the Superblocksystem. The second stage is the Spork 8 only if Superblock are online - Chris 2020
if(sporkManager.IsSporkActive(SPORK_22_MASTERNODE_PAYMENT_ENFORCEMENT))
{
LogPrintf("IsBlockPayeeValid SPORK_22 -- ERROR: Invalid masternode payment detected at height %d: %s\n", nBlockHeight, txNew->ToString());
Expand Down Expand Up @@ -311,9 +311,23 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int nBlockH
}

int CMasternodePayments::GetMinMasternodePaymentsProto() {
return sporkManager.IsSporkActive(SPORK_10_MASTERNODE_PAY_UPDATED_NODES)
? MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2
: MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1;
if (DEFAULTMINPROTO < sporkManager.GetSporkValue(SPORK_BTX_18_MIN_PEER_PROTO_VERSION))
{
return sporkManager.GetSporkValue(SPORK_BTX_18_MIN_PEER_PROTO_VERSION);
}
else
{
return DEFAULTMINPROTO;
}
}

int CMasternodePayments::GetFactorEnforcement() {

if (FACTOR_ENFORCEMENT > sporkManager.GetSporkValue(SPORK_22_FACTOR_ENFORCEMENT)|| sporkManager.GetSporkValue(SPORK_22_FACTOR_ENFORCEMENT) > 200)
{
return FACTOR_ENFORCEMENT;
}
return sporkManager.GetSporkValue(SPORK_22_FACTOR_ENFORCEMENT);
}

void CMasternodePayments::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman)
Expand Down Expand Up @@ -683,14 +697,7 @@ bool CMasternodePaymentVote::IsValid(CNode* pnode, int nValidationHeight, std::s
return false;
}

int nMinRequiredProtocol;
if(nBlockHeight >= nValidationHeight) {
// new votes must comply SPORK_10_MASTERNODE_PAY_UPDATED_NODES rules
nMinRequiredProtocol = mnpayments.GetMinMasternodePaymentsProto();
} else {
// allow non-updated masternodes for old blocks
nMinRequiredProtocol = MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1;
}
int nMinRequiredProtocol = mnpayments.GetMinMasternodePaymentsProto();

if(mnInfo.nProtocolVersion < nMinRequiredProtocol) {
strError = strprintf("Masternode protocol is too old: nProtocolVersion=%d, nMinRequiredProtocol=%d", mnInfo.nProtocolVersion, nMinRequiredProtocol);
Expand All @@ -710,13 +717,14 @@ bool CMasternodePaymentVote::IsValid(CNode* pnode, int nValidationHeight, std::s
}

if(nRank > MNPAYMENTS_SIGNATURES_TOTAL) {
int vCount = mnpayments.GetFactorEnforcement();
// It's common to have masternodes mistakenly think they are in the top 10
// We don't want to print all of these messages in normal mode, debug mode should print though
strError = strprintf("Masternode is not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL, nRank);
// Only ban for new mnw which is out of bounds, for old mnw MN list itself might be way too much off
if(nRank > MNPAYMENTS_SIGNATURES_TOTAL*2 && nBlockHeight > nValidationHeight) {
if(nRank > MNPAYMENTS_SIGNATURES_TOTAL * vCount && nBlockHeight > nValidationHeight) {
LOCK(cs_main);
strError = strprintf("Masternode is not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL*2, nRank);
strError = strprintf("Masternode is not in the top %d (%d)", MNPAYMENTS_SIGNATURES_TOTAL * vCount, nRank);
LogPrintf("CMasternodePaymentVote::IsValid -- Error: %s\n", strError);
Misbehaving(pnode->GetId(), 20);
}
Expand Down
5 changes: 3 additions & 2 deletions src/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class CMasternodeBlockPayees;

static const int MNPAYMENTS_SIGNATURES_REQUIRED = 6;
static const int MNPAYMENTS_SIGNATURES_TOTAL = 10;
static const int DEFAULTMINPROTO = 79999;
static const int FACTOR_ENFORCEMENT = 2;

//! minimum peer version that can receive and send masternode payment messages,
// vote for masternode and be elected as a payment winner
// V1 - Last protocol version before update
// V2 - Newest protocol version
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1 = 70206;
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2 = 70208;

extern CCriticalSection cs_vecPayees;
extern CCriticalSection cs_mapMasternodeBlocks;
Expand Down Expand Up @@ -210,6 +210,7 @@ class CMasternodePayments
bool CanVote(COutPoint outMasternode, int nBlockHeight);

int GetMinMasternodePaymentsProto();
int GetFactorEnforcement();
void ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
std::string GetRequiredPaymentsString(int nBlockHeight);
void FillBlockPayee(CMutableTransaction& txNew, int nBlockHeight, CAmount blockReward, CTxOut& txoutMasternodeRet);
Expand Down
4 changes: 2 additions & 2 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class CMasternodePing
nSentinelVersion = DEFAULT_SENTINEL_VERSION;
return;
}
READWRITE(fSentinelIsCurrent);
READWRITE(nSentinelVersion);
//READWRITE(fSentinelIsCurrent);
//READWRITE(nSentinelVersion);
}

uint256 GetHash() const
Expand Down
18 changes: 6 additions & 12 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void CMasternodeMan::Check()
LOCK2(cs_main, cs);
// FXTC END

LogPrint(BCLog::MASTERNODE, "CMasternodeMan::Check -- nLastWatchdogVoteTime=%d, IsWatchdogActive()=%d\n", nLastWatchdogVoteTime, IsWatchdogActive());
//LogPrint(BCLog::MASTERNODE, "CMasternodeMan::Check -- nLastWatchdogVoteTime=%d, IsWatchdogActive()=%d\n", nLastWatchdogVoteTime, IsWatchdogActive());

for (auto& mnpair : mapMasternodes) {
mnpair.second.Check();
Expand Down Expand Up @@ -802,8 +802,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand,
// if masternode uses sentinel ping instead of watchdog
// we shoud update nTimeLastWatchdogVote here if sentinel
// ping flag is actual
if(pmn && mnp.fSentinelIsCurrent)
UpdateWatchdogVoteTime(mnp.vin.prevout, mnp.sigTime);
//if(pmn && mnp.fSentinelIsCurrent)
// UpdateWatchdogVoteTime(mnp.vin.prevout, mnp.sigTime);

// too late, new MNANNOUNCE is required
if(pmn && pmn->IsNewStartRequired()) return;
Expand Down Expand Up @@ -1495,12 +1495,6 @@ void CMasternodeMan::UpdateWatchdogVoteTime(const COutPoint& outpoint, uint64_t
nLastWatchdogVoteTime = GetTime();
}

bool CMasternodeMan::IsWatchdogActive()
{
LOCK(cs);
// Check if any masternodes have voted recently, otherwise return false
return (GetTime() - nLastWatchdogVoteTime) <= MASTERNODE_WATCHDOG_MAX_SECONDS;
}

bool CMasternodeMan::AddGovernanceVote(const COutPoint& outpoint, uint256 nGovernanceObjectHash)
{
Expand Down Expand Up @@ -1553,9 +1547,9 @@ void CMasternodeMan::SetMasternodeLastPing(const COutPoint& outpoint, const CMas
// if masternode uses sentinel ping instead of watchdog
// we shoud update nTimeLastWatchdogVote here if sentinel
// ping flag is actual
if(mnp.fSentinelIsCurrent) {
UpdateWatchdogVoteTime(mnp.vin.prevout, mnp.sigTime);
}
//if(mnp.fSentinelIsCurrent) {
// UpdateWatchdogVoteTime(mnp.vin.prevout, mnp.sigTime);
//}
mapSeenMasternodePing.insert(std::make_pair(mnp.GetHash(), mnp));

CMasternodeBroadcast mnb(*pmn);
Expand Down
1 change: 0 additions & 1 deletion src/masternodeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ class CMasternodeMan
return vecTmp;;
}

bool IsWatchdogActive();
void UpdateWatchdogVoteTime(const COutPoint& outpoint, uint64_t nVoteTime = 0);
bool AddGovernanceVote(const COutPoint& outpoint, uint256 nGovernanceObjectHash);
void RemoveGovernanceObject(uint256 nGovernanceObjectHash);
Expand Down
1 change: 0 additions & 1 deletion src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,6 @@ UniValue getgovernanceinfo(const JSONRPCRequest& request)

UniValue obj(UniValue::VOBJ);
obj.push_back(Pair("governanceminquorum", Params().GetConsensus().nGovernanceMinQuorum));
obj.push_back(Pair("masternodewatchdogmaxseconds", MASTERNODE_WATCHDOG_MAX_SECONDS));
obj.push_back(Pair("proposalfee", ValueFromAmount(GOVERNANCE_PROPOSAL_FEE_TX)));
obj.push_back(Pair("superblockcycle", Params().GetConsensus().nSuperblockCycle));
obj.push_back(Pair("lastsuperblock", nLastSuperblock));
Expand Down
4 changes: 0 additions & 4 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,6 @@ UniValue masternodelist(const JSONRPCRequest& request)
" addr - Print ip address associated with a masternode (can be additionally filtered, partial match)\n"
" full - Print info in format 'status protocol payee lastseen activeseconds lastpaidtime lastpaidblock IP'\n"
" (can be additionally filtered, partial match)\n"
" info - Print info in format 'status protocol payee lastseen activeseconds sentinelversion sentinelstate IP'\n"
" (can be additionally filtered, partial match)\n"
" lastpaidblock - Print the last block height a node was paid on the network\n"
" lastpaidtime - Print the last time a node was paid on the network\n"
" lastseen - Print timestamp of when a masternode was last seen on the network\n"
Expand Down Expand Up @@ -581,8 +579,6 @@ UniValue masternodelist(const JSONRPCRequest& request)
EncodeDestination(mn.pubKeyCollateralAddress.GetID()) << " " <<
(int64_t)mn.lastPing.sigTime << " " << std::setw(8) <<
(int64_t)(mn.lastPing.sigTime - mn.sigTime) << " " <<
SafeIntVersionToString(mn.lastPing.nSentinelVersion) << " " <<
(mn.lastPing.fSentinelIsCurrent ? "current" : "expired") << " " <<
mn.addr.ToString();
std::string strInfo = streamInfo.str();
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
Expand Down
8 changes: 4 additions & 4 deletions src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool CSporkManager::IsSporkActive(int nSporkID)
case SPORK_BTX_19_MIN_VERSION_COUNT: r = SPORK_BTX_19_MIN_VERSION_COUNT_DEFAULT; break;
case SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT: r = SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT_DEFAULT; break;
case SPORK_BTX_21_MAX_VERSION_COUNT: r = SPORK_BTX_21_MAX_VERSION_COUNT_DEFAULT; break;
case SPORK_BTX_22_UNKNOW: r = SPORK_BTX_22_UNKNOW_DEFAULT; break;
case SPORK_22_FACTOR_ENFORCEMENT: r = SPORK_22_FACTOR_ENFORCEMENT_DEFAULT; break;
// FXTC END
default:
LogPrint(BCLog::SPORK, "CSporkManager::IsSporkActive -- Unknown Spork ID %d\n", nSporkID);
Expand Down Expand Up @@ -252,7 +252,7 @@ int64_t CSporkManager::GetSporkValue(int nSporkID)
case SPORK_BTX_19_MIN_VERSION_COUNT: return SPORK_BTX_19_MIN_VERSION_COUNT_DEFAULT;
case SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT: return SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT_DEFAULT;
case SPORK_BTX_21_MAX_VERSION_COUNT: return SPORK_BTX_21_MAX_VERSION_COUNT_DEFAULT;
case SPORK_BTX_22_UNKNOW: return SPORK_BTX_22_UNKNOW_DEFAULT;
case SPORK_22_FACTOR_ENFORCEMENT: return SPORK_22_FACTOR_ENFORCEMENT_DEFAULT;

default:
LogPrint(BCLog::SPORK, "CSporkManager::GetSporkValue -- Unknown Spork ID %d\n", nSporkID);
Expand Down Expand Up @@ -291,7 +291,7 @@ int CSporkManager::GetSporkIDByName(std::string strName)
if (strName == "SPORK_BTX_19_MIN_VERSION_COUNT") return SPORK_BTX_19_MIN_VERSION_COUNT;
if (strName == "SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT") return SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT;
if (strName == "SPORK_BTX_21_MAX_VERSION_COUNT") return SPORK_BTX_21_MAX_VERSION_COUNT;
if (strName == "SPORK_BTX_22_UNKNOW") return SPORK_BTX_22_UNKNOW;
if (strName == "SPORK_22_FACTOR_ENFORCEMENT") return SPORK_22_FACTOR_ENFORCEMENT;

LogPrint(BCLog::SPORK, "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
return -1;
Expand Down Expand Up @@ -328,7 +328,7 @@ std::string CSporkManager::GetSporkNameByID(int nSporkID)
case SPORK_BTX_19_MIN_VERSION_COUNT: return "SPORK_BTX_19_MIN_VERSION_COUNT";
case SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT: return "SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT";
case SPORK_BTX_21_MAX_VERSION_COUNT: return "SPORK_BTX_21_MAX_VERSION_COUNT";
case SPORK_BTX_22_UNKNOW: return "SPORK_BTX_22_UNKNOW";
case SPORK_22_FACTOR_ENFORCEMENT: return "SPORK_22_FACTOR_ENFORCEMENT";

default:
LogPrint(BCLog::SPORK, "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
Expand Down
4 changes: 2 additions & 2 deletions src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static const int SPORK_BTX_18_MIN_PEER_PROTO_VERSION = 94680031;
static const int SPORK_BTX_19_MIN_VERSION_COUNT = 94680032;
static const int SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT = 94680026;
static const int SPORK_BTX_21_MAX_VERSION_COUNT = 94680027;
static const int SPORK_BTX_22_UNKNOW = 94680028;
static const int SPORK_22_FACTOR_ENFORCEMENT = 94680028;
// FXTC END

static const int64_t SPORK_2_INSTANTSEND_ENABLED_DEFAULT = 0; // ON
Expand Down Expand Up @@ -90,7 +90,7 @@ static const int64_t SPORK_BTX_18_MIN_PEER_PROTO_VERSION_DEFAULT = 70016;// OFF
static const int64_t SPORK_BTX_19_MIN_VERSION_COUNT_DEFAULT = 4070908800ULL;// OFF
static const int64_t SPORK_BTX_20_MIN_FOR_WORK_VERSION_COUNT_DEFAULT = 4070908800ULL;// OFF
static const int64_t SPORK_BTX_21_MAX_VERSION_COUNT_DEFAULT = 4070908800ULL;// OFF
static const int64_t SPORK_BTX_22_UNKNOW_DEFAULT = 4070908800ULL;// OFF
static const int64_t SPORK_22_FACTOR_ENFORCEMENT_DEFAULT = 4070908800ULL;// OFF



Expand Down
3 changes: 0 additions & 3 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,6 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
pindexNew->nStatus = diskindex.nStatus;
pindexNew->nTx = diskindex.nTx;

// BitCore BEGIN
if (pindexNew->nHeight > consensusParams.nlastValidPowHashHeight)
// FXTC END
if (!CheckProofOfWork(pindexNew->GetBlockPoWHash(), pindexNew->nBits, consensusParams))
return error("%s: CheckProofOfWork failed: %s", __func__, pindexNew->ToString());

Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3660,7 +3660,7 @@ bool CChainState::AcceptBlockHeader(const CBlockHeader& block, CValidationState&
if (pindexPrev->nStatus & BLOCK_FAILED_MASK)
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
// FXTC BEGIN
if (fCheckpointsEnabled && pindexPrev->nHeight < chainparams.GetConsensus().nlastValidPowHashHeight && !Checkpoints::IsExpectedCheckpoint(chainparams.Checkpoints(), pindexPrev->nHeight + 1, block.GetHash()))
if (fCheckpointsEnabled && !Checkpoints::IsExpectedCheckpoint(chainparams.Checkpoints(), pindexPrev->nHeight + 1, block.GetHash()))
return state.DoS(100, error("%s: Checkpoints::IsExpectedCheckpoint(): invalid checkpoint at height %d", __func__, pindexPrev->nHeight + 1), REJECT_CHECKPOINT, "bad-chackpoint");
// FXTC END
if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime()))
Expand Down

0 comments on commit 9033c57

Please sign in to comment.