p-token: Add custom entrypoint#85
Merged
Merged
Conversation
3d74a84 to
fafdd3e
Compare
2edf20b to
9e62a06
Compare
fafdd3e to
8a3de38
Compare
joncinque
approved these changes
Sep 2, 2025
Contributor
joncinque
left a comment
There was a problem hiding this comment.
No show-stoppers from my side! I didn't calculate all of the consts myself to check, but the overall logic looks good to me.
Comment on lines
+110
to
+115
| && (*input.add(ACCOUNT1_DATA_LEN).cast::<u64>() == 165) | ||
| && (*input.add(ACCOUNT2_HEADER_OFFSET) == 255) | ||
| && (*input.add(ACCOUNT2_DATA_LEN).cast::<u64>() == 82) | ||
| && (*input.add(IX12_ACCOUNT3_HEADER_OFFSET) == 255) | ||
| && (*input.add(IX12_ACCOUNT3_DATA_LEN).cast::<u64>() == 165) | ||
| && (*input.add(IX12_ACCOUNT4_HEADER_OFFSET) == 255) |
Contributor
There was a problem hiding this comment.
nit: let's use the consts for token account size / mint size / non-dup marker here
Contributor
Author
There was a problem hiding this comment.
We need the non-dup constant to be public in pinocchio, which will be in the next patch release. Not use whether to wait for that or make this change in a separate PR.
Contributor
Author
There was a problem hiding this comment.
@joncinque Bumped the pinocchio version, so now it is using the NON_DUP_MARKER constant.
joncinque
approved these changes
Sep 12, 2025
f300632 to
2cefb4e
Compare
joncinque
previously approved these changes
Sep 15, 2025
809ab3d to
6877bf1
Compare
2cefb4e to
c68c3d3
Compare
joncinque
approved these changes
Sep 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently
p-tokenuses the "generic" entrypoint. There is an opportunity to give priority to most used instruction to further save CUs. Looking at token instructions from a period of one month, the most used instructions are:transfer_checked36.33%transfer13.22%close_account12.23%initialize_account39.98%initialize_immutable_owner9.78%sync_native4.53%initialize_account2.58%Other instructions account for less than
1%each.Solution
This PR adds a custom entrypoint to
p-tokenthat includes a "fast-path" to transfer instructions. It also modifies the current processor to give priority tosync_nativeandinitialize_immutable_ownerinstructions. Both modifications lead to significant improvements in CU consumption when considering the usage distribution.➡️ Credits to @cavemanloverboy for the "fast-path" approach.