validation: Pass chainparams in AcceptToMemoryPoolWorker(...) #13909

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:remove-chainparams-argument-to-AcceptToMemoryPoolWorker changing 1 files +1 −1
  1. practicalswift commented at 7:32 AM on August 8, 2018: contributor

    Remove unused CChainParams argument in AcceptToMemoryPoolWorker(...).

    After the merge of #13527 ("policy: Remove promiscuousmempoolflags") yesterday the CChainParams argument is no longer used in AcceptToMemoryPoolWorker(...).

  2. practicalswift renamed this:
    validation: Remove unused CChainParams argument to AcceptToMemoryPoolWorker(...)
    validation: Remove unused CChainParams argument in AcceptToMemoryPoolWorker(...)
    on Aug 8, 2018
  3. fanquake added the label Refactoring on Aug 8, 2018
  4. DrahtBot commented at 7:54 AM on August 8, 2018: member

    <!--e57a25ab6845829454e8d69fc972939a-->No more conflicts as of last run.

  5. domob1812 commented at 11:14 AM on August 8, 2018: contributor

    utACK fa61ddfbf54ca64c6807d9a49f661fff530fa5f1

  6. Empact commented at 6:43 PM on August 8, 2018: member

    utACK fa61ddf

  7. MarcoFalke commented at 7:23 PM on August 8, 2018: member

    Hmm, note that there was a silent merge conflict between 24980a3e40284d375ac8c19da25fa399ee883830 (replacing/removing Params()) and b5fea8d0ccc8117644a4ea11256bc531b60fd9a3 (adding Params()) in ATMP.

    I am not sure if this is the right way to solve this merge conflict.

    cc @jtimon, maybe?

  8. practicalswift commented at 11:12 PM on August 8, 2018: contributor

    @MarcoFalke Oh, a silent merge conflict - that's interesting! Could we make that less likely to happen somehow via automation?

    Could it theoretically be avoided by having say the @DrahtBot test merge with different git diff algorithms and report when one of the alternative algorithms report a merge conflict and the default algorithm does not?

  9. MarcoFalke commented at 11:18 PM on August 8, 2018: member
  10. practicalswift commented at 11:24 PM on August 8, 2018: contributor

    @MarcoFalke Got it! Thanks for clarifying!

  11. practicalswift commented at 4:14 PM on August 27, 2018: contributor

    What is the correct way to proceed here? Any advice @jtimon, @mariodian or @TheBlueMatt who touched on the silent merge conflict file? :-)

  12. MarcoFalke commented at 5:28 PM on August 27, 2018: member

    Passing them in to GetBlockScriptFlags looks like the smallest diff that still makes sense.

  13. MarcoFalke commented at 8:16 PM on September 20, 2018: member

    No activity in about a month. Closing for now. Let me know when you want to work on this again.

  14. MarcoFalke closed this on Sep 20, 2018

  15. practicalswift commented at 9:37 AM on September 21, 2018: contributor

    @MarcoFalke I'm ready. Would you mind re-opening? :-)

    Does the following patch look correct?

    diff --git a/src/validation.cpp b/src/validation.cpp
    index d55bbfb2b..f3feea510 100644
    --- a/src/validation.cpp
    +++ b/src/validation.cpp
    @@ -557,7 +557,7 @@ static bool CheckInputsFromMempoolAndCache(const CTransaction& tx, CValidationSt
         return CheckInputs(tx, state, view, true, flags, cacheSigStore, true, txdata);
     }
    
    -static bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const CTransactionRef& ptx,
    +static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool& pool, CValidationState& state, const CTransactionRef& ptx,
                                   bool* pfMissingInputs, int64_t nAcceptTime, std::list<CTransactionRef>* plTxnReplaced,
                                   bool bypass_limits, const CAmount& nAbsurdFee, std::vector<COutPoint>& coins_to_uncache, bool test_accept)
     {
    @@ -927,7 +927,7 @@ static bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state,
             // There is a similar check in CreateNewBlock() to prevent creating
             // invalid blocks (using TestBlockValidity), however allowing such
             // transactions into the mempool can be exploited as a DoS attack.
    -        unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(chainActive.Tip(), Params().GetConsensus());
    +        unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(chainActive.Tip(), chainparams.GetConsensus());
             if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, currentBlockScriptVerifyFlags, true, txdata)) {
                 return error("%s: BUG! PLEASE REPORT THIS! CheckInputs failed against latest-block but not STANDARD flags %s, %s",
                         __func__, hash.ToString(), FormatStateMessage(state));
    @@ -980,7 +980,7 @@ static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPo
                             bool bypass_limits, const CAmount nAbsurdFee, bool test_accept)
     {
         std::vector<COutPoint> coins_to_uncache;
    -    bool res = AcceptToMemoryPoolWorker(pool, state, tx, pfMissingInputs, nAcceptTime, plTxnReplaced, bypass_limits, nAbsurdFee, coins_to_uncache, test_accept);
    +    bool res = AcceptToMemoryPoolWorker(chainparams, pool, state, tx, pfMissingInputs, nAcceptTime, plTxnReplaced, bypass_limits, nAbsurdFee, coins_to_uncache, test_accept);
         if (!res) {
             for (const COutPoint& hashTx : coins_to_uncache)
                 pcoinsTip->Uncache(hashTx);
    

    The net change from this PR would then be:

    diff --git a/src/validation.cpp b/src/validation.cpp
    index fceb13585..f3feea510 100644
    --- a/src/validation.cpp
    +++ b/src/validation.cpp
    @@ -927,7 +927,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
             // There is a similar check in CreateNewBlock() to prevent creating
             // invalid blocks (using TestBlockValidity), however allowing such
             // transactions into the mempool can be exploited as a DoS attack.
    -        unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(chainActive.Tip(), Params().GetConsensus());
    +        unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(chainActive.Tip(), chainparams.GetConsensus());
             if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, currentBlockScriptVerifyFlags, true, txdata)) {
                 return error("%s: BUG! PLEASE REPORT THIS! CheckInputs failed against latest-block but not STANDARD flags %s, %s",
                         __func__, hash.ToString(), FormatStateMessage(state));
    
  16. MarcoFalke reopened this on Sep 21, 2018

  17. jtimon commented at 12:18 PM on September 24, 2018: contributor

    Concept NACK, there's uses of Params() inside the function that could use the parameter instead. Also, it calls to functions that could take CChainParams or Consensus::Params as parameter. This seems the reversal of some incomplete work I was doing to eliminate the use of the Params() global.

    I strongly disagree with the seemingly general preference of using globals over passing parameters explicitly to the functions that need them. In no other project ever I had to defend the notion that generally globals should be avoided when possible. It is disappointing to see that not only people don't want the pseudo-global Params() to disappear but people also embrace it and undo previous changes towards making it disappear. It seems the same love exists at least for global gArgs.

  18. practicalswift commented at 12:36 PM on September 24, 2018: contributor

    @jtimon I don't have any preference for globals to be sure :-) This PR tries to get rid of an unused parameter - that's all :-)

    Is the patch in #13909 (comment) in line with your suggestion?

  19. practicalswift renamed this:
    validation: Remove unused CChainParams argument in AcceptToMemoryPoolWorker(...)
    validation: Remove unused CChainParams parameter in AcceptToMemoryPoolWorker(...)
    on Sep 24, 2018
  20. MarcoFalke commented at 12:57 PM on September 24, 2018: member

    Does the following patch look correct?

    You don't need to ask for permission to fixup a change nor need to post patches in comments and ask for review. I believe in you that you can figure out from the feedback by jtimon and me what to do here.

  21. practicalswift force-pushed on Sep 24, 2018
  22. practicalswift commented at 1:02 PM on September 24, 2018: contributor

    @MarcoFalke Yes perhaps I'm too cautious sometimes :-) @MarcoFalke @jtimon Please re-review!

  23. MarcoFalke renamed this:
    validation: Remove unused CChainParams parameter in AcceptToMemoryPoolWorker(...)
    validation: Pass chainparams in AcceptToMemoryPoolWorker(...)
    on Sep 24, 2018
  24. practicalswift renamed this:
    validation: Pass chainparams in AcceptToMemoryPoolWorker(...)
    validation: Resolve silent merge conflict. Pass chainparams in AcceptToMemoryPoolWorker(...).
    on Sep 24, 2018
  25. practicalswift renamed this:
    validation: Resolve silent merge conflict. Pass chainparams in AcceptToMemoryPoolWorker(...).
    validation: Pass chainparams in AcceptToMemoryPoolWorker(...)
    on Sep 24, 2018
  26. validation: Pass chainparams in AcceptToMemoryPoolWorker(...) 97ddc6026b
  27. practicalswift force-pushed on Sep 24, 2018
  28. practicalswift closed this on Oct 19, 2018

  29. jtimon commented at 4:41 PM on October 19, 2018: contributor

    Oh, sorry, I missed this. A small change but 97ddc6026b4e14ee0bb4c5b04a7824ac0a7e23ab looks good to me, utACK

  30. MarcoFalke commented at 2:42 PM on October 20, 2018: member

    utACK 97ddc6026b4e14ee0bb4c5b04a7824ac0a7e23ab

  31. practicalswift reopened this on Oct 20, 2018

  32. practicalswift commented at 7:09 PM on October 20, 2018: contributor

    Re-opened due to indication of interest :-)

  33. MarcoFalke merged this on Oct 21, 2018
  34. MarcoFalke closed this on Oct 21, 2018

  35. MarcoFalke referenced this in commit 75795603dd on Oct 21, 2018
  36. practicalswift deleted the branch on Apr 10, 2021
  37. DrahtBot locked this on Aug 18, 2022

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: 2026-04-16 15:15 UTC

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