diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index a76435ada..352739626 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -398,9 +398,11 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import if (!pd) { auto pdata = pd.rlp(); - cwarn << "Odd: details is returning false despite block known:" << RLP(pdata); + clog(BlockChainDebug) << "Details is returning false despite block known:" << RLP(pdata); auto parentBlock = block(bi.parentHash); - cwarn << "Block:" << RLP(parentBlock); + clog(BlockChainDebug) << "Block:" << RLP(parentBlock); + clog(BlockChainDebug) << "DATABASE CORRUPTION: CRITICAL FAILURE"; + exit(-1); } // Check it's not crazy @@ -620,6 +622,14 @@ ImportRoute BlockChain::import(bytes const& _block, OverlayDB const& _db, Import cnote << "checkBest:" << checkBest; #endif + if (isKnown(bi.hash()) && !details(bi.hash())) + { + clog(BlockChainDebug) << "Known block just inserted has no details."; + clog(BlockChainDebug) << "Block:" << bi; + clog(BlockChainDebug) << "DATABASE CORRUPTION: CRITICAL FAILURE"; + exit(-1); + } + h256s fresh; h256s dead; bool isOld = true; diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 0529e305e..70a9f93db 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -59,6 +59,7 @@ struct FutureTime: virtual Exception {}; struct BlockChainChat: public LogChannel { static const char* name() { return "-B-"; } static const int verbosity = 7; }; struct BlockChainNote: public LogChannel { static const char* name() { return "=B="; } static const int verbosity = 4; }; struct BlockChainWarn: public LogChannel { static const char* name() { return "=B="; } static const int verbosity = 1; }; +struct BlockChainDebug: public LogChannel { static const char* name() { return "#B#"; } static const int verbosity = 0; }; // TODO: Move all this Genesis stuff into Genesis.h/.cpp std::map const& genesisState(); diff --git a/libethereum/EthereumPeer.cpp b/libethereum/EthereumPeer.cpp index 83fe22a71..9fbbdd61e 100644 --- a/libethereum/EthereumPeer.cpp +++ b/libethereum/EthereumPeer.cpp @@ -405,6 +405,13 @@ bool EthereumPeer::interpret(unsigned _id, RLP const& _r) { unsigned count = _r.itemCount(); clog(NetMessageSummary) << "GetBlocks (" << dec << count << "entries)"; + + if (!count) + { + clog(NetImpolite) << "Zero-entry GetBlocks: Not replying."; + addRating(-10); + break; + } // return the requested blocks. bytes rlp; unsigned n = 0; diff --git a/libp2p/Common.h b/libp2p/Common.h index 9ad5bb206..691ef7fb3 100644 --- a/libp2p/Common.h +++ b/libp2p/Common.h @@ -77,6 +77,7 @@ struct InvalidHostIPAddress: virtual dev::Exception {}; struct NetWarn: public LogChannel { static const char* name() { return "!N!"; } static const int verbosity = 0; }; struct NetNote: public LogChannel { static const char* name() { return "*N*"; } static const int verbosity = 1; }; +struct NetImpolite: public LogChannel { static const char* name() { return "#!*"; } static const int verbosity = 1; }; struct NetMessageSummary: public LogChannel { static const char* name() { return "-N-"; } static const int verbosity = 2; }; struct NetConnect: public LogChannel { static const char* name() { return "+N+"; } static const int verbosity = 10; }; struct NetMessageDetail: public LogChannel { static const char* name() { return "=N="; } static const int verbosity = 5; };