validation: Pass chainparams in AcceptToMemoryPoolWorker(...)#13909
Conversation
| No more conflicts as of last run. |
|
utACK fa61ddfbf54ca64c6807d9a49f661fff530fa5f1 |
|
utACK fa61ddf |
|
@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? |
|
I doubt it, since they are in completely different lines. |
|
@MarcoFalke Got it! Thanks for clarifying! |
|
What is the correct way to proceed here? Any advice @jtimon, @mariodian or @TheBlueMatt who touched on the silent merge conflict file? :-) |
|
Passing them in to |
|
No activity in about a month. Closing for now. Let me know when you want to work on this again. |
|
@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)); |
|
Concept NACK, there's uses of Params() inside the function that could use the parameter instead. 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. |
|
@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? |
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. |
fa61ddf to
3f1f3bc
Compare
|
@MarcoFalke Yes perhaps I'm too cautious sometimes :-) @MarcoFalke @jtimon Please re-review! |
3f1f3bc to
97ddc60
Compare
|
Oh, sorry, I missed this. A small change but 97ddc60 looks good to me, utACK |
|
utACK 97ddc60 |
|
Re-opened due to indication of interest :-) |
…r(...) 97ddc60 validation: Pass chainparams in AcceptToMemoryPoolWorker(...) (practicalswift) Pull request description: Remove unused `CChainParams` argument in `AcceptToMemoryPoolWorker(...)`. After the merge of #13527 ("policy: Remove promiscuousmempoolflags") yesterday the `CChainParams` argument is no longer used in `AcceptToMemoryPoolWorker(...)`. Tree-SHA512: f1bab4498b64f0ab5230b8172f860df8fa8a302e4ee7385be4ba9c65a37cbc3ef640df78348c477169b9414e5c6a160a0b6471a11f4bb27921500ec208ef5340
Remove unused
CChainParamsargument inAcceptToMemoryPoolWorker(...).After the merge of #13527 ("policy: Remove promiscuousmempoolflags") yesterday the
CChainParamsargument is no longer used inAcceptToMemoryPoolWorker(...).