-
Notifications
You must be signed in to change notification settings - Fork 38.7k
consensus lib work: add status codes to the script interpreter and remove logging #5212
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
|
@theuni I was actually thinking not to expose the script verification flags externally, as they are implementation and policy specific, but instead have the interface define its own flags, which get translated into internal ones. |
|
I'll defer to you on that. I can nuke the top commit and save that for a separate discussion. |
src/script/types.h
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.
These two are also under BIP62 (they're also used for standardness checks outside of BIP62, but that shouldn't matter for a consensus lib).
|
With respect to the concern that callers might use the error code to decide pass/fail instead of the actual return. Why not set the error value to the unknown error at entry, so long as an error pointer is provided at all? |
src/script/interpreter.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.
Nit: can you add the error messages that you remove here as comment? ie
- if (vchPubKey.size() < 33)
+ if (vchPubKey.size() < 33) // Non-canonical public key: too short
- return error("Non-canonical public key: too short");
+ return false;We do lose some troubleshooting information here, as the error mechanism provides no way to signal warnings/details of script interpretation. But I don't see an alternative either. Maybe in the future it would be useful to add a way to get a detailed trace of execution.
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 started to add a bitmask for more detailed info in the case of ERR_EVAL_VALSE or ERR_VERIFY_*, but that ended up looking a little over-engineered and error-prone. If you think it's worth it, i can re-add that.
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.
That's not necessary for this pull
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.
But please do add the comments as suggested, so that the cases are documented and if later on we have a way to return details execution status, we can return it.
|
Looks good to me, utACK (will test) |
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.
Currently this function is unused! Shouldn't we call this function where we use EvalScript/VerifyScript, and log the message?
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.
@laanwj I didn't want to hook it up in each place, since it could be potentially much noisier than the old logging. To be close to on-par with current behavior, we could check for something like SCRIPT_ERR_SIG_DER || SCRIPT_ERR_SIG_HASHTYPE || SCRIPT_ERR_SIG_HIGH_S. Those are pretty arbitrary though.
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.
Yes, it's pretty arbitrary. But it's also strange to have a function that is called from nowhere, not even from the unit tests. But I'm fine with doing that in a later pull, and regarding this as preparation.
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.
@laanwj Yes, I'd prefer to address the logging in a later pull, as I assumed that would lead to some bikeshedding. Though I agree that it wouldn't make sense to push this without using it anywhere, so I've updated the tests to check the values.
|
@laanwj Sorry, I missed your comment (about comments) the first time around. re-added those and rebased on master. |
src/script/interpreter.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.
Isnt this unknown opcode?
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.
yes, thanks for catching that!
|
ACK commithash 4eefa373ae4866a1ad25cea3615270f58693e6a7 (+/- the incorrect error message on unknown opcode): http://bitcoin.ninja/TheBlueMatt-5212.txt |
src/script/interpreter.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.
Sorry to nit, but indentation is wrong here (and in some other places where comments are added)
|
|
@sipa Ok, thanks. If/when that happens, I'll follow-up with the more detailed values. |
|
Squashed. This is code-identical to the last push except for the comments white-space nit fix. |
…ve logging Attempt to codify the possible error statuses associated with script validation. script/types.h has been created with the expectation that it will be part of the public lib interface. The other flag enums will be moved here in a future commit. Logging has also been removed in order to drop the dependency on core.h. It can be re-added to bitcoind as-needed. This makes script verification finally free of application state and boost!
|
utACK |
219a147 script: check ScriptError values in script tests (Cory Fields) ab9edbd script: create sane error return codes for script validation and remove logging (Cory Fields)
Cleaned up version of #5188
Attempt to codify the possible error statuses associated with script
validation. The second commit (move-only) moves the other flags into the newly
created script/types.h as part of the upcoming external interface.
Logging has also been removed in order to drop the dependency on util.h. It can
be re-added to bitcoind as-needed. This makes script verification finally free
of application state and boost!