|
29 | 29 | #include <logging/timer.h>
|
30 | 30 | #include <node/blockstorage.h>
|
31 | 31 | #include <node/utxo_snapshot.h>
|
| 32 | +#include <policy/v3_policy.h> |
32 | 33 | #include <policy/policy.h>
|
33 | 34 | #include <policy/rbf.h>
|
34 | 35 | #include <policy/settings.h>
|
@@ -332,7 +333,9 @@ void Chainstate::MaybeUpdateMempoolForReorg(
|
332 | 333 | // Also updates valid entries' cached LockPoints if needed.
|
333 | 334 | // If false, the tx is still valid and its lockpoints are updated.
|
334 | 335 | // If true, the tx would be invalid in the next block; remove this entry and all of its descendants.
|
335 |
| - const auto filter_final_and_mature = [this](CTxMemPool::txiter it) |
| 336 | + // Note that v3 rules are not applied here, so reorgs may cause violations of v3 inheritance or |
| 337 | + // topology restrictions. |
| 338 | + const auto filter_final_and_mature = [&](CTxMemPool::txiter it) |
336 | 339 | EXCLUSIVE_LOCKS_REQUIRED(m_mempool->cs, ::cs_main) {
|
337 | 340 | AssertLockHeld(m_mempool->cs);
|
338 | 341 | AssertLockHeld(::cs_main);
|
@@ -760,9 +763,12 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
760 | 763 | // check all unconfirmed ancestors; otherwise an opt-in ancestor
|
761 | 764 | // might be replaced, causing removal of this descendant.
|
762 | 765 | //
|
763 |
| - // If replaceability signaling is ignored due to node setting, |
764 |
| - // replacement is always allowed. |
765 |
| - if (!m_pool.m_full_rbf && !SignalsOptInRBF(*ptxConflicting)) { |
| 766 | + // All V3 transactions are considered replaceable. |
| 767 | + // |
| 768 | + // Replaceability signaling of the original transactions may be |
| 769 | + // ignored due to node setting. |
| 770 | + const bool allow_rbf{m_pool.m_full_rbf || SignalsOptInRBF(*ptxConflicting) || ptxConflicting->nVersion == 3}; |
| 771 | + if (!allow_rbf) { |
766 | 772 | return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "txn-mempool-conflict");
|
767 | 773 | }
|
768 | 774 |
|
@@ -864,7 +870,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
864 | 870 | // while a tx could be package CPFP'd when entering the mempool, we do not have a DoS-resistant
|
865 | 871 | // method of ensuring the tx remains bumped. For example, the fee-bumping child could disappear
|
866 | 872 | // due to a replacement.
|
867 |
| - if (!bypass_limits && ws.m_modified_fees < m_pool.m_min_relay_feerate.GetFee(ws.m_vsize)) { |
| 873 | + // The only exception is v3 transactions. |
| 874 | + if (!bypass_limits && ws.m_ptx->nVersion != 3 && ws.m_modified_fees < m_pool.m_min_relay_feerate.GetFee(ws.m_vsize)) { |
868 | 875 | // Even though this is a fee-related failure, this result is TX_MEMPOOL_POLICY, not
|
869 | 876 | // TX_RECONSIDERABLE, because it cannot be bypassed using package validation.
|
870 | 877 | return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "min relay fee not met",
|
@@ -946,6 +953,9 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
|
946 | 953 | }
|
947 | 954 |
|
948 | 955 | ws.m_ancestors = *ancestors;
|
| 956 | + if (const auto err_string{SingleV3Checks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) { |
| 957 | + return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "v3-rule-violation", *err_string); |
| 958 | + } |
949 | 959 |
|
950 | 960 | // A transaction that spends outputs that would be replaced by it is invalid. Now
|
951 | 961 | // that we have the set of all ancestors we can detect this
|
@@ -1306,6 +1316,15 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
|
1306 | 1316 | m_viewmempool.PackageAddTransaction(ws.m_ptx);
|
1307 | 1317 | }
|
1308 | 1318 |
|
| 1319 | + // At this point we have all in-mempool ancestors, and we know every transaction's vsize. |
| 1320 | + // Run the v3 checks on the package. |
| 1321 | + for (Workspace& ws : workspaces) { |
| 1322 | + if (auto err{PackageV3Checks(ws.m_ptx, ws.m_vsize, txns, ws.m_ancestors)}) { |
| 1323 | + package_state.Invalid(PackageValidationResult::PCKG_POLICY, "v3-violation", err.value()); |
| 1324 | + return PackageMempoolAcceptResult(package_state, {}); |
| 1325 | + } |
| 1326 | + } |
| 1327 | + |
1309 | 1328 | // Transactions must meet two minimum feerates: the mempool minimum fee and min relay fee.
|
1310 | 1329 | // For transactions consisting of exactly one child and its parents, it suffices to use the
|
1311 | 1330 | // package feerate (total modified fees / total virtual size) to check this requirement.
|
|
0 commit comments