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

refactor(runtime): change system_program error to enum #618

Merged
merged 2 commits into from
Mar 17, 2025

Conversation

yewman
Copy link
Contributor

@yewman yewman commented Mar 17, 2025

Native program errors should be enums, or implement a mapError method to map the error to the correct int according to Agave's analogous enum definition. If try semantics are required, using a map function with a switch may be the best option. Otherwise an enum is simpler.

@yewman yewman requested a review from Rexicon226 March 17, 2025 17:53
@yewman yewman marked this pull request as draft March 17, 2025 18:01
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 37.50000% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/runtime/program/system_program/execute.zig 0.00% 10 Missing ⚠️
Files with missing lines Coverage Δ
src/runtime/pubkey_utils.zig 91.22% <100.00%> (+1.03%) ⬆️
src/runtime/program/system_program/execute.zig 86.01% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yewman yewman marked this pull request as ready for review March 17, 2025 18:15
Rexicon226
Rexicon226 previously approved these changes Mar 17, 2025
Copy link
Contributor

@Rexicon226 Rexicon226 left a comment

Choose a reason for hiding this comment

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

We can merge without full test coverage, as those areas require a lot of boilerplate to hit. Will revisit later to improve.

issue: https://github.com/orgs/Syndica/projects/2/views/10?pane=issue&itemId=96044650&issue=Syndica%7Csig%7C528

@yewman yewman added this pull request to the merge queue Mar 17, 2025
Merged via the queue into main with commit d234fbc Mar 17, 2025
16 of 17 checks passed
@yewman yewman deleted the harnew/system-program-error branch March 17, 2025 21:20
@@ -1,5 +1,5 @@
/// [agave] https://github.com/solana-program/system/blob/6185b40460c3e7bf8badf46626c60f4e246eb422/interface/src/error.rs#L12
pub const Error = error{
pub const Error = enum(u8) {
/// An account with the same address already exists.
AccountAlreadyInUse,
Copy link
Contributor

Choose a reason for hiding this comment

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

With the switch to enum, I think the variants should now be snake_case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants