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

[Transfer App] Return Result instead of boolean for is_send_enabled and is_receive_enabled‍‍ methods #508

Closed
Farhad-Shabani opened this issue Mar 8, 2023 · 2 comments · Fixed by #516
Assignees
Labels
A: breaking Admin: breaking change that may impact operators O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding O: reliability Objective: cause to improve trustworthiness and consistent performing S: errors Scope: related to error handlings
Milestone

Comments

@Farhad-Shabani
Copy link
Member

Problem Definition

The is_send_enabled and is_receive_enabled methods under the TokenTransferValidationContext return a boolean value whose sole purpose is to propagate errors. This violates Rust's error-handling convention of using the Result type for error reporting.
This implementation was suitable as long as no specific error reporting was required, but it can become an issue as our codebase grow and require more detailed error reporting.

@Farhad-Shabani Farhad-Shabani added A: breaking Admin: breaking change that may impact operators O: reliability Objective: cause to improve trustworthiness and consistent performing S: errors Scope: related to error handlings O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding labels Mar 8, 2023
@plafer
Copy link
Contributor

plafer commented Mar 8, 2023

whose sole purpose is to propagate errors.

can you expand on that? IMO, the purpose is to fail the transfer if for any reason the hosts wants to freeze transfers. In other words, it's sort of a "kill switch" on transfers.

@Farhad-Shabani
Copy link
Member Author

can you expand on that? IMO, the purpose is to fail the transfer if for any reason the hosts want to freeze transfers. In other words, it's sort of a "kill switch" on transfers.

Indeed, it is. What I meant:

  • It's actually uncommon to use a boolean as a return type instead of Result to handle failures. In our case, we return a boolean and just afterward use it to handle failures. Why not just fail right away?
  • Also, this way implementors have more control over the message of propagated error and can keep it consistent with their own project

@Farhad-Shabani Farhad-Shabani moved this to 🏗️ In Progress in ibc-rs Mar 9, 2023
@Farhad-Shabani Farhad-Shabani added this to the v0.32.0 milestone Mar 9, 2023
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Done in ibc-rs Mar 9, 2023
@Farhad-Shabani Farhad-Shabani self-assigned this Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: breaking Admin: breaking change that may impact operators O: maintainability Objective: cause to ease modification, fault corrections and improve code understanding O: reliability Objective: cause to improve trustworthiness and consistent performing S: errors Scope: related to error handlings
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants