Skip to content
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

Merged
merged 1 commit into from
Jan 21, 2022
Merged

Return FastPayResult<ExecutionStatus> from adapter #215

merged 1 commit into from
Jan 21, 2022

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Jan 20, 2022

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 of ExecutionStatus::Failure, we also include gas used for gas charge in the fail case.

@@ -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:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// 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,
Copy link
Collaborator

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.

@@ -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>),
Copy link
Collaborator

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:

Suggested change
Failure(u64, Box<FastPayError>),
Failure { gas_used: u64, error: Box<FastPayError> }

Copy link
Contributor

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

@lxfind lxfind merged commit a4936b0 into MystenLabs:main Jan 21, 2022
mwtian pushed a commit that referenced this pull request Sep 12, 2022
fix: broken links in files
mwtian pushed a commit to mwtian/sui that referenced this pull request Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants