Skip to content

Commit fb2dcbb

Browse files
committed
qa: test cached failure for compact block
Submit the block with an invalid transaction Script again, leading to CACHED_INVALID being returned by AcceptBlockHeader(). Ensure that also this code path does not lead to a disconnection. This was previously untested, as can be checked with the following diff: ```diff diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 0c4a89c..e8e0c805367 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1814,10 +1814,10 @@ void PeerManagerImpl::MaybePunishNodeForBlock(NodeId nodeid, const BlockValidati { // Discourage outbound (but not inbound) peers if on an invalid chain. // Exempt HB compact block peers. Manual connections are always protected from discouragement. - if (peer && !via_compact_block && !peer->m_is_inbound) { + //if (peer && !via_compact_block && !peer->m_is_inbound) { if (peer) Misbehaving(*peer, message); return; - } + //} break; } case BlockValidationResult::BLOCK_INVALID_HEADER: ```
1 parent f12d8b1 commit fb2dcbb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/functional/p2p_compactblocks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,13 @@ def test_invalid_tx_in_compactblock(self, test_node):
744744
assert_not_equal(node.getbestblockhash(), block.hash_hex)
745745
test_node.sync_with_ping()
746746

747+
# The failure above was cached. Submitting the compact block again will returned a cached
748+
# consensus error (the code path is different) and still not get us disconnected (nor
749+
# advance the tip).
750+
test_node.send_and_ping(msg)
751+
assert_not_equal(node.getbestblockhash(), block.hash_hex)
752+
test_node.sync_with_ping()
753+
747754
# Helper for enabling cb announcements
748755
# Send the sendcmpct request and sync headers
749756
def request_cb_announcements(self, peer):

0 commit comments

Comments
 (0)