Skip to content

fix: request governance votes from more nodes on regtest #6712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,9 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&

int64_t nNow = GetTime();
int nTimeout = 60 * 60;
size_t nPeersPerHashMax = 3;
// We isolate nodes on regtest during tests so let's use extra nodes to make sure
// votes from isolated nodes are requested by non-isolated nodes correctly.
size_t nPeersPerHashMax = Params().IsMockableChain() ? 10 : 3;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to choose "isolated" nodes somehow by more deterministic way instead bumping this variable?


std::vector<uint256> vTriggerObjHashes;
std::vector<uint256> vOtherObjHashes;
Expand Down
23 changes: 18 additions & 5 deletions test/functional/feature_governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ def run_test(self):
self.wait_until(lambda: self.nodes[1].gobject("get", self.p2_hash)["FundingResult"]["NoCount"] == 2, timeout = 5)

assert_equal(len(self.nodes[0].gobject("list", "valid", "triggers")), 0)
assert_equal(self.nodes[0].gobject("count")["votes"], 15)
assert_equal(self.nodes[1].gobject("count")["votes"], 15)

block_count = self.nodes[0].getblockcount()

Expand Down Expand Up @@ -206,6 +208,8 @@ def run_test(self):
self.wait_until(lambda: list(isolated.gobject("list", "valid", "triggers").values())[0]['YesCount'] == 1, timeout=5)
more_votes = self.wait_until(lambda: list(isolated.gobject("list", "valid", "triggers").values())[0]['YesCount'] > 1, timeout=5, do_assert=False)
assert_equal(more_votes, False)
assert_equal(self.nodes[0].gobject("count")["votes"], 15)
assert_equal(isolated.gobject("count")["votes"], 16)

self.log.info("Move 1 block enabling the Superblock maturity window on non-isolated nodes")
self.bump_mocktime(1)
Expand All @@ -228,6 +232,8 @@ def run_test(self):
self.wait_until(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] == 1, timeout=5)
more_votes = self.wait_until(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] > 1, timeout=5, do_assert=False)
assert_equal(more_votes, False)
assert_equal(self.nodes[0].gobject("count")["votes"], 16)
assert_equal(isolated.gobject("count")["votes"], 16)

self.log.info("Make sure amounts aren't trimmed")
payment_amounts_expected = [str(satoshi_round(str(self.p0_amount))), str(satoshi_round(str(self.p1_amount))), str(satoshi_round(str(self.p2_amount)))]
Expand All @@ -244,6 +250,8 @@ def run_test(self):
self.wait_until(lambda: list(self.nodes[0].gobject("list", "valid", "triggers").values())[0]['YesCount'] == self.mn_count - 1, timeout=5)
more_triggers = self.wait_until(lambda: len(self.nodes[0].gobject("list", "valid", "triggers")) > 1, timeout=5, do_assert=False)
assert_equal(more_triggers, False)
assert_equal(self.nodes[0].gobject("count")["votes"], 19)
assert_equal(isolated.gobject("count")["votes"], 16)

self.reconnect_isolated_node(payee_idx, 0)
# self.connect_nodes(0, payee_idx)
Expand Down Expand Up @@ -276,11 +284,16 @@ def sync_gov(node):
self.bump_mocktime(1)
self.generate(self.nodes[0], 1, sync_fun=self.sync_blocks())

self.log.info("Should see NO votes on both triggers now")
self.wait_until(lambda: self.nodes[0].gobject("list", "valid", "triggers")[winning_trigger_hash]['NoCount'] == 1, timeout=5)
self.wait_until(lambda: self.nodes[0].gobject("list", "valid", "triggers")[isolated_trigger_hash]['NoCount'] == self.mn_count - 1, timeout=5)
self.log.info("Should wait until all 24 votes are counted for success on next stages")
self.wait_until(lambda: self.nodes[1].gobject("count")["votes"] == 24, timeout=5)
self.log.info("Should see same YES and NO vote count for both triggers on all nodes now")
for node in self.nodes:
self.wait_until(lambda: node.gobject("list", "valid", "triggers")[winning_trigger_hash]['YesCount'] == self.mn_count - 1, timeout=5)
self.wait_until(lambda: node.gobject("list", "valid", "triggers")[winning_trigger_hash]['NoCount'] == 1, timeout=5)
self.wait_until(lambda: node.gobject("list", "valid", "triggers")[isolated_trigger_hash]['YesCount'] == 1, timeout=5)
self.wait_until(lambda: node.gobject("list", "valid", "triggers")[isolated_trigger_hash]['NoCount'] == self.mn_count - 1, timeout=5)

self.log.info("Should have 25 votes on all nodes")
for node in self.nodes:
assert_equal(node.gobject("count")["votes"], 25)

self.log.info("Remember vote count")
before = self.nodes[1].gobject("count")["votes"]
Expand Down
Loading