Skip to content

p-token: Fix error codes #52

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

Merged
merged 14 commits into from
May 5, 2025
Merged

p-token: Fix error codes #52

merged 14 commits into from
May 5, 2025

Conversation

febo
Copy link
Contributor

@febo febo commented Apr 18, 2025

Problem

Fuzzing p-token has revealed mismatches in the error codes returned by p-token compared to spl-token implementation.

Solution

Fix the mismatches. In some cases, extra validation on the account data was needed to replicate the same error code.

@febo febo requested review from joncinque and buffalojoec April 18, 2025 08:54
Copy link
Contributor

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Good looks, but I think we have a deeper problem when it comes to mismatching. As I mentioned in a few comments, since P-Token is storing primitives and using fallible on-demand deserialization, it will probably fail on different invalid account states than when SPL-Token would.

For example, if a malformed Mint gets passed to SPL-Token, it's going to throw at Mint::unpack for a whole range of invalid fields. On P-Token, some invalid state fields may not be caught until they are queried.

Some of these things may not be realistic test scenarios, and we can consider that fact, but it's going to make it hard to differentially fuzz these programs if we're too divergent in that respect.

@febo febo force-pushed the febo/fix-error-codes branch from eadc3ae to e3eee9e Compare April 22, 2025 20:55
@febo febo force-pushed the febo/fix-error-codes branch from eb26717 to df7e7c3 Compare April 25, 2025 14:41
@febo febo marked this pull request as ready for review May 1, 2025 13:48
@febo febo requested a review from buffalojoec May 1, 2025 13:49
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.

Looks good to me overall! Just a few little things

@febo febo requested a review from joncinque May 2, 2025 10:56
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.

Looks great to me!

@febo febo merged commit 4c3fabd into main May 5, 2025
15 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.

3 participants