-
Notifications
You must be signed in to change notification settings - Fork 57
p-token: Add custom entrypoint #85
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
Conversation
3d74a84
to
fafdd3e
Compare
2edf20b
to
9e62a06
Compare
fafdd3e
to
8a3de38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
p-token/src/entrypoint.rs
Outdated
&& (*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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: let's use the consts for token account size / mint size / non-dup marker here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joncinque Bumped the pinocchio version, so now it is using the NON_DUP_MARKER
constant.
f300632
to
2cefb4e
Compare
809ab3d
to
6877bf1
Compare
2cefb4e
to
c68c3d3
Compare
Problem
Currently
p-token
uses 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_checked
36.33%
transfer
13.22%
close_account
12.23%
initialize_account3
9.98%
initialize_immutable_owner
9.78%
sync_native
4.53%
initialize_account
2.58%
Other instructions account for less than
1%
each.Solution
This PR adds a custom entrypoint to
p-token
that includes a "fast-path" to transfer instructions. It also modifies the current processor to give priority tosync_native
andinitialize_immutable_owner
instructions. Both modifications lead to significant improvements in CU consumption when considering the usage distribution.➡️ Credits to @cavemanloverboy for the "fast-path" approach.