-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Make signature caching optional, and move it out. #4890
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
ef0289b
to
035a4de
Compare
@TheBlueMatt fwiw, this pull-tester false-negative is the same one we get on Travis: http://jenkins.bluematt.me/pull-tester/p4890_035a4de88b03fcdfd9e0bf747f301fcc8f1bb299/test.log So it seems it's not anything related to a specific setup. Not really worth worrying about, just pointing it out. |
@jtimon Yes indeed; this would allow #4692 to do checking without needing to depend on the cache, by using SignatureChecker() and not CachingSignatureChecker(). And you're very right: the flags passing through CheckSig and VerifySignature is ugly, as SCRIPT_VERIFY_NOCACHE shouldn't be an interpreter flag at all, as it's no longer a feature of the interpreter. I added a commit that removes that flag, and turns it into a constructor argument to CachingSignatureChecker. |
82acca7
to
4e8f7e1
Compare
Haven't verified code movements, but I like these code changes. |
bc889ef
to
078ff4a
Compare
@laanwj Would you mind verifying code movement? |
Yes I'll take a look. |
@@ -697,7 +697,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) | |||
// IsStandard() will have already returned false | |||
// and this method isn't called. | |||
vector<vector<unsigned char> > stack; | |||
if (!EvalScript(stack, tx.vin[i].scriptSig, tx, i, false)) | |||
if (!EvalScript(stack, tx.vin[i].scriptSig, false, BaseSignatureChecker())) |
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.
flags
doesn't match against signature EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker)
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.
Indeed, the false
should be 0 or SCRIPT_VERIFY_NONE, but I didn't want to touch that here.
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.
Okay, agreed, didn't notice that was the case in the original code as well.
This comment about NOCACHE script flag can also be removed: https://github.com/bitcoin/bitcoin/blob/master/src/test/transaction_tests.cpp#L34 |
@@ -342,12 +342,13 @@ class CScriptCheck | |||
const CTransaction *ptxTo; | |||
unsigned int nIn; | |||
unsigned int nFlags; | |||
bool cache; |
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 think this argument should be called cacheWrite
or cacheStore
, to make it apparent that the cache is always used, but the difference that this boolean makes is whether the result is stored.
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.
Fixed.
utACK apart from above nits, going to test this |
Addressed all nits, I think. |
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4890_c41cd3a3b2424748a701437d49f3622afd9ca5be/ for binaries and test log. |
Bleh, needs rebase after #5017 (a trivial debug message change). |
Rebased. |
utACK. Can we move this one forward? |
CHECKLOCKTIMEVERIFY patch because EvalScript() no longer receives txTo and nIn.
This will make it easier to export the script verification code to a thread-agnostic library.
By moving some of the parameters into a SignatureChecker object, some of the long argument lists are reduced.
Builds on top of (a rebased version of) #4555.