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

feat(types): Enable failable conversions to/from sdk and core types #4871

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jkrvivian
Copy link
Contributor

@jkrvivian jkrvivian commented Jan 17, 2025

Description of change

Merging upstream changes: MystenLabs/sui#19414
This one is needed for the next fix: #4687

Avoid panicking in sdk/core conversion by replacing From to TryFrom and introduce the new error type SdkTypeConversionError.

Links to any relevant issues

Close #4776

Type of change

  • Enhancement

Change checklist

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

@jkrvivian jkrvivian requested review from a team as code owners January 17, 2025 08:41
Copy link

vercel bot commented Jan 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
apps-backend ❌ Failed (Inspect) Jan 20, 2025 7:24am
apps-ui-kit ❌ Failed (Inspect) Jan 20, 2025 7:24am
rebased-explorer ❌ Failed (Inspect) Jan 20, 2025 7:24am
wallet-dashboard ❌ Failed (Inspect) Jan 20, 2025 7:24am

Copy link
Contributor

@DaughterOfMars DaughterOfMars left a comment

Choose a reason for hiding this comment

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

So, I don't think we should do this. These types should be infallibly convertible. The only things that aren't right now are the Identifier and signatures and those are only because there are no functions defined to do it because this behavior isn't part of their public API. However, those conversions are still infallible as the types are represented the same. This introduces a lot of unnecessary complexity IMO for no gain.

However, please tell me if there is a reason I am missing!

@jkrvivian
Copy link
Contributor Author

So, I don't think we should do this. These types should be infallibly convertible. The only things that aren't right now are the Identifier and signatures and those are only because there are no functions defined to do it because this behavior isn't part of their public API. However, those conversions are still infallible as the types are represented the same. This introduces a lot of unnecessary complexity IMO for no gain.

However, please tell me if there is a reason I am missing!

I totally understand your perspective, but here’s why we believe this change is still worthwhile:

  1. Technical Debt and Alignment with Sui

    This change helps address technical debt, reducing future maintenance challenges. It also aligns with Sui’s updates. It’s possible Sui encountered bugs that led to this fix, even if they didn’t explicitly state the reasons in the PR description. Following their changes, particularly in error handling and bug fixes, could help prevent potential issues in the future.

  2. Error Handling and Future-Proofing

    Adopting try_from enhances extensibility and prepares the codebase for unforeseen requirements, saving effort in the long term.

@muXxer
Copy link
Contributor

muXxer commented Jan 20, 2025

It is about users being able to feed bad data. That's the reason sui did this IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-protocol node Issues related to the Core Node team
Projects
None yet
4 participants