This project implements the VerusHash v2.2 algorithm for use within the Solana blockchain environment. It consists of:
verus
crate: A Rust crate containing the core VerusHash logic, adapted to be compilable for both native host targets (using optimized intrinsics if available) and the Solana SBF (Solana Bytecode Format) target (using a portable C implementation).program
crate: A Solana program (smart contract) written in Rust that exposes an instruction to verify a VerusHash solution on-chain. It uses theverus
crate for the hashing logic.client
crate: A command-line client application that interacts with the deployed Solana program. It uses theverus
crate (native host version) to search for a valid nonce that satisfies a given difficulty target and then submits this solution to the on-chain program for verification.origin-impl
directory: Contains the original C/C++ source code from the VerusCoin repository for reference.verus/c
directory: Contains the C/C++ source code adapted for the Solana SBF environment (portable, no stdlib dependencies, etc.).
The current development cycle involves building the on-chain program, deploying it to a local validator (or testnet/devnet), and then running the client to test the interaction.
Prerequisites:
- Rust toolchain installed (
rustup
) - Solana CLI tool suite installed
- A running Solana validator (e.g.,
solana-test-validator
)
Steps:
-
Build the Solana Program: Compile the
program
crate into the SBF bytecode.cargo build-sbf # This command compiles the program and places the output (`program.so`) in the `target/deploy/` directory.
-
Deploy the Program: Deploy the compiled program to your target Solana cluster (local validator, devnet, etc.). You'll need the program's keypair (e.g.,
program/target/deploy/program-keypair.json
generated bycargo build-sbf
if it doesn't exist, or provide your own).Example using the default keypair location and deploying to localhost:
# Make sure your Solana CLI is configured for the target cluster (e.g., localhost) # solana config set --url localhost # Deploy the program solana program deploy target/deploy/program.so --program-id program/target/deploy/program-keypair.json
Note: Replace
--program-id
with the actual path to your program's keypair file if it differs.Take note of the Program ID output by the deploy command. You may need to update
PROGRAM_ID
constant inclient/src/main.rs
if it changes or if you are deploying with a specific ID. -
Build the Client: Navigate to the client directory and build the client application.
cd client cargo build
-
Run the Client: Execute the client application. It will connect to the RPC endpoint specified in
client/src/main.rs
(defaulting to localhost), search for a valid nonce using the native VerusHash implementation, and then send a transaction to the deployed program to verify the solution on-chain.cargo run
The client will print output indicating whether the nonce search was successful and whether the on-chain verification passed or failed.
This cycle (modify code -> build program -> deploy -> build client -> run client) is repeated as needed during development and testing.