-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs #8346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/txmempool.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, does CheckInputs change state in assert in the original code (i.e. is it against our Assertions should not have side-effects rule)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know we had just a rule, is there a place where those "rules" are documented?
If we do, I suggest we change that rule to at least not apply to CValidationState.
In any case, this is not a change in this PR: there's no change in functionality here, it was doing the same before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
So, yes, it seems these asserts were not complying with that rule. Neither before not after my change.
If there's an easy fix to add here, I'm all for it.
Should I launch an exception instead ?
It doesn't seem right the way CTxMemPool::check is written...
Maybe it's enough to rename the offending state local variables to dummyState ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assign the result to a local scope bool and assert the value of the bool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah, is as simple as that. Happy to code and squash that.
|
CheckTxInputs should return true; if it is a coinbase. (agree that in theory it should not happen, but I prefer that we don't change the semantic by mistake) |
|
@NicolasDorier I'm doing that later in https://github.com/jtimon/bitcoin/commits/0.12.99-consensus , but since you refuse to review that branch...Little steps first, preparations, remember? |
|
Updated solving @paveljanik 's nit as suggested by @MarcoFalke . Didn't squashed the commit yet though. |
src/txmempool.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to move this into the smaller else {} scopes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I actually moved the state out. I thought this would be clearer. I will change it back and declare the bool twice in their smaller scopes. Reusing the bool actually takes one extra line.
|
@jtimon just saying the returns true if coinbase should be part of this commit, not later. EDIT: oh I think you were responding to the first comment I made and deleted shortly before you replied. Don't take note to what I said before, my only complain on this commit is that CheckTxInputs should returns true if it is a coinbase. |
|
I'm not sure I understand. Which return true if coinbase? |
|
CheckTxInputs should returns true if it is a coinbase. |
|
as the main::CheckInputs was doing. |
src/txmempool.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, either you should add
fCheckResult = Consensus::CheckTxInputs(tx, state, mempoolDuplicate, nSpendHeight) || tx.IsCoinbase;
Or better, CheckTxInputs should do it internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah again lost in re-write. it's even stated in the Preconditions of Consensus::CheckTxInputs in the doc I'm adding just now!
008114f to
00b4943
Compare
|
Updated with more fixes and after squashing. |
|
utACK 00b4943 |
|
utACK 00b4943 |
|
utACK 00b4943 Nice proof of work commit there :-p |
|
utACK 00b4943c2794fecf93c21d3db814ea7b2e362087 |
|
I'm not a fan of having the code in main.cpp while the header is in consensus.h. What is the plan afterwards? Will CheckTxInputs move to consesus/consensus.cpp as well? Will that mean that CCoinsViewCache (on which it depends) also moves to consensus? |
|
@sipa most likely in the future for libconsensus, we'll need to make an interface and replace CCoinsViewCache dependencies by such interface. CCoinsViewCache would stay out of consensuslib. The implementation of the interface in libconsensus will use user provided callbacks, while bitcoin core's implementation would use CCoinViewCache under the hood. |
|
@NicolasDorier I mean in the immediate future. It's not a nice state that the definition for a function is inside a module where the code can't actually move yet. |
|
@sipa ah yes, I also think so. |
|
I'd rather not move things until they can actually cleanly moved. |
|
@sipa My plan was to move it later to tx_verify as shown in #8329, but there's many other options. |
00b4943 to
a6cc299
Compare
|
Updated with the new declaration in main. |
|
utACK a6cc299 |
|
utACK a6cc299 |
|
nit: commit message typo: direclty -> directly |
|
utACK a6cc299 |
…::CheckInputs a6cc299 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs (Jorge Timón)
…er main::CheckInputs a6cc299 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs (Jorge Timón)
Overwinter SignatureHash Implements zcash/zips#129. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#6915 - Only the rework of `mempool.check()` calls that the next PR depends on. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2254. Closes #1408 and #2584.
Overwinter SignatureHash Implements zcash/zips#129. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#6915 - Only the rework of `mempool.check()` calls that the next PR depends on. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2074 and #2254. Closes #1408 and #2584.
Overwinter SignatureHash Implements ZIP 143. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2074 and #2254. Closes #1408 and #2584.
Overwinter SignatureHash Implements ZIP 143. Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7276 - bitcoin/bitcoin#7976 - bitcoin/bitcoin#8118 - bitcoin/bitcoin#8149 - Only amount validation and SignatureHash commits. - bitcoin/bitcoin#8346 - bitcoin/bitcoin#8524 Part of #2074 and #2254. Closes #1408 and #2584.
…er main::CheckInputs a6cc299 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs (Jorge Timón)
The mempool doesn't need to CheckInputs with fCheckScripts=false, it can call Consensus::CheckTxInputs() directly.
We could also remove the parameter from CheckInputs now, since all the remaining callers always pass fCheckScripts=true. But I have left for later, when/if we separate the function in two: one for libconsensus, the other for the multi-threaded validation (both called from ConnectBlock, the former also called from AcceptToMemeoryPool see jtimon@24a0999 ).
I've tried to do this several times, but usually combined with moveonly commits and more changes.
One of those times, @sipa suggested to remove the checks here instead, but I can't remember his reasoning or find a reference. I believe he changed his mind later.
Ping @NicolasDorier @kanzure