feat(token): add p-token (SIMD-0266) and missing SPL Token instructions#366
feat(token): add p-token (SIMD-0266) and missing SPL Token instructions#366hxuan190 wants to merge 3 commits into
Conversation
332a19a to
133fb4c
Compare
Add support for 7 missing token instructions to the SPL Token program: Instructions 21-24 (existing on-chain, missing from solana-go): - GetAccountDataSize (ID 21) - InitializeImmutableOwner (ID 22) - AmountToUiAmount (ID 23) - UiAmountToAmount (ID 24) P-token exclusive instructions (SIMD-0266 / Pinocchio): - WithdrawExcessLamports (ID 38) - UnwrapLamports (ID 45) - Batch (ID 255) Updated instructions.go with new constants, InstructionIDToName entries, extended InstructionImplDef for IDs 0-24, and added pTokenInstructionMap with custom DecodeInstruction dispatch for non-contiguous p-token IDs. Verified on Solana testnet (SIMD-0266 feature gate activated at slot 396236256, address ptokFjwyJtrwCa9Kgo9xoDS59V4QccBGEaRFnRPnSdP): Simulation tests (IDs 20-24): - InitializeMint2: 364 CUs - GetAccountDataSize: 179 CUs - AmountToUiAmount: 615 CUs - UiAmountToAmount: 589 CUs Send+confirm tests (p-token exclusive): - WithdrawExcessLamports (ID 38): 3C9iNnUPPaqRCA1RSD5tXDpD7ZW72VQYsKYm1j3voEYcH4UCfzKURan63Df2jdfX3gzPzEHZDu6eFfnTf2K4H98d - UnwrapLamports partial (ID 45): zPrV9K6wLqnES4RBDAQs15S8MgvC48QjsLZAmPoimvY6vmQkh8yi3XBJYqQBkpo28HpiNdhuPL3N65Dqf1ovhWn - UnwrapLamports all (ID 45): 5VVDC6PeWo5sAAUhbc3xRRiZDMo1t5Y6c1VDktBqLLhXZtri1HshL9y7TmEu9BBZEpiQCdAmULazfNjTfeHd5ujH - Batch with 2 transfers (ID 255): 2y1jC5rXbQvvym1bM5ukRcQfiovUQPi4fbcryixXpjTe5fc2UDGvvgurZqLNx7DEYd7NHHwEnEt6oPX4anV9kXnh All 68 tests pass (30 existing + 38 new), zero regressions. Made-with: Cursor
133fb4c to
4fbf100
Compare
|
This feature is live on mainnet & made some test on devnet with test keypair |
sonicfromnewyoke
left a comment
There was a problem hiding this comment.
Overall looks good, left some comments after addressing them and adding some tests it will be nice to add it
There was a problem hiding this comment.
this instruction delivesr their result via sol_get_return_data
There was a problem hiding this comment.
this instruction delivesr their result via sol_get_return_data
There was a problem hiding this comment.
this instruction delivesr their result via sol_get_return_data
|
@sonicfromnewyoke can you tell me more information about your review? confused a little bit |
sorry, my inline notes were too terse... i meant the next one: there is no Go-side helper for the return-data instructions. Marked ixns deliver their result via
also, the novel logic has no test, for example round-trip fuzz tests for Batc missing - the file only asserts ID constants despite comments above, this is a solid PR overall 💪 |
| }) | ||
| } | ||
|
|
||
| func (obj Batch) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { |
There was a problem hiding this comment.
Batch.MarshalWithEncoder silently truncates if a sub-instruction has > 255 accounts or > 255 bytes of data — please return an explicit error.
Add support for 7 missing token instructions to the SPL Token program:
Instructions 21-24 (existing on-chain, missing from solana-go):
P-token exclusive instructions (SIMD-0266 / Pinocchio):
Updated instructions.go with new constants, InstructionIDToName entries, extended InstructionImplDef for IDs 0-24, and added pTokenInstructionMap with custom DecodeInstruction dispatch for non-contiguous p-token IDs.
Verified on Solana testnet (SIMD-0266 feature gate activated at slot 396236256, address ptokFjwyJtrwCa9Kgo9xoDS59V4QccBGEaRFnRPnSdP):
Simulation tests (IDs 20-24):
Send+confirm tests (p-token exclusive):