mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
[validation] remove PackageMempoolAcceptResult::m_package_feerate
This value creates an extremely confusing interface as its existence is dependent upon implementation details (whether something was submitted on its own, etc). MempoolAcceptResult::m_effective_feerate is much more helpful, as it always exists for submitted transactions.
This commit is contained in:
@@ -101,9 +101,6 @@ BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
|
||||
BOOST_CHECK(it_child != result_parent_child.m_tx_results.end());
|
||||
BOOST_CHECK_MESSAGE(it_child->second.m_state.IsValid(),
|
||||
"Package validation unexpectedly failed: " << it_child->second.m_state.GetRejectReason());
|
||||
BOOST_CHECK(result_parent_child.m_package_feerate.has_value());
|
||||
BOOST_CHECK(result_parent_child.m_package_feerate.value() ==
|
||||
CFeeRate(2 * COIN, GetVirtualTransactionSize(*tx_parent) + GetVirtualTransactionSize(*tx_child)));
|
||||
BOOST_CHECK(it_child->second.m_effective_feerate.value().GetFee(GetVirtualTransactionSize(*tx_child)) == COIN);
|
||||
BOOST_CHECK_EQUAL(it_child->second.m_wtxids_fee_calculations.value().size(), 1);
|
||||
BOOST_CHECK_EQUAL(it_child->second.m_wtxids_fee_calculations.value().front(), tx_child->GetWitnessHash());
|
||||
@@ -118,7 +115,6 @@ BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
|
||||
auto it_giant_tx = result_single_large.m_tx_results.find(giant_ptx->GetWitnessHash());
|
||||
BOOST_CHECK(it_giant_tx != result_single_large.m_tx_results.end());
|
||||
BOOST_CHECK_EQUAL(it_giant_tx->second.m_state.GetRejectReason(), "tx-size");
|
||||
BOOST_CHECK(result_single_large.m_package_feerate == std::nullopt);
|
||||
|
||||
// Check that mempool size hasn't changed.
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize);
|
||||
@@ -239,7 +235,6 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
|
||||
BOOST_CHECK_EQUAL(result_unrelated_submit.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
|
||||
BOOST_CHECK_EQUAL(result_unrelated_submit.m_state.GetRejectReason(), "package-not-child-with-parents");
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
BOOST_CHECK(result_unrelated_submit.m_package_feerate == std::nullopt);
|
||||
|
||||
// Parent and Child (and Grandchild) Package
|
||||
Package package_parent_child;
|
||||
@@ -281,7 +276,6 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
|
||||
BOOST_CHECK_EQUAL(result_3gen_submit.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
|
||||
BOOST_CHECK_EQUAL(result_3gen_submit.m_state.GetRejectReason(), "package-not-child-with-parents");
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
BOOST_CHECK(result_3gen_submit.m_package_feerate == std::nullopt);
|
||||
}
|
||||
|
||||
// Parent and child package where transactions are invalid for reasons other than fee and
|
||||
@@ -314,8 +308,6 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
|
||||
BOOST_CHECK_EQUAL(result_missing_parent.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
|
||||
BOOST_CHECK_EQUAL(result_missing_parent.m_state.GetRejectReason(), "package-not-child-with-unconfirmed-parents");
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
|
||||
BOOST_CHECK(result_missing_parent.m_package_feerate == std::nullopt);
|
||||
}
|
||||
|
||||
// Submit package with parent + child.
|
||||
@@ -341,10 +333,6 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_parent->GetHash())));
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_child->GetHash())));
|
||||
|
||||
// Since both transactions have high feerates, they each passed validation individually.
|
||||
// Package validation was unnecessary, so there is no package feerate.
|
||||
BOOST_CHECK(submit_parent_child.m_package_feerate == std::nullopt);
|
||||
}
|
||||
|
||||
// Already-in-mempool transactions should be detected and de-duplicated.
|
||||
@@ -365,8 +353,6 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_parent->GetHash())));
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(tx_child->GetHash())));
|
||||
|
||||
BOOST_CHECK(submit_deduped.m_package_feerate == std::nullopt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,11 +428,8 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(ptx_child1->GetHash())));
|
||||
|
||||
// Child2 would have been validated individually.
|
||||
BOOST_CHECK(submit_witness1.m_package_feerate == std::nullopt);
|
||||
|
||||
const auto submit_witness2 = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
|
||||
{ptx_parent, ptx_child2}, /*test_accept=*/false);
|
||||
BOOST_CHECK(submit_witness2.m_package_feerate == std::nullopt);
|
||||
BOOST_CHECK_MESSAGE(submit_witness2.m_state.IsValid(),
|
||||
"Package validation unexpectedly failed: " << submit_witness2.m_state.GetRejectReason());
|
||||
auto it_parent2_deduped = submit_witness2.m_tx_results.find(ptx_parent->GetWitnessHash());
|
||||
@@ -470,7 +453,6 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
|
||||
auto it_child_dup = submit_segwit_dedup.m_tx_results.find(ptx_child1->GetWitnessHash());
|
||||
BOOST_CHECK(it_parent_dup->second.m_result_type == MempoolAcceptResult::ResultType::MEMPOOL_ENTRY);
|
||||
BOOST_CHECK(it_child_dup->second.m_result_type == MempoolAcceptResult::ResultType::MEMPOOL_ENTRY);
|
||||
BOOST_CHECK(submit_witness2.m_package_feerate == std::nullopt);
|
||||
}
|
||||
|
||||
// Try submitting Package1{child2, grandchild} where child2 is same-txid-different-witness as
|
||||
@@ -505,9 +487,6 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(ptx_child2->GetHash())));
|
||||
BOOST_CHECK(!m_node.mempool->exists(GenTxid::Wtxid(ptx_child2->GetWitnessHash())));
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Wtxid(ptx_grandchild->GetWitnessHash())));
|
||||
|
||||
// Since child2 is ignored, grandchild would be validated individually.
|
||||
BOOST_CHECK(submit_spend_ignored.m_package_feerate == std::nullopt);
|
||||
}
|
||||
|
||||
// A package Package{parent1, parent2, parent3, child} where the parents are a mixture of
|
||||
@@ -620,11 +599,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
|
||||
BOOST_CHECK(m_node.mempool->exists(GenTxid::Txid(ptx_mixed_child->GetHash())));
|
||||
|
||||
// package feerate should include parent3 and child. It should not include parent1 or parent2_v1.
|
||||
BOOST_CHECK(mixed_result.m_package_feerate.has_value());
|
||||
const CFeeRate expected_feerate(1 * COIN, GetVirtualTransactionSize(*ptx_parent3) + GetVirtualTransactionSize(*ptx_mixed_child));
|
||||
BOOST_CHECK_MESSAGE(mixed_result.m_package_feerate.value() == expected_feerate,
|
||||
strprintf("Expected package feerate %s, got %s", expected_feerate.ToString(),
|
||||
mixed_result.m_package_feerate.value().ToString()));
|
||||
BOOST_CHECK(it_parent3->second.m_effective_feerate.value() == expected_feerate);
|
||||
BOOST_CHECK(it_child->second.m_effective_feerate.value() == expected_feerate);
|
||||
std::vector<uint256> expected_wtxids({ptx_parent3->GetWitnessHash(), ptx_mixed_child->GetWitnessHash()});
|
||||
@@ -678,11 +653,6 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
BOOST_CHECK(submit_cpfp_deprio.m_tx_results.empty());
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
const CFeeRate expected_feerate(0, GetVirtualTransactionSize(*tx_parent) + GetVirtualTransactionSize(*tx_child));
|
||||
BOOST_CHECK(submit_cpfp_deprio.m_package_feerate.has_value());
|
||||
BOOST_CHECK(submit_cpfp_deprio.m_package_feerate.value() == CFeeRate{0});
|
||||
BOOST_CHECK_MESSAGE(submit_cpfp_deprio.m_package_feerate.value() == expected_feerate,
|
||||
strprintf("Expected package feerate %s, got %s", expected_feerate.ToString(),
|
||||
submit_cpfp_deprio.m_package_feerate.value().ToString()));
|
||||
}
|
||||
|
||||
// Clear the prioritisation of the parent transaction.
|
||||
@@ -718,10 +688,6 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
BOOST_CHECK(it_parent->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
BOOST_CHECK(it_child->second.m_wtxids_fee_calculations.value() == expected_wtxids);
|
||||
BOOST_CHECK(expected_feerate.GetFeePerK() > 1000);
|
||||
BOOST_CHECK(submit_cpfp.m_package_feerate.has_value());
|
||||
BOOST_CHECK_MESSAGE(submit_cpfp.m_package_feerate.value() == expected_feerate,
|
||||
strprintf("Expected package feerate %s, got %s", expected_feerate.ToString(),
|
||||
submit_cpfp.m_package_feerate.value().ToString()));
|
||||
}
|
||||
|
||||
// Just because we allow low-fee parents doesn't mean we allow low-feerate packages.
|
||||
@@ -756,10 +722,6 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
const CFeeRate expected_feerate(200,
|
||||
GetVirtualTransactionSize(*tx_parent_cheap) + GetVirtualTransactionSize(*tx_child_cheap));
|
||||
BOOST_CHECK(expected_feerate.GetFeePerK() < 1000);
|
||||
BOOST_CHECK(submit_package_too_low.m_package_feerate.has_value());
|
||||
BOOST_CHECK_MESSAGE(submit_package_too_low.m_package_feerate.value() == expected_feerate,
|
||||
strprintf("Expected package feerate %s, got %s", expected_feerate.ToString(),
|
||||
submit_package_too_low.m_package_feerate.value().ToString()));
|
||||
}
|
||||
|
||||
// Package feerate includes the modified fees of the transactions.
|
||||
@@ -774,10 +736,6 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
"Package validation unexpectedly failed" << submit_prioritised_package.m_state.GetRejectReason());
|
||||
const CFeeRate expected_feerate(1 * COIN + 200,
|
||||
GetVirtualTransactionSize(*tx_parent_cheap) + GetVirtualTransactionSize(*tx_child_cheap));
|
||||
BOOST_CHECK(submit_prioritised_package.m_package_feerate.has_value());
|
||||
BOOST_CHECK_MESSAGE(submit_prioritised_package.m_package_feerate.value() == expected_feerate,
|
||||
strprintf("Expected package feerate %s, got %s", expected_feerate.ToString(),
|
||||
submit_prioritised_package.m_package_feerate.value().ToString()));
|
||||
auto it_parent = submit_prioritised_package.m_tx_results.find(tx_parent_cheap->GetWitnessHash());
|
||||
auto it_child = submit_prioritised_package.m_tx_results.find(tx_child_cheap->GetWitnessHash());
|
||||
BOOST_CHECK(it_parent != submit_prioritised_package.m_tx_results.end());
|
||||
@@ -823,10 +781,6 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
BOOST_CHECK_MESSAGE(submit_rich_parent.m_state.IsInvalid(), "Package validation unexpectedly succeeded");
|
||||
|
||||
// The child would have been validated on its own and failed, then submitted as a "package" of 1.
|
||||
// The package feerate is just the child's feerate, which is 0sat/vb.
|
||||
BOOST_CHECK(submit_rich_parent.m_package_feerate.has_value());
|
||||
BOOST_CHECK_MESSAGE(submit_rich_parent.m_package_feerate.value() == CFeeRate(),
|
||||
"expected 0, got " << submit_rich_parent.m_package_feerate.value().ToString());
|
||||
BOOST_CHECK_EQUAL(submit_rich_parent.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
|
||||
BOOST_CHECK_EQUAL(submit_rich_parent.m_state.GetRejectReason(), "package-fee-too-low");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user