-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Return FastPayResult<ExecutionStatus> from adapter #215
Conversation
@@ -44,7 +45,11 @@ pub fn new_move_vm(natives: NativeFunctionTable) -> Result<Arc<MoveVM>, FastPayE | |||
|
|||
/// Execute `module::function<type_args>(object_args ++ pure_args)` as a call from `sender` with the given `gas_budget`. | |||
/// Execution will read from/write to the store in `state_view`. | |||
/// Returns both the execution result, and the amount of gas used (even in the case of error). | |||
/// IMPORTANT NOTES on the resturn value: |
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.
/// IMPORTANT NOTES on the resturn value: | |
/// IMPORTANT NOTES on the return value: |
/// IMPORTANT NOTES on the resturn value: | ||
/// The return value indicates whether a system error has occured (i.e. issues with the fastx system, not with user transaction). | ||
/// As long as there are no system issues we return Ok(ExecutionStatus). | ||
/// ExecutionStatus indicates the execution result. If execution faied, we wrap both the gas used and the error |
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.
/// ExecutionStatus indicates the execution result. If execution faied, we wrap both the gas used and the error | |
/// ExecutionStatus indicates the execution result. If execution failed, we wrap both the gas used and the error |
@@ -128,25 +128,26 @@ pub struct OrderInfoResponse { | |||
#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)] | |||
pub enum ExecutionStatus { | |||
Success, |
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 we should eventually plumb through the gas used here too.
fastx_types/src/messages.rs
Outdated
@@ -128,25 +128,26 @@ pub struct OrderInfoResponse { | |||
#[derive(Eq, PartialEq, Clone, Debug, Serialize, Deserialize)] | |||
pub enum ExecutionStatus { | |||
Success, | |||
Failure(Box<FastPayError>), | |||
// Gas used in the failed case, and the error. | |||
Failure(u64, Box<FastPayError>), |
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.
Rust has these fancy inline structs (I think that's what this feature is called? @huitseeker?) that are useful for this:
Failure(u64, Box<FastPayError>), | |
Failure { gas_used: u64, error: Box<FastPayError> } |
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.
"Any variant that is valid as a struct [variant] is also valid as an enum [variant]"
https://doc.rust-lang.org/rust-by-example/custom_types/enum.html
fix: broken links in files
All order execution functions now return
FastPayResult<ExecutionStatus>
. The result indicates whether there is system issue.ExecutionStatus
indicates the actual execution result. In the case ofExecutionStatus::Failure
, we also include gas used for gas charge in the fail case.