Verifier CLI
The Verifier CLI is the product entry point for checking that a Solana program can be rebuilt from a known source revision and produce the same executable as the deployed program. It connects source code, a versioned build environment, Solana account data, and optional remote verification into one command flow.
Product role
The Rust command-line application turns a verification request into a small set of related actions. It selects the command, resolves shared connection and signing settings, then hands the work to the build, artifact, Solana, or service boundary that owns the next step.
The main path is verify-from-repo. It treats a repository URL, commit, program ID, build options, and Solana connection as one verification record. A successful match can then publish the source and build details on Solana so that later users can inspect or verify the result.
Command coordination
The command router maps each user goal to a supporting system. The same program ID and RPC connection can therefore be used for local hash checks, on-chain comparisons, PDA records, and remote job requests.
| User goal | Command family | Result |
|---|---|---|
| Build a local checkout | build | A deterministic container build and an optional executable hash |
| Verify source against a deployed program | verify-from-repo | A build hash comparison followed by optional on-chain verification data upload |
| Verify an executable already held in an image | verify-from-image | A comparison between the image executable and the deployed program |
| Inspect executable or deployed data | get-executable-hash, get-buffer-hash, get-program-hash | A normalized program hash |
| Inspect or manage verification records | get-program-pda, list-program-pdas, close | Verification record details or an on-chain record action |
| Prepare or run a verification job | export-pda-tx, remote ... | An unsigned upload transaction or a remote job/status result |
References: src/main.rs• L115-412 src/main.rs• L414-696
Shared command context
Commands that use Solana read the RPC URL from --url, a custom Solana CLI config, or the normal Solana CLI configuration. Short network names such as mainnet, devnet, testnet, and localnet resolve to their known endpoints. Upload and close actions also use a signer from the config or from an explicit keypair path.
The command starts by validating a supplied config and keypair when needed. It also applies the shared compute-unit price to transactions that write verification data, while read-only commands only need a usable RPC connection.
References: src/main.rs• L414-429 src/solana_program.rs• L140-190 src/solana_program.rs• L277-312
Verification lifecycle
The verification lifecycle starts with a source snapshot and ends with a hash decision. The CLI keeps the source and build environment separate from the Solana read and write steps so that a build can be checked before any verification record is changed, unless the user selects --skip-build.
The diagram shows how command handling coordinates the main local verification path and its external boundaries.
flowchart LR
A[User command] --> B[Parse command and shared settings]
B --> C[Select source snapshot]
C --> D[Choose build image]
D --> E[Build Solana executable]
E --> F[Hash rebuilt executable]
F --> G[Read deployed program hash]
G --> H{Hashes match?}
H -->|Yes| I[Optionally write verification data on Solana]
H -->|No| J[Report mismatch]
I --> K[Optional explicit remote verification job]
Source and build handoff
verify-from-repo obtains a repository and checks out the requested commit. If no commit is supplied, the CLI resolves the remote repository's default branch to a commit so the build has a fixed source point. It then determines the program target and workspace, runs basic checks, and sends the build request to the container-based build path.
The build uses the Solana version declared by workspace metadata when available. For older program layouts it can infer a single supported Solana 1.x version from the relevant dependency tree or lock file. Ambiguous or newer package versions do not silently choose an image. The user must provide the version metadata or a base image. This link between source metadata and the image is the core control that makes the rebuilt executable repeatable.
See Build verification execution for the detailed build lifecycle and result handling.
References: src/main.rs• L1347-1425 src/main.rs• L1428-1491 src/main.rs• L1508-1627 src/main.rs• L1717-1889
Hash comparison
After the build, the CLI hashes the rebuilt .so executable and reads the deployed program bytes through Solana RPC. It removes trailing zero bytes from the program data before hashing so that local and on-chain representations compare as program content rather than account padding.
The deployed data path depends on the Solana loader. Upgradeable programs use their program-data account, while legacy BPF loaders keep the executable data in the program account. An unsupported loader or missing account stops the comparison with an error instead of producing a misleading result.
See Solana program artifacts for the Solana-specific artifact and loader rules.
References: src/main.rs• L786-879 src/main.rs• L1630-1674
Verification record publication
When the hashes match, the CLI can write verification data to the Solana verification program. The record binds the program ID to the source URL, commit, CLI version, build arguments, and the deployment slot used for the check. The user can confirm this write or bypass the prompt with --skip-prompt.
The same path supports updating an existing record, creating a record for another signer, closing a signer-owned record, and exporting an unsigned transaction for approval by a multisignature tool. These actions use the program ID and uploader identity to find the correct program-derived address, or PDA.
See Verified programs API integration for the external service path and Solana program artifacts for the on-chain verification record model.
References: src/solana_program.rs• L68-126 src/solana_program.rs• L314-410 src/main.rs• L1597-1615
Supporting boundaries
The CLI is an orchestration layer. It does not treat a container image, a Solana account, or the remote service as interchangeable data sources; each boundary has its own inputs, checks, and result meaning.
Build image boundary
The image boundary supplies the toolchain used to rebuild the program. The CLI maps a discovered supported Solana version to a digest-pinned image, or accepts a user-selected base image. The build can also use the older BPF build path for programs that require it.
See Build image configuration for how version and image choices are represented.
References: src/main.rs• L926-1035 src/image_config.rs• L1-7
Solana network boundary
The Solana boundary provides deployed program bytes, deployment-slot data, signer accounts, and the verification PDA records. Read commands report hashes or records. Write commands create, update, or close verification data through signed Solana transactions.
The CLI retries selected RPC reads, but a valid network does not guarantee that the program uses a supported loader or that the requested verification record exists. Those are product-level states that the caller must resolve.
References: src/main.rs• L814-887 src/solana_program.rs• L192-275 src/main.rs• L1938-1954
Remote service boundary
The remote boundary sends an existing on-chain verification record to https://verify.osec.io for server-side checking. The CLI requires the mainnet genesis hash before it submits a job, then polls the returned job ID and compares the service's executable hash with its on-chain hash. Status and job commands expose the same service state without starting a new job. The older verify-from-repo --remote form is rejected; users must upload the record first and then use remote submit-job.
See Verified programs API integration for request, response, and job-state details.
References: src/…/client.rs• L20-21 src/…/client.rs• L92-123 src/…/client.rs• L125-223 src/…/client.rs• L265-287 src/main.rs• L495-508 src/main.rs• L654-686
Installation and operation
The CLI is distributed as the solana-verify binary. The installation script downloads a platform-specific release binary for supported macOS and Linux targets, places it in a user bin directory, and can add that directory to the shell path. Normal operation also needs Docker for container builds and access to the selected Solana RPC endpoint.
The process watches for interrupt signals while it owns a build container or temporary checkout. On interruption it attempts to stop the container, remove temporary data, and exit with an interrupt status. This keeps a failed or cancelled verification from leaving its local build resources behind.
References: verifier-cli-install.sh• L1-9 verifier-cli-install.sh• L43-67 verifier-cli-install.sh• L107-163 src/main.rs• L66-113
Change checklist
When these files or sections are changed, remember to consider these:
- Command names, required arguments, or global options in src/main.rs must stay aligned with the dispatch branches and with the child page for build verification execution.
- Changes to executable hashing or Solana loader handling must preserve the comparison contract between local
.sofiles and deployed account data. - Changes to Solana version discovery or image digests must update the image configuration contract and the supported build-environment documentation.
- Changes to verification PDA fields, signer rules, instruction types, or transaction encoding must be checked against both upload commands and
export-pda-txconsumers. - Changes to remote endpoints or job states must stay aligned across the client requests, response models, and the remote command output.
- Changes to the deprecated
verify-from-repo --remotepath must preserve the handoff to the explicitremote submit-jobworkflow.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The workspace has no Cargo.lock, has an ambiguous dependency version, or has no discoverable supported Solana version | The deterministic build stops before it starts | Add the lock file, set workspace Solana metadata, select the correct library, or provide a compatible --base-image |
| The rebuilt executable hash differs from the deployed program hash | Verification data is not uploaded and the mismatch is reported | Use the exact source commit, target library, build mode, and toolchain image |
| The program uses an unsupported loader or its program-data account is missing | The deployed hash cannot be read reliably | Verify the program ID and use a supported legacy BPF or upgradeable loader |
| A remote job is submitted from a non-mainnet RPC endpoint | The remote submission is rejected | Connect to mainnet and confirm the uploader's verification PDA exists |
| A write command has no valid signer or the signer does not own the expected PDA | The transaction cannot be built or confirmed | Use a valid Solana CLI config or explicit keypair and inspect PDA ownership |
| Docker or RPC work is interrupted | The command exits before a result is complete | Allow the signal cleanup to run, then retry after checking local resources and network state |
Key files
| File | Why to read it |
|---|---|
| src/main.rs | Defines the CLI surface, shared settings, command dispatch, and the high-level build and verification flows. |
| src/solana_program.rs | Defines the Solana-facing verification record, signer, PDA, transaction, and upload boundary. |
| src/…/client.rs | Defines remote job submission, polling, status reporting, and result comparison. |
| src/…/models.rs | Defines the response shapes and job states exchanged with the remote verification service. |
| src/…/solana.rs | Defines the deployment-slot lookup used when the CLI records verification data. |
| src/image_config.rs | Defines the version-to-image digest map used by automatic build image selection. |
| Cargo.toml | Defines the Rust package identity and the Solana, Docker-adjacent, RPC, and API support libraries used by the CLI. |
| verifier-cli-install.sh | Shows the supported local binary installation path for CLI users. |