-
Notifications
You must be signed in to change notification settings - Fork 228
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
refactor: Improve script error #2164
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
doitian
commented
Jul 13, 2020
•
edited
Loading
edited
- Add information to help locating which script produces the error, including the first input or output index, whether it is lock or type script.
- Add extra info:
- Add the upper limit in ExceededMaximumCycles
- Add a link to the system script exit codes table for ValidationFailure
quake
previously approved these changes
Jul 17, 2020
driftluo
previously approved these changes
Jul 23, 2020
BREAKING CHANGE: this commit has changed some public interfaces in crate `ckb-script`. Some methods return `ckb_error::Error` as the error, now they return `ckb_script::ScriptError`: * `IllTransactionChecker::check` * `IllScriptChecker::check` * `TypeIdSystemScript::verify` * `TransactionScriptsVerifier::extract_script` * `TransactionScriptsVerifier::verify_single` The display message returned from script verifier looks like: ``` Script(TransactionScriptError { source: Inputs[0], cause: ExceededMaximumCycles }) ``` which was ``` Script(ScriptError(ExceededMaximumCycles)) ``` The new message shows the first input or output index of the script group that causes the error.
The limit can be applied in two different places: * Block cycles limit. This is a consensus rule. Since the block total cycles must not exceed this limit, a single transaction should not either. * Pool limit. This is a per node configuration. See option `max_tx_verify_cycles` in the config file `ckb.toml`. A node reject the transaction and stop relaying it when cycles exceed this limit. Adding the limit value can help developers to figure out which limit is currently applied upon the transaction.
Each script can define its own exit codes. Later, there may be a site can search the exit code linked to the failed script. But now we only have a table for the system scripts. This commit adds the link to the system script exit codes table in the error message..
Add the info whether the error is thrown when running lock or type script. It resolves the issue mentioned in #2049 (comment)
``` error: redundant field names in struct initialization --> script/src/types.rs:20:13 | 20 | group_type: group_type, | ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `group_type` | = note: `-D clippy::redundant-field-names` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names error: this `else { if .. }` block can be collapsed --> script/src/error.rs:49:16 | 49 | } else { | ________________^ 50 | | if let Some(n) = script_group.output_indices.first() { 51 | | TransactionScriptErrorSource::Outputs(*n, script_group.group_type) 52 | | } else { 53 | | TransactionScriptErrorSource::Unknown 54 | | } 55 | | } | |_________^ | = note: `-D clippy::collapsible-if` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if help: try | 49 | } else if let Some(n) = script_group.output_indices.first() { 50 | TransactionScriptErrorSource::Outputs(*n, script_group.group_type) 51 | } else { 52 | TransactionScriptErrorSource::Unknown 53 | } error: this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) --> script/src/verify.rs:331:28 | 331 | script_group_type: &ScriptGroupType, | ^^^^^^^^^^^^^^^^ help: consider passing by value instead: `ScriptGroupType` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref error: identical conversion --> script/src/verify.rs:408:17 | 408 | Err(ScriptError::ValidationFailure(code).into()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `ScriptError::ValidationFailure(code)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#identity_conversion | ```
Resolved conflicts with the data loader traits changes. |
quake
approved these changes
Jul 31, 2020
zhangsoledad
approved these changes
Aug 3, 2020
bors r=quake,zhangsoledad |
Build succeeded:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.