libbitcoin / libbitcoin-network

Bitcoin P2P Network Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolve overlapped pong nonce warnings.

evoskuil opened this issue · comments

Currently we can receive an invalid pong nonce for one of three reasons. Either the peer has sent the wrong nonce, traffic has been modified/faulted, or we have sent a second before receiving the first - resetting our own expectation. The former two problems should result in drop of the peer. However we are retaining such peers because the last problem is common. This problem breaks our DOS assumption that we only allow traffic that is expected.

To resolve this we should drop the peer at the point when we are configured to send the next nonce if the previously-expected pong has not yet arrived and cleared it. This results in the configured heartbeat time becoming a maximum channel latency. Given the very high latency we've seen with some peers this would be beneficial (for both ends of the connection). We don't see this warning too often, but when we do it implies that either our own node or the peer is bogged down.

Resolved in #127