Skip to content

Commit bcd14b0

Browse files
Merge #6625: fix: adjust quorum rotation data results in some edge cases, add tests
8b9a728 chore: drop redundant debug logging in tests (UdjinM6) 4f57afa chore: fix clang format (UdjinM6) 275ed8e test: a few trivial checks for `quorum rotationinfo` RPC (UdjinM6) 9c98f99 fix: off-by-one: do not ignore the base block which matches the requested block (UdjinM6) 422a695 fix: default to genesis block as the last base block (UdjinM6) Pull request description: ## Issue being fixed or feature implemented Before this PR you could get `baseBlockHash` as all 0s for some cases. Also, a known `baseBlockHash` that matched the `cycleHash` was ignored which means that results included quorum changes from an older known `baseBlockHash` till the `cycleHash`(which is the same as the `baseBlockHash` in question) i.e. these changes were already known to the requester. ## What was done? Pls see individual commits ## How Has This Been Tested? Run tests ## Breaking Changes n/a, results should simply be a bit more meaningful and compact ## Checklist: - [ ] 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 - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 8b9a728 Tree-SHA512: 88e5463ca0a40e3decb5cfcab948d7be2febc3583f7a24d455a5a93eb730e34c25246a1384fcfeea887a91348651e6250e226afa02b73f4403d8d10624a84d55
2 parents 1549daa + 8b9a728 commit bcd14b0

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/llmq/snapshot.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,14 @@ bool BuildQuorumRotationInfo(CDeterministicMNManager& dmnman, CQuorumSnapshotMan
392392
uint256 GetLastBaseBlockHash(Span<const CBlockIndex*> baseBlockIndexes, const CBlockIndex* blockIndex,
393393
bool use_legacy_construction)
394394
{
395-
uint256 hash;
396395
if (!use_legacy_construction) {
397396
std::sort(baseBlockIndexes.begin(), baseBlockIndexes.end(),
398397
[](const CBlockIndex* a, const CBlockIndex* b) { return a->nHeight < b->nHeight; });
399398
}
399+
// default to genesis block
400+
uint256 hash{Params().GenesisBlock().GetHash()};
400401
for (const auto baseBlock : baseBlockIndexes) {
401-
if (baseBlock->nHeight >= blockIndex->nHeight)
402-
break;
402+
if (baseBlock->nHeight > blockIndex->nHeight) break;
403403
hash = baseBlock->GetBlockHash();
404404
}
405405
return hash;

test/functional/feature_llmq_rotation.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@ def run_test(self):
231231
self.wait_until(lambda: self.nodes[0].getbestblockhash() == new_quorum_blockhash)
232232
assert_equal(self.nodes[0].quorum("list", llmq_type), new_quorum_list)
233233

234+
self.log.info("Test 'quorum rotationinfo' RPC")
235+
genesis_blockhash = self.nodes[0].getblockhash(0)
236+
block_count = self.nodes[0].getblockcount()
237+
hmc_base_blockhash = self.nodes[0].getblockhash(block_count - (block_count % 24) - 24 - 8)
238+
best_block_hash = self.nodes[0].getbestblockhash()
239+
rpc_qr_info = self.nodes[0].quorum("rotationinfo", best_block_hash, False, hmc_base_blockhash)
240+
assert_equal(rpc_qr_info["mnListDiffTip"]["blockHash"], best_block_hash)
241+
assert_equal(rpc_qr_info["mnListDiffTip"]["baseBlockHash"], rpc_qr_info["mnListDiffH"]["blockHash"])
242+
assert_equal(rpc_qr_info["mnListDiffH"]["baseBlockHash"], rpc_qr_info["mnListDiffAtHMinusC"]["blockHash"])
243+
assert_equal(rpc_qr_info["mnListDiffAtHMinusC"]["blockHash"], hmc_base_blockhash)
244+
assert_equal(rpc_qr_info["mnListDiffAtHMinusC"]["baseBlockHash"], hmc_base_blockhash)
245+
assert_equal(rpc_qr_info["mnListDiffAtHMinusC"]["newQuorums"], [])
246+
assert_equal(rpc_qr_info["mnListDiffAtHMinusC"]["deletedQuorums"], [])
247+
assert_equal(rpc_qr_info["mnListDiffAtHMinus2C"]["baseBlockHash"], rpc_qr_info["mnListDiffAtHMinus3C"]["blockHash"])
248+
assert_equal(rpc_qr_info["mnListDiffAtHMinus3C"]["baseBlockHash"], genesis_blockhash)
249+
234250
def test_getmnlistdiff_quorums(self, baseBlockHash, blockHash, baseQuorumList, expectedDeleted, expectedNew, testQuorumsCLSigs = True):
235251
d = self.test_getmnlistdiff_base(baseBlockHash, blockHash, testQuorumsCLSigs)
236252

0 commit comments

Comments
 (0)