Skip to content

Commit 19b968f

Browse files
committed
Merge bitcoin/bitcoin#29722: 28950 followups
7b29119 use const ref for client_maxfeerate (Greg Sanders) f10fd07 scripted-diff: Rename max_sane_feerate to client_maxfeerate (Greg Sanders) Pull request description: Follow-ups to bitcoin/bitcoin#28950 ACKs for top commit: glozow: utACK 7b29119 stickies-v: ACK 7b29119 Tree-SHA512: b9e13509c6e9d7c08aa9d4e759f9707004c1c7b8f3e521fe2ec0037160b87c7fb02528966b9f26eaca6291621df9300e84b5aec66dbc2e97d13bf2f3cd7f979c
2 parents c2dbbc3 + 7b29119 commit 19b968f

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

src/rpc/mempool.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static RPCHelpMan testmempoolaccept()
181181
Chainstate& chainstate = chainman.ActiveChainstate();
182182
const PackageMempoolAcceptResult package_result = [&] {
183183
LOCK(::cs_main);
184-
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true, /*max_sane_feerate=*/{});
184+
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true, /*client_maxfeerate=*/{});
185185
return PackageMempoolAcceptResult(txns[0]->GetWitnessHash(),
186186
chainman.ProcessTransaction(txns[0], /*test_accept=*/true));
187187
}();
@@ -873,10 +873,10 @@ static RPCHelpMan submitpackage()
873873

874874
// Fee check needs to be run with chainstate and package context
875875
const CFeeRate max_raw_tx_fee_rate = ParseFeeRate(self.Arg<UniValue>(1));
876-
std::optional<CFeeRate> max_sane_feerate{max_raw_tx_fee_rate};
876+
std::optional<CFeeRate> client_maxfeerate{max_raw_tx_fee_rate};
877877
// 0-value is special; it's mapped to no sanity check
878878
if (max_raw_tx_fee_rate == CFeeRate(0)) {
879-
max_sane_feerate = std::nullopt;
879+
client_maxfeerate = std::nullopt;
880880
}
881881

882882
// Burn sanity check is run with no context
@@ -906,7 +906,7 @@ static RPCHelpMan submitpackage()
906906
NodeContext& node = EnsureAnyNodeContext(request.context);
907907
CTxMemPool& mempool = EnsureMemPool(node);
908908
Chainstate& chainstate = EnsureChainman(node).ActiveChainstate();
909-
const auto package_result = WITH_LOCK(::cs_main, return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/ false, max_sane_feerate));
909+
const auto package_result = WITH_LOCK(::cs_main, return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/ false, client_maxfeerate));
910910

911911
std::string package_msg = "success";
912912

src/test/fuzz/package_eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
277277
auto single_submit = txs.size() == 1 && fuzzed_data_provider.ConsumeBool();
278278

279279
const auto result_package = WITH_LOCK(::cs_main,
280-
return ProcessNewPackage(chainstate, tx_pool, txs, /*test_accept=*/single_submit, /*max_sane_feerate=*/{}));
280+
return ProcessNewPackage(chainstate, tx_pool, txs, /*test_accept=*/single_submit, /*client_maxfeerate=*/{}));
281281

282282
// Always set bypass_limits to false because it is not supported in ProcessNewPackage and
283283
// can be a source of divergence.

