ask for mn / lower ban score for mnw
This commit is contained in:
parent
6fdefceb24
commit
f57c470f95
@ -138,7 +138,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
|
|||||||
|
|
||||||
mapTxLockVote.insert(make_pair(ctx.GetHash(), ctx));
|
mapTxLockVote.insert(make_pair(ctx.GetHash(), ctx));
|
||||||
|
|
||||||
if(ProcessConsensusVote(ctx)){
|
if(ProcessConsensusVote(pfrom, ctx)){
|
||||||
//Spam/Dos protection
|
//Spam/Dos protection
|
||||||
/*
|
/*
|
||||||
Masternodes will sometimes propagate votes before the transaction is known to the client.
|
Masternodes will sometimes propagate votes before the transaction is known to the client.
|
||||||
@ -297,7 +297,7 @@ void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//received a consensus vote
|
//received a consensus vote
|
||||||
bool ProcessConsensusVote(CConsensusVote& ctx)
|
bool ProcessConsensusVote(CNode* pnode, CConsensusVote& ctx)
|
||||||
{
|
{
|
||||||
int n = mnodeman.GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION);
|
int n = mnodeman.GetMasternodeRank(ctx.vinMasternode, ctx.nBlockHeight, MIN_INSTANTX_PROTO_VERSION);
|
||||||
|
|
||||||
@ -309,6 +309,7 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
{
|
{
|
||||||
//can be caused by past versions trying to vote with an invalid protocol
|
//can be caused by past versions trying to vote with an invalid protocol
|
||||||
LogPrint("instantx", "InstantX::ProcessConsensusVote - Unknown Masternode\n");
|
LogPrint("instantx", "InstantX::ProcessConsensusVote - Unknown Masternode\n");
|
||||||
|
mnodeman.AskForMN(pnode, ctx.vinMasternode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +321,8 @@ bool ProcessConsensusVote(CConsensusVote& ctx)
|
|||||||
|
|
||||||
if(!ctx.SignatureValid()) {
|
if(!ctx.SignatureValid()) {
|
||||||
LogPrintf("InstantX::ProcessConsensusVote - Signature invalid\n");
|
LogPrintf("InstantX::ProcessConsensusVote - Signature invalid\n");
|
||||||
//don't ban, it could just be a non-synced masternode
|
// don't ban, it could just be a non-synced masternode
|
||||||
|
mnodeman.AskForMN(pnode, ctx.vinMasternode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
|
|||||||
void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight);
|
void DoConsensusVote(CTransaction& tx, int64_t nBlockHeight);
|
||||||
|
|
||||||
//process consensus vote message
|
//process consensus vote message
|
||||||
bool ProcessConsensusVote(CConsensusVote& ctx);
|
bool ProcessConsensusVote(CNode *pnode, CConsensusVote& ctx);
|
||||||
|
|
||||||
// keep transaction locks in memory for an hour
|
// keep transaction locks in memory for an hour
|
||||||
void CleanTransactionLocksList();
|
void CleanTransactionLocksList();
|
||||||
|
@ -926,6 +926,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
CMasternode* pmn = mnodeman.Find(vote.vin);
|
CMasternode* pmn = mnodeman.Find(vote.vin);
|
||||||
if(pmn == NULL) {
|
if(pmn == NULL) {
|
||||||
LogPrint("mnbudget", "mvote - unknown masternode - vin: %s\n", vote.vin.ToString());
|
LogPrint("mnbudget", "mvote - unknown masternode - vin: %s\n", vote.vin.ToString());
|
||||||
|
mnodeman.AskForMN(pfrom, vote.vin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,6 +935,8 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
if(!vote.SignatureValid(true)){
|
if(!vote.SignatureValid(true)){
|
||||||
LogPrintf("mvote - signature invalid\n");
|
LogPrintf("mvote - signature invalid\n");
|
||||||
Misbehaving(pfrom->GetId(), 20);
|
Misbehaving(pfrom->GetId(), 20);
|
||||||
|
// it could just be a non-synced masternode
|
||||||
|
mnodeman.AskForMN(pfrom, vote.vin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -994,6 +997,7 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
CMasternode* pmn = mnodeman.Find(vote.vin);
|
CMasternode* pmn = mnodeman.Find(vote.vin);
|
||||||
if(pmn == NULL) {
|
if(pmn == NULL) {
|
||||||
LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.ToString());
|
LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.ToString());
|
||||||
|
mnodeman.AskForMN(pfrom, vote.vin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,6 +1005,8 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
if(!vote.SignatureValid(true)){
|
if(!vote.SignatureValid(true)){
|
||||||
LogPrintf("fbvote - signature invalid\n");
|
LogPrintf("fbvote - signature invalid\n");
|
||||||
Misbehaving(pfrom->GetId(), 20);
|
Misbehaving(pfrom->GetId(), 20);
|
||||||
|
// it could just be a non-synced masternode
|
||||||
|
mnodeman.AskForMN(pfrom, vote.vin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(!winner.IsValid(strError)){
|
if(!winner.IsValid(pfrom, strError)){
|
||||||
LogPrintf("mnw - invalid message - %s\n", strError);
|
LogPrintf("mnw - invalid message - %s\n", strError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -388,7 +388,9 @@ void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::st
|
|||||||
|
|
||||||
if(!winner.SignatureValid()){
|
if(!winner.SignatureValid()){
|
||||||
LogPrintf("mnw - invalid signature\n");
|
LogPrintf("mnw - invalid signature\n");
|
||||||
Misbehaving(pfrom->GetId(), 100);
|
Misbehaving(pfrom->GetId(), 20);
|
||||||
|
// it could just be a non-synced masternode
|
||||||
|
mnodeman.AskForMN(pfrom, winner.vinMasternode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,7 +618,7 @@ bool IsReferenceNode(CTxIn& vin)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMasternodePaymentWinner::IsValid(std::string& strError)
|
bool CMasternodePaymentWinner::IsValid(CNode* pnode, std::string& strError)
|
||||||
{
|
{
|
||||||
if(IsReferenceNode(vinMasternode)) return true;
|
if(IsReferenceNode(vinMasternode)) return true;
|
||||||
|
|
||||||
@ -626,6 +628,7 @@ bool CMasternodePaymentWinner::IsValid(std::string& strError)
|
|||||||
{
|
{
|
||||||
strError = strprintf("Unknown Masternode %s", vinMasternode.prevout.ToStringShort());
|
strError = strprintf("Unknown Masternode %s", vinMasternode.prevout.ToStringShort());
|
||||||
LogPrintf ("CMasternodePaymentWinner::IsValid - %s\n", strError);
|
LogPrintf ("CMasternodePaymentWinner::IsValid - %s\n", strError);
|
||||||
|
mnodeman.AskForMN(pnode, vinMasternode);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
|
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
|
||||||
bool IsValid(std::string& strError);
|
bool IsValid(CNode* pnode, std::string& strError);
|
||||||
bool SignatureValid();
|
bool SignatureValid();
|
||||||
void Relay();
|
void Relay();
|
||||||
|
|
||||||
|
@ -224,6 +224,23 @@ bool CMasternodeMan::Add(CMasternode &mn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMasternodeMan::AskForMN(CNode* pnode, CTxIn &vin)
|
||||||
|
{
|
||||||
|
std::map<COutPoint, int64_t>::iterator i = mWeAskedForMasternodeListEntry.find(vin.prevout);
|
||||||
|
if (i != mWeAskedForMasternodeListEntry.end())
|
||||||
|
{
|
||||||
|
int64_t t = (*i).second;
|
||||||
|
if (GetTime() < t) return; // we've asked recently
|
||||||
|
}
|
||||||
|
|
||||||
|
// ask for the mnb info once from the node that sent mnp
|
||||||
|
|
||||||
|
LogPrintf("CMasternodeMan::AskForMN - Asking node for missing entry, vin: %s\n", vin.ToString());
|
||||||
|
pnode->PushMessage("dseg", vin);
|
||||||
|
int64_t askAgain = GetTime() + MASTERNODE_MIN_MNP_SECONDS;
|
||||||
|
mWeAskedForMasternodeListEntry[vin.prevout] = askAgain;
|
||||||
|
}
|
||||||
|
|
||||||
void CMasternodeMan::Check()
|
void CMasternodeMan::Check()
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
@ -691,30 +708,18 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
|
|||||||
if(mnp.CheckAndUpdate(nDoS)) return;
|
if(mnp.CheckAndUpdate(nDoS)) return;
|
||||||
|
|
||||||
if(nDoS > 0) {
|
if(nDoS > 0) {
|
||||||
// if anything significant failed, mark that node and return
|
// if anything significant failed, mark that node
|
||||||
Misbehaving(pfrom->GetId(), nDoS);
|
Misbehaving(pfrom->GetId(), nDoS);
|
||||||
return;
|
} else {
|
||||||
}
|
// if nothing significant failed, search existing Masternode list
|
||||||
|
|
||||||
//search existing Masternode list, if it's known -- don't ask for the mnb
|
|
||||||
CMasternode* pmn = mnodeman.Find(mnp.vin);
|
CMasternode* pmn = mnodeman.Find(mnp.vin);
|
||||||
|
// if it's known, don't ask for the mnb, just return
|
||||||
if(pmn != NULL) return;
|
if(pmn != NULL) return;
|
||||||
|
|
||||||
// we wasn't able to accept mnp but nothing significant happened,
|
|
||||||
// we might just have to ask for a masternode entry once
|
|
||||||
std::map<COutPoint, int64_t>::iterator i = mWeAskedForMasternodeListEntry.find(mnp.vin.prevout);
|
|
||||||
if (i != mWeAskedForMasternodeListEntry.end())
|
|
||||||
{
|
|
||||||
int64_t t = (*i).second;
|
|
||||||
if (GetTime() < t) return; // we've asked recently
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask for the mnb info once from the node that sent mnp
|
// something significant is broken or mn is unknown,
|
||||||
|
// we might have to ask for a masternode entry once
|
||||||
LogPrintf("mnp - Asking source node for missing entry, vin: %s\n", mnp.vin.ToString());
|
AskForMN(pfrom, mnp.vin);
|
||||||
pfrom->PushMessage("dseg", mnp.vin);
|
|
||||||
int64_t askAgain = GetTime() + MASTERNODE_MIN_MNP_SECONDS;
|
|
||||||
mWeAskedForMasternodeListEntry[mnp.vin.prevout] = askAgain;
|
|
||||||
|
|
||||||
} else if (strCommand == "dseg") { //Get Masternode list or specific entry
|
} else if (strCommand == "dseg") { //Get Masternode list or specific entry
|
||||||
|
|
||||||
|
@ -94,6 +94,9 @@ public:
|
|||||||
/// Add an entry
|
/// Add an entry
|
||||||
bool Add(CMasternode &mn);
|
bool Add(CMasternode &mn);
|
||||||
|
|
||||||
|
/// Ask (source) node for mnb
|
||||||
|
void AskForMN(CNode *pnode, CTxIn &vin);
|
||||||
|
|
||||||
/// Check all Masternodes
|
/// Check all Masternodes
|
||||||
void Check();
|
void Check();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user