Don't process unrequested, low-work blocks
A peer could try to waste our resources by sending us unrequested blocks with
low work, eg to fill up our disk. Since
e2652002b6
we no longer request blocks until we
know we're on a chain with more than nMinimumChainWork (our anti-DoS
threshold), but we would still process unrequested blocks that had more work
than our tip. This commit fixes that behavior.
This commit is contained in:
parent
ff92fbf247
commit
ce8cd7a7da
1 changed files with 6 additions and 0 deletions
|
@ -3135,6 +3135,12 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
|
||||||
if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned
|
if (pindex->nTx != 0) return true; // This is a previously-processed block that was pruned
|
||||||
if (!fHasMoreWork) return true; // Don't process less-work chains
|
if (!fHasMoreWork) return true; // Don't process less-work chains
|
||||||
if (fTooFarAhead) return true; // Block height is too high
|
if (fTooFarAhead) return true; // Block height is too high
|
||||||
|
|
||||||
|
// Protect against DoS attacks from low-work chains.
|
||||||
|
// If our tip is behind, a peer could try to send us
|
||||||
|
// low-work blocks on a fake chain that we would never
|
||||||
|
// request; don't process these.
|
||||||
|
if (pindex->nChainWork < nMinimumChainWork) return true;
|
||||||
}
|
}
|
||||||
if (fNewBlock) *fNewBlock = true;
|
if (fNewBlock) *fNewBlock = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue