mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
feat: use m_protxHash instead of masternodeOutpoint for hashing dsq and dstx after v19 activation (#5404)
## Issue being fixed or feature implemented Should fix #5401 with minimal potential coinjoin service interruption (~1 minute around v19 fork point) for up to date clients. Fully backwards compatible prior to v19 activation. Old clients won't be able to mix after v19 activation though until they implement similar changes. _EDIT: Actually, this is already the case cause bls sigs are going to change too._ And I think we should also be able to finally drop `masternodeOutpoint` from `CCoinJoinQueue` and `CCoinJoinBroadcastTx` once v19 is active because of that which would be a nice bonus. cc @HashEngineering ## What was done? re-use v19 activation to switch `GetSignatureHash` logic ## How Has This Been Tested? mixing on mainnet ## Breaking Changes mixing won't work on current testnet until MNs are updated ## 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
12d50c806d
commit
599fd87723
@ -41,22 +41,22 @@ bool CCoinJoinEntry::AddScriptSig(const CTxIn& txin)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 CCoinJoinQueue::GetSignatureHash() const
|
uint256 CCoinJoinQueue::GetSignatureHash(bool legacy) const
|
||||||
{
|
{
|
||||||
return SerializeHash(*this);
|
int version = legacy ? COINJOIN_PROTX_HASH_PROTO_VERSION - 1 : PROTOCOL_VERSION;
|
||||||
|
return SerializeHash(*this, SER_GETHASH, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoinJoinQueue::Sign()
|
bool CCoinJoinQueue::Sign()
|
||||||
{
|
{
|
||||||
if (!fMasternodeMode) return false;
|
if (!fMasternodeMode) return false;
|
||||||
|
|
||||||
|
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
|
||||||
uint256 hash = GetSignatureHash();
|
uint256 hash = GetSignatureHash(legacy_bls_scheme);
|
||||||
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
|
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
|
||||||
if (!sig.IsValid()) {
|
if (!sig.IsValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
|
|
||||||
vchSig = sig.ToByteVector(legacy_bls_scheme);
|
vchSig = sig.ToByteVector(legacy_bls_scheme);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -64,7 +64,8 @@ bool CCoinJoinQueue::Sign()
|
|||||||
|
|
||||||
bool CCoinJoinQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
|
bool CCoinJoinQueue::CheckSignature(const CBLSPublicKey& blsPubKey) const
|
||||||
{
|
{
|
||||||
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
|
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
|
||||||
|
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash(legacy_bls_scheme))) {
|
||||||
LogPrint(BCLog::COINJOIN, "CCoinJoinQueue::CheckSignature -- VerifyInsecure() failed\n");
|
LogPrint(BCLog::COINJOIN, "CCoinJoinQueue::CheckSignature -- VerifyInsecure() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -89,21 +90,22 @@ bool CCoinJoinQueue::IsTimeOutOfBounds(int64_t current_time) const
|
|||||||
nTime - current_time > COINJOIN_QUEUE_TIMEOUT;
|
nTime - current_time > COINJOIN_QUEUE_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 CCoinJoinBroadcastTx::GetSignatureHash() const
|
uint256 CCoinJoinBroadcastTx::GetSignatureHash(bool legacy) const
|
||||||
{
|
{
|
||||||
return SerializeHash(*this);
|
int version = legacy ? COINJOIN_PROTX_HASH_PROTO_VERSION - 1 : PROTOCOL_VERSION;
|
||||||
|
return SerializeHash(*this, SER_GETHASH, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoinJoinBroadcastTx::Sign()
|
bool CCoinJoinBroadcastTx::Sign()
|
||||||
{
|
{
|
||||||
if (!fMasternodeMode) return false;
|
if (!fMasternodeMode) return false;
|
||||||
|
|
||||||
uint256 hash = GetSignatureHash();
|
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
|
||||||
|
uint256 hash = GetSignatureHash(legacy_bls_scheme);
|
||||||
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
|
CBLSSignature sig = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.blsKeyOperator->Sign(hash));
|
||||||
if (!sig.IsValid()) {
|
if (!sig.IsValid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
|
|
||||||
vchSig = sig.ToByteVector(legacy_bls_scheme);
|
vchSig = sig.ToByteVector(legacy_bls_scheme);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -111,7 +113,8 @@ bool CCoinJoinBroadcastTx::Sign()
|
|||||||
|
|
||||||
bool CCoinJoinBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
|
bool CCoinJoinBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
|
||||||
{
|
{
|
||||||
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash())) {
|
bool legacy_bls_scheme = !llmq::utils::IsV19Active(::ChainActive().Tip());
|
||||||
|
if (!CBLSSignature(vchSig).VerifyInsecure(blsPubKey, GetSignatureHash(legacy_bls_scheme))) {
|
||||||
LogPrint(BCLog::COINJOIN, "CCoinJoinBroadcastTx::CheckSignature -- VerifyInsecure() failed\n");
|
LogPrint(BCLog::COINJOIN, "CCoinJoinBroadcastTx::CheckSignature -- VerifyInsecure() failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ public:
|
|||||||
{
|
{
|
||||||
READWRITE(obj.nDenom);
|
READWRITE(obj.nDenom);
|
||||||
|
|
||||||
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION || (s.GetType() & SER_GETHASH)) {
|
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION) {
|
||||||
READWRITE(obj.masternodeOutpoint);
|
READWRITE(obj.masternodeOutpoint);
|
||||||
} else {
|
} else {
|
||||||
READWRITE(obj.m_protxHash);
|
READWRITE(obj.m_protxHash);
|
||||||
@ -230,7 +230,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] uint256 GetSignatureHash() const;
|
[[nodiscard]] uint256 GetSignatureHash(bool legacy) const;
|
||||||
/** Sign this mixing transaction
|
/** Sign this mixing transaction
|
||||||
* return true if all conditions are met:
|
* return true if all conditions are met:
|
||||||
* 1) we have an active Masternode,
|
* 1) we have an active Masternode,
|
||||||
@ -292,7 +292,7 @@ public:
|
|||||||
{
|
{
|
||||||
READWRITE(obj.tx);
|
READWRITE(obj.tx);
|
||||||
|
|
||||||
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION || (s.GetType() & SER_GETHASH)) {
|
if (s.GetVersion() < COINJOIN_PROTX_HASH_PROTO_VERSION) {
|
||||||
READWRITE(obj.masternodeOutpoint);
|
READWRITE(obj.masternodeOutpoint);
|
||||||
} else {
|
} else {
|
||||||
READWRITE(obj.m_protxHash);
|
READWRITE(obj.m_protxHash);
|
||||||
@ -317,7 +317,7 @@ public:
|
|||||||
return *this != CCoinJoinBroadcastTx();
|
return *this != CCoinJoinBroadcastTx();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] uint256 GetSignatureHash() const;
|
[[nodiscard]] uint256 GetSignatureHash(bool legacy) const;
|
||||||
|
|
||||||
bool Sign();
|
bool Sign();
|
||||||
[[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
|
[[nodiscard]] bool CheckSignature(const CBLSPublicKey& blsPubKey) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user