-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Remove unused fScriptChecks parameter from CheckInputs #13868
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
b161464
to
1d7cc70
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
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.
utACK 1d7cc70.
Recommend reviewing with git show --ignore-all-space
Also view with&w=1
.
@practicalswift @TheBlueMatt deserves the credit. :) |
1d7cc70
to
7b471ea
Compare
Rebased for #13527 |
7b471ea
to
852c7aa
Compare
Rebased for #13083 |
852c7aa
to
b5f7e32
Compare
Rebased for #14908, updated to single line coinbase check. |
Concept ACK, but this removes the quite useful comment about how assume valid works:
Perhaps you can incorporate that information after the line: Line 1850 in 169dced
|
099f32e
to
d99bb14
Compare
d99bb14
to
dab9e84
Compare
Rebased and I split the coinbase change into another commit. Once again: https://github.com/bitcoin/bitcoin/pull/13868/files?w=1 |
Fails tx_validationcache_tests/checkinputs_test (both on travis and locally) |
dab9e84
to
195dfcf
Compare
8fed5a1
to
5b99467
Compare
Rebased, and squashed the minor coinbase change. |
utACK 5b99467 |
@TheBlueMatt @BugTheBlueMatt want to take a look here given it's your change. |
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.
Concept ACK.
fScriptChecks = false just short-circuits the entire function, so passing it in is entirely useless.
5b99467
to
9b92538
Compare
@TheBlueMatt thanks for pointing that out. Comment moved to |
utACK 9b92538. Checked diff had no functional change and new comment copy looks correct. |
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.
ACK 9b92538 - Notes / testing below.
CheckInputs() is called from:
-
CheckInputsFromMempoolAndCache() - fScriptChecks was true
-
AcceptToMemoryPoolWorker() - 3 times and fScriptChecks was always true
-
CChainState::ConnectBlock() - fScriptChecks is true unless
- we have an assumeValid hash and
- GetBlockProofEquivalentTime() is <= 1’209’600 seconds ( 2 weeks)
Changes to CheckInputs()
:
- Drop the
fScriptChecks
parameter. IsCoinBase()
check is now clearer. i.e
if (!tx.IsCoinBase()) {
// do input checking
}
return true
is now:
if (tx.IsCoinBase()) return true;
// do input checking
return true
- Brackets around the
pvChecks
check. - Moved the "The first loop above does.." comment to
AcceptToMemoryPoolWorker
. - Moved "Skip script verification.." to
ConnectBlock
.
Added some logging and tested:
- Given a garbage
-assumevalid=garbage
hash fScriptChecks was true (early IBD). - Modified CheckInputs() to return false - checked that we drop into the ConnectBlock error.
- Modified CheckInputs() to return false and ran with
-assumevalid=garbage
- checked that we drop into the ConnectBlock error.
Other thought. It looks like everywhere we call CheckInputs()
we are already checking prior that the tx is not a coinbase. Although I cannot see a downside to a belt-and-suspenders check inside CheckInputs()
.
@jnewbery can you re-review here?
ACK 9b92538 Verified that function does essentially nothing if the flag is false. |
ACK 9b92538 ; code review, checked tests work. Looks right to me, and fanquake's notes make sense. Could change the coinbase early exit to |
I think that can be discussed / done in a follow up. We've got ACKs, so I'm merging this. Thanks to those of you that I harassed for review for following up. Post-merge ACKs still welcome. |
9b92538 Remove unused fScriptChecks parameter from CheckInputs (Matt Corallo) Pull request description: fScriptChecks = false just short-circuits the entire function, so passing it in is entirely useless. This is extracted from #13233 /cc TheBlueMatt. Recommend reviewing with `git show --ignore-all-space`, i.e.: https://github.com/bitcoin/bitcoin/pull/13868/files?w=1 ACKs for top commit: TheBlueMatt: utACK 9b92538. Checked diff had no functional change and new comment copy looks correct. kallewoof: ACK 9b92538 ajtowns: ACK 9b92538 ; code review, checked tests work. Looks right to me, and fanquake's notes make sense. Could change the coinbase early exit to `assert(!tx.IsCoinBase());`. fanquake: ACK 9b92538 - Notes / testing below. Tree-SHA512: add253a3e8cf4b33eddbc49efcec333c14b5ea61c7d34e43230351d40cff6adc919a75b91c72c4de8647a395284db74a61639f4c67848d4b2fec3a705b557790
Posthumous ACK 9b92538 |
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.
post-merge ACK 9b92538 with one comment nit.
@@ -773,15 +773,17 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool | |||
constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS; | |||
|
|||
// Check against previous transactions | |||
// This is done last to help prevent CPU exhaustion denial-of-service attacks. | |||
// The first loop above does all the inexpensive checks. |
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.
This is a really confusing comment here. "The first loop" refers to the checks inside CheckTxInputs()
call on L566, which has been moved around since the comment was first written.
I'll fix this comment in a follow-up PR.
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.
Being addressed in #16658.
…Inputs 9b92538 Remove unused fScriptChecks parameter from CheckInputs (Matt Corallo) Pull request description: fScriptChecks = false just short-circuits the entire function, so passing it in is entirely useless. This is extracted from bitcoin#13233 /cc TheBlueMatt. Recommend reviewing with `git show --ignore-all-space`, i.e.: https://github.com/bitcoin/bitcoin/pull/13868/files?w=1 ACKs for top commit: TheBlueMatt: utACK 9b92538. Checked diff had no functional change and new comment copy looks correct. kallewoof: ACK 9b92538 ajtowns: ACK 9b92538 ; code review, checked tests work. Looks right to me, and fanquake's notes make sense. Could change the coinbase early exit to `assert(!tx.IsCoinBase());`. fanquake: ACK 9b92538 - Notes / testing below. Tree-SHA512: add253a3e8cf4b33eddbc49efcec333c14b5ea61c7d34e43230351d40cff6adc919a75b91c72c4de8647a395284db74a61639f4c67848d4b2fec3a705b557790
Summary: Remove unused fScriptChecks parameter from CheckInputs (Matt Corallo) Pull request description: fScriptChecks = false just short-circuits the entire function, so passing it in is entirely useless. This is extracted from #13233 /cc TheBlueMatt. Recommend reviewing with `git show --ignore-all-space`, i.e.: https://github.com/bitcoin/bitcoin/pull/13868/files?w=1 --- Backport of Core [[bitcoin/bitcoin#13868 | PR13868]] Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7628
fScriptChecks = false just short-circuits the entire function, so
passing it in is entirely useless.
This is extracted from #13233 /cc TheBlueMatt.
Recommend reviewing with
git show --ignore-all-space
, i.e.:https://github.com/bitcoin/bitcoin/pull/13868/files?w=1