mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-09 19:13:28 +02:00
Merge #19107: p2p: Move all header verification into the network layer, extend logging
deb52711a1
Remove header checks out of net_processing (Troy Giorshev)52d4ae46ab
Give V1TransportDeserializer CChainParams& member (Troy Giorshev)5bceef6b12
Change CMessageHeader Constructor (Troy Giorshev)1ca20c1af8
Add doxygen comment for ReceiveMsgBytes (Troy Giorshev)890b1d7c2b
Move checksum check from net_processing to net (Troy Giorshev)2716647ebf
Give V1TransportDeserializer an m_node_id member (Troy Giorshev) Pull request description: Inspired by #15206 and #15197, this PR moves all message header verification from the message processing layer and into the network/transport layer. In the previous PRs there is a change in behavior, where we would disconnect from peers upon a single failed checksum check. In various discussions there was concern over whether this was the right choice, and some expressed a desire to see how this would look if it was made to be a pure refactor. For more context, see https://bitcoincore.reviews/15206.html#l-81. This PR improves the separation between the p2p layers, helping improvements like [BIP324](https://github.com/bitcoin/bitcoin/pull/18242) and #18989. ACKs for top commit: ryanofsky: Code review ACKdeb52711a1
just rebase due to conflict on adjacent line jnewbery: Code review ACKdeb52711a1
. Tree-SHA512: 1a3b7ae883b020cfee1bef968813e04df651ffdad9dd961a826bd80654f2c98676ce7f4721038a1b78d8790e4cebe8060419e3d8affc97ce2b9b4e4b72e6fa9f
This commit is contained in:
@@ -80,7 +80,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
|
||||
def test_magic_bytes(self):
|
||||
self.log.info("Test message with invalid magic bytes disconnects peer")
|
||||
conn = self.nodes[0].add_p2p_connection(P2PDataStore())
|
||||
with self.nodes[0].assert_debug_log(['PROCESSMESSAGE: INVALID MESSAGESTART badmsg']):
|
||||
with self.nodes[0].assert_debug_log(['HEADER ERROR - MESSAGESTART (badmsg, 2 bytes), received ffffffff']):
|
||||
msg = conn.build_message(msg_unrecognized(str_data="d"))
|
||||
# modify magic bytes
|
||||
msg = b'\xff' * 4 + msg[4:]
|
||||
@@ -106,7 +106,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
|
||||
def test_size(self):
|
||||
self.log.info("Test message with oversized payload disconnects peer")
|
||||
conn = self.nodes[0].add_p2p_connection(P2PDataStore())
|
||||
with self.nodes[0].assert_debug_log(['']):
|
||||
with self.nodes[0].assert_debug_log(['HEADER ERROR - SIZE (badmsg, 4000001 bytes)']):
|
||||
msg = msg_unrecognized(str_data="d" * (VALID_DATA_LIMIT + 1))
|
||||
msg = conn.build_message(msg)
|
||||
conn.send_raw_message(msg)
|
||||
@@ -116,9 +116,8 @@ class InvalidMessagesTest(BitcoinTestFramework):
|
||||
def test_msgtype(self):
|
||||
self.log.info("Test message with invalid message type logs an error")
|
||||
conn = self.nodes[0].add_p2p_connection(P2PDataStore())
|
||||
with self.nodes[0].assert_debug_log(['PROCESSMESSAGE: ERRORS IN HEADER']):
|
||||
with self.nodes[0].assert_debug_log(['HEADER ERROR - COMMAND']):
|
||||
msg = msg_unrecognized(str_data="d")
|
||||
msg.msgtype = b'\xff' * 12
|
||||
msg = conn.build_message(msg)
|
||||
# Modify msgtype
|
||||
msg = msg[:7] + b'\x00' + msg[7 + 1:]
|
||||
|
Reference in New Issue
Block a user