src/test/fuzz/tx_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
291291
// Make sure ProcessNewPackage on one transaction works.
292292
// The result is not guaranteed to be the same as what is returned by ATMP.
293293
const auto result_package = WITH_LOCK(::cs_main,
294-
return ProcessNewPackage(chainstate, tx_pool, {tx}, true, /*max_sane_feerate=*/{}));
294+
return ProcessNewPackage(chainstate, tx_pool, {tx}, true, /*client_maxfeerate=*/{}));
295295
// If something went wrong due to a package-specific policy, it might not return a
296296
// validation result for the transaction.
297297
if (result_package.m_state.GetResult() != PackageValidationResult::PCKG_POLICY) {

src/test/txpackage_tests.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
132132
/*output_amount=*/CAmount(48 * COIN), /*submit=*/false);
133133
CTransactionRef tx_child = MakeTransactionRef(mtx_child);
134134
Package package_parent_child{tx_parent, tx_child};
135-
const auto result_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_parent_child, /*test_accept=*/true, /*max_sane_feerate=*/{});
135+
const auto result_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_parent_child, /*test_accept=*/true, /*client_maxfeerate=*/{});
136136
if (auto err_parent_child{CheckPackageMempoolAcceptResult(package_parent_child, result_parent_child, /*expect_valid=*/true, nullptr)}) {
137137
BOOST_ERROR(err_parent_child.value());
138138
} else {
@@ -151,7 +151,7 @@ BOOST_FIXTURE_TEST_CASE(package_validation_tests, TestChain100Setup)
151151
CTransactionRef giant_ptx = create_placeholder_tx(999, 999);
152152
BOOST_CHECK(GetVirtualTransactionSize(*giant_ptx) > DEFAULT_ANCESTOR_SIZE_LIMIT_KVB * 1000);
153153
Package package_single_giant{giant_ptx};
154-
auto result_single_large = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_single_giant, /*test_accept=*/true, /*max_sane_feerate=*/{});
154+
auto result_single_large = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_single_giant, /*test_accept=*/true, /*client_maxfeerate=*/{});
155155
if (auto err_single_large{CheckPackageMempoolAcceptResult(package_single_giant, result_single_large, /*expect_valid=*/false, nullptr)}) {
156156
BOOST_ERROR(err_single_large.value());
157157
} else {
@@ -275,7 +275,7 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
275275
package_unrelated.emplace_back(MakeTransactionRef(mtx));
276276
}
277277
auto result_unrelated_submit = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
278-
package_unrelated, /*test_accept=*/false, /*max_sane_feerate=*/{});
278+
package_unrelated, /*test_accept=*/false, /*client_maxfeerate=*/{});
279279
// We don't expect m_tx_results for each transaction when basic sanity checks haven't passed.
280280
BOOST_CHECK(result_unrelated_submit.m_state.IsInvalid());
281281
BOOST_CHECK_EQUAL(result_unrelated_submit.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
@@ -315,7 +315,7 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
315315
// 3 Generations is not allowed.
316316
{
317317
auto result_3gen_submit = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
318-
package_3gen, /*test_accept=*/false, /*max_sane_feerate=*/{});
318+
package_3gen, /*test_accept=*/false, /*client_maxfeerate=*/{});
319319
BOOST_CHECK(result_3gen_submit.m_state.IsInvalid());
320320
BOOST_CHECK_EQUAL(result_3gen_submit.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
321321
BOOST_CHECK_EQUAL(result_3gen_submit.m_state.GetRejectReason(), "package-not-child-with-parents");
@@ -332,7 +332,7 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
332332
CTransactionRef tx_parent_invalid = MakeTransactionRef(mtx_parent_invalid);
333333
Package package_invalid_parent{tx_parent_invalid, tx_child};
334334
auto result_quit_early = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
335-
package_invalid_parent, /*test_accept=*/ false, /*max_sane_feerate=*/{});
335+
package_invalid_parent, /*test_accept=*/ false, /*client_maxfeerate=*/{});
336336
if (auto err_parent_invalid{CheckPackageMempoolAcceptResult(package_invalid_parent, result_quit_early, /*expect_valid=*/false, m_node.mempool.get())}) {
337337
BOOST_ERROR(err_parent_invalid.value());
338338
} else {
@@ -353,7 +353,7 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
353353
package_missing_parent.push_back(MakeTransactionRef(mtx_child));
354354
{
355355
const auto result_missing_parent = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
356-
package_missing_parent, /*test_accept=*/false, /*max_sane_feerate=*/{});
356+
package_missing_parent, /*test_accept=*/false, /*client_maxfeerate=*/{});
357357
BOOST_CHECK(result_missing_parent.m_state.IsInvalid());
358358
BOOST_CHECK_EQUAL(result_missing_parent.m_state.GetResult(), PackageValidationResult::PCKG_POLICY);
359359
BOOST_CHECK_EQUAL(result_missing_parent.m_state.GetRejectReason(), "package-not-child-with-unconfirmed-parents");
@@ -363,7 +363,7 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
363363
// Submit package with parent + child.
364364
{
365365
const auto submit_parent_child = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
366-
package_parent_child, /*test_accept=*/false, /*max_sane_feerate=*/{});
366+
package_parent_child, /*test_accept=*/false, /*client_maxfeerate=*/{});
367367
expected_pool_size += 2;
368368
BOOST_CHECK_MESSAGE(submit_parent_child.m_state.IsValid(),
369369
"Package validation unexpectedly failed: " << submit_parent_child.m_state.GetRejectReason());
@@ -385,7 +385,7 @@ BOOST_FIXTURE_TEST_CASE(package_submission_tests, TestChain100Setup)
385385
// Already-in-mempool transactions should be detected and de-duplicated.
386386
{
387387
const auto submit_deduped = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
388-
package_parent_child, /*test_accept=*/false, /*max_sane_feerate=*/{});
388+
package_parent_child, /*test_accept=*/false, /*client_maxfeerate=*/{});
389389
if (auto err_deduped{CheckPackageMempoolAcceptResult(package_parent_child, submit_deduped, /*expect_valid=*/true, m_node.mempool.get())}) {
390390
BOOST_ERROR(err_deduped.value());
391391
} else {
@@ -456,15 +456,15 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
456456
{
457457
Package package_parent_child1{ptx_parent, ptx_child1};
458458
const auto submit_witness1 = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
459-
package_parent_child1, /*test_accept=*/false, /*max_sane_feerate=*/{});
459+
package_parent_child1, /*test_accept=*/false, /*client_maxfeerate=*/{});
460460
if (auto err_witness1{CheckPackageMempoolAcceptResult(package_parent_child1, submit_witness1, /*expect_valid=*/true, m_node.mempool.get())}) {
461461
BOOST_ERROR(err_witness1.value());
462462
}
463463

