69 const auto tx1 =
make_tx( {m_coinbase_txns[0]}, {10 *
COIN});
75 const auto tx3 =
make_tx( {m_coinbase_txns[1]}, {1099 *
CENT});
81 const auto tx5 =
make_tx( {m_coinbase_txns[2]}, {1099 *
CENT});
90 const auto tx7 =
make_tx( {m_coinbase_txns[3]}, {999 *
CENT});
92 const auto tx8 =
make_tx( {m_coinbase_txns[4]}, {999 *
CENT});
96 const auto tx11 =
make_tx( {m_coinbase_txns[7]}, {995 *
CENT});
98 const auto tx12 =
make_tx( {m_coinbase_txns[8]}, {995 *
CENT});
102 const auto tx13 =
make_tx( {m_coinbase_txns[9]}, {995 *
CENT, 995 *
CENT});
105 const auto entry1_normal = pool.
GetIter(tx1->GetHash()).value();
106 const auto entry2_normal = pool.
GetIter(tx2->GetHash()).value();
107 const auto entry3_low = pool.
GetIter(tx3->GetHash()).value();
108 const auto entry4_high = pool.
GetIter(tx4->GetHash()).value();
109 const auto entry5_low = pool.
GetIter(tx5->GetHash()).value();
110 const auto entry6_low_prioritised = pool.
GetIter(tx6->GetHash()).value();
111 const auto entry7_high = pool.
GetIter(tx7->GetHash()).value();
112 const auto entry8_high = pool.
GetIter(tx8->GetHash()).value();
128 entry5_low, entry6_low_prioritised, entry7_high, entry8_high};
173 const int NUM_OUTPUTS = 51;
174 std::vector<CAmount> output_values;
175 output_values.reserve(NUM_OUTPUTS);
176 for (
int i = 0; i < NUM_OUTPUTS; ++i) {
177 output_values.push_back(1 *
COIN);
180 const auto parent_tx_1 =
make_tx( {m_coinbase_txns[0]}, output_values);
181 const auto parent_tx_2 =
make_tx( {m_coinbase_txns[1]}, output_values);
185 std::vector<CTransactionRef> direct_children;
188 for (
const auto& parent_tx : {parent_tx_1, parent_tx_2}) {
189 for (
auto i = 0; i < NUM_OUTPUTS; ++i) {
192 tx.vin[0].prevout.n = i;
205 const auto parent_entry_1 = pool.
GetIter(parent_tx_1->GetHash()).value();
206 const auto parent_entry_2 = pool.
GetIter(parent_tx_2->GetHash()).value();
207 const auto conflicting_transaction =
make_tx({parent_tx_1, parent_tx_2}, {50 *
CENT});
211 {parent_entry_1, parent_entry_2},
212 all_conflicts) == std::nullopt);
219 dummy) == std::nullopt);
227 for (
const auto& child : direct_children) {
233 for (
auto i = 0; i < 100; ++i) {
234 conflicts.insert(pool.
GetIter(direct_children[i]->GetHash()).value());
239 dummy) == std::nullopt);
242 conflicts.insert(pool.
GetIter(direct_children[100]->GetHash()).value());
259 const auto tx1 =
make_tx( {m_coinbase_txns[0], m_coinbase_txns[1]}, {10 *
COIN});
264 const auto entry1 = pool.
GetIter(tx1->GetHash()).value();
265 const auto tx1_fee = entry1->GetModifiedFee();
266 const auto entry2 = pool.
GetIter(tx2->GetHash()).value();
267 const auto tx2_fee = entry2->GetModifiedFee();
270 const auto tx1_conflict =
make_tx( {m_coinbase_txns[0], m_coinbase_txns[2]}, {10 *
COIN});
271 const auto tx3 =
make_tx( {tx1_conflict}, {995 *
CENT});
272 auto entry3 = entry.
FromTx(tx3);
278 changeset->StageRemoval(entry1);
279 changeset->StageRemoval(entry2);
280 changeset->StageAddition(tx1_conflict, tx1_fee, 0, 1, 0,
false, 4,
LockPoints());
281 changeset->StageAddition(tx3, tx2_fee, 0, 1, 0,
false, 4,
LockPoints());
285 BOOST_CHECK(res1.value().second ==
"insufficient feerate: does not improve feerate diagram");
290 changeset->StageRemoval(entry1);
291 changeset->StageRemoval(entry2);
292 changeset->StageAddition(tx1_conflict, tx1_fee+1, 0, 1, 0,
false, 4,
LockPoints());
293 changeset->StageAddition(tx3, tx2_fee, 0, 1, 0,
false, 4,
LockPoints());
300 changeset->StageRemoval(entry1);
301 changeset->StageRemoval(entry2);
302 changeset->StageAddition(tx1_conflict, tx1_fee+1, 0, 1, 0,
false, 4,
LockPoints());
303 changeset->StageAddition(tx3, tx2_fee, 0, 1, 0,
false, 4,
LockPoints());
307 BOOST_CHECK(res2.value().second ==
"insufficient feerate: does not improve feerate diagram");
317 changeset->StageRemoval(entry1);
318 changeset->StageRemoval(entry2);
319 changeset->StageAddition(tx1_conflict, tx1_fee, 0, 1, 0,
false, 4,
LockPoints());
320 changeset->StageAddition(entry4.GetSharedTx(), tx2_fee, 0, 1, 0,
false, 4,
LockPoints());
327 const auto entry5 = pool.
GetIter(tx5->GetHash()).value();
330 changeset->StageRemoval(entry1);
331 changeset->StageRemoval(entry2);
332 changeset->StageRemoval(entry5);
333 changeset->StageAddition(tx1_conflict, tx1_fee, 0, 1, 0,
false, 4,
LockPoints());
334 changeset->StageAddition(entry4.GetSharedTx(), tx2_fee + entry5->GetModifiedFee() + 1, 0, 1, 0,
false, 4,
LockPoints());
350 const auto low_tx =
make_tx( {m_coinbase_txns[0]}, {10 *
COIN});
353 const auto entry_low = pool.
GetIter(low_tx->GetHash()).value();
354 const auto low_size = entry_low->GetAdjustedWeight();
356 const auto replacement_tx =
make_tx( {m_coinbase_txns[0]}, {9 *
COIN});
357 auto entry_replacement = entry.
FromTx(replacement_tx);
362 changeset->StageRemoval(entry_low);
363 changeset->StageAddition(replacement_tx, 0, 0, 1, 0,
false, 4,
LockPoints());
364 const auto replace_one{changeset->CalculateChunksForRBF()};
366 std::vector<FeeFrac> expected_old_chunks{{
low_fee, low_size}};
367 BOOST_CHECK(replace_one->first == expected_old_chunks);
368 std::vector<FeeFrac> expected_new_chunks{{0, entry_replacement.GetAdjustedWeight()}};
369 BOOST_CHECK(replace_one->second == expected_new_chunks);
375 changeset->StageRemoval(entry_low);
377 const auto replace_one_fee{changeset->CalculateChunksForRBF()};
379 std::vector<FeeFrac> expected_old_diagram{{
low_fee, low_size}};
380 BOOST_CHECK(replace_one_fee->first == expected_old_diagram);
381 std::vector<FeeFrac> expected_new_diagram{{
high_fee, entry_replacement.GetAdjustedWeight()}};
382 BOOST_CHECK(replace_one_fee->second == expected_new_diagram);
386 const auto high_tx =
make_tx( {low_tx}, {995 *
CENT});
388 const auto entry_high = pool.
GetIter(high_tx->GetHash()).value();
389 const auto high_size = entry_high->GetAdjustedWeight();
393 changeset->StageRemoval(entry_low);
394 changeset->StageRemoval(entry_high);
396 const auto replace_single_chunk{changeset->CalculateChunksForRBF()};
398 std::vector<FeeFrac> expected_old_chunks{{
low_fee +
high_fee, low_size + high_size}};
399 BOOST_CHECK(replace_single_chunk->first == expected_old_chunks);
400 std::vector<FeeFrac> expected_new_chunks{{
high_fee, entry_replacement.GetAdjustedWeight()}};
401 BOOST_CHECK(replace_single_chunk->second == expected_new_chunks);
407 changeset->StageRemoval(entry_high);
409 const auto replace_cpfp_child{changeset->CalculateChunksForRBF()};
411 std::vector<FeeFrac> expected_old_chunks{{
low_fee +
high_fee, low_size + high_size}};
412 BOOST_CHECK(replace_cpfp_child->first == expected_old_chunks);
413 std::vector<FeeFrac> expected_new_chunks{{
high_fee, entry_replacement.GetAdjustedWeight()}, {
low_fee, low_size}};
414 BOOST_CHECK(replace_cpfp_child->second == expected_new_chunks);
418 const auto high_tx_2 =
make_tx( {m_coinbase_txns[1]}, {10 *
COIN});
420 const auto entry_high_2 = pool.
GetIter(high_tx_2->GetHash()).value();
421 const auto high_size_2 = entry_high_2->GetAdjustedWeight();
423 const auto low_tx_2 =
make_tx( {high_tx_2}, {9 *
COIN});
425 const auto entry_low_2 = pool.
GetIter(low_tx_2->GetHash()).value();
426 const auto low_size_2 = entry_low_2->GetAdjustedWeight();
430 changeset->StageRemoval(entry_high_2);
431 changeset->StageRemoval(entry_low_2);
433 const auto replace_two_chunks_single_cluster{changeset->CalculateChunksForRBF()};
434 BOOST_CHECK(replace_two_chunks_single_cluster.has_value());
435 std::vector<FeeFrac> expected_old_chunks{{
high_fee, high_size_2}, {
low_fee, low_size_2}};
436 BOOST_CHECK(replace_two_chunks_single_cluster->first == expected_old_chunks);
437 std::vector<FeeFrac> expected_new_chunks{{
high_fee, low_size_2}};
438 BOOST_CHECK(replace_two_chunks_single_cluster->second == expected_new_chunks);
442 const auto conflict_1 =
make_tx( {m_coinbase_txns[2]}, {10 *
COIN});
444 const auto conflict_1_entry = pool.
GetIter(conflict_1->GetHash()).value();
446 const auto conflict_2 =
make_tx( {m_coinbase_txns[3]}, {10 *
COIN});
448 const auto conflict_2_entry = pool.
GetIter(conflict_2->GetHash()).value();
450 const auto conflict_3 =
make_tx( {m_coinbase_txns[4]}, {10 *
COIN});
452 const auto conflict_3_entry = pool.
GetIter(conflict_3->GetHash()).value();
456 changeset->StageRemoval(conflict_1_entry);
457 changeset->StageRemoval(conflict_2_entry);
458 changeset->StageRemoval(conflict_3_entry);
460 const auto replace_multiple_clusters{changeset->CalculateChunksForRBF()};
461 BOOST_CHECK(replace_multiple_clusters.has_value());
462 BOOST_CHECK(replace_multiple_clusters->first.size() == 3);
463 BOOST_CHECK(replace_multiple_clusters->second.size() == 1);
467 const auto conflict_1_child =
make_tx({conflict_1}, {995 *
CENT});
469 const auto conflict_1_child_entry = pool.
GetIter(conflict_1_child->GetHash()).value();
473 changeset->StageRemoval(conflict_1_entry);
474 changeset->StageRemoval(conflict_2_entry);
475 changeset->StageRemoval(conflict_3_entry);
476 changeset->StageRemoval(conflict_1_child_entry);
478 const auto replace_multiple_clusters_2{changeset->CalculateChunksForRBF()};
480 BOOST_CHECK(replace_multiple_clusters_2.has_value());
481 BOOST_CHECK(replace_multiple_clusters_2->first.size() == 4);
482 BOOST_CHECK(replace_multiple_clusters_2->second.size() == 1);
491 std::vector<FeeFrac> old_chunks{{{950, 300}, {100, 100}}};
492 std::vector<FeeFrac> new_chunks{{{1000, 300}, {50, 100}}};
498 old_chunks = {{950, 300}, {100, 100}};
499 new_chunks = {{1000, 300}, {0, 100}};
505 old_chunks = {{950, 300}, {100, 100}};
506 new_chunks = {{1100, 300}};
513 old_chunks = {{950, 300}, {100, 100}};
514 new_chunks = {{1100, 100}, {0, 100}};
520 old_chunks = {{950, 300}, {100, 100}};
521 new_chunks = {{750, 100}, {249, 250}, {151, 650}};
527 old_chunks = {{950, 300}, {100, 100}};
528 new_chunks = {{750, 100}, {250, 250}, {150, 150}};
534 old_chunks = {{950, 300}, {100, 100}};
535 new_chunks = {{950, 300}, {100, 100}};
541 old_chunks = {{950, 300}, {100, 99}};
542 new_chunks = {{950, 300}, {100, 100}};
549 old_chunks = {{950, 300}, {100, 99}};
550 new_chunks = {{950, 300}, {100, 100}, {0, 1}, {0, 1}};
556 new_chunks = {{950, 300}, {100, 100}, {0, 1}, {0, 1}, {1, 1}};
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.