[p2p] only attempt 1p1c when both txns provided by the same peer

Now that we track all announcers of an orphan, it's not helpful to
consider an orphan provided by a peer that didn't send us this parent.
It can only hurt our chances of finding the right orphan when there are
multiple candidates.

Adapt the 2 tests in p2p_opportunistic_1p1c.py that looked at 1p1c
packages from different peers. Instead of checking that the right peer
is punished, we now check that the package is not submitted. We can't
use the functional test to see that the package was not considered
because the behavior is indistinguishable (except for the logs).
This commit is contained in:
glozow
2024-08-20 11:39:18 +01:00
parent f7658d9b14
commit 86d7135e36
6 changed files with 14 additions and 101 deletions

View File

@@ -93,15 +93,6 @@ static bool EqualTxns(const std::set<CTransactionRef>& set_txns, const std::vect
}
return true;
}
static bool EqualTxns(const std::set<CTransactionRef>& set_txns,
const std::vector<std::pair<CTransactionRef, NodeId>>& vec_txns)
{
if (vec_txns.size() != set_txns.size()) return false;
for (const auto& [tx, nodeid] : vec_txns) {
if (!set_txns.contains(tx)) return false;
}
return true;
}
BOOST_AUTO_TEST_CASE(DoS_mapOrphans)
{
@@ -312,9 +303,6 @@ BOOST_AUTO_TEST_CASE(get_children)
BOOST_CHECK(EqualTxns(expected_parent1_children, orphanage.GetChildrenFromSamePeer(parent1, node1)));
BOOST_CHECK(EqualTxns(expected_parent2_children, orphanage.GetChildrenFromSamePeer(parent2, node1)));
BOOST_CHECK(EqualTxns(expected_parent1_children, orphanage.GetChildrenFromDifferentPeer(parent1, node2)));
BOOST_CHECK(EqualTxns(expected_parent2_children, orphanage.GetChildrenFromDifferentPeer(parent2, node2)));
// The peer must match
BOOST_CHECK(orphanage.GetChildrenFromSamePeer(parent1, node2).empty());
BOOST_CHECK(orphanage.GetChildrenFromSamePeer(parent2, node2).empty());
@@ -322,8 +310,6 @@ BOOST_AUTO_TEST_CASE(get_children)
// There shouldn't be any children of this tx in the orphanage
BOOST_CHECK(orphanage.GetChildrenFromSamePeer(child_p1n0_p2n0, node1).empty());
BOOST_CHECK(orphanage.GetChildrenFromSamePeer(child_p1n0_p2n0, node2).empty());
BOOST_CHECK(orphanage.GetChildrenFromDifferentPeer(child_p1n0_p2n0, node1).empty());
BOOST_CHECK(orphanage.GetChildrenFromDifferentPeer(child_p1n0_p2n0, node2).empty());
}
// Orphans provided by node1 and node2
@@ -346,7 +332,6 @@ BOOST_AUTO_TEST_CASE(get_children)
std::set<CTransactionRef> expected_parent1_node1{child_p1n0};
BOOST_CHECK(EqualTxns(expected_parent1_node1, orphanage.GetChildrenFromSamePeer(parent1, node1)));
BOOST_CHECK(EqualTxns(expected_parent1_node1, orphanage.GetChildrenFromDifferentPeer(parent1, node2)));
}
// Children of parent2 from node1:
@@ -354,7 +339,6 @@ BOOST_AUTO_TEST_CASE(get_children)
std::set<CTransactionRef> expected_parent2_node1{child_p2n1};
BOOST_CHECK(EqualTxns(expected_parent2_node1, orphanage.GetChildrenFromSamePeer(parent2, node1)));
BOOST_CHECK(EqualTxns(expected_parent2_node1, orphanage.GetChildrenFromDifferentPeer(parent2, node2)));
}
// Children of parent1 from node2:
@@ -362,7 +346,6 @@ BOOST_AUTO_TEST_CASE(get_children)
std::set<CTransactionRef> expected_parent1_node2{child_p1n0_p1n1, child_p1n0_p2n0};
BOOST_CHECK(EqualTxns(expected_parent1_node2, orphanage.GetChildrenFromSamePeer(parent1, node2)));
BOOST_CHECK(EqualTxns(expected_parent1_node2, orphanage.GetChildrenFromDifferentPeer(parent1, node1)));
}
// Children of parent2 from node2:
@@ -370,7 +353,6 @@ BOOST_AUTO_TEST_CASE(get_children)
std::set<CTransactionRef> expected_parent2_node2{child_p1n0_p2n0};
BOOST_CHECK(EqualTxns(expected_parent2_node2, orphanage.GetChildrenFromSamePeer(parent2, node2)));
BOOST_CHECK(EqualTxns(expected_parent2_node2, orphanage.GetChildrenFromDifferentPeer(parent2, node1)));
}
}
}