Skip to content

Improve installation scripts and documentation #1843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
79 changes: 69 additions & 10 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Light Protocol Installation

Running `install.sh` is the first thing you should do after cloning this monorepo.

```bash
Expand All @@ -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

Expand All @@ -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
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
35 changes: 29 additions & 6 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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."
17 changes: 15 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,21 @@ main() {
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--full-keys] [--no-reset] [--skip-components <comma-separated-list>] [--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
Expand Down
Loading