Bugfix: Enable ConnectBestBlock to properly report back validation problems, and ensure orphan processing (when their parents are found) cannot be used to counter-DDoS the node providing the parent
Also fix a minor typo
This commit is contained in:
parent
5b989722be
commit
8c4e43130b
1 changed files with 7 additions and 4 deletions
11
src/main.cpp
11
src/main.cpp
|
@ -1250,7 +1250,6 @@ bool ConnectBestBlock(CValidationState &state) {
|
||||||
BOOST_FOREACH(CBlockIndex *pindexSwitch, vAttach) {
|
BOOST_FOREACH(CBlockIndex *pindexSwitch, vAttach) {
|
||||||
if (fRequestShutdown)
|
if (fRequestShutdown)
|
||||||
break;
|
break;
|
||||||
CValidationState state;
|
|
||||||
try {
|
try {
|
||||||
if (!SetBestChain(state, pindexSwitch))
|
if (!SetBestChain(state, pindexSwitch))
|
||||||
return false;
|
return false;
|
||||||
|
@ -1405,7 +1404,7 @@ bool CTransaction::CheckInputs(CValidationState &state, CCoinsViewCache &inputs,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nValueIn < GetValueOut())
|
if (nValueIn < GetValueOut())
|
||||||
return state.DoS(100, error("ChecktInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
|
return state.DoS(100, error("CheckInputs() : %s value in < value out", GetHash().ToString().substr(0,10).c_str()));
|
||||||
|
|
||||||
// Tally transaction fees
|
// Tally transaction fees
|
||||||
int64 nTxFee = nValueIn - GetValueOut();
|
int64 nTxFee = nValueIn - GetValueOut();
|
||||||
|
@ -2259,7 +2258,9 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
|
||||||
++mi)
|
++mi)
|
||||||
{
|
{
|
||||||
CBlock* pblockOrphan = (*mi).second;
|
CBlock* pblockOrphan = (*mi).second;
|
||||||
if (pblockOrphan->AcceptBlock(state))
|
// Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan resolution (that is, feeding people an invalid block based on LegitBlockX in order to get anyone relaying LegitBlockX banned)
|
||||||
|
CValidationState stateDummy;
|
||||||
|
if (pblockOrphan->AcceptBlock(stateDummy))
|
||||||
vWorkQueue.push_back(pblockOrphan->GetHash());
|
vWorkQueue.push_back(pblockOrphan->GetHash());
|
||||||
mapOrphanBlocks.erase(pblockOrphan->GetHash());
|
mapOrphanBlocks.erase(pblockOrphan->GetHash());
|
||||||
delete pblockOrphan;
|
delete pblockOrphan;
|
||||||
|
@ -3453,8 +3454,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||||
CDataStream(vMsg) >> tx;
|
CDataStream(vMsg) >> tx;
|
||||||
CInv inv(MSG_TX, tx.GetHash());
|
CInv inv(MSG_TX, tx.GetHash());
|
||||||
bool fMissingInputs2 = false;
|
bool fMissingInputs2 = false;
|
||||||
|
// Use a dummy CValidationState so someone can't setup nodes to counter-DoS based on orphan resolution (that is, feeding people an invalid transaction based on LegitTxX in order to get anyone relaying LegitTxX banned)
|
||||||
|
CValidationState stateDummy;
|
||||||
|
|
||||||
if (tx.AcceptToMemoryPool(state, true, true, &fMissingInputs2))
|
if (tx.AcceptToMemoryPool(stateDummy, true, true, &fMissingInputs2))
|
||||||
{
|
{
|
||||||
printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
|
printf(" accepted orphan tx %s\n", inv.hash.ToString().substr(0,10).c_str());
|
||||||
RelayTransaction(tx, inv.hash, vMsg);
|
RelayTransaction(tx, inv.hash, vMsg);
|
||||||
|
|
Loading…
Reference in a new issue