Browse Source

Reduce p2p net verbosity.

cl-refactor
Gav Wood 10 years ago
parent
commit
19f3a58021
  1. 5
      libethash-cl/ethash_cl_miner.cpp
  2. 1
      libethash-cl/ethash_cl_miner.h
  3. 4
      libethereum/State.cpp
  4. 6
      libp2p/Common.cpp
  5. 7
      libp2p/Common.h
  6. 12
      libp2p/Host.cpp
  7. 28
      libp2p/RLPxHandshake.cpp

5
libethash-cl/ethash_cl_miner.cpp

@ -61,6 +61,11 @@ ethash_cl_miner::ethash_cl_miner()
{ {
} }
ethash_cl_miner::~ethash_cl_miner()
{
finish();
}
std::string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId) std::string ethash_cl_miner::platform_info(unsigned _platformId, unsigned _deviceId)
{ {
std::vector<cl::Platform> platforms; std::vector<cl::Platform> platforms;

1
libethash-cl/ethash_cl_miner.h

@ -30,6 +30,7 @@ public:
public: public:
ethash_cl_miner(); ethash_cl_miner();
~ethash_cl_miner();
static unsigned get_num_platforms(); static unsigned get_num_platforms();
static unsigned get_num_devices(unsigned _platformId = 0); static unsigned get_num_devices(unsigned _platformId = 0);

4
libethereum/State.cpp

@ -816,14 +816,14 @@ void State::commitToMine(BlockChain const& _bc)
{ {
// Find great-uncles (or second-cousins or whatever they are) - children of great-grandparents, great-great-grandparents... that were not already uncles in previous generations. // Find great-uncles (or second-cousins or whatever they are) - children of great-grandparents, great-great-grandparents... that were not already uncles in previous generations.
// cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl; // cout << "Checking " << m_previousBlock.hash << ", parent=" << m_previousBlock.parentHash << endl;
h256Hash knownUncles = _bc.allKinFrom(m_currentBlock.parentHash); h256Hash excluded = _bc.allKinFrom(m_currentBlock.parentHash, 6);
auto p = m_previousBlock.parentHash; auto p = m_previousBlock.parentHash;
for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash() && unclesCount < 2; ++gen, p = _bc.details(p).parent) for (unsigned gen = 0; gen < 6 && p != _bc.genesisHash() && unclesCount < 2; ++gen, p = _bc.details(p).parent)
{ {
auto us = _bc.details(p).children; auto us = _bc.details(p).children;
assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent! assert(us.size() >= 1); // must be at least 1 child of our grandparent - it's our own parent!
for (auto const& u: us) for (auto const& u: us)
if (!knownUncles.count(u)) // ignore any uncles/mainline blocks that we know about. if (!excluded.count(u)) // ignore any uncles/mainline blocks that we know about.
{ {
BlockInfo ubi(_bc.block(u)); BlockInfo ubi(_bc.block(u));
ubi.streamRLP(unclesData, WithNonce); ubi.streamRLP(unclesData, WithNonce);

6
libp2p/Common.cpp

@ -47,6 +47,9 @@ const char* NetTriviaDetail::name() { return EthYellow "N" EthCoal " 0"; }
const char* NetAllDetail::name() { return EthYellow "N" EthCoal " A"; } const char* NetAllDetail::name() { return EthYellow "N" EthCoal " A"; }
const char* NetRight::name() { return EthYellow "N" EthGreen "->"; } const char* NetRight::name() { return EthYellow "N" EthGreen "->"; }
const char* NetLeft::name() { return EthYellow "N" EthNavy "<-"; } const char* NetLeft::name() { return EthYellow "N" EthNavy "<-"; }
const char* NetP2PWarn::name() { return EthYellow "N" EthRed " X"; }
const char* NetP2PNote::name() { return EthYellow "N" EthBlue " i"; }
const char* NetP2PConnect::name() { return EthYellow "N" EthYellow " C"; }
#else #else
const char* NetWarn::name() { return EthYellow "" EthRed ""; } const char* NetWarn::name() { return EthYellow "" EthRed ""; }
const char* NetImpolite::name() { return EthYellow "" EthRed " !"; } const char* NetImpolite::name() { return EthYellow "" EthRed " !"; }
@ -59,6 +62,9 @@ const char* NetTriviaDetail::name() { return EthYellow "⧎" EthCoal " ◍"; }
const char* NetAllDetail::name() { return EthYellow "" EthCoal ""; } const char* NetAllDetail::name() { return EthYellow "" EthCoal ""; }
const char* NetRight::name() { return EthYellow "" EthGreen "▬▶"; } const char* NetRight::name() { return EthYellow "" EthGreen "▬▶"; }
const char* NetLeft::name() { return EthYellow "" EthNavy "◀▬"; } const char* NetLeft::name() { return EthYellow "" EthNavy "◀▬"; }
const char* NetP2PWarn::name() { return EthYellow "" EthRed ""; }
const char* NetP2PNote::name() { return EthYellow "" EthBlue ""; }
const char* NetP2PConnect::name() { return EthYellow "" EthYellow ""; }
#endif #endif
bool p2p::isPublicAddress(std::string const& _addressToCheck) bool p2p::isPublicAddress(std::string const& _addressToCheck)

7
libp2p/Common.h

@ -78,8 +78,8 @@ struct InvalidHostIPAddress: virtual dev::Exception {};
struct NetWarn: public LogChannel { static const char* name(); static const int verbosity = 0; }; struct NetWarn: public LogChannel { static const char* name(); static const int verbosity = 0; };
struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 1; }; struct NetNote: public LogChannel { static const char* name(); static const int verbosity = 1; };
struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 1; }; struct NetImpolite: public LogChannel { static const char* name(); static const int verbosity = 2; };
struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 2; }; struct NetMessageSummary: public LogChannel { static const char* name(); static const int verbosity = 3; };
struct NetConnect: public LogChannel { static const char* name(); static const int verbosity = 10; }; struct NetConnect: public LogChannel { static const char* name(); static const int verbosity = 10; };
struct NetMessageDetail: public LogChannel { static const char* name(); static const int verbosity = 5; }; struct NetMessageDetail: public LogChannel { static const char* name(); static const int verbosity = 5; };
struct NetTriviaSummary: public LogChannel { static const char* name(); static const int verbosity = 10; }; struct NetTriviaSummary: public LogChannel { static const char* name(); static const int verbosity = 10; };
@ -87,6 +87,9 @@ struct NetTriviaDetail: public LogChannel { static const char* name(); static co
struct NetAllDetail: public LogChannel { static const char* name(); static const int verbosity = 13; }; struct NetAllDetail: public LogChannel { static const char* name(); static const int verbosity = 13; };
struct NetRight: public LogChannel { static const char* name(); static const int verbosity = 14; }; struct NetRight: public LogChannel { static const char* name(); static const int verbosity = 14; };
struct NetLeft: public LogChannel { static const char* name(); static const int verbosity = 15; }; struct NetLeft: public LogChannel { static const char* name(); static const int verbosity = 15; };
struct NetP2PWarn: public LogChannel { static const char* name(); static const int verbosity = 2; };
struct NetP2PNote: public LogChannel { static const char* name(); static const int verbosity = 6; };
struct NetP2PConnect: public LogChannel { static const char* name(); static const int verbosity = 10; };
enum PacketType enum PacketType
{ {

12
libp2p/Host.cpp

@ -244,7 +244,7 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io
m_sessions[_id] = ps; m_sessions[_id] = ps;
} }
clog(NetNote) << "p2p.host.peer.register" << _id; clog(NetP2PNote) << "p2p.host.peer.register" << _id;
StructuredLogger::p2pConnected(_id.abridged(), ps->m_peer->endpoint, ps->m_peer->m_lastConnected, clientVersion, peerCount()); StructuredLogger::p2pConnected(_id.abridged(), ps->m_peer->endpoint, ps->m_peer->m_lastConnected, clientVersion, peerCount());
} }
@ -252,7 +252,7 @@ void Host::onNodeTableEvent(NodeId const& _n, NodeTableEventType const& _e)
{ {
if (_e == NodeEntryAdded) if (_e == NodeEntryAdded)
{ {
clog(NetNote) << "p2p.host.nodeTable.events.nodeEntryAdded " << _n; clog(NetP2PNote) << "p2p.host.nodeTable.events.nodeEntryAdded " << _n;
// only add iff node is in node table // only add iff node is in node table
if (Node n = m_nodeTable->node(_n)) if (Node n = m_nodeTable->node(_n))
{ {
@ -268,7 +268,7 @@ void Host::onNodeTableEvent(NodeId const& _n, NodeTableEventType const& _e)
{ {
p.reset(new Peer(n)); p.reset(new Peer(n));
m_peers[_n] = p; m_peers[_n] = p;
clog(NetNote) << "p2p.host.peers.events.peerAdded " << _n << p->endpoint; clog(NetP2PNote) << "p2p.host.peers.events.peerAdded " << _n << p->endpoint;
} }
} }
if (peerSlotsAvailable(Egress)) if (peerSlotsAvailable(Egress))
@ -277,7 +277,7 @@ void Host::onNodeTableEvent(NodeId const& _n, NodeTableEventType const& _e)
} }
else if (_e == NodeEntryDropped) else if (_e == NodeEntryDropped)
{ {
clog(NetNote) << "p2p.host.nodeTable.events.NodeEntryDropped " << _n; clog(NetP2PNote) << "p2p.host.nodeTable.events.NodeEntryDropped " << _n;
RecursiveGuard l(x_sessions); RecursiveGuard l(x_sessions);
m_peers.erase(_n); m_peers.erase(_n);
} }
@ -647,14 +647,14 @@ void Host::startedWorking()
runAcceptor(); runAcceptor();
} }
else else
clog(NetNote) << "p2p.start.notice id:" << id() << "TCP Listen port is invalid or unavailable."; clog(NetP2PNote) << "p2p.start.notice id:" << id() << "TCP Listen port is invalid or unavailable.";
shared_ptr<NodeTable> nodeTable(new NodeTable(m_ioService, m_alias, NodeIPEndpoint(bi::address::from_string(listenAddress()), listenPort(), listenPort()))); shared_ptr<NodeTable> nodeTable(new NodeTable(m_ioService, m_alias, NodeIPEndpoint(bi::address::from_string(listenAddress()), listenPort(), listenPort())));
nodeTable->setEventHandler(new HostNodeTableHandler(*this)); nodeTable->setEventHandler(new HostNodeTableHandler(*this));
m_nodeTable = nodeTable; m_nodeTable = nodeTable;
restoreNetwork(&m_restoreNetwork); restoreNetwork(&m_restoreNetwork);
clog(NetNote) << "p2p.started id:" << id(); clog(NetP2PNote) << "p2p.started id:" << id();
run(boost::system::error_code()); run(boost::system::error_code());
} }

28
libp2p/RLPxHandshake.cpp

@ -30,7 +30,7 @@ using namespace CryptoPP;
void RLPXHandshake::writeAuth() void RLPXHandshake::writeAuth()
{ {
clog(NetConnect) << "p2p.connect.egress sending auth to " << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.egress sending auth to " << m_socket->remoteEndpoint();
m_auth.resize(Signature::size + h256::size + Public::size + h256::size + 1); m_auth.resize(Signature::size + h256::size + Public::size + h256::size + 1);
bytesRef sig(&m_auth[0], Signature::size); bytesRef sig(&m_auth[0], Signature::size);
bytesRef hepubk(&m_auth[Signature::size], h256::size); bytesRef hepubk(&m_auth[Signature::size], h256::size);
@ -56,7 +56,7 @@ void RLPXHandshake::writeAuth()
void RLPXHandshake::writeAck() void RLPXHandshake::writeAck()
{ {
clog(NetConnect) << "p2p.connect.ingress sending ack to " << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.ingress sending ack to " << m_socket->remoteEndpoint();
m_ack.resize(Public::size + h256::size + 1); m_ack.resize(Public::size + h256::size + 1);
bytesRef epubk(&m_ack[0], Public::size); bytesRef epubk(&m_ack[0], Public::size);
bytesRef nonce(&m_ack[Public::size], h256::size); bytesRef nonce(&m_ack[Public::size], h256::size);
@ -74,7 +74,7 @@ void RLPXHandshake::writeAck()
void RLPXHandshake::readAuth() void RLPXHandshake::readAuth()
{ {
clog(NetConnect) << "p2p.connect.ingress recving auth from " << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.ingress recving auth from " << m_socket->remoteEndpoint();
m_authCipher.resize(307); m_authCipher.resize(307);
auto self(shared_from_this()); auto self(shared_from_this());
ba::async_read(m_socket->ref(), ba::buffer(m_authCipher, 307), [this, self](boost::system::error_code ec, std::size_t) ba::async_read(m_socket->ref(), ba::buffer(m_authCipher, 307), [this, self](boost::system::error_code ec, std::size_t)
@ -95,13 +95,13 @@ void RLPXHandshake::readAuth()
m_remoteEphemeral = recover(*(Signature*)sig.data(), sharedSecret ^ m_remoteNonce); m_remoteEphemeral = recover(*(Signature*)sig.data(), sharedSecret ^ m_remoteNonce);
if (sha3(m_remoteEphemeral) != *(h256*)hepubk.data()) if (sha3(m_remoteEphemeral) != *(h256*)hepubk.data())
clog(NetConnect) << "p2p.connect.ingress auth failed (invalid: hash mismatch) for" << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.ingress auth failed (invalid: hash mismatch) for" << m_socket->remoteEndpoint();
transition(); transition();
} }
else else
{ {
clog(NetConnect) << "p2p.connect.ingress recving auth decrypt failed for" << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.ingress recving auth decrypt failed for" << m_socket->remoteEndpoint();
m_nextState = Error; m_nextState = Error;
transition(); transition();
} }
@ -110,7 +110,7 @@ void RLPXHandshake::readAuth()
void RLPXHandshake::readAck() void RLPXHandshake::readAck()
{ {
clog(NetConnect) << "p2p.connect.egress recving ack from " << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.egress recving ack from " << m_socket->remoteEndpoint();
m_ackCipher.resize(210); m_ackCipher.resize(210);
auto self(shared_from_this()); auto self(shared_from_this());
ba::async_read(m_socket->ref(), ba::buffer(m_ackCipher, 210), [this, self](boost::system::error_code ec, std::size_t) ba::async_read(m_socket->ref(), ba::buffer(m_ackCipher, 210), [this, self](boost::system::error_code ec, std::size_t)
@ -125,7 +125,7 @@ void RLPXHandshake::readAck()
} }
else else
{ {
clog(NetConnect) << "p2p.connect.egress recving ack decrypt failed for " << m_socket->remoteEndpoint(); clog(NetP2PConnect) << "p2p.connect.egress recving ack decrypt failed for " << m_socket->remoteEndpoint();
m_nextState = Error; m_nextState = Error;
transition(); transition();
} }
@ -138,9 +138,9 @@ void RLPXHandshake::error()
auto connected = m_socket->isConnected(); auto connected = m_socket->isConnected();
if (connected && !m_socket->remoteEndpoint().address().is_unspecified()) if (connected && !m_socket->remoteEndpoint().address().is_unspecified())
clog(NetConnect) << "Disconnecting " << m_socket->remoteEndpoint() << " (Handshake Failed)"; clog(NetP2PConnect) << "Disconnecting " << m_socket->remoteEndpoint() << " (Handshake Failed)";
else else
clog(NetConnect) << "Handshake Failed (Connection reset by peer)"; clog(NetP2PConnect) << "Handshake Failed (Connection reset by peer)";
m_socket->close(); m_socket->close();
if (m_io != nullptr) if (m_io != nullptr)
@ -151,7 +151,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
{ {
if (_ech || m_nextState == Error || m_cancel) if (_ech || m_nextState == Error || m_cancel)
{ {
clog(NetConnect) << "Handshake Failed (I/O Error:" << _ech.message() << ")"; clog(NetP2PConnect) << "Handshake Failed (I/O Error:" << _ech.message() << ")";
return error(); return error();
} }
@ -175,7 +175,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
else if (m_nextState == WriteHello) else if (m_nextState == WriteHello)
{ {
m_nextState = ReadHello; m_nextState = ReadHello;
clog(NetConnect) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "sending capabilities handshake"; clog(NetP2PConnect) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "sending capabilities handshake";
/// This pointer will be freed if there is an error otherwise /// This pointer will be freed if there is an error otherwise
/// it will be passed to Host which will take ownership. /// it will be passed to Host which will take ownership.
@ -220,7 +220,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
return; return;
} }
clog(NetNote) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "recvd hello header"; clog(NetP2PNote) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "recvd hello header";
/// check frame size /// check frame size
bytes& header = m_handshakeInBuffer; bytes& header = m_handshakeInBuffer;
@ -228,7 +228,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
if (frameSize > 1024) if (frameSize > 1024)
{ {
// all future frames: 16777216 // all future frames: 16777216
clog(NetWarn) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "hello frame is too large" << frameSize; clog(NetP2PWarn) << (m_originated ? "p2p.connect.egress" : "p2p.connect.ingress") << "hello frame is too large" << frameSize;
m_nextState = Error; m_nextState = Error;
transition(); transition();
return; return;
@ -279,7 +279,7 @@ void RLPXHandshake::transition(boost::system::error_code _ech)
if (!_ec) if (!_ec)
{ {
if (!m_socket->remoteEndpoint().address().is_unspecified()) if (!m_socket->remoteEndpoint().address().is_unspecified())
clog(NetConnect) << "Disconnecting " << m_socket->remoteEndpoint() << " (Handshake Timeout)"; clog(NetP2PConnect) << "Disconnecting " << m_socket->remoteEndpoint() << " (Handshake Timeout)";
cancel(); cancel();
} }
}); });

Loading…
Cancel
Save