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

program: map pubkey err to customs #45

Merged
merged 1 commit into from
Nov 13, 2024
Merged

program: map pubkey err to customs #45

merged 1 commit into from
Nov 13, 2024

Conversation

buffalojoec
Copy link
Contributor

Problem

I don't really like this change, but I'm putting it up here for discussion.

In the SDK, PubkeyError can be mapped to ProgramError, but not InstructionError. That means the builtin will throw custom error codes when Pubkey::create_program_address fails, but the BPF version will throw a proper ProgramError.

Summary of Changes

Put some awful indirection into the processor to map PubkeyError to custom error codes, just like the builtin.

@joncinque
Copy link
Contributor

Sorry, I'm not sure I understand the motivation for this change. I'm assuming it comes from ensuring compatibility with the differential fuzzer, but then you'll need to special-case these errors in the fuzzer, correct? Does this mean that the BPF version of this program will return different errors from the builtin version no matter what? In that case, why don't we just change the fuzzer rather than changing the program?

@buffalojoec
Copy link
Contributor Author

Sorry, I'm not sure I understand the motivation for this change. I'm assuming it comes from ensuring compatibility with the differential fuzzer, but then you'll need to special-case these errors in the fuzzer, correct? Does this mean that the BPF version of this program will return different errors from the builtin version no matter what? In that case, why don't we just change the fuzzer rather than changing the program?

What I meant to lay out here was that, since PubkeyError from Pubkey::create_program_address can't be mapped to a InstructionError variant, in the builtin it throws a custom error (defaults to InstructionError::Custom). In the BPF program, PubkeyError maps to ProgramError, therefore it won't be custom but rather an actual ProgramError.

It's not really a sensible change beyond just aligning error codes with what the builtin was throwing at the Pubkey::create_program_address callsite.

The alternative is we can just skip fixtures that provide a bad bump seed to CreateLookupTable.

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Ah gotcha, if this aligns the bpf program errors with the builtin program errors, then it makes sense. Thanks for the explanation!

@buffalojoec buffalojoec merged commit 82af5f8 into main Nov 13, 2024
9 checks passed
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.

2 participants