Solana program artifacts
The verifier turns a Solana source workspace into a named program binary and compares that binary with the program data deployed at a Solana program ID. It also selects a Solana-compatible build environment and records the source and build inputs that explain the result.
Artifact identity
Source target identity
The verifier treats the Cargo library name as the identity of the source target and the Solana program ID as the identity of the deployed target. The source target can be selected explicitly or inferred when the workspace has one clear library target. In a monorepo, the mount path locates the repository and the workspace path locates the Cargo workspace that owns the build.
These names connect the local source to the deployed program. A mismatch can produce a valid build for the wrong program, so repository verification checks that the named library exists before it starts the build.
References: src/main.rs• L1279-1321 src/main.rs• L1441-1495 src/main.rs• L1871-1928
Program binary artifact
The build artifact is the .so binary produced for the selected Solana library. The verifier expects it in the workspace's target/deploy area and derives its file name from the library name. Image verification uses the executable path supplied for the image, then treats the copied file as the candidate program binary.
This gives each verification path the same comparison point: one rebuilt or extracted program binary and one on-chain program payload.
References: src/main.rs• L1122-1134 src/main.rs• L1143-1223 src/main.rs• L1562-1606
Solana build inputs
Build target selection
The verifier uses the selected library name to find its Cargo manifest and sets the build directory to that library's workspace. It requires a Cargo.lock file in the workspace because dependency versions are part of the build input. Repository verification also carries the repository URL and commit into the verification record so that another engineer can identify the source used for the build.
The target can receive Solana-specific build choices when a program needs them. These choices include the older BPF build path, a target architecture, and arguments for the SBF build command.
References: src/main.rs• L936-947 src/main.rs• L980-1012 src/main.rs• L1247-1357 src/main.rs• L1562-1606
Solana version selection
The Solana version selects the default container image because the compiler and Solana build tools must match the program's expected toolchain. The verifier first reads a three-part version from workspace metadata. If that value is not present, it reads a Solana package version from the lockfile.
The version is then mapped to a pinned build image. A caller can provide a custom image instead. The legacy BPF mode uses a compatibility image rather than the normal version map.
This selection keeps the build environment tied to the program's declared Solana inputs. An unsupported version stops verification unless the caller supplies an image that supports it.
References: src/main.rs• L949-975 src/main.rs• L1649-1705 src/image_config.rs• L1-9
Program data comparison
Binary hash normalization
The verifier compares a SHA-256 hash of the meaningful program bytes rather than the raw storage container. Before hashing, it removes zero bytes at the end of the byte sequence. The same rule applies to a local .so file, a buffer account, and deployed program data.
This normalization matters because Solana account storage can include unused trailing space. It lets the verifier compare the program payload across local files and the different account forms used by Solana.
References: src/main.rs• L768-793
Loader-aware on-chain data
The program ID points to a Solana account whose owner identifies how its executable data is stored. For an upgradeable program, the verifier follows the program ID to its separate program-data account and skips that account's metadata. For legacy BPF loaders, it reads the executable bytes directly from the program account.
The resulting payload hash is the on-chain value used against the locally rebuilt or extracted binary. An unknown loader, missing program data, empty legacy data, or incomplete metadata prevents a trustworthy comparison.
References: src/main.rs• L796-862
Verification result
Repository verification succeeds as a match only when the local artifact hash equals the on-chain program hash. A match permits the verifier to publish the source location, commit, build arguments, verifier version, and deployment slot as Solana verification data. A mismatch reports both hashes and does not publish that result.
The deployment slot records when the current program data was deployed. The verifier reads it from the parsed program-data account so the record describes the specific deployed payload that was checked.
References: src/main.rs• L1441-1558 src/…/solana.rs• L86-112 src/solana_program.rs• L102-109 src/solana_program.rs• L315-405
Solana verification records
Verification program data
The verifier stores build facts in a program-derived address (PDA), which is a deterministic Solana account derived from the verified program ID and the signer. The record links the deployed program to its source URL, commit, build arguments, verifier version, and deployment slot.
The current signer updates its existing record. A new signer can create a separate record when the program already has verification data. This lets the Solana program hold more than one uploader's verification record without changing the artifact comparison rule.
References: src/solana_program.rs• L68-88 src/solana_program.rs• L315-405 src/solana_program.rs• L412-415 src/main.rs• L1774-1868
Network account access
The verifier uses a Solana RPC connection to read program accounts and to publish verification records. A network alias resolves to a known Solana cluster, while an explicit RPC URL or Solana CLI configuration can provide another connection.
RPC reads retry a small number of times for transient failures. They do not turn missing accounts or unsupported loaders into valid artifacts.
References: src/solana_program.rs• L140-160 src/solana_program.rs• L277-301 src/main.rs• L796-862 src/main.rs• L1931-1953
Verification flow
The flow below shows how source identity, Solana build inputs, binary data, and on-chain data meet at the final decision.
flowchart TD
A[Repository and commit] --> B[Cargo library target]
B --> C[Solana version and build options]
C --> D[Solana build image]
D --> E[Program .so binary]
E --> F[Normalized binary hash]
G[Program ID] --> H[Loader-aware on-chain payload]
H --> I[Normalized program hash]
F --> J{Hashes match}
I --> J
J -->|Yes| K[Record verification facts on Solana]
J -->|No| L[Report mismatch]
Repository verification clones the selected source revision, locates the target, builds it in the chosen Solana environment, and finds the resulting .so file. It then compares that artifact with the payload addressed by the program ID. Image verification starts with an existing image and executable path, but joins the same hash comparison at the artifact stage.
For the wider command entry point, see Verifier CLI. The build lifecycle is described in Build verification execution. The RPC and external service boundary is described in Verified programs API integration, and the image catalog is described in Build image configuration.
References: src/main.rs• L1441-1606 src/main.rs• L1143-1244 src/main.rs• L1871-1928
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the library-name-to-
.sonaming rule aligned with target discovery and image executable paths. - Keep the Solana version sources aligned with the pinned image map. A version that parses correctly but has no image still cannot build by default.
- Keep local-file hashing and loader-specific account extraction under the same trailing-zero normalization rule.
- Keep the verification record's deployment slot tied to the same program-data account used for the hash.
- Keep PDA seed and record fields compatible with existing verification accounts when changing upload behavior.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The selected library name has no matching Cargo library manifest | The verifier cannot choose a build target | Preflight target discovery and explicit --library-name selection |
| The workspace has no Cargo.lock file | The deterministic build stops before image selection | Require the lockfile in the selected workspace |
| The Solana version has no mapped image | The default build cannot select a compatible environment | Supply a supported version or an explicit base image |
The expected .so file is absent from target/deploy | No local artifact hash is available | Build the selected library and check its derived artifact path |
| The program uses an unsupported loader or has missing program data | The on-chain hash cannot be trusted or computed | Accept only legacy BPF loaders and the upgradeable loader with valid data |
| Local and on-chain hashes differ | Verification does not publish a success record | Report both hashes and investigate source, target, or build inputs |
Key files
| File | Why to read it |
|---|---|
| src/main.rs | Defines target discovery, Solana version selection, artifact lookup, hash comparison, and repository/image verification flow. |
| src/solana_program.rs | Defines Solana account access and the on-chain verification record used after a matching build. |
| src/…/solana.rs | Defines the lookup of the deployed program's last deployment slot. |
| src/image_config.rs | Provides the generated mapping from Solana versions to pinned build image digests. |
| docs/build-verification-execution.md | Explains the larger build and verification lifecycle around these artifact rules. |
| docs/verified-programs-api.md | Explains the service boundary that uses verification information beyond the local artifact comparison. |
| docs/image-configuration.md | Explains how the build image configuration supports reproducible Solana environments. |