mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
feat: skip governance checks for blocks below the best chainlock
This commit is contained in:
parent
cfc40864c1
commit
41ab95dbf8
@ -181,7 +181,7 @@ CAmount PlatformShare(const CAmount reward)
|
|||||||
* - Other blocks are 10% lower in outgoing value, so in total, no extra coins are created
|
* - Other blocks are 10% lower in outgoing value, so in total, no extra coins are created
|
||||||
* - When non-superblocks are detected, the normal schedule should be maintained
|
* - When non-superblocks are detected, the normal schedule should be maintained
|
||||||
*/
|
*/
|
||||||
bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const int nBlockHeight, const CAmount blockReward, std::string& strErrorRet)
|
bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const int nBlockHeight, const CAmount blockReward, std::string& strErrorRet, const bool check_superblock)
|
||||||
{
|
{
|
||||||
bool isBlockRewardValueMet = (block.vtx[0]->GetValueOut() <= blockReward);
|
bool isBlockRewardValueMet = (block.vtx[0]->GetValueOut() <= blockReward);
|
||||||
|
|
||||||
@ -242,6 +242,8 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const int nBlo
|
|||||||
return isBlockRewardValueMet;
|
return isBlockRewardValueMet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!check_superblock) return true;
|
||||||
|
|
||||||
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
||||||
|
|
||||||
if (!CSuperblockManager::IsSuperblockTriggered(m_govman, tip_mn_list, nBlockHeight)) {
|
if (!CSuperblockManager::IsSuperblockTriggered(m_govman, tip_mn_list, nBlockHeight)) {
|
||||||
@ -267,7 +269,7 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const int nBlo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward)
|
bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, const bool check_superblock)
|
||||||
{
|
{
|
||||||
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
|
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
|
||||||
|
|
||||||
@ -298,6 +300,7 @@ bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CB
|
|||||||
// superblocks started
|
// superblocks started
|
||||||
|
|
||||||
if (AreSuperblocksEnabled(m_sporkman)) {
|
if (AreSuperblocksEnabled(m_sporkman)) {
|
||||||
|
if (!check_superblock) return true;
|
||||||
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
||||||
if (CSuperblockManager::IsSuperblockTriggered(m_govman, tip_mn_list, nBlockHeight)) {
|
if (CSuperblockManager::IsSuperblockTriggered(m_govman, tip_mn_list, nBlockHeight)) {
|
||||||
if (CSuperblockManager::IsValid(m_govman, tip_mn_list, txNew, nBlockHeight, blockSubsidy + feeReward)) {
|
if (CSuperblockManager::IsValid(m_govman, tip_mn_list, txNew, nBlockHeight, blockSubsidy + feeReward)) {
|
||||||
|
@ -52,8 +52,8 @@ public:
|
|||||||
const CMasternodeSync& mn_sync, const CSporkManager& sporkman) :
|
const CMasternodeSync& mn_sync, const CSporkManager& sporkman) :
|
||||||
m_dmnman{dmnman}, m_govman{govman}, m_consensus_params{consensus_params}, m_mn_sync{mn_sync}, m_sporkman{sporkman} {}
|
m_dmnman{dmnman}, m_govman{govman}, m_consensus_params{consensus_params}, m_mn_sync{mn_sync}, m_sporkman{sporkman} {}
|
||||||
|
|
||||||
bool IsBlockValueValid(const CBlock& block, const int nBlockHeight, const CAmount blockReward, std::string& strErrorRet);
|
bool IsBlockValueValid(const CBlock& block, const int nBlockHeight, const CAmount blockReward, std::string& strErrorRet, const bool check_superblock);
|
||||||
bool IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward);
|
bool IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, const bool check_superblock);
|
||||||
void FillBlockPayments(CMutableTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
|
void FillBlockPayments(CMutableTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
|
||||||
std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet);
|
std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet);
|
||||||
};
|
};
|
||||||
|
@ -2445,7 +2445,9 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||||||
int64_t nTime5_3 = GetTimeMicros(); nTimeCreditPool += nTime5_3 - nTime5_2;
|
int64_t nTime5_3 = GetTimeMicros(); nTimeCreditPool += nTime5_3 - nTime5_2;
|
||||||
LogPrint(BCLog::BENCHMARK, " - CheckCreditPoolDiffForBlock: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5_3 - nTime5_2), nTimeCreditPool * MICRO, nTimeCreditPool * MILLI / nBlocksTotal);
|
LogPrint(BCLog::BENCHMARK, " - CheckCreditPoolDiffForBlock: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5_3 - nTime5_2), nTimeCreditPool * MICRO, nTimeCreditPool * MILLI / nBlocksTotal);
|
||||||
|
|
||||||
if (!m_chain_helper->mn_payments->IsBlockValueValid(block, pindex->nHeight, blockSubsidy + feeReward, strError)) {
|
bool check_superblock = m_clhandler->GetBestChainLock().getHeight() < pindex->nHeight;
|
||||||
|
|
||||||
|
if (!m_chain_helper->mn_payments->IsBlockValueValid(block, pindex->nHeight, blockSubsidy + feeReward, strError, check_superblock)) {
|
||||||
// NOTE: Do not punish, the node might be missing governance data
|
// NOTE: Do not punish, the node might be missing governance data
|
||||||
LogPrintf("ERROR: ConnectBlock(DASH): %s\n", strError);
|
LogPrintf("ERROR: ConnectBlock(DASH): %s\n", strError);
|
||||||
return state.Invalid(BlockValidationResult::BLOCK_RESULT_UNSET, "bad-cb-amount");
|
return state.Invalid(BlockValidationResult::BLOCK_RESULT_UNSET, "bad-cb-amount");
|
||||||
@ -2454,7 +2456,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||||||
int64_t nTime5_4 = GetTimeMicros(); nTimeValueValid += nTime5_4 - nTime5_3;
|
int64_t nTime5_4 = GetTimeMicros(); nTimeValueValid += nTime5_4 - nTime5_3;
|
||||||
LogPrint(BCLog::BENCHMARK, " - IsBlockValueValid: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5_4 - nTime5_3), nTimeValueValid * MICRO, nTimeValueValid * MILLI / nBlocksTotal);
|
LogPrint(BCLog::BENCHMARK, " - IsBlockValueValid: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5_4 - nTime5_3), nTimeValueValid * MICRO, nTimeValueValid * MILLI / nBlocksTotal);
|
||||||
|
|
||||||
if (!m_chain_helper->mn_payments->IsBlockPayeeValid(*block.vtx[0], pindex->pprev, blockSubsidy, feeReward)) {
|
if (!m_chain_helper->mn_payments->IsBlockPayeeValid(*block.vtx[0], pindex->pprev, blockSubsidy, feeReward, check_superblock)) {
|
||||||
// NOTE: Do not punish, the node might be missing governance data
|
// NOTE: Do not punish, the node might be missing governance data
|
||||||
LogPrintf("ERROR: ConnectBlock(DASH): couldn't find masternode or superblock payments\n");
|
LogPrintf("ERROR: ConnectBlock(DASH): couldn't find masternode or superblock payments\n");
|
||||||
return state.Invalid(BlockValidationResult::BLOCK_RESULT_UNSET, "bad-cb-payee");
|
return state.Invalid(BlockValidationResult::BLOCK_RESULT_UNSET, "bad-cb-payee");
|
||||||
|
Loading…
Reference in New Issue
Block a user