refactor prep for package rbf #30072

pull instagibbs wants to merge 5 commits into bitcoin:master from instagibbs:2024-05-package_rbf_prep changing 3 files +128 โˆ’56
  1. instagibbs commented at 1:58 pm on May 9, 2024: member

    First few commits of #28984 to set the stage for the package RBF logic.

    These refactors are preparation for evaluating an RBF in a multi-proposed-transaction context instead of only a single proposed transaction. Also, carveouts and sibling evictions only should work in single RBF cases so add logic to preclude multi-tx cases in the future.

    No behavior changes aside from bailing earlier from failed carve-outs.

  2. DrahtBot commented at 1:58 pm on May 9, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK glozow, sr-gi, theStack
    Stale ACK sdaftuar, ismaelsadeeq

    If your review is incorrectly listed, please react with ๐Ÿ‘Ž to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #29680 (wallet: fix unrelated parent conflict doesn’t cause child tx to be marked as conflict by Eunovo)
    • #29496 (policy: bump TX_MAX_STANDARD_VERSION to 3 by glozow)
    • #29325 (consensus: Store transaction nVersion as uint32_t by achow101)
    • #26593 (tracing: Only prepare tracepoint arguments when actually tracing by 0xB10C)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. instagibbs commented at 1:58 pm on May 9, 2024: member
    suggested by @glozow , can close if this ends up not being helpful
  4. in src/validation.cpp:715 in ff7c71f210 outdated
    710+    // AcceptSingleTransaction and AcceptMultipleTransactions invocations
    711+
    712+    /** Aggregated modified fees of all transactions, used to calculate package feerate. */
    713+    CAmount m_total_modified_fees;
    714+    /** Aggregated virtual size of all transactions, used to calculate package feerate. */
    715+    int64_t m_total_vsize;
    


    glozow commented at 2:21 pm on May 9, 2024:
    0    CAmount m_total_modified_fees{0};
    1    /** Aggregated virtual size of all transactions, used to calculate package feerate. */
    2    int64_t m_total_vsize{0};
    

    instagibbs commented at 4:24 pm on May 9, 2024:
    done
  5. in src/validation.cpp:1245 in ff7c71f210 outdated
    1216@@ -1179,9 +1217,10 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
    1217                 entry->GetTxSize(),
    1218                 entry->GetFee()
    1219         );
    1220-        ws.m_replaced_transactions.push_back(it->GetSharedTx());
    1221+        m_replaced_transactions.push_back(it->GetSharedTx());
    1222     }
    1223-    m_pool.RemoveStaged(ws.m_all_conflicting, false, MemPoolRemovalReason::REPLACED);
    1224+    m_pool.RemoveStaged(m_all_conflicts, false, MemPoolRemovalReason::REPLACED);
    1225+    m_all_conflicts.clear();
    


    glozow commented at 2:24 pm on May 9, 2024:

    Worth commenting that even though clearing happens in ClearSubPackageState, this is cleared so that we don’t process the vector over and over again for each tx in the package.

    fwiw here’s a test for it, doing an RBF (but not package RBF) within package eval: https://github.com/glozow/bitcoin/blob/2024-05-review-30072/src/test/txpackage_tests.cpp#L940-L996


    instagibbs commented at 4:24 pm on May 9, 2024:
    added comment

    instagibbs commented at 4:39 pm on May 9, 2024:

    fwiw that test is a single tx rbf, so even without this line it should pass. With package RBF it might result in multiple RemoveStaged calls on same conflicts, though I’m unsure what exactly that would do.

    edit: I suppose it would result in every tx in subpackage reporting the whole set of m_all_conflicts during package rbf multiple times


    glozow commented at 4:45 pm on May 9, 2024:
    Oh yes I was confused. Then I wonder why this is needed…?

    instagibbs commented at 4:56 pm on May 9, 2024:
    In package RBF contexts, the 2nd time Finalize() is called in a subpackage, the child tx, it will try and enumerate the m_all_conflicts list again, but those transactions were already removed, so we would crash.

    instagibbs commented at 4:58 pm on May 9, 2024:
    elaborated on the comment a bit more
  6. in test/functional/mempool_package_onemore.py:57 in ff7c71f210 outdated
    54@@ -55,14 +55,23 @@ def run_test(self):
    55         assert_raises_rpc_error(-26, "too-long-mempool-chain, too many descendants", self.chain_tx, [chain[0], second_chain])
    56         # ...especially if its > 40k weight
    57         assert_raises_rpc_error(-26, "too-long-mempool-chain, too many descendants", self.chain_tx, [chain[0]], num_outputs=350)
    58+        # ...even if it's submitted with other transactions
    


    glozow commented at 2:28 pm on May 9, 2024:

    Don’t think the other transactions help

    0        # ...or if it's submitted with other transactions
    

    instagibbs commented at 4:24 pm on May 9, 2024:
    done

    sr-gi commented at 7:48 pm on May 16, 2024:

    In 90b60a16731ac756dce44c29f57d111f4dffba75

    I see :%s/even/or was applied a few lines above, but this suggestion seems not to have been covered. Was it applied to the above line by mistake?

  7. glozow commented at 3:57 pm on May 9, 2024: member
    ACK ff7c71f2105. Code review + checked that the members get cleared properly in between subpackage evals.
  8. instagibbs force-pushed on May 9, 2024
  9. instagibbs force-pushed on May 9, 2024
  10. ismaelsadeeq commented at 10:58 am on May 10, 2024: member
    Code Review ACK 6a39183b53a41bb282ebf8373d0e11691d97d365
  11. DrahtBot requested review from glozow on May 10, 2024
  12. in src/validation.cpp:1223 in 6a39183b53 outdated
    1216@@ -1179,9 +1217,12 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
    1217                 entry->GetTxSize(),
    1218                 entry->GetFee()
    1219         );
    1220-        ws.m_replaced_transactions.push_back(it->GetSharedTx());
    1221+        m_replaced_transactions.push_back(it->GetSharedTx());
    1222     }
    1223-    m_pool.RemoveStaged(ws.m_all_conflicting, false, MemPoolRemovalReason::REPLACED);
    1224+    m_pool.RemoveStaged(m_all_conflicts, false, MemPoolRemovalReason::REPLACED);
    1225+    // Don't attempt process same conflicts repeatedly during subpackage evaluation:
    


    glozow commented at 12:41 pm on May 10, 2024:

    nitty nit (nonblocking)

    0    // Don't attempt to process the same conflicts repeatedly during subpackage evaluation:
    

    instagibbs commented at 1:51 pm on May 10, 2024:
    will fix if touching again

    instagibbs commented at 2:11 pm on May 20, 2024:
    done
  13. glozow commented at 12:41 pm on May 10, 2024: member
    reACK 6a39183b53
  14. DrahtBot added the label Needs rebase on May 15, 2024
  15. instagibbs force-pushed on May 15, 2024
  16. instagibbs commented at 12:04 pm on May 15, 2024: member
    rebased due to merge conflict
  17. DrahtBot removed the label Needs rebase on May 15, 2024
  18. glozow commented at 12:47 pm on May 15, 2024: member
    reACK 186a00e644 via range-diff
  19. DrahtBot requested review from ismaelsadeeq on May 15, 2024
  20. ismaelsadeeq commented at 5:18 pm on May 15, 2024: member
    re-ACK 186a00e64490bb5b7b3c544346ae047ad1a66696
  21. laanwj added the label Mempool on May 16, 2024
  22. in src/validation.cpp:999 in 9eb9c030a0 outdated
     995@@ -996,7 +996,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
     996     // already calculated.
     997     if (const auto err{SingleV3Checks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
     998         // Disabled within package validation.
     999-        if (err->second != nullptr && args.m_allow_replacement) {
    1000+        if (err->second != nullptr && args.m_allow_replacement && !args.m_package_feerates) {
    


    instagibbs commented at 7:01 pm on May 16, 2024:

    m_package_feerates is experiencing mission creep here. Really this is asking “was I called in AcceptSingleTransaction”?

    Should we bikeshed this to make it clearer @glozow ?


    glozow commented at 9:09 am on May 17, 2024:

    Agree there’s room for improvement clarity-wise.

    Perhaps a good approach is to have each flag control 1 part of the validation logic (even if 1 flag implies another flag)

    • whether you call LimitMempoolSize() within Finalize()
    • whether all conflicts should be rejected immediately
    • whether CheckFeeRate should be skipped in PreChecks
    • whether sibling eviction can be considered
    • whether package RBF can be considered

    The ATMPArgs constructors should decide the flags based on where they are created and we can add a sanity checking function within each ctor to assert that package RBF implies package feerates, package feerates implies package submission, etc.


    instagibbs commented at 2:11 pm on May 20, 2024:
    added an explicit m_allow_sibling_eviction ATMPArg and had it being true imply m_allow_replacements.
  23. in src/validation.cpp:481 in 90b60a1673 outdated
    475@@ -476,6 +476,9 @@ class MemPoolAccept
    476          */
    477         const std::optional<CFeeRate> m_client_maxfeerate;
    478 
    479+        /** Whether CPFP carveout and RBF carveout are granted. */
    


    sr-gi commented at 7:12 pm on May 16, 2024:

    In 90b60a16731ac756dce44c29f57d111f4dffba75

    nit (not-blocking):

    0        /** Whether CPFP and RBF carveouts are granted. */
    

    instagibbs commented at 6:49 pm on May 23, 2024:
    will touch if I have to retouch the PR
  24. in src/validation.cpp:994 in 90b60a1673 outdated
    956@@ -948,6 +957,13 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
    957         ws.m_ancestors = std::move(*ancestors);
    958     } else {
    959         // If CalculateMemPoolAncestors fails second time, we want the original error string.
    


    sr-gi commented at 7:20 pm on May 16, 2024:

    In 90b60a16731ac756dce44c29f57d111f4dffba75

    I think this comment is not accurate (it was not all that accurate before that PR either). At this point, CalculateMemPoolAncestors has only been called once. The only case in which this caching applies is in the last else case of this context. I think this should be reworded


    instagibbs commented at 6:49 pm on May 23, 2024:

    My reading of it is if it fails below for a second time, we will want to have cached the first error string.

    either way, this PR hopefully doesn’t make this confusion worse than status quo?


    sr-gi commented at 7:05 pm on May 23, 2024:
    Yeah, I don’t think it makes it worse

    glozow commented at 9:23 am on May 24, 2024:
    This is probably from when CalculateMemPoolAncestors took an in-out string param and we wanted to make a copy of the string before it got mutated. Probably best to just move the comment to the code where stuff is actually returned.
  25. in src/validation.cpp:1437 in 90b60a1673 outdated
    1437-    // because it's unnecessary. Also, CPFP carve out can increase the limit for individual
    1438-    // transactions, but this exemption is not extended to packages in CheckPackageLimits().
    1439-    std::string err_string;
    1440-    if (txns.size() > 1 && !PackageMempoolChecks(txns, m_total_vsize, package_state)) {
    1441+    // Apply package mempool ancestor/descendant limits.
    1442+    if (!PackageMempoolChecks(txns, m_total_vsize, package_state)) {
    


    sr-gi commented at 7:45 pm on May 16, 2024:

    In 90b60a16731ac756dce44c29f57d111f4dffba75

    If we are removing txns.size() > 1 because it is a truism, we should at least assume it to make sure we are not overlooking it


    instagibbs commented at 6:49 pm on May 23, 2024:
    I reverted that change based on your feedback already :)

    sr-gi commented at 7:05 pm on May 23, 2024:
    Oh sorry, this was left on my first pass, which I never submitted ๐Ÿ˜†
  26. instagibbs force-pushed on May 20, 2024
  27. in src/validation.cpp:1481 in 868c3e77e0 outdated
    1445@@ -1431,9 +1446,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
    1446     }
    1447 
    1448     // Apply package mempool ancestor/descendant limits. Skip if there is only one transaction,
    1449-    // because it's unnecessary. Also, CPFP carve out can increase the limit for individual
    1450-    // transactions, but this exemption is not extended to packages in CheckPackageLimits().
    1451-    std::string err_string;
    1452+    // because it's unnecessary.
    


    instagibbs commented at 2:15 pm on May 20, 2024:
    @sr-gi I reverted the logic change here to reduce review surface, just shortening the comment here instead.
  28. instagibbs commented at 3:25 pm on May 20, 2024: member
  29. DrahtBot added the label CI failed on May 20, 2024
  30. DrahtBot removed the label CI failed on May 20, 2024
  31. in src/validation.cpp:568 in 07bb2736c1 outdated
    561@@ -555,6 +562,7 @@ class MemPoolAccept
    562               m_coins_to_uncache{coins_to_uncache},
    563               m_test_accept{test_accept},
    564               m_allow_replacement{allow_replacement},
    565+              m_allow_sibling_eviction{allow_sibling_eviction},
    566               m_package_submission{package_submission},
    567               m_package_feerates{package_feerates},
    568               m_client_maxfeerate{client_maxfeerate}
    


    glozow commented at 1:37 pm on May 21, 2024:

    07bb2736c17dd50b6ec3d4770001f8e6f0c8710a: would be good to put the sanity checks here

    0            // If we are using package feerates, we must be doing package submission.
    1            // It also means carveouts and sibling eviction are not permitted.
    2            if (m_package_feerates) {
    3                Assume(m_package_submission);
    4                Assume(!m_allow_carveouts);
    5                Assume(!m_allow_sibling_eviction);
    6            }
    7            if (m_allow_sibling_evction) Assume(m_allow_replacement);
    

    instagibbs commented at 2:14 pm on May 22, 2024:
    took, thanks
  32. glozow commented at 2:03 pm on May 21, 2024: member
    lgtm ACK 6fcd3cc016eaf07e47c5c448482ff844855a247b
  33. in src/validation.cpp:459 in 3be46d01b9 outdated
    455@@ -456,6 +456,7 @@ class MemPoolAccept
    456          * the mempool.
    457          */
    458         std::vector<COutPoint>& m_coins_to_uncache;
    459+        /** When true, the transaction or package will not be submited to the mempool. */
    


    theStack commented at 3:42 pm on May 21, 2024:

    spelling nit:

    0        /** When true, the transaction or package will not be submitted to the mempool. */
    

    instagibbs commented at 2:13 pm on May 22, 2024:
    fixed, thanks
  34. theStack approved
  35. theStack commented at 4:56 pm on May 21, 2024: contributor

    Code-review ACK 6fcd3cc016eaf07e47c5c448482ff844855a247b

    Out of curiosity, I verified that the extended carve-out functional test in 868c3e77e01df8cfdc00a7599f16d0adf019aee7 (checking testmempoolaccept and submitpackage results) would also fail on master, but in a slightly different way, as the carve out leads to a failure later (in CheckPackageLimits() vs the earlier PreChecks() for testmempoolaccept; for submitpackage the first tx succeeds, and only the second fails with "too-long-mempool-chain"):

     0diff --git a/test/functional/mempool_package_onemore.py b/test/functional/mempool_package_onemore.py
     1index 76e5ad2ff8..a6883f09fe 100755
     2--- a/test/functional/mempool_package_onemore.py
     3+++ b/test/functional/mempool_package_onemore.py
     4@@ -59,10 +59,10 @@ class MempoolPackagesTest(BitcoinTestFramework):
     5         replaceable_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=[chain[0]])
     6         txns = [replaceable_tx["tx"], self.wallet.create_self_transfer_multi(utxos_to_spend=replaceable_tx["new_utxos"])["tx"]]
     7         txns_hex = [tx.serialize().hex() for tx in txns]
     8-        assert_equal(self.nodes[0].testmempoolaccept(txns_hex)[0]["reject-reason"], "too-long-mempool-chain")
     9+        assert "package-mempool-limits" in self.nodes[0].testmempoolaccept(txns_hex)[0]["package-error"]
    10         pkg_result = self.nodes[0].submitpackage(txns_hex)
    11-        assert "too-long-mempool-chain" in pkg_result["tx-results"][txns[0].getwtxid()]["error"]
    12-        assert_equal(pkg_result["tx-results"][txns[1].getwtxid()]["error"], "bad-txns-inputs-missingorspent")
    13+        assert "error" not in pkg_result["tx-results"][txns[0].getwtxid()]
    14+        assert "too-long-mempool-chain" in pkg_result["tx-results"][txns[1].getwtxid()]["error"]
    15         # But not if it chains directly off the first transaction
    16         self.nodes[0].sendrawtransaction(replaceable_tx["hex"])
    17         # and the second chain should work just fine
    
  36. instagibbs force-pushed on May 22, 2024
  37. in src/validation.cpp:585 in a84b57462c outdated
    581+            if (m_package_feerates) {
    582+                Assume(m_package_submission);
    583+                Assume(!m_allow_carveouts);
    584+                Assume(!m_allow_sibling_eviction);
    585+            }
    586+            if (m_allow_sibling_eviction) Assume(m_allow_replacement);
    


    theStack commented at 3:10 pm on May 22, 2024:
    Kind of unrelated, and more like a “I wish my c++ skills were better” nit: I wonder if there is a way to do the introduced sanity checks already at compile-time, since these flags are all constant for each of the ATMPArgs instances (probably not, or at least not without significant changes in structure…).
  38. theStack approved
  39. theStack commented at 3:11 pm on May 22, 2024: contributor
    re-ACK a84b57462cd3dfcd059783696aacd796ef1793d4 ๐Ÿ“ฆ
  40. DrahtBot requested review from glozow on May 22, 2024
  41. in src/validation.cpp:751 in d7907ae740 outdated
    736+    CAmount m_conflicting_fees{0};
    737+    /** Total size (in virtual bytes) of mempool transactions being replaced. */
    738+    size_t m_conflicting_size{0};
    739+
    740+    /** Re-set sub-package state to not leak between evaluations */
    741+    void ClearSubPackageState() EXCLUSIVE_LOCKS_REQUIRED(cs_main, m_pool.cs)
    


    sdaftuar commented at 6:45 pm on May 22, 2024:
    Do you think it might make sense to explicitly group these variables into a single struct that makes it clear we have one grouping of per-subpackage state? All these variables that are at the same scope level as other things that don’t get reset seems maybe a bit messy…

    instagibbs commented at 7:34 pm on May 22, 2024:
    Probably worth doing now to make it more clear over time. Let me know what you think.

    sdaftuar commented at 7:43 pm on May 22, 2024:
    Seems more readable to me, thanks.

    sdaftuar commented at 12:23 pm on May 23, 2024:
    Looks like the commit message for commit 6b3373248656ef45d73262aa6dba3aec5866f7ca should be updated now, sorry!

    instagibbs commented at 12:50 pm on May 23, 2024:
    touched up the commit message
  42. sdaftuar commented at 6:52 pm on May 22, 2024: member

    utACK a84b57462cd3dfcd059783696aacd796ef1793d4

    Left one nit/question for you, but looks good to me regardless.

  43. instagibbs force-pushed on May 22, 2024
  44. instagibbs force-pushed on May 23, 2024
  45. sdaftuar commented at 1:48 pm on May 23, 2024: member
    ACK 63cfa4ce88cac26abcacf3b243916e722ab17d75
  46. DrahtBot requested review from theStack on May 23, 2024
  47. ismaelsadeeq commented at 2:22 pm on May 23, 2024: member
    re-ACK 63cfa4ce88cac26abcacf3b243916e722ab17d75
  48. theStack approved
  49. theStack commented at 2:29 pm on May 23, 2024: contributor
    re-ACK 63cfa4ce88cac26abcacf3b243916e722ab17d75
  50. in src/validation.cpp:748 in 63cfa4ce88 outdated
    747+        CAmount m_conflicting_fees{0};
    748+        /** Total size (in virtual bytes) of mempool transactions being replaced. */
    749+        size_t m_conflicting_size{0};
    750+    };
    751+
    752+    struct SubPackageState m_subpackage;
    


    glozow commented at 2:44 pm on May 23, 2024:

    Is there a reason for struct (seems like a C thing?)

    0    SubPackageState m_subpackage;
    

    instagibbs commented at 2:54 pm on May 23, 2024:
    old habits!
  51. in src/validation.cpp:1441 in 63cfa4ce88 outdated
    1437@@ -1380,6 +1438,7 @@ PackageMempoolAcceptResult MemPoolAccept::AcceptMultipleTransactions(const std::
    1438         // replacements, we don't need to track the coins spent. Note that this logic will need to be
    1439         // updated if package replace-by-fee is allowed in the future.
    1440         assert(!args.m_allow_replacement);
    1441+        assert(!m_subpackage.m_rbf);
    


    glozow commented at 2:50 pm on May 23, 2024:
    Seems this will need to be deleted immediately in the next PR?
  52. glozow commented at 2:51 pm on May 23, 2024: member
    ACK 63cfa4ce88
  53. Add description for m_test_accept 57ee3029dd
  54. Add m_allow_sibling_eviction as separate ATMPArgs flag 69f7ab05ba
  55. cpfp carveout is excluded in packages
    The behavior is not new, but this rule exits earlier than before.
    Previously, a carve out could have been granted in PreChecks() but then
    nullified in PackageMempoolChecks() when CheckPackageLimits() is called
    with the default limits.
    cbbfe719b2
  56. [refactor] make some members MemPoolAccept-wide
    No change in behavior.
    
    For single transaction acceptance, this is a simple refactor:
    Workspace::m_all_conflicting
    Workspace::m_conflicting_fees
    Workspace::m_conflicting_size
    Workspace::m_replaced_transactions
    
    are now grouped under a new SubPackageState struct that is
    a member of MemPoolAccept.
    
    And local variables m_total_vsize and m_total_modified_fees are now
    SubpackageState members so they can be accessed from
    PackageMempoolChecks.
    
    We want these to be package-wide variables because
    - Transactions could conflict with the same tx (just not the same
    prevout), or their conflicts could share descendants.
    - We want to compare conflicts with the package fee rather than
    individual transaction fee.
    
    We reset these MemPoolAccept-wide fields for each subpackage
    evaluation to not cause state leaking, similar to temporary
    coins.
    20d8936d8b
  57. Add sanity checks for various ATMPArgs booleans 2fd34ba504
  58. instagibbs force-pushed on May 23, 2024
  59. instagibbs commented at 4:11 pm on May 23, 2024: member

    sadly, forced to rebased post #29873

    Should be pretty trivial to review with something like: git range-diff master 63cfa4c 2fd34ba504957331f5a08614b6e1f8317260f04d

  60. glozow commented at 4:14 pm on May 23, 2024: member
    reACK 2fd34ba504957331f5a08614b6e1f8317260f04d via range-diff
  61. DrahtBot requested review from sdaftuar on May 23, 2024
  62. DrahtBot requested review from theStack on May 23, 2024
  63. DrahtBot requested review from ismaelsadeeq on May 23, 2024
  64. in src/validation.cpp:465 in 69f7ab05ba outdated
    461+        /** Whether we allow transactions to replace mempool transactions. If false,
    462          * any transaction spending the same inputs as a transaction in the mempool is considered
    463          * a conflict. */
    464         const bool m_allow_replacement;
    465+        /** When true, allow sibling eviction. This only occurs in single transaction package settings. */
    466+        const bool m_allow_sibling_eviction;
    


    murchandamus commented at 5:15 pm on May 23, 2024:

    I thought sibling eviction was relevant in a TRUC Transaction constellation when there already exist an unconfirmed parent and unconfirmed child, and now a newly submitted transaction is a child of the same parent, but spends a different output than the original child, i.e. not actually in conflict with the original child except for the topological restrictions affecting TRUC Transactions.

    If I got all that right, I would posit that “This only occurs in single transaction package settings.” is a bit confusing, unless Iโ€™m the only person for whom itโ€™s not obvious that “single transaction package settings” is exclusively describing the replacement transaction.


    instagibbs commented at 5:29 pm on May 23, 2024:
    “single transaction subpackage”?

    glozow commented at 9:29 am on May 24, 2024:

    “single transaction package settings” is exclusively describing the replacement transaction.

    The replacement transaction is always going to be the one we’re currently validating - maybe I’m misunderstanding what you’re saying :sweat_smile: . I agree “single transaction package” doesn’t mean much to me in this context, perhaps “disallowed when evaluating a multi-transaction subpackage or package” ?

  65. in src/validation.cpp:995 in 69f7ab05ba outdated
    988@@ -981,8 +989,11 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
    989     // check using the full ancestor set here because it's more convenient to use what we have
    990     // already calculated.
    991     if (const auto err{SingleV3Checks(ws.m_ptx, ws.m_ancestors, ws.m_conflicts, ws.m_vsize)}) {
    992-        // Disabled within package validation.
    993-        if (err->second != nullptr && args.m_allow_replacement) {
    994+        // Single transaction contexts only.
    995+        if (args.m_allow_sibling_eviction && err->second != nullptr) {
    996+            // We should only be considering where replacement is considered valid as well.
    997+            Assume(args.m_allow_replacement);
    


    sr-gi commented at 6:13 pm on May 23, 2024:

    Is there any case in which m_allow_sibling_eviction is not shadowing m_allow_replacement? All the uses I see, they have the same value, or if one is set, the other is assumed.

    Is that just the case now, and may it be different in a follow-up? Otherwise, what is the point of having two flags?


    instagibbs commented at 6:49 pm on May 23, 2024:

    glozow commented at 9:21 am on May 24, 2024:
    Will add that imo it’s much clearer to have distinct flags each controlling small pieces of logic within validation (even if one flag could cover multiple things) while the dedicated ATMPArgs constructors make decisions on what combinations of the flags are allowed.
  66. sr-gi commented at 6:36 pm on May 23, 2024: member

    utACK 2fd34ba

    Sorry it took me a while to get familiar with the validation logic. I left some non-blocking comments.

  67. theStack approved
  68. theStack commented at 10:08 pm on May 23, 2024: contributor
    re-ACK 2fd34ba504957331f5a08614b6e1f8317260f04d
  69. glozow merged this on May 24, 2024
  70. glozow closed this on May 24, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me