Reimplementation of the world program with Pinocchio
| Status | Type | ⚠️ Core Change | Issue |
|---|---|---|---|
| Ready | Feature | Yes | Nil |
Problem
What problem are you trying to solve?
Anchor is not the most adequate for real-time systems on solana. Bloated, slow, expensive
Solution
How did you solve the problem?
Rewrite pieces of bolt with zero-copy pinocchio with full backwards compatiblity
Before & After Screenshots
Deploy Notes
cargo build-sbf over anchor build. anchor build for generating idls
New dependencies:
pinocchio: Pinocchio
Greptile Summary
This PR introduces a significant architectural change by implementing a Pinocchio-based alternative to the existing Anchor-based world program in the Bolt framework. The core motivation is performance optimization - addressing Anchor's limitations for real-time systems on Solana by replacing it with zero-copy operations.
Key Changes:
-
New Pinocchio World Program: A complete rewrite of the world program using the
pinocchioframework, located incrates/pinocchio/world/. This includes all instruction handlers (add_entity,apply_system,initialize_component, etc.) rewritten with manual memory management and unsafe operations for performance. -
CPI Interface Layer: A new
bolt-cpi-interfacecrate that provides cross-program invocation interfaces for component operations (initialize, update, destroy) and system execution using Pinocchio's primitives instead of Anchor's CPI abstractions. -
State Management Rewrite: Complete reimplementation of state structures (
World,Entity,Registry,SystemWhitelist) using zero-copyTransmutabletraits and manual discriminator handling. -
Instruction Dispatching: Custom instruction dispatch system using u64 discriminators instead of Anchor's automatic deserialization, with manual byte parsing and unsafe pointer operations.
Architecture Integration:
The implementation maintains full backwards compatibility by preserving the same program ID, instruction discriminators, and account structures. This allows existing clients to work unchanged while benefiting from reduced compute unit costs. The new implementation coexists with the existing Anchor version, suggesting a gradual migration strategy where both can operate during the transition period.
The change affects the core ECS (Entity Component System) functionality of Bolt, including world management, entity creation, component lifecycle, and system execution - all critical paths for real-time blockchain gaming applications.
Confidence score: 1/5
- This PR contains critical bugs that will cause runtime failures and prevent proper program execution
- Multiple critical typos in discriminator constants create mismatches between instruction identification and execution paths
- The combination of unsafe memory operations, complex manual memory management, and discriminator inconsistencies makes this unsafe to merge
- Files with the most critical issues:
crates/pinocchio/world/src/instructions/mod.rs,crates/pinocchio/world/src/state/world.rs,crates/pinocchio/world/src/consts.rs
How are you testing it? bolt test is running the previous world program.