mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +02:00
[validation] change package-fee-too-low, return wtxid(s) and effective feerate
With subpackage evaluation and de-duplication, it's not always the entire package that is used in CheckFeerate. To be more helpful to the caller, specify which transactions were included in the evaluation and what the feerate was. Instead of PCKG_POLICY (which is supposed to be for package-wide errors), use PCKG_TX.
This commit is contained in:
@@ -154,12 +154,15 @@ void CheckATMPInvariants(const MempoolAcceptResult& res, bool txid_in_mempool, b
|
||||
// It may be already in the mempool since in ATMP cases we don't set MEMPOOL_ENTRY or DIFFERENT_WITNESS
|
||||
Assert(!res.m_state.IsValid());
|
||||
Assert(res.m_state.IsInvalid());
|
||||
|
||||
const bool is_reconsiderable{res.m_state.GetResult() == TxValidationResult::TX_RECONSIDERABLE};
|
||||
Assert(!res.m_replaced_transactions);
|
||||
Assert(!res.m_vsize);
|
||||
Assert(!res.m_base_fees);
|
||||
// Unable or unwilling to calculate fees
|
||||
Assert(!res.m_effective_feerate);
|
||||
Assert(!res.m_wtxids_fee_calculations);
|
||||
// Fee information is provided if the failure is TX_RECONSIDERABLE.
|
||||
// In other cases, validation may be unable or unwilling to calculate the fees.
|
||||
Assert(res.m_effective_feerate.has_value() == is_reconsiderable);
|
||||
Assert(res.m_wtxids_fee_calculations.has_value() == is_reconsiderable);
|
||||
Assert(!res.m_other_wtxid);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -753,15 +753,26 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
|
||||
BOOST_CHECK(m_node.mempool->GetMinFee().GetFee(GetVirtualTransactionSize(*tx_parent_cheap) + GetVirtualTransactionSize(*tx_child_cheap)) > parent_fee + child_fee);
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
|
||||
// Cheap package should fail with package-fee-too-low.
|
||||
// Cheap package should fail for being too low fee.
|
||||
{
|
||||
const auto submit_package_too_low = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
|
||||
package_still_too_low, /*test_accept=*/false);
|
||||
BOOST_CHECK_EQUAL(submit_package_too_low.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
|
||||
BOOST_CHECK_EQUAL(submit_package_too_low.m_state.GetRejectReason(), "package-fee-too-low");
|
||||
if (auto err_package_too_low{CheckPackageMempoolAcceptResult(package_still_too_low, submit_package_too_low, /*expect_valid=*/false, m_node.mempool.get())}) {
|
||||
BOOST_ERROR(err_package_too_low.value());
|
||||
} else {
|
||||
// Individual feerate of parent is too low.
|
||||
BOOST_CHECK_EQUAL(submit_package_too_low.m_tx_results.at(tx_parent_cheap->GetWitnessHash()).m_state.GetResult(),
|
||||
TxValidationResult::TX_RECONSIDERABLE);
|
||||
BOOST_CHECK(submit_package_too_low.m_tx_results.at(tx_parent_cheap->GetWitnessHash()).m_effective_feerate.value() ==
|
||||
CFeeRate(parent_fee, GetVirtualTransactionSize(*tx_parent_cheap)));
|
||||
// Package feerate of parent + child is too low.
|
||||
BOOST_CHECK_EQUAL(submit_package_too_low.m_tx_results.at(tx_child_cheap->GetWitnessHash()).m_state.GetResult(),
|
||||
TxValidationResult::TX_RECONSIDERABLE);
|
||||
BOOST_CHECK(submit_package_too_low.m_tx_results.at(tx_child_cheap->GetWitnessHash()).m_effective_feerate.value() ==
|
||||
CFeeRate(parent_fee + child_fee, GetVirtualTransactionSize(*tx_parent_cheap) + GetVirtualTransactionSize(*tx_child_cheap)));
|
||||
}
|
||||
BOOST_CHECK_EQUAL(submit_package_too_low.m_state.GetResult(), PackageValidationResult::PCKG_TX);
|
||||
BOOST_CHECK_EQUAL(submit_package_too_low.m_state.GetRejectReason(), "transaction failed");
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,11 +89,14 @@ std::optional<std::string> CheckPackageMempoolAcceptResult(const Package& txns,
|
||||
}
|
||||
|
||||
// m_effective_feerate and m_wtxids_fee_calculations should exist iff the result was valid
|
||||
if (atmp_result.m_effective_feerate.has_value() != valid) {
|
||||
// or if the failure was TX_RECONSIDERABLE
|
||||
const bool valid_or_reconsiderable{atmp_result.m_result_type == MempoolAcceptResult::ResultType::VALID ||
|
||||
atmp_result.m_state.GetResult() == TxValidationResult::TX_RECONSIDERABLE};
|
||||
if (atmp_result.m_effective_feerate.has_value() != valid_or_reconsiderable) {
|
||||
return strprintf("tx %s result should %shave m_effective_feerate",
|
||||
wtxid.ToString(), valid ? "" : "not ");
|
||||
}
|
||||
if (atmp_result.m_wtxids_fee_calculations.has_value() != valid) {
|
||||
if (atmp_result.m_wtxids_fee_calculations.has_value() != valid_or_reconsiderable) {
|
||||
return strprintf("tx %s result should %shave m_effective_feerate",
|
||||
wtxid.ToString(), valid ? "" : "not ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user