Include masternodeProTxHash in CTxLockVote (#2484)
* Introduce proTxHash to CActiveMasternodeInfo * Include masternodeProTxHash in CTxLockVote
This commit is contained in:
parent
aa495405b3
commit
fa8f4a10cc
@ -94,6 +94,7 @@ void CActiveDeterministicMasternodeManager::Init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activeMasternodeInfo.proTxHash = mnListEntry->proTxHash;
|
||||||
activeMasternodeInfo.outpoint = mnListEntry->collateralOutpoint;
|
activeMasternodeInfo.outpoint = mnListEntry->collateralOutpoint;
|
||||||
state = MASTERNODE_READY;
|
state = MASTERNODE_READY;
|
||||||
}
|
}
|
||||||
@ -113,6 +114,7 @@ void CActiveDeterministicMasternodeManager::UpdatedBlockTip(const CBlockIndex* p
|
|||||||
if (!mnList.IsMNValid(mnListEntry->proTxHash)) {
|
if (!mnList.IsMNValid(mnListEntry->proTxHash)) {
|
||||||
// MN disappeared from MN list
|
// MN disappeared from MN list
|
||||||
state = MASTERNODE_REMOVED;
|
state = MASTERNODE_REMOVED;
|
||||||
|
activeMasternodeInfo.proTxHash = uint256();
|
||||||
activeMasternodeInfo.outpoint.SetNull();
|
activeMasternodeInfo.outpoint.SetNull();
|
||||||
// MN might have reappeared in same block with a new ProTx (with same masternode key)
|
// MN might have reappeared in same block with a new ProTx (with same masternode key)
|
||||||
Init();
|
Init();
|
||||||
|
@ -37,6 +37,7 @@ struct CActiveMasternodeInfo {
|
|||||||
std::unique_ptr<CBLSSecretKey> blsKeyOperator;
|
std::unique_ptr<CBLSSecretKey> blsKeyOperator;
|
||||||
|
|
||||||
// Initialized while registering Masternode
|
// Initialized while registering Masternode
|
||||||
|
uint256 proTxHash;
|
||||||
COutPoint outpoint;
|
COutPoint outpoint;
|
||||||
CService service;
|
CService service;
|
||||||
};
|
};
|
||||||
|
@ -281,7 +281,8 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we haven't voted for this outpoint yet, let's try to do this now
|
// we haven't voted for this outpoint yet, let's try to do this now
|
||||||
CTxLockVote vote(txHash, outpointLockPair.first, activeMasternodeInfo.outpoint);
|
// Please note that activeMasternodeInfo.proTxHash is only valid after spork15 activation
|
||||||
|
CTxLockVote vote(txHash, outpointLockPair.first, activeMasternodeInfo.outpoint, activeMasternodeInfo.proTxHash);
|
||||||
|
|
||||||
if (!vote.Sign()) {
|
if (!vote.Sign()) {
|
||||||
LogPrintf("CInstantSend::Vote -- Failed to sign consensus vote\n");
|
LogPrintf("CInstantSend::Vote -- Failed to sign consensus vote\n");
|
||||||
@ -1029,6 +1030,19 @@ bool CTxLockVote::IsValid(CNode* pnode, CConnman& connman) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify that masternodeProTxHash belongs to the same MN referred by the collateral
|
||||||
|
// Only v13 nodes will send us locks with this field set, and only after spork15 activation
|
||||||
|
if (!masternodeProTxHash.IsNull()) {
|
||||||
|
masternode_info_t mnInfo;
|
||||||
|
if (!mnodeman.GetMasternodeInfo(masternodeProTxHash, mnInfo) || mnInfo.outpoint != outpointMasternode) {
|
||||||
|
LogPrint("instantsend", "CTxLockVote::IsValid -- invalid masternodeProTxHash %s\n", masternodeProTxHash.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
||||||
|
LogPrint("instantsend", "CTxLockVote::IsValid -- missing masternodeProTxHash while DIP3 is active\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Coin coin;
|
Coin coin;
|
||||||
if (!GetUTXOCoin(outpoint, coin)) {
|
if (!GetUTXOCoin(outpoint, coin)) {
|
||||||
LogPrint("instantsend", "CTxLockVote::IsValid -- Failed to find UTXO %s\n", outpoint.ToStringShort());
|
LogPrint("instantsend", "CTxLockVote::IsValid -- Failed to find UTXO %s\n", outpoint.ToStringShort());
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "primitives/transaction.h"
|
#include "primitives/transaction.h"
|
||||||
|
|
||||||
|
#include "evo/deterministicmns.h"
|
||||||
|
|
||||||
class CTxLockVote;
|
class CTxLockVote;
|
||||||
class COutPointLock;
|
class COutPointLock;
|
||||||
class CTxLockRequest;
|
class CTxLockRequest;
|
||||||
@ -231,7 +233,9 @@ class CTxLockVote
|
|||||||
private:
|
private:
|
||||||
uint256 txHash;
|
uint256 txHash;
|
||||||
COutPoint outpoint;
|
COutPoint outpoint;
|
||||||
|
// TODO remove this member when the legacy masternode code is removed after DIP3 deployment
|
||||||
COutPoint outpointMasternode;
|
COutPoint outpointMasternode;
|
||||||
|
uint256 masternodeProTxHash;
|
||||||
std::vector<unsigned char> vchMasternodeSignature;
|
std::vector<unsigned char> vchMasternodeSignature;
|
||||||
// local memory only
|
// local memory only
|
||||||
int nConfirmedHeight; ///< When corresponding tx is 0-confirmed or conflicted, nConfirmedHeight is -1
|
int nConfirmedHeight; ///< When corresponding tx is 0-confirmed or conflicted, nConfirmedHeight is -1
|
||||||
@ -242,15 +246,17 @@ public:
|
|||||||
txHash(),
|
txHash(),
|
||||||
outpoint(),
|
outpoint(),
|
||||||
outpointMasternode(),
|
outpointMasternode(),
|
||||||
|
masternodeProTxHash(),
|
||||||
vchMasternodeSignature(),
|
vchMasternodeSignature(),
|
||||||
nConfirmedHeight(-1),
|
nConfirmedHeight(-1),
|
||||||
nTimeCreated(GetTime())
|
nTimeCreated(GetTime())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CTxLockVote(const uint256& txHashIn, const COutPoint& outpointIn, const COutPoint& outpointMasternodeIn) :
|
CTxLockVote(const uint256& txHashIn, const COutPoint& outpointIn, const COutPoint& outpointMasternodeIn, const uint256& masternodeProTxHashIn) :
|
||||||
txHash(txHashIn),
|
txHash(txHashIn),
|
||||||
outpoint(outpointIn),
|
outpoint(outpointIn),
|
||||||
outpointMasternode(outpointMasternodeIn),
|
outpointMasternode(outpointMasternodeIn),
|
||||||
|
masternodeProTxHash(masternodeProTxHashIn),
|
||||||
vchMasternodeSignature(),
|
vchMasternodeSignature(),
|
||||||
nConfirmedHeight(-1),
|
nConfirmedHeight(-1),
|
||||||
nTimeCreated(GetTime())
|
nTimeCreated(GetTime())
|
||||||
@ -263,6 +269,11 @@ public:
|
|||||||
READWRITE(txHash);
|
READWRITE(txHash);
|
||||||
READWRITE(outpoint);
|
READWRITE(outpoint);
|
||||||
READWRITE(outpointMasternode);
|
READWRITE(outpointMasternode);
|
||||||
|
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
|
||||||
|
// Starting with spork15 activation, the proTxHash is included. When we bump to >= 70213, we can remove
|
||||||
|
// the surrounding if. We might also remove outpointMasternode as well later
|
||||||
|
READWRITE(masternodeProTxHash);
|
||||||
|
}
|
||||||
if (!(s.GetType() & SER_GETHASH)) {
|
if (!(s.GetType() & SER_GETHASH)) {
|
||||||
READWRITE(vchMasternodeSignature);
|
READWRITE(vchMasternodeSignature);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user