Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

Pinocchio for Dummies- 1813

BlueshiftPosted 3 Months Ago
  • Most Solana programs are written using Anchor. If you're really chasing performance, you may write raw Rust code too. Recently, the Pinocchio framework was developed as a middle ground between the two more common approaches. It acts as a minimalist Rust library for crafting Solana programs. This has the benefit of using fewer compute units, small binaries, and very few dependencies. This document is meant to be an overview of Pinocchio.
  • With Pinocchio, it's closer to native than to Anchor. You must write your own entrypoint function that performs function discriminator checks and operation routing. Compared to solana-program, it performs zero-copy operations by reading data directly from the byte array without copying anything. This eliminates serialization/deserialization overhead.
  • For Accounts, there aren't any macros for data types. Instead, the trait TryFrom() is used for deserializing account data into a structure to use. On an instruction context, there is another TryFrom trait that will perform necessary validations. Proper amount of accounts, signer checks, account ownership checks... all of the good Solana account checks. A similar validation process is done on the instruction data with TryFrom again.
  • Account creation must be manually checked for validity and done. This is a major downgrade from Anchor and adds a lot of complexity. Overall, a good article on the new Solana framework!