add pinocchio create-token example#599
Conversation
6e08f7a to
e995793
Compare
Greptile SummaryThis PR adds a Pinocchio implementation of the
Confidence Score: 5/5Safe to merge — the Metaplex CPI wire format, account ordering, and Borsh serialization are all correct, and the bankrun test exercises both the fungible and NFT creation paths against the actual mainnet program binary. The hand-rolled Metaplex serialization (discriminator 33, DataV2 layout, is_mutable, collection_details) matches the on-chain spec. The alloc-free, fixed-buffer design is sound: every write is bounds-checked before advancing the offset, and the buffer is sized to the exact Metaplex field maxima. No correctness issues were found. No files require special attention. Important Files Changed
Reviews (6): Last reviewed commit: "create-token pinocchio: move Metaplex he..." | Re-trigger Greptile |
e995793 to
ac589b7
Compare
|
@Perelyn-sama @dev-jodee — rebased onto latest main (picks up the ASM sbpf/Solana pin from #625), CI is now fully green. Ready for review whenever you have a chance 🙏 |
dev-jodee
left a comment
There was a problem hiding this comment.
thanks for the work, couple of comments !
|
@dev-jodee thanks for the review! Pushed a commit addressing all five points:
Ready for another look when you have a moment. |
dev-jodee
left a comment
There was a problem hiding this comment.
Thanks for the fixes ! just a couple more :)
|
@dev-jodee thanks for the second pass! Pushed 2027b84:
Rebuilt with cargo build-sbf + bankrun (2 passing), fmt/clippy clean. |
|
lgtm, just realized commits aren't signed :') so can't merge it, can you re-sign the commits ? will merge after thanks |
- prepare.mjs: dump program via 'solana program dump -um' instead of mutating the user's Solana CLI config - reuse pinocchio_token Mint::LEN instead of a hand-rolled MINT_SIZE const - move CreateTokenArgs into create_token.rs (ix-specific) and the borsh string helpers into a util module; slim mod.rs to module wiring - tests: run async bankrun setup in a before() hook so the it() blocks actually register (a describe callback runs synchronously)
…g tests The tests were previously registered inside an async describe callback, so mocha ran 0 of them and CI passed without ever executing the program. With the before() hook they actually run — and surfaced a real failure: Program log: Instruction: CreateToken failed: unsupported BPF instruction Root cause: Rent::try_minimum_balance() takes a floating-point path for the exemption threshold (an f64), which the current platform-tools lower to a float instruction the solana-bankrun VM rejects. Compute the rent-exempt minimum with integer math using pinocchio's default rent constants instead (DEFAULT_LAMPORTS_PER_BYTE already folds in the 2-year threshold). While here, make the program alloc-free: build the Metaplex instruction data in a fixed stack buffer and switch to program_entrypoint! + no_allocator!, matching the other pinocchio examples. Verified with cargo build-sbf (Solana 4.1.1 / platform-tools v1.54) + the bankrun test: both cases pass.
Address review feedback: the Metaplex Token Metadata program ID, the CreateMetadataAccountV3 discriminator, the metadata-data size bound, and the instruction-data builder now live in util_metaplex.rs, keeping create_token.rs focused on the account/CPI flow.
2027b84 to
b83e6b8
Compare
|
@dev-jodee the branch is now re-signed — all commits show as Verified on GitHub. Ready to merge whenever you get a chance. Thanks! |
|
thanks for the work @MarkFeder |
Move the async bankrun setup out of the `describe` callback and into a
`before` hook so Mocha collects the `it` block (an async `describe` body
registers tests after the suite is already collected, so nothing ran).
With the test now executing, replace `Rent::try_minimum_balance` with the
integer rent formula: its floating-point exemption-threshold path emits an
opcode the bankrun VM rejects ("unsupported BPF instruction"). Matches the
create-token example (solana-foundation#599).
Adds a Pinocchio implementation of
tokens/create-token, continuing the Pinocchio token-examples lane aftertransfer-tokens(#596) andescrow(#598).What it does
Creates an SPL Token mint and attaches an on-chain Metaplex metadata account (name, symbol, URI) — the same flow as the existing
anchorandnativeoptions.Notes
CreateMetadataAccountV3CPI is built by hand (rawInstructionView/cpi::invoke), matching the on-chain wire format.[name, symbol, uri, decimals], identical to thenativeexample's wire format.token_metadata.sofixture via apostinstallscript, the same approach as theanchorexample.nativeexample.Files
tokens/create-token/pinocchio/(program + bankrun test)Cargo.toml(workspace member),README.md(pinocchio link),Cargo.lock