Skip to content

Commit 76ba1c9

Browse files
TheBlueMattMarcoFalke
authored andcommitted
More agressively filter compact block requests
Unit test adaptations by Pieter Wuille. Github-Pull: #8637 Rebased-From: fe998e962dc015978f104b782afb7daec3c4d4df
1 parent 36e3b95 commit 76ba1c9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

qa/rpc-tests/p2p-compactblocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def test_incorrect_blocktxn_response(self, node, test_node, version):
594594
def test_getblocktxn_handler(self, node, test_node, version):
595595
# bitcoind won't respond for blocks whose height is more than 15 blocks
596596
# deep.
597-
MAX_GETBLOCKTXN_DEPTH = 15
597+
MAX_GETBLOCKTXN_DEPTH = 10
598598
chain_height = node.getblockcount()
599599
current_height = chain_height
600600
while (current_height >= chain_height - MAX_GETBLOCKTXN_DEPTH):
@@ -635,7 +635,7 @@ def test_getblocktxn_handler(self, node, test_node, version):
635635

636636
def test_compactblocks_not_at_tip(self, node, test_node):
637637
# Test that requesting old compactblocks doesn't work.
638-
MAX_CMPCTBLOCK_DEPTH = 11
638+
MAX_CMPCTBLOCK_DEPTH = 6
639639
new_blocks = []
640640
for i in range(MAX_CMPCTBLOCK_DEPTH):
641641
test_node.clear_block_announcement()

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4855,7 +4855,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
48554855
// and we don't feel like constructing the object for them, so
48564856
// instead we respond with the full, non-compact block.
48574857
bool fPeerWantsWitness = State(pfrom->GetId())->fWantsCmpctWitness;
4858-
if (mi->second->nHeight >= chainActive.Height() - 10) {
4858+
if (CanDirectFetch(Params().GetConsensus()) && mi->second->nHeight >= chainActive.Height() - 5) {
48594859
CBlockHeaderAndShortTxIDs cmpctblock(block, fPeerWantsWitness);
48604860
pfrom->PushMessageWithFlag(fPeerWantsWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS, NetMsgType::CMPCTBLOCK, cmpctblock);
48614861
} else
@@ -5401,8 +5401,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
54015401
return true;
54025402
}
54035403

5404-
if (it->second->nHeight < chainActive.Height() - 15) {
5405-
LogPrint("net", "Peer %d sent us a getblocktxn for a block > 15 deep", pfrom->id);
5404+
if (it->second->nHeight < chainActive.Height() - 10) {
5405+
LogPrint("net", "Peer %d sent us a getblocktxn for a block > 10 deep", pfrom->id);
54065406
return true;
54075407
}
54085408

0 commit comments

Comments
 (0)