diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 9cab2461763..c539f4a5180 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2955,6 +2955,13 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, Peer& peer, state, &pindexLast)}; if (!processed) { if (state.IsInvalid()) { + if (!pfrom.IsInboundConn() && state.GetResult() == BlockValidationResult::BLOCK_CACHED_INVALID) { + // Warn user if outgoing peers send us headers of blocks that we previously marked as invalid. + LogWarning("%s (received from peer=%i). " + "If this happens with all peers, consider database corruption (that -reindex may fix) " + "or a potential consensus incompatibility.", + state.GetDebugMessage(), pfrom.GetId()); + } MaybePunishNodeForBlock(pfrom.GetId(), state, via_compact_block, "invalid header received"); return; } diff --git a/src/validation.cpp b/src/validation.cpp index 73b3e91dd20..e1d6babfd0e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4244,7 +4244,8 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida *ppindex = pindex; if (pindex->nStatus & BLOCK_FAILED_MASK) { LogDebug(BCLog::VALIDATION, "%s: block %s is marked invalid\n", __func__, hash.ToString()); - return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate-invalid"); + return state.Invalid(BlockValidationResult::BLOCK_CACHED_INVALID, "duplicate-invalid", + strprintf("block %s was previously marked invalid", hash.ToString())); } return true; }