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

Make ProgramError compatible with pinocchio #12

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

kevinheavey
Copy link
Contributor

Problem: solana-program-error and pinocchio define ProgramError enums that are identical except for the BorshIoError variant, which looks like BorshIoError(String) in solana-program-error and is fieldless (just BorshIoError) in pinocchio.

It is going to be a significant source of grief for users to have two almost-identical ProgramError types in their dependency tree. People will accidentally import the wrong one a lot

Solution: make solana_program_error::ProgramError the same as the pinocchio one so pinocchio can replace its definition with a re-export.

Breaking changes:

  • the BorshIoError variants of ProgramError and InstructionError become fieldless. This will require a major version bump for solana-program-error, solana-instruction-error, solana-program and solana-sdk. I haven't included the version bump in the PR as it breaks compilation because of the solana-system-interface dep. This may or may not be curable with patching but is ultimately not a real problem.
  • add a num-traits feature to solana-program-error so that all functionality requiring num-traits becomes optional (pinocchio isn't using this functionality)
  • make std optional in solana-program-error as pinocchio is no-std. The only thing this affects is impl std::error::Error for ProgramError {}

Other changes:

  • Extract solana-pubkey-error and solana-instruction-error crates and use them in solana-program-error. This is so pinocchio's deps can be as light as possible
  • Make num-traits optional

@kevinheavey
Copy link
Contributor Author

CI error is as expected given the breaking change

@kevinheavey kevinheavey force-pushed the program-error-pinocchio-compat branch from f625acf to bc3494a Compare February 13, 2025 09:16
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.

1 participant