Skip to content

Commit 5e4a892

Browse files
Merge #6608: fix: cycleHash should represent a cycle starting block of the signing quorum
d150a65 docs: add release notes (UdjinM6) 85c6b58 feat: bump PROTOCOL_VERSION/MIN_MASTERNODE_PROTO_VERSION to 70237 (UdjinM6) c20dfd8 fix: `cycleHash` should represent a cycle starting block of the signing quorum (UdjinM6) Pull request description: ## Issue being fixed or feature implemented Currently `cycleHash` is calculated based on the current chain height we are signing `isdlock` at. This however can result in `cycleHash` to be a block hash of a new cycle where DKG is still in progress which can be confusing to verifiers. ## What was done? Select a signing quorum first and then calculate `cycleHash` based on the quorum's base block index instead of using the current chain height. ## How Has This Been Tested? Running a testnet MN for some time. It's creating new `isdlock`s and processing `isdlock`s from other nodes with no issues. ## Breaking Changes None, `cycleHash` is simply going to be more accurate now. ## 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 ACKs for top commit: PastaPastaPasta: utACK d150a65 knst: utACK d150a65 Tree-SHA512: ff7e8a9f37aded9ac330185a34db0eef346c6a3f4a6e22f11a6081ff074a789d260fbdf9efc1d8590d4013ecd95a273e07126dfcb5a7f6d6ebebdb45a543f053
2 parents bcd14b0 + d150a65 commit 5e4a892

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

doc/release-notes-6608.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
P2P Changes
2+
-----------
3+
4+
* `cycleHash` field in `isdlock` message will now represent a DKG cycle starting block of the signing quorum instead of a DKG cycle starting block corresponding to the current chain height. While this is fully backwards compatible with older versions of Dash Core, other implementations might not be expecting this, so the P2P protocol version was bumped to 70237.

src/llmq/instantsend.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -672,21 +672,26 @@ void CInstantSendManager::TrySignInstantSendLock(const CTransaction& tx)
672672
islock.inputs.emplace_back(in.prevout);
673673
}
674674

675-
{
676-
const auto &llmq_params_opt = Params().GetLLMQ(llmqType);
677-
assert(llmq_params_opt);
678-
LOCK(cs_main);
679-
const auto dkgInterval = llmq_params_opt->dkgInterval;
680-
const auto quorumHeight = m_chainstate.m_chain.Height() - (m_chainstate.m_chain.Height() % dkgInterval);
681-
islock.cycleHash = m_chainstate.m_chain[quorumHeight]->GetBlockHash();
682-
}
683-
684675
auto id = islock.GetRequestId();
685676

686677
if (sigman.HasRecoveredSigForId(llmqType, id)) {
687678
return;
688679
}
689680

681+
const auto& llmq_params_opt = Params().GetLLMQ(llmqType);
682+
assert(llmq_params_opt);
683+
const auto quorum = SelectQuorumForSigning(llmq_params_opt.value(), m_chainstate.m_chain, qman, id);
684+
685+
if (!quorum) {
686+
LogPrint(BCLog::INSTANTSEND, "CInstantSendManager::%s -- failed to select quorum. islock id=%s, txid=%s\n",
687+
__func__, id.ToString(), tx.GetHash().ToString());
688+
return;
689+
}
690+
691+
const int cycle_height = quorum->m_quorum_base_block_index->nHeight -
692+
quorum->m_quorum_base_block_index->nHeight % llmq_params_opt->dkgInterval;
693+
islock.cycleHash = quorum->m_quorum_base_block_index->GetAncestor(cycle_height)->GetBlockHash();
694+
690695
{
691696
LOCK(cs_creating);
692697
auto e = creatingInstantSendLocks.emplace(id, std::move(islock));
@@ -696,7 +701,7 @@ void CInstantSendManager::TrySignInstantSendLock(const CTransaction& tx)
696701
txToCreatingInstantSendLocks.emplace(tx.GetHash(), &e.first->second);
697702
}
698703

699-
sigman.AsyncSignIfMember(llmqType, shareman, id, tx.GetHash());
704+
sigman.AsyncSignIfMember(llmqType, shareman, id, tx.GetHash(), quorum->m_quorum_base_block_index->GetBlockHash());
700705
}
701706

702707
void CInstantSendManager::HandleNewInstantSendLockRecoveredSig(const llmq::CRecoveredSig& recoveredSig)

src/version.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313

14-
static const int PROTOCOL_VERSION = 70236;
14+
static const int PROTOCOL_VERSION = 70237;
1515

1616
//! initial proto version, to be increased after version/verack negotiation
1717
static const int INIT_PROTO_VERSION = 209;
@@ -20,7 +20,7 @@ static const int INIT_PROTO_VERSION = 209;
2020
static const int MIN_PEER_PROTO_VERSION = 70216;
2121

2222
//! minimum proto version of masternode to accept in DKGs
23-
static const int MIN_MASTERNODE_PROTO_VERSION = 70235;
23+
static const int MIN_MASTERNODE_PROTO_VERSION = 70237;
2424

2525
//! protocol version is included in MNAUTH starting with this version
2626
static const int MNAUTH_NODE_VER_VERSION = 70218;
@@ -64,6 +64,9 @@ static const int INCREASE_MAX_HEADERS2_VERSION = 70235;
6464
//! Behavior of QRINFO is changed in this protocol version
6565
static const int EFFICIENT_QRINFO_VERSION = 70236;
6666

67+
//! cycleHash in isdlock message switched to using quorum's base block in this version
68+
static const int ISDLOCK_CYCLEHASH_UPDATE_VERSION = 70237;
69+
6770
// Make sure that none of the values above collide with `ADDRV2_FORMAT`.
6871

6972
#endif // BITCOIN_VERSION_H

test/functional/test_framework/p2p.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@
9999
# The minimum P2P version that this test framework supports
100100
MIN_P2P_VERSION_SUPPORTED = 60001
101101
# The P2P version that this test framework implements and sends in its `version` message
102-
# Version 70235 increased max header count for HEADERS2 message from 2000 to 8000
103-
P2P_VERSION = 70236
102+
# Version 70237 switched cycleHash in isdlock message to using quorum's base block
103+
P2P_VERSION = 70237
104104
# The services that this test framework offers in its `version` message
105105
P2P_SERVICES = NODE_NETWORK | NODE_HEADERS_COMPRESSED
106106
# The P2P user agent string that this test framework sends in its `version` message

0 commit comments

Comments
 (0)