Scale or Die 2025: No-strings-attached programs w/ Pinocchio
Discover how Pinocchio is revolutionizing Solana program development with improved efficiency and performance
Solana developers, get ready for a game-changer! Fernando Otero from ANZA's dev tooling team unveils Pinocchio, a revolutionary new SDK set to transform how we write and optimize Solana programs. With promises of drastically reduced compute units, smaller binary sizes, and improved performance, Pinocchio is poised to take Solana development to the next level.
Summary
Fernando Otero, also known as Febo, introduces Pinocchio, a new dependency-free SDK designed to help developers write more efficient Solana programs. Born out of a conversation at the Hackinghouse in London, Pinocchio aims to be a "program first" SDK that prioritizes on-chain program performance.
The SDK follows key principles, including avoiding external dependencies in the main crate, focusing on performance through zero-copy data access and no dynamic memory allocation, and providing both safe and unsafe variants of functions. Pinocchio offers significant improvements in areas such as entry point efficiency, lightweight view types, and program logging.
Otero presents two case studies demonstrating Pinocchio's effectiveness: a reimplementation of the SPL token program (dubbed "Pitoken") and an optimized version of the memo program. Both examples show substantial reductions in compute unit usage and binary size while maintaining the same functionality.
Key Points:
Origins and Principles of Pinocchio
Pinocchio was conceived as a solution to the dependency issues plaguing the Solana program crate. The idea of a dependency-free SDK emerged from a conversation between Fernando Otero and John at the Hackinghouse in London. Pinocchio's core principles include:
- No external dependencies in the main crate
- Focus on performance
- No dynamic memory allocation
- Zero-copy data access when possible
- Provision of both safe and unsafe function variants
These principles aim to create an SDK that is tailored specifically for on-chain programs, offering improved performance and mitigating dependency issues that often arise in Solana development.
Efficiency Improvements
Pinocchio introduces several key improvements to enhance program efficiency:
- A more efficient entry point that uses a single pointer to reference account information directly from the input, resulting in an order of magnitude improvement in performance.
- A new "lazy" entry point type that delays reading input, giving developers more control over when and what to read. This is particularly useful for programs with a single instruction or very few instructions.
- Lightweight view types that redefine account info, account meta, and instruction to use references instead of owning data. This reduces cloning and improves efficiency, especially in cross-program invocations (CPIs).
- An optimized approach to program logging, featuring a lighter way to format messages without allocations or external dependencies. This can lead to significant reductions in compute unit usage for logging operations.
These improvements collectively contribute to more efficient Solana programs, reducing compute unit usage and improving overall performance.
Case Studies: Pitoken and Memo Program
Otero presented two compelling case studies to demonstrate Pinocchio's effectiveness:
- Pitoken: A reimplementation of the SPL token program using Pinocchio. This new version achieved a 88-95% reduction in compute unit usage and a 40% reduction in binary size while maintaining the same behavior and output. Notably, 70% of the reduction came from changing the entry point and implementing zero-copy account data access.
- Memo Program: An optimized version of the memo program using Pinocchio's lazy entry point. This implementation resulted in an 80-87% reduction in compute unit usage, achieved through the efficient entry point, optimized logging, and an improved method for converting public keys to base58 format.
These case studies provide concrete evidence of Pinocchio's potential to significantly improve the efficiency of Solana programs across various use cases.
Facts + Figures
- Pinocchio achieves an order of magnitude improvement in entry point efficiency compared to traditional methods
- The SDK offers a 5x reduction in compute unit usage for cross-program invocations (CPIs)
- Pitoken, the Pinocchio implementation of the SPL token program, reduces compute unit usage by 88-95%
- Pitoken's binary size is 40% smaller than the original SPL token program
- 70% of Pitoken's efficiency gains come from changing the entry point and implementing zero-copy account data access
- The optimized memo program using Pinocchio reduces compute unit usage by 80-87%
- Pinocchio's logging system can achieve up to an order of magnitude improvement in formatting cost for program logs
- The SDK is designed to be used as a drop-in replacement for the Solana program crate
- Pinocchio is a no-std crate, meaning it doesn't use any of the standard library types
- The ANZA team is working on integrating Pinocchio's new types into the Solana SDK
- Future plans include optimizing the Associated Token Account (ATA) program and Token22 program using Pinocchio
Top quotes
- "Pinocchio is to be a program first SDK that is going to follow what works best for on-chain programs."
- "The idea of Pinocchio is to be a program first SDK that is going to follow what works best for on-chain programs."
- "It's possible to write a Pinocchio program without any unsafe code."
- "We managed to reduce the CU's used by the token program by 88% to 95% depending on the instruction that you are executing."
- "70% of their reduction is achieved by changing the entry point to use Pinocchio entry point and doing zero-copy account data access."
Questions Answered
What is Pinocchio and why was it created?
Pinocchio is a new dependency-free SDK for writing efficient Solana programs. It was created in response to the dependency issues plaguing the Solana program crate. The idea emerged from a conversation between Fernando Otero and John at the Hackinghouse in London, with the goal of creating an SDK that prioritizes on-chain program performance and mitigates dependency problems.
How does Pinocchio improve program efficiency?
Pinocchio improves program efficiency through several key features. It offers a more efficient entry point that uses a single pointer to reference account information directly from the input. It also introduces lightweight view types that reduce cloning, especially in cross-program invocations. Additionally, Pinocchio provides an optimized approach to program logging, which can significantly reduce compute unit usage for logging operations.
What are the main principles behind Pinocchio's design?
The main principles behind Pinocchio's design include avoiding external dependencies in the main crate, focusing on performance, using no dynamic memory allocation, implementing zero-copy data access when possible, and providing both safe and unsafe function variants. These principles aim to create an SDK that is tailored specifically for on-chain programs and offers improved performance.
How effective is Pinocchio in reducing compute unit usage?
Pinocchio has shown impressive results in reducing compute unit usage. In the case of Pitoken, a reimplementation of the SPL token program, compute unit usage was reduced by 88-95% depending on the instruction. For the optimized memo program, Pinocchio achieved an 80-87% reduction in compute unit usage. These significant reductions demonstrate Pinocchio's effectiveness in improving program efficiency.
Can Pinocchio be used as a drop-in replacement for the Solana program crate?
Yes, Pinocchio is designed to be used as a drop-in replacement for the Solana program crate. Developers can use Pinocchio in the same way they would use the Solana program crate, making it easy to integrate into existing projects and workflows.
What are the future plans for Pinocchio?
The ANZA team is currently working on integrating Pinocchio's new types into the Solana SDK to make it easier for developers to write code that can be used in both off-chain clients and on-chain programs. Future plans also include optimizing other programs such as the Associated Token Account (ATA) program and potentially creating a "Pitoken 22" version of the Token22 program using Pinocchio's optimizations.
Is it safe to use Pinocchio for Solana program development?
Yes, it is safe to use Pinocchio for Solana program development. While the SDK offers unsafe variants of functions for improved performance, Fernando Otero emphasizes that it's entirely possible to write a Pinocchio program without any unsafe code. The unsafe variants are provided as options for cases where developers can guarantee safety constraints and want to achieve extra performance.
Comments
Please login to leave a comment.
On this page
- Summary
- Key Points:
- Facts + Figures
- Top quotes
-
Questions Answered
- What is Pinocchio and why was it created?
- How does Pinocchio improve program efficiency?
- What are the main principles behind Pinocchio's design?
- How effective is Pinocchio in reducing compute unit usage?
- Can Pinocchio be used as a drop-in replacement for the Solana program crate?
- What are the future plans for Pinocchio?
- Is it safe to use Pinocchio for Solana program development?
Related Content
Solana Changelog: Colosseum Hackathon Success, Builder Interest Surge, and Developer Experience Improvements
Explore Solana's latest achievements: record-breaking hackathon, increased founder interest, and crucial updates enhancing the developer experience.
Anchor: Today and Tomorrow
Anchor 1.0 launches with major security improvements, better tooling, and a roadmap featuring Pinocchio integration, native fuzzing, and security linting
Solana Changelog October 23
Explore Solana's record-breaking hackathon, increased builder interest, and key updates enhancing developer experience and blockchain efficiency.
Compass: Ensuring SPL-Token Stays Safe on Pinocchio Runtime Verification
Learn how Runtime Verification is using Compass to mathematically prove the Solana Token Program's Pinocchio upgrade won't break anything
Solana Changelog Oct 23
Discover how Solana is attracting more developers than ever, with insights on the largest crypto hackathon and recent performance optimizations.
Scale or Die at Accelerate 2025: Writing Optimized Solana Programs
Learn advanced Solana program optimization techniques to boost efficiency and reduce costs
Solana Changelog Nov 6th
Explore the latest Solana updates including Agave v2.1, Web3.js v2 release candidate, SIMD-0187 proposal, and upcoming Anchor v0.31.0 features in this comprehensive changelog.
The Great Online Game with Packy McCormick
Discover how the internet has transformed careers into a global game with exponential upside. Learn how to play and win in the new digital economy.
Product Keynote: Blueshift
Blueshift launches Learn V3 at Breakpoint 2024, introducing paths, points, and perks to revolutionize Solana developer education alongside quantum-secure wallet tech
Solana Changelog Jun 19 - Test validator fix, new Syscall, RPC updates, and more
Exciting Solana developments: test validator improvements, new GetEpochStake syscall, RPC updates for interest-bearing tokens, and continued Core BPF program migration.
Solana Changelog November 6th
Get the latest Solana updates including SIMD 189 for stricter ELF headers, Agave 2.1 pre-release, Web3.js 2.0 launch, and crucial developer insights.
Solana Changelog - Mar 19: Anza's Agave Client, Compute, and create-solana-program
Explore Solana's latest developments: Anza's Agave client, block space challenges, priority fees, and new developer tools like create-solana-program.
Building StarAtlas, the blockchain game and economy with Michael Wagner, CEO - Solfate Podcast #29
Explore how Star Atlas is building a groundbreaking MMO economy and metaverse on Solana, featuring innovative on-chain game logic and an open IP model.
Breakpoint 2025: Security Block: Asymmetric Research
Discover the biggest security risks facing Solana in 2025, from oracle compromises to CU optimization dangers, and learn how developers can protect their protocols.
Solforge Fusion: Combining Physical Card Games With Web3 Primitives | Justin Gary
Discover how Solforge Fusion is bridging the gap between physical and digital card games, leveraging Web3 to create a unique gaming experience that empowers players and solves longstanding industry issues.
Solana Token Markets
