From 8d7fc8598c046c385fc720b2f974bdd6a326fd26 Mon Sep 17 00:00:00 2001 From: furszy Date: Tue, 23 Nov 2021 18:51:53 -0300 Subject: [PATCH] tiertwo: clean inactive MNs from the fin count. --- src/budget/finalizedbudget.cpp | 11 +++++++++++ src/budget/finalizedbudget.h | 2 +- test/functional/tiertwo_governance_sync_basic.py | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/budget/finalizedbudget.cpp b/src/budget/finalizedbudget.cpp index 38be1f06f20f0..a03cf46260442 100644 --- a/src/budget/finalizedbudget.cpp +++ b/src/budget/finalizedbudget.cpp @@ -263,6 +263,17 @@ bool CFinalizedBudget::UpdateValid(int nCurrentHeight) return true; } +int CFinalizedBudget::GetVoteCount() const +{ + int ret = 0; + for (const auto& it : mapVotes) { + if (it.second.IsValid()) { + ret++; + } + } + return ret; +} + std::vector CFinalizedBudget::GetVotesHashes() const { std::vector vRet; diff --git a/src/budget/finalizedbudget.h b/src/budget/finalizedbudget.h index 02ecdf71b7bdb..d936dabb92af0 100644 --- a/src/budget/finalizedbudget.h +++ b/src/budget/finalizedbudget.h @@ -86,7 +86,7 @@ class CFinalizedBudget int GetBlockStart() const { return nBlockStart; } int GetBlockEnd() const { return nBlockStart + (int)(vecBudgetPayments.size() - 1); } const uint256& GetFeeTXHash() const { return nFeeTXHash; } - int GetVoteCount() const { return (int)mapVotes.size(); } + int GetVoteCount() const; std::vector GetVotesHashes() const; bool IsPaidAlready(const uint256& nProposalHash, const uint256& nBlockHash, int nBlockHeight) const; TrxValidationStatus IsTransactionValid(const CTransaction& txNew, const uint256& nBlockHash, int nBlockHeight) const; diff --git a/test/functional/tiertwo_governance_sync_basic.py b/test/functional/tiertwo_governance_sync_basic.py index 70f93c8280188..5ea02cc589cfb 100755 --- a/test/functional/tiertwo_governance_sync_basic.py +++ b/test/functional/tiertwo_governance_sync_basic.py @@ -360,6 +360,7 @@ def run_test(self): self.stake(15, [self.remoteTwo]) # create blocks to remove staled votes time.sleep(2) # wait a little bit self.check_vote_existence(firstProposal.name, self.mnOneCollateral.hash, "YES", False) + self.check_budget_finalization_sync(2, "OK") # budget finalization vote removal self.log.info("MN1 vote expired after collateral spend, all good") self.log.info("expiring DMN1..") @@ -369,6 +370,7 @@ def run_test(self): self.stake(15, [self.remoteTwo]) # create blocks to remove staled votes time.sleep(2) # wait a little bit self.check_vote_existence(firstProposal.name, self.proRegTx1, "YES", False) + self.check_budget_finalization_sync(1, "OK") # budget finalization vote removal self.log.info("DMN vote expired after collateral spend, all good") # Check that the budget is removed 200 blocks after the last payment