Overview of Fibonacci Input Initial Guest Program
maininit_a and init_b as the first two elements of the sequence.repository·main·Indexed 22 days ago
https://github.com/nexus-xyz/nexus-cliA high-performance command-line interface (nexus-compute-cli) for contributing proofs to the Nexus network. The documentation covers installation, node registration, adaptive task difficulty configuration, and Docker deployment. It also includes guides for building guest programs for the Nexus zkVM using the RISC-V target (riscv32i-unknown-none-elf), utilizing tools like cargo-nexus and the build_guest.sh script, as well as details on the associated Firebase Cloud Functions for versioning and analytics.
init_a and init_b as the first two elements of the sequence.The Nexus CLI uses an adaptive difficulty system that starts at small and auto-promotes if tasks complete in under 7 minutes. You can override this behavior using the --max-difficulty flag to optimize for your hardware.
| Difficulty | Use Case |
|---|---|
small | Default, starting task |
small_medium | Building reputation |
medium and large | Standard desktop/laptop |
extra_large and above | High-performance systems, more points |
For resource-constrained systems (low difficulty):
nexus-compute-cli start --max-difficulty small
nexus-compute-cli start --max-difficulty small_mediumFor high-performance hardware (high difficulty):
nexus-compute-cli start --max-difficulty medium
nexus-compute-cli start --max-difficulty large
nexus-compute-cli start --max-difficulty extra_large
nexus-compute-cli start --max-difficulty extra_large_2
nexus-compute-cli start --max-difficulty extra_large_3
nexus-compute-cli start --max-difficulty extra_large_4
nexus-compute-cli start --max-difficulty extra_large_5Note: extra_large_5 is equivalent to extra_large_4 if no extra_large_5 tasks are available. The flag is case-insensitive (e.g., MEDIUM is the same as medium).
nexus-compute-cli start --max-difficulty extra_large_2To prevent rate limiting and ensure reliability, the Nexus CLI fetches version.json using a tiered fallback strategy. If one source fails, it attempts to reach the next in the following order:
https://cli.nexus.xyz/version.json (via Firebase Hosting)https://us-central1-nexus-cli.cloudfunctions.net/version (via Cloud Function)https://raw.githubusercontent.com/nexus-xyz/nexus-cli/refs/heads/main/public/version.json (via GitHub)To automate the process of building the guest program for the RISC-V target and placing the resulting ELF file into the Nexus CLI assets directory, use the provided shell script. This script copies the ELF file to ../../clients/cli/assets/fib_input_initial (without a file extension).
./build_and_copy.shThe fib_input_initial program is a guest program used for anonymous proving in the Nexus CLI. It computes the nth Fibonacci number in a generalized sequence with custom initial values. To build the program manually, you must have the riscv32im-unknown-none-elf Rust target installed.
# 1. Add the RISC-V target
rustup target add riscv32im-unknown-none-elf
# 2. Build the program
cargo build --release --target riscv32im-unknown-none-elfThe build_guest.sh script automates the creation and compilation of guest programs. It uses cargo nexus host to generate or rebuild the program, compiles it for the RISC-V target (riscv32i-unknown-none-elf), and copies the resulting ELF file to the assets/[guest_name] directory.
Requirements:
cargo nexus must be installed and available in your PATH.assets/ directory must exist in the CLI repository root.Workflow for modifying programs:
programs/[guest_name]/src/guest/src/main.rs../scripts/build_guest.sh [guest_name].assets/[guest_name].# Build with default name (fib_input_initial)
./scripts/build_guest.sh
# Build with a custom name
./scripts/build_guest.sh my_custom_programThe peak_memory.sh script monitors the peak memory consumption of nexus-compute-cli during operation. It starts nexus-compute-cli start --headless in the background and tracks memory usage every second for a specified duration.
Requirements:
nexus-compute-cli must be built and available in your PATH or the current directory.Usage: Run the script with a duration in seconds to capture statistics.
# Monitor for 20 seconds
./scripts/peak_memory.sh 20
# Monitor for 5 minutes
./scripts/peak_memory.sh 300The Nexus CLI (command name nexus-compute-cli) can be installed via a precompiled binary or a non-interactive script for automation.
Run the following command to download the latest binary, accept the Terms of Use, and enter interactive mode:
curl https://cli.nexus.xyz/ | shFor CI/CD or automated environments, use the NONINTERACTIVE environment variable:
curl -sSf https://cli.nexus.xyz/ -o install.sh
chmod +x install.sh
NONINTERACTIVE=1 ./install.shNote: While
nexus-cliremains available as an alias for a transition period, all new setups should usenexus-compute-cli.
You can start contributing proofs to the Nexus network using several methods.
If you already have a node ID, start the CLI directly:
nexus-compute-cli start --node-id <your-node-id>If you do not have credentials, you can register your wallet and create a node ID via the CLI:
nexus-compute-cli register-user --wallet-address <your-wallet-address>
nexus-compute-cli register-node --node-id <your-cli-node-id>
nexus-compute-cli startTo run the CLI without interactive prompts:
nexus-compute-cli start --headlessCredentials (wallet and node ID) are saved to ~/.nexus/config.json. To clear them, use:
nexus-compute-cli logoutTo build this guest program, you must target the riscv32i-unknown-none-elf architecture. The resulting ELF file will be located at target/riscv32i-unknown-none-elf/release/guest.
# Build for RISC-V target
cargo build --target riscv32i-unknown-none-elf --releaseNexus VM example programs are built against nexus-rt, a minimal RISC-V runtime. You can execute these programs using the nexus-run tool. In this repository, nexus-run is configured as the default runner for cargo.
To run the default 'hello world' program, use the following command:
cargo run -r --bin exampleTo work with the Firebase Functions in this repository, follow these steps in the functions directory:
Install dependencies:
cd functions
npm installRun locally:
npm run serveBuild the functions:
npm run buildDeploy to Firebase:
npm run deploycd functions
npm install
npm run serve
npm run build
npm run deploy