mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
fix: ignore triggers from the past when voting (#5798)
## Issue being fixed or feature implemented we should not vote on triggers from the past ## What was done? ## How Has This Been Tested? n/a ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
This commit is contained in:
parent
4ebdaf69bc
commit
acd3ce7783
@ -738,6 +738,11 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
|
|||||||
const auto activeTriggers = triggerman.GetActiveTriggers();
|
const auto activeTriggers = triggerman.GetActiveTriggers();
|
||||||
for (const auto& trigger : activeTriggers) {
|
for (const auto& trigger : activeTriggers) {
|
||||||
const uint256 trigger_hash = trigger->GetGovernanceObject(*this)->GetHash();
|
const uint256 trigger_hash = trigger->GetGovernanceObject(*this)->GetHash();
|
||||||
|
if (trigger->GetBlockHeight() <= nCachedBlockHeight) {
|
||||||
|
// ignore triggers from the past
|
||||||
|
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Not voting NO-FUNDING for outdated trigger:%s\n", __func__, trigger_hash.ToString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (trigger_hash == votedFundingYesTriggerHash) {
|
if (trigger_hash == votedFundingYesTriggerHash) {
|
||||||
// Skip actual trigger
|
// Skip actual trigger
|
||||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Not voting NO-FUNDING for trigger:%s, we voted yes for it already\n", __func__, trigger_hash.ToString());
|
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Not voting NO-FUNDING for trigger:%s, we voted yes for it already\n", __func__, trigger_hash.ToString());
|
||||||
|
@ -303,13 +303,34 @@ class DashGovernanceTest (DashTestFramework):
|
|||||||
self.check_superblockbudget(True)
|
self.check_superblockbudget(True)
|
||||||
self.check_superblock()
|
self.check_superblock()
|
||||||
|
|
||||||
|
# Move a few block past the recent superblock height and make sure we have no new votes
|
||||||
|
for _ in range(5):
|
||||||
|
with self.nodes[1].assert_debug_log("", [f"Voting NO-FUNDING for trigger:{winning_trigger_hash} success"]):
|
||||||
|
self.nodes[0].generate(1)
|
||||||
|
self.bump_mocktime(1)
|
||||||
|
self.sync_blocks()
|
||||||
|
# Votes on both triggers should NOT change
|
||||||
|
assert_equal(self.nodes[0].gobject("list", "valid", "triggers")[winning_trigger_hash]['NoCount'], 1)
|
||||||
|
assert_equal(self.nodes[0].gobject("list", "valid", "triggers")[isolated_trigger_hash]['NoCount'], self.mn_count - 1)
|
||||||
|
|
||||||
|
block_count = self.nodes[0].getblockcount()
|
||||||
|
n = sb_cycle - block_count % sb_cycle
|
||||||
|
|
||||||
|
# Move remaining n blocks until the next Superblock
|
||||||
|
for i in range(n):
|
||||||
|
self.nodes[0].generate(1)
|
||||||
|
self.bump_mocktime(1)
|
||||||
|
self.sync_blocks()
|
||||||
|
assert_equal(self.nodes[0].getblockcount(), 260)
|
||||||
|
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")
|
||||||
|
|
||||||
# Mine and check a couple more superblocks
|
# Mine and check a couple more superblocks
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
for _ in range(20):
|
for _ in range(20):
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
self.bump_mocktime(1)
|
self.bump_mocktime(1)
|
||||||
self.sync_blocks()
|
self.sync_blocks()
|
||||||
assert_equal(self.nodes[0].getblockcount(), 240 + (i + 1) * 20)
|
assert_equal(self.nodes[0].getblockcount(), 260 + (i + 1) * 20)
|
||||||
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")
|
assert_equal(self.nodes[0].getblockchaininfo()["softforks"]["v20"]["bip9"]["status"], "active")
|
||||||
self.check_superblockbudget(True)
|
self.check_superblockbudget(True)
|
||||||
self.check_superblock()
|
self.check_superblock()
|
||||||
|
Loading…
Reference in New Issue
Block a user