diff --git a/Cargo.toml b/Cargo.toml index 176115adb1..483637f565 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,8 +109,8 @@ pinocchio = { version = "0.8.4" } bs58 = "^0.5.1" litesvm = "0.6.1" # Anchor -anchor-lang = { version = "=0.31.1", features = ["idl-build"] } -anchor-spl = "=0.31.1" +anchor-lang = { version = "0.31", features = ["idl-build"] } +anchor-spl = "0.31" # Anchor compatibility borsh = "0.10.0" diff --git a/INSTALL.md b/INSTALL.md index f3b779164e..73bef46041 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,3 +1,5 @@ +# Light Protocol Installation + Running `install.sh` is the first thing you should do after cloning this monorepo. ```bash @@ -11,18 +13,63 @@ Running `install.sh` is the first thing you should do after cloning this monorep ./scripts/install.sh --skip-components "redis,keys,go" ``` +## System Requirements + +- **Linux/macOS**: Ubuntu 20.04+/macOS 12+ +- **RAM**: Minimum 8 GB, recommended 16 GB +- **Disk space**: Minimum 10 GB free space +- **Dependencies**: build-essential, curl, git + +### Installing Dependencies + +#### Ubuntu/Debian +```bash +sudo apt update +sudo apt install build-essential curl git autoconf automake libtool zlib1g-dev pkg-config libssl-dev +``` + +#### macOS +```bash +xcode-select --install +brew install automake libtool pkg-config openssl +``` + ## Components -- `go` - Golang -- `rust` - Rust toolchain -- `node` - Node.js runtime -- `pnpm` - Package manager -- `solana` - Solana CLI tools -- `anchor` - Anchor -- `jq` - JSON processor -- `keys` - Gnark proving keys -- `dependencies` - all PNPM deps -- `redis` - Redis server +- `go` - Golang (for working with network components) +- `rust` - Rust toolchain (base programming language) +- `node` - Node.js runtime (for JavaScript/TypeScript) +- `pnpm` - Package manager (JavaScript dependency management) +- `solana` - Solana CLI tools (tools for working with Solana) +- `anchor` - Anchor (framework for Solana development) +- `jq` - JSON processor (JSON processing in scripts) +- `keys` - Gnark proving keys (keys for ZK proofs) +- `dependencies` - all PNPM deps (JavaScript project dependencies) +- `redis` - Redis server (for caching and asynchronous task processing) + +## Common Issues and Solutions + +### General Issues + +- **Access errors**: Make sure you have write permissions to the project directory +- **Disk space**: Check available disk space (especially when using `--full-keys`) +- **Network errors**: Check your internet connection and package server availability + +### Specific Issues + +- **Redis**: If you have problems installing Redis, you can install it separately through your package manager: + - Ubuntu: `sudo apt install redis-server` + - macOS: `brew install redis` + +- **Keys**: If key download fails, try running: + ```bash + ./prover/server/scripts/download_keys.sh + ``` + +- **Node.js**: If you already have Node.js installed but the script doesn't recognize it, try skipping this component: + ```bash + ./scripts/install.sh --skip-components "node" + ``` ## CI Usage @@ -32,3 +79,15 @@ Running `install.sh` is the first thing you should do after cloning this monorep with: skip-components: "redis" ``` + +## After Installation + +After successful installation, run: + +```bash +# Verify successful installation +./scripts/devenv.sh + +# Build the project +./scripts/build.sh +``` diff --git a/README.md b/README.md index 9a2fcc85fc..8f3cd92679 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ If you still want to setup dependencies manually, these are the requirements: - [Rust installed with Rustup](https://rustup.rs/), stable and nightly toolchains - [NodeJS](https://nodejs.org/) [(20.9.0 LTS)](https://nodejs.org/en/blog/release/v20.9.0) -- [Anchor](https://www.anchor-lang.com/) [(0.29.0)](https://crates.io/crates/anchor-cli/0.29.0) +- [Anchor](https://www.anchor-lang.com/) [(0.31.1)](https://crates.io/crates/anchor-cli/0.31.1) If you are using Ubuntu and encounter errors during the build process, you may need to install additional dependencies. Use the following command: diff --git a/scripts/build.sh b/scripts/build.sh index 089eaca8ca..2f9a1c3153 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,16 +1,39 @@ #!/usr/bin/env bash -command -v pnpm >/dev/null 2>&1 || { echo >&2 "pnpm is not installed. Aborting."; exit 1; } -command -v npx >/dev/null 2>&1 || { echo >&2 "npx is not installed. Aborting."; exit 1; } +# Exit on any error +set -e -set -eux +# Function to handle errors +handle_error() { + echo "❌ Error occurred on line $1" + exit 1 +} -pnpm install || { echo >&2 "Failed to install dependencies. Aborting."; exit 1; } +# Set trap to catch errors +trap 'handle_error $LINENO' ERR +# Check for required tools +echo "🔍 Checking required dependencies..." +if ! command -v pnpm >/dev/null 2>&1; then + echo "❌ pnpm is not installed. Run ./scripts/install.sh to install dependencies." + exit 1 +fi + +if ! command -v npx >/dev/null 2>&1; then + echo "❌ npx is not installed. Run ./scripts/install.sh to install dependencies." + exit 1 +fi + +echo "📦 Installing project dependencies..." +pnpm install || { echo "❌ Failed to install dependencies. Check your internet connection and access rights."; exit 1; } + +echo "🔧 Checking for required files..." if [ ! -f target/deploy/spl_noop.so ]; then + echo "📄 Copying spl_noop.so..." mkdir -p target/deploy && cp third-party/solana-program-library/spl_noop.so target/deploy fi -npx nx run-many --target=build --all +echo "🚀 Starting build process for all packages..." +npx nx run-many --target=build --all || { echo "❌ Error during package build."; exit 1; } -echo "Build process completed successfully." +echo "✅ Build process completed successfully." diff --git a/scripts/install.sh b/scripts/install.sh index 5053f35900..312aac695e 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -422,8 +422,21 @@ main() { ;; *) echo "Unknown option: $1" - echo "Usage: $0 [--full-keys] [--no-reset] [--skip-components ] [--force-reinstall]" - echo "Components that can be skipped: go,rust,node,pnpm,solana,anchor,jq,photon,keys,dependencies,redis" + echo "------------------------------------------------" + echo "Usage: $0 [OPTIONS]" + echo "Options:" + echo " --full-keys Download full set of keys for production use" + echo " --no-reset Don't reset installation log" + echo " --skip-components LIST Skip installation of specified components" + echo " --force-reinstall Force reinstall of all components" + echo "" + echo "LIST is a comma-separated list of components:" + echo " go,rust,node,pnpm,solana,anchor,jq,photon,keys,dependencies,redis" + echo "" + echo "Examples:" + echo " $0 --full-keys # Install with full production keys" + echo " $0 --skip-components redis,keys,go # Skip Redis, keys and Go installation" + echo "------------------------------------------------" exit 1 ;; esac