464464
// Child2 would have been validated individually.
465465
Package package_parent_child2{ptx_parent, ptx_child2};
466466
const auto submit_witness2 = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
467-
package_parent_child2, /*test_accept=*/false, /*max_sane_feerate=*/{});
467+
package_parent_child2, /*test_accept=*/false, /*client_maxfeerate=*/{});
468468
if (auto err_witness2{CheckPackageMempoolAcceptResult(package_parent_child2, submit_witness2, /*expect_valid=*/true, m_node.mempool.get())}) {
469469
BOOST_ERROR(err_witness2.value());
470470
} else {
@@ -478,7 +478,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
478478
// Deduplication should work when wtxid != txid. Submit package with the already-in-mempool
479479
// transactions again, which should not fail.
480480
const auto submit_segwit_dedup = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
481-
package_parent_child1, /*test_accept=*/false, /*max_sane_feerate=*/{});
481+
package_parent_child1, /*test_accept=*/false, /*client_maxfeerate=*/{});
482482
if (auto err_segwit_dedup{CheckPackageMempoolAcceptResult(package_parent_child1, submit_segwit_dedup, /*expect_valid=*/true, m_node.mempool.get())}) {
483483
BOOST_ERROR(err_segwit_dedup.value());
484484
} else {
@@ -508,7 +508,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
508508
{
509509
Package package_child2_grandchild{ptx_child2, ptx_grandchild};
510510
const auto submit_spend_ignored = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
511-
package_child2_grandchild, /*test_accept=*/false, /*max_sane_feerate=*/{});
511+
package_child2_grandchild, /*test_accept=*/false, /*client_maxfeerate=*/{});
512512
if (auto err_spend_ignored{CheckPackageMempoolAcceptResult(package_child2_grandchild, submit_spend_ignored, /*expect_valid=*/true, m_node.mempool.get())}) {
513513
BOOST_ERROR(err_spend_ignored.value());
514514
} else {
@@ -606,7 +606,7 @@ BOOST_FIXTURE_TEST_CASE(package_witness_swap_tests, TestChain100Setup)
606606
// parent3 should be accepted
607607
// child should be accepted
608608
{
609-
const auto mixed_result = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_mixed, false, /*max_sane_feerate=*/{});
609+
const auto mixed_result = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool, package_mixed, false, /*client_maxfeerate=*/{});
610610
if (auto err_mixed{CheckPackageMempoolAcceptResult(package_mixed, mixed_result, /*expect_valid=*/true, m_node.mempool.get())}) {
611611
BOOST_ERROR(err_mixed.value());
612612
} else {
@@ -670,7 +670,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
670670
{
671671
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
672672
const auto submit_cpfp_deprio = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
673-
package_cpfp, /*test_accept=*/ false, /*max_sane_feerate=*/{});
673+
package_cpfp, /*test_accept=*/ false, /*client_maxfeerate=*/{});
674674
if (auto err_cpfp_deprio{CheckPackageMempoolAcceptResult(package_cpfp, submit_cpfp_deprio, /*expect_valid=*/false, m_node.mempool.get())}) {
675675
BOOST_ERROR(err_cpfp_deprio.value());
676676
} else {
@@ -692,7 +692,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
692692
{
693693
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
694694
const auto submit_cpfp = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
695-
package_cpfp, /*test_accept=*/ false, /*max_sane_feerate=*/{});
695+
package_cpfp, /*test_accept=*/ false, /*client_maxfeerate=*/{});
696696
if (auto err_cpfp{CheckPackageMempoolAcceptResult(package_cpfp, submit_cpfp, /*expect_valid=*/true, m_node.mempool.get())}) {
697697
BOOST_ERROR(err_cpfp.value());
698698
} else {
@@ -744,7 +744,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
744744
// Cheap package should fail for being too low fee.
745745
{
746746
const auto submit_package_too_low = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
747-
package_still_too_low, /*test_accept=*/false, /*max_sane_feerate=*/{});
747+
package_still_too_low, /*test_accept=*/false, /*client_maxfeerate=*/{});
748748
if (auto err_package_too_low{CheckPackageMempoolAcceptResult(package_still_too_low, submit_package_too_low, /*expect_valid=*/false, m_node.mempool.get())}) {
749749
BOOST_ERROR(err_package_too_low.value());
750750
} else {
@@ -770,7 +770,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
770770
// Now that the child's fees have "increased" by 1 BTC, the cheap package should succeed.
771771
{
772772
const auto submit_prioritised_package = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
773-
package_still_too_low, /*test_accept=*/false, /*max_sane_feerate=*/{});
773+
package_still_too_low, /*test_accept=*/false, /*client_maxfeerate=*/{});
774774
if (auto err_prioritised{CheckPackageMempoolAcceptResult(package_still_too_low, submit_prioritised_package, /*expect_valid=*/true, m_node.mempool.get())}) {
775775
BOOST_ERROR(err_prioritised.value());
776776
} else {
@@ -818,7 +818,7 @@ BOOST_FIXTURE_TEST_CASE(package_cpfp_tests, TestChain100Setup)
818818
{
819819
BOOST_CHECK_EQUAL(m_node.mempool->size(), expected_pool_size);
820820
const auto submit_rich_parent = ProcessNewPackage(m_node.chainman->ActiveChainstate(), *m_node.mempool,
821-
package_rich_parent, /*test_accept=*/false, /*max_sane_feerate=*/{});
821+
package_rich_parent, /*test_accept=*/false, /*client_maxfeerate=*/{});
822822
if (auto err_rich_parent{CheckPackageMempoolAcceptResult(package_rich_parent, submit_rich_parent, /*expect_valid=*/false, m_node.mempool.get())}) {
823823
BOOST_ERROR(err_rich_parent.value());
824824
} else {

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ class MemPoolAccept
511511

512512
/** Parameters for child-with-unconfirmed-parents package validation. */
513513
static ATMPArgs PackageChildWithParents(const CChainParams& chainparams, int64_t accept_time,
514-
std::vector<COutPoint>& coins_to_uncache, std::optional<CFeeRate>& client_maxfeerate) {
514+
std::vector<COutPoint>& coins_to_uncache, const std::optional<CFeeRate>& client_maxfeerate) {
515515
return ATMPArgs{/* m_chainparams */ chainparams,
516516
/* m_accept_time */ accept_time,
517517
/* m_bypass_limits */ false,
@@ -1716,7 +1716,7 @@ MempoolAcceptResult AcceptToMemoryPool(Chainstate& active_chainstate, const CTra
17161716
}
17171717

17181718
PackageMempoolAcceptResult ProcessNewPackage(Chainstate& active_chainstate, CTxMemPool& pool,
1719-
const Package& package, bool test_accept, std::optional<CFeeRate> client_maxfeerate)
1719+
const Package& package, bool test_accept, const std::optional<CFeeRate>& client_maxfeerate)
17201720
{
17211721
AssertLockHeld(cs_main);
17221722
assert(!package.empty());

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ MempoolAcceptResult AcceptToMemoryPool(Chainstate& active_chainstate, const CTra
275275
* Validate (and maybe submit) a package to the mempool. See doc/policy/packages.md for full details
276276
* on package validation rules.
277277
* @param[in] test_accept When true, run validation checks but don't submit to mempool.
278-
* @param[in] max_sane_feerate If exceeded by an individual transaction, rest of (sub)package evalution is aborted.
278+
* @param[in] client_maxfeerate If exceeded by an individual transaction, rest of (sub)package evalution is aborted.
279279
* Only for sanity checks against local submission of transactions.
280280
* @returns a PackageMempoolAcceptResult which includes a MempoolAcceptResult for each transaction.
281281
* If a transaction fails, validation will exit early and some results may be missing. It is also
282282
* possible for the package to be partially submitted.
283283
*/
284284
PackageMempoolAcceptResult ProcessNewPackage(Chainstate& active_chainstate, CTxMemPool& pool,
285-
const Package& txns, bool test_accept, std::optional<CFeeRate> max_sane_feerate)
285+
const Package& txns, bool test_accept, const std::optional<CFeeRate>& client_maxfeerate)
286286
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
287287

288288
/* Mempool validation helper functions */

0 commit comments

Comments
 (0)