Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Limiting result of the execution to execution-specific errors #1071

Merged
merged 5 commits into from
May 14, 2016

Conversation

NikVolf
Copy link
Contributor

@NikVolf NikVolf commented May 11, 2016

Before this refactoring api calling parity should have an idea, what kind of errors it should or should not handle, because fn call/fn transact returned the most broad error type combined from erros of several crates (including some external ones)

After refactoring it should return error type designed specifically to the execution logic (or initial condition), and calling party has a complete number of errors it can possibly encounter in the single enum ExecitionResult

@NikVolf NikVolf added the A0-pleasereview 🤓 Pull request needs code review. label May 11, 2016
let sender = try!(t.sender());
let sender = try!(t.sender().map_err(|e| {
warn!(target: "evm", "Transaction mallformed: {:?}", e);
ExecutionError::TransactionMallformed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to wrap the original error inside TransactionMalformed? Maybe at least a string representation of the error to have some more details?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just thought about this as well, thanx

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And by implementing From trait you should be able to get rid of map_err functions (unless we want to print warning here - altough it could also be a side effect in From::from implementation (not sure if it's a good practice though))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well perhaps from "pattern" should not be used here, because conversion of generic error into concrete error of the function is not one-to-one in general (unlike when you transform in the opposite direction), this is just one case here

@@ -439,7 +439,10 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
};
// that's just a copy of the state.
let mut state = self.state();
let sender = try!(t.sender());
let sender = try!(t.sender().map_err(|e| {
let message = format!("Transaction mallformed: {:?}", e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling, "Malformed transaction"

@arkpar arkpar added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels May 12, 2016
@NikVolf
Copy link
Contributor Author

NikVolf commented May 12, 2016

There were previous "mallformed" all around the source )

@NikVolf NikVolf added A8-looksgood 🦄 Pull request is reviewed well. A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. A8-looksgood 🦄 Pull request is reviewed well. labels May 12, 2016
@@ -59,7 +59,9 @@ pub enum ExecutionError {
got: U512
},
/// Returned when internal evm error occurs.
Internal
Internal,
/// Returned when generic transaction occurs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generic transaction error occurs.

@gavofyork gavofyork added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels May 14, 2016
@gavofyork gavofyork merged commit 354ac7d into master May 14, 2016
@gavofyork gavofyork deleted the error-refact branch May 14, 2016 12:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants