Pinocchio hello-world example
The Pinocchio hello-world example is a small Solana program used to check verifiable builds for a program that does not use the traditional solana-program dependency. Its Cargo project gives the verification tool a second local build fixture and shows how build-tool choices can affect the resulting executable hash.
Program purpose
The program in examples/…/lib.rs provides the smallest useful runtime behavior for this fixture. It writes Hello, world! to the Solana program log and returns success for a non-zero program address. It returns an incorrect-program-ID error for the all-zero address.
The program does not use account state or instruction data. This keeps the example focused on the build and verification result rather than on application behavior.
References: examples/…/lib.rs• L1-17
Cargo project
The Cargo project in examples/…/Cargo.toml packages the program as both a reusable Rust library and a deployable Solana shared object. Its direct dependencies provide the Pinocchio program interface and Solana logging support.
The project also declares Solana CLI version 3.0.7 through Cargo metadata. This gives the build system a toolchain hint for programs that do not expose a Solana version through solana-program; the general version-selection rule is described in the repository README.
References: examples/…/Cargo.toml• L1-20 README.md• L24-37
Verification fixture
The Pinocchio project is an alternate local fixture beside the conventional hello-world example. Both fixtures produce a deployable hello_world.so, but they exercise different Solana program development approaches. The parent page, Example Solana programs, places these samples in the wider set of build demonstrations.
The local verification tests build the project with solana-verify, read the executable at examples/hello_world_pinocchio/target/deploy/hello_world.so, and compare its hash with a known value. This confirms that the tool can build and measure a Pinocchio program through the same local verification path used by the other example.
References: src/test.rs• L63-73 src/test.rs• L75-120 src/test.rs• L190-199
Build-tool variation
The fixture also checks the build argument path. One run selects platform tools version v1.47 and another selects v1.54; each run writes to a separate target directory and has its own expected executable hash.
This check treats the build environment as part of the verification input. A change to the forwarded Cargo build arguments or to the selected platform tools can therefore change the executable hash even when the program source stays the same. See Build verification and execution for the broader build and hash flow.
The relationship is shown below:
flowchart LR
S[Pinocchio source] --> B1[Build with platform tools v1.47]
S --> B2[Build with platform tools v1.54]
B1 --> H1[Executable hash v1.47]
B2 --> H2[Executable hash v1.54]
H1 --> C[Compare with expected fixture values]
H2 --> C
References: src/test.rs• L201-239
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the Cargo metadata that identifies the Solana CLI aligned with the build image or toolchain used for Pinocchio programs.
- Update the expected hashes when source, dependency versions, or platform tools change. Keep separate target paths when comparing tool versions.
- Keep the executable path in the local verification checks aligned with the crate name and the target directory used by each build.
- Preserve the distinction between this Pinocchio fixture and the conventional hello-world fixture when changing shared verification helpers.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The Solana CLI metadata is missing or points to an unsuitable version | The build system can select the wrong environment for a Pinocchio project | Keep [workspace.metadata.cli] solana current in the fixture Cargo manifest |
| A build argument changes the platform tools version without a matching expected hash | The local verification check reports a hash mismatch | Store each tool-version build in its own target directory and expected-hash entry |
| The crate name or target directory changes without updating the test path | Hash verification cannot find the generated executable | Keep the Cargo library name and test executable path in sync |
| The program receives the all-zero program address | The example returns IncorrectProgramId instead of success | Use a valid non-zero program address for success-path checks |
Key files
| File | Why to read it |
|---|---|
| examples/…/lib.rs | Defines the program's minimal log and program-ID behavior |
| examples/…/Cargo.toml | Defines the standalone fixture package, Pinocchio dependencies, output types, and Solana CLI hint |
| src/test.rs | Shows the local build, executable-hash, and platform-tools variation checks |
| examples/…/Cargo.toml | Provides the conventional hello-world project used for comparison |
| README.md | Explains why Pinocchio projects need an explicit Solana CLI version hint |