Skip to content
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

Release script and install docs #589

Merged
merged 35 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9998e6b
build and tar installation in docker for ubuntu22
yshekel Aug 26, 2024
b7daf85
add dockerfiles for ubuntu20 and centos7 too
yshekel Aug 26, 2024
1af6e00
updated readme file for install, use and release
yshekel Aug 27, 2024
3e83421
update docs for install and use
yshekel Aug 27, 2024
ed8d12e
updated release build script for split frontend and backend libs
yshekel Aug 27, 2024
7e443aa
update docs about install and issues that may rise
yshekel Aug 27, 2024
6440c74
skip libraries that do not seem to be icicle backend libs
yshekel Aug 27, 2024
b50d089
fix spelling and formatting
yshekel Aug 27, 2024
899159a
add C++ example for install and use icicle release
yshekel Aug 28, 2024
ea5641a
cover custom install path too
yshekel Aug 28, 2024
c4ecd6e
updated doc with link to example
yshekel Aug 28, 2024
8e1144b
Update scripts/release/build_release_and_tar.sh
yshekel Aug 28, 2024
8158c4f
spelling
yshekel Aug 28, 2024
8501957
ubi docker files and script to build all
yshekel Aug 28, 2024
e50d46b
typo
yshekel Aug 28, 2024
5ed3ce9
install cmake in ubi dockers
yshekel Aug 28, 2024
a17b21a
add output dir as arg of build_all.sh script
yshekel Aug 28, 2024
f676112
formatting
yshekel Aug 28, 2024
275582c
add rust example for install and use CUDA backend
yshekel Aug 28, 2024
a5ef1b2
update rust use installed binaries example
yshekel Aug 28, 2024
e4a8e16
dummy run scripts for examples
yshekel Aug 28, 2024
87bcb04
fix minor mistake in doc
yshekel Aug 28, 2024
5ec47f8
fix doc
yshekel Aug 28, 2024
7e4a648
Update examples/c++/install-and-use-icicle/README.md
yshekel Aug 29, 2024
4c798cb
Update examples/c++/install-and-use-icicle/README.md
yshekel Aug 29, 2024
712bdfc
Update examples/c++/install-and-use-icicle/README.md
yshekel Aug 29, 2024
d3cdd1f
Update examples/c++/install-and-use-icicle/README.md
yshekel Aug 29, 2024
e0dcb27
Update scripts/release/README.md
yshekel Aug 29, 2024
05c138e
Update scripts/release/README.md
yshekel Aug 29, 2024
a3f9ce4
make smoe debug pring verbose
yshekel Aug 29, 2024
e179664
code review fixes
yshekel Aug 29, 2024
7275872
update release.yml script to build and upload the release
yshekel Aug 29, 2024
e9e9b2a
fixed cuda backend license info
yshekel Aug 29, 2024
e7b6ef2
more code review fixes
yshekel Aug 29, 2024
3442cbd
fix missing > in readme
yshekel Aug 29, 2024
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
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,15 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p release_output && rm -rf ./release_output/*
./scripts/release/build_all.sh ./release_output
LATEST_TAG=$(git describe --tags --abbrev=0)
gh release create $LATEST_TAG --generate-notes -d --verify-tag -t "Release $LATEST_TAG"
- name: Upload release tars
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LATEST_TAG=$(git describe --tags --abbrev=0)
for file in ./release_output/*.tar.gz; do
gh release upload $LATEST_TAG "$file"
done
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Getting Started with ICICLE V3
# Build ICICLE from source

This guide will help you get started with building, testing, and installing ICICLE, whether you're using C++, Rust, or Go. It also covers installation of the CUDA backend and important build options.

Expand Down Expand Up @@ -48,7 +48,7 @@ target_link_libraries(yourApp PRIVATE icicle_field_babybear icicle_device)
```

5. **Installation (optional):**
To install the libs, specify the install prefix in the [cmake command](./getting_started.md#build-commands)
To install the libs, specify the install prefix in the [cmake command](./build_from_source.md#build-commands)
`-DCMAKE_INSTALL_PREFIX=/install/dir/`. Default install path on linux is `/usr/local` if not specified. For other systems it may differ. The cmake command will print it to the log
```
-- CMAKE_INSTALL_PREFIX=/install/dir/for/cmake/install
Expand All @@ -61,7 +61,7 @@ cmake --install build # install icicle to /path/to/install/dir/
```

6. **Run tests (optional):**
Add `-DBUILD_TESTS=ON` to the [cmake command](./getting_started.md#build-commands) and build.
Add `-DBUILD_TESTS=ON` to the [cmake command](./build_from_source.md#build-commands) and build.
Execute all tests
```bash
cmake -S icicle -B build -DFIELD=babybear -DBUILD_TESTS=ON
Expand Down Expand Up @@ -124,7 +124,7 @@ Cargo features are used to disable features, rather than enable them, for the re

They can be disabled as follows:
```bash
cargo build --release --no-default-features --features=no_ecntt,no_g2
cargo build --release --features=no_ecntt,no_g2
```

:::note
Expand All @@ -144,21 +144,19 @@ Most tests assume a CUDA backend is installed and fail otherwise.

4. **Install the library:**

By default, the libraries are installed to the `target/<buildmode>/deps/icicle` dir. For custom install dir. define the env variable:
By default, the libraries are installed to the `target/<buildmode>/deps/icicle` dir. If you want them installed elsewhere, define the env variable:
```bash
export ICICLE_INSTALL_DIR=/path/to/install/dir
```

(TODO: cargo install ?)

#### Use as cargo dependency
In cargo.toml, specify the ICICLE libs to use:

```bash
[dependencies]
icicle-runtime = { path = "git = "https://github.com/ingonyama-zk/icicle.git"" }
icicle-core = { path = "git = "https://github.com/ingonyama-zk/icicle.git"" }
icicle-bls12-377 = { path = "git = "https://github.com/ingonyama-zk/icicle.git" }
icicle-runtime = { git = "https://github.com/ingonyama-zk/icicle.git", branch="main" }
icicle-core = { git = "https://github.com/ingonyama-zk/icicle.git", branch="main" }
icicle-babybear = { git = "https://github.com/ingonyama-zk/icicle.git", branch="main" }
# add other ICICLE crates here if need additional fields/curves
```

Expand Down
158 changes: 158 additions & 0 deletions docs/docs/icicle/install_and_use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Install and use ICICLE

## Overview

This page describes the content of a release and how to install and use it.
Icicle binaries are released for multiple Linux distributions, including Ubuntu 20.04, Ubuntu 22.04, and CentOS 7.

:::note
Future releases will also include MacOS and other systems.
:::

## Content of a Release

Each Icicle release includes a tar file, named `icicle30-<distribution>.tar.gz`, where `icicle30` stands for version 3.0. This tar contains icicle-frontend build artifacts and headers for a specific distribution. The tar file includes the following structure:

- **`./icicle/include/`**: This directory contains all the necessary header files for using the Icicle library from C++.
- **`./icicle/lib/`**:
- **Icicle Libraries**: All the core Icicle libraries are located in this directory. Applications linking to Icicle will use these libraries.
- **Backends**: The `./icicle/lib/backend/` directory houses backend libraries, including the CUDA backend (not included in this tar).

- **CUDA backend** comes as separate tar `icicle30-<distribution>-cuda122.tar.gz`
- per distribution, for icicle-frontend V3.0 and CUDA 12.2.

## installing and using icicle

- Full C++ example here: https://github.com/ingonyama-zk/icicle/tree/yshekel/V3_release_and_install/examples/c++/install-and-use-icicle
- Full Rust example here: https://github.com/ingonyama-zk/icicle/tree/yshekel/V3_release_and_install/examples/rust/install-and-use-icicle

(TODO update links to main branch when merged)

1. **Extract and install the Tar Files**:
- Download (TODO link to latest release) the appropriate tar files for your distribution (Ubuntu 20.04, Ubuntu 22.04, or UBI 8,9 for RHEL compatible binaries).
- **Frontend libs and headers** should be installed in default search paths (such as `/usr/lib` and `usr/local/include`) for the compiler and linker to find.
- **Backend libs** should be installed in `/opt`
- Extract it to your desired location:
```bash
# install the frontend part (Can skip for Rust)
tar xzvf icicle30-ubuntu22.tar.gz
cp -r ./icicle/lib/* /usr/lib/
cp -r ./icicle/include/icicle/ /usr/local/include/ # copy C++ headers
# extract CUDA backend (OPTIONAL)
tar xzvf icicle30-ubuntu22-cuda122.tar.gz -C /opt
```

:::note
Installing the frontend is optional. Rust is not using it.
You may install to any directory but need to make sure it can be found by the linker at compile and runtime.
:::

:::tip
You can install anywhere and use a link so that it can be easily found as if in the default directory.
:::

1. **Linking Your Application**:

Apps need to link to the ICICLE device library and to every field and/or curve libraries. The backend libraries are dynamically loaded at runtime, so not linking to them.

**C++**
- When compiling your C++ application, link against the Icicle libraries:
```bash
g++ -o myapp myapp.cpp -licicle_device -licicle_field_bn254 -licicle_curve_bn254

# if not installed in standard dirs, for example /custom/path/, need to specify it
g++ -o myapp myapp.cpp -I/custom/path/icicle/include -L/custom/path/icicle/lib -licicle_device -licicle_field_bn254 -licicle_curve_bn254 -Wl,-rpath,/custom/path/icicle/lib/
```

- Or via cmake
```cmake
# Add the executable
add_executable(example example.cpp)
# Link the libraries
target_link_libraries(example icicle_device icicle_field_bn254 icicle_curve_bn254)

# OPTIONAL (if not installed in default location)

# The following is setting compile and runtime paths for headers and libs assuming
# - headers in /custom/path/icicle/include
# - libs in/custom/path/icicle/lib

# Include directories
target_include_directories(example PUBLIC /custom/path/icicle/include)
# Library directories
target_link_directories(example PUBLIC /custom/path/icicle/lib/)
# Set the RPATH so linker finds icicle libs at runtime
set_target_properties(example PROPERTIES
BUILD_RPATH /custom/path/icicle/lib/
INSTALL_RPATH /custom/path/icicle/lib/)
```

:::tip
If you face linkage issues, try `ldd myapp` to see the runtime deps. If ICICLE libs are not found, you need to add the install directory to the search path of the linker. In a development env you can do that using the env variable `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/custom/path/icicle/lib` or similar (for non linux). For deployment, make sure it can be found and avoid `LD_LIBRARY_PATH`.

Alternatively you can embed the search path on the app as an `rpath` by adding `-Wl,-rpath,/custom/path/icicle/lib/`. This is what is demonstrated above.
:::

**Rust**
- When building the icicle crates, icicle frontend libs are built from source, in addition to the rust bindings. They are installed to `target/<buildtype>/deps/icile` and cargo will link correctly. Note that you still need to install CUDA backend if you have a CUDA GPU.
- Simply use `cargo build` or `cargo run` and it should link to icicle libs.

**Go** - TODO

:::warning when deploying an application (either C++, Rust or Go), you must make sure to either deploy the icicle libs (that you download or build from source) along the application binaries (as tar, docker image, package manager installer or else) or make sure to install icicle (and the backend) on the target machine. Otherwise the target machine will have linkage issues.
:::

## Backend Loading

The Icicle library dynamically loads backend libraries at runtime. By default, it searches for backends in the following order:

1. **Environment Variable**: If the `ICICLE_BACKEND_INSTALL_DIR` environment variable is defined, Icicle will prioritize this location.
2. **Default Directory**: If the environment variable is not set, Icicle will search in the default directory `/opt/icicle/lib/backend`.

:::warning
If building ICICLE frontend from source, make sure to load a backend that is compatible to the frontend version. CUDA backend libs are forward compatible with newer frontends (e.g. CUDA-backend-3.0 works with ICICLE-3.2). The opposite is not guaranteed.
:::

If you install in a custom dir, make sure to set `ICICLE_BACKEND_INSTALL_DIR`:
```bash
ICICLE_BACKEND_INSTALL_DIR=path/to/icicle/lib/backend/ myapp # for an executable maypp
ICICLE_BACKEND_INSTALL_DIR=path/to/icicle/lib/backend/ cargo run # when using cargo
```

Then to load backend from ICICLE_BACKEND_INSTALL_DIR or `/opt/icicle/lib/backend` in your application:

**C++**
```cpp
extern "C" eIcicleError icicle_load_backend_from_env_or_default();
```
**Rust**
```rust
pub fn load_backend_from_env_or_default() -> Result<(), eIcicleError>;
```
**Go**
```go
TODO
```

### Custom Backend Loading

If you need to load a backend from a custom location at any point during runtime, you can call the following function:

**C++**
```cpp
extern "C" eIcicleError icicle_load_backend(const char* path, bool is_recursive);
```
- **`path`**: The directory where the backend libraries are located.
- **`is_recursive`**: If `true`, the function will search for backend libraries recursively within the specified path.

**Rust**
```rust
pub fn load_backend(path: &str) -> Result<(), eIcicleError>; // OR
pub fn load_backend_non_recursive(path: &str) -> Result<(), eIcicleError>;
```
- **`path`**: The directory where the backend libraries are located.

**Go**
```go
TODO
```
53 changes: 15 additions & 38 deletions docs/docs/icicle/install_cuda_backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,28 @@ The CUDA backend in ICICLE V3 is a high-performance, closed-source component des

## Installation

The CUDA backend is a closed-source component that requires a license. To install the CUDA backend:
The CUDA backend is a closed-source component that requires a license. [To install the CUDA backend, see here](./install_and_use#installing-and-using-icicle).

1. **Download the CUDA backend package** from the [ICICLE website](#). TODO fix link.
### Licensing

2. **Install to the default path:**
```bash
sudo tar -xzf icicle-cuda-backend.tar.gz -C /opt/icicle/backend/
```
The CUDA backend requires a valid license to function. There are two CUDA backend license types:

3. **Set up the environment variable if you installed it in a custom location:**
```bash
export ICICLE_BACKEND_INSTALL_DIR=/custom/path/to/icicle/backend
# OR symlink
sudo ln -s /custom/path/to/icicle/backend /opt/icicle/backend
```
1. **Floating license**: In this mode, you will host a license-server that is supplied as binary. This license is limited to N concurrent gpus but can be distributed however the user needs between his machines. N is decremented by 1 for every GPU that is using ICICLE, per process. Once the process is terminated (or crashes), the licenses are released.
2. **Node locked license**: in this mode, you will get a license for a specific machine. It is accepted by the CUDA backend only if used on the licensed machine.

4. **Load the backend in your application:**
```cpp
extern "C" eIcicleError icicle_load_backend_from_env_or_default();
// OR
extern "C" eIcicleError icicle_load_backend(const char* path, bool is_recursive);
```
Rust:
```rust
pub fn load_backend_from_env_or_default() -> Result<(), eIcicleError>;
pub fn load_backend(path: &str) -> Result<(), eIcicleError>;
```
Go:
```
TODO
```
:::note
As for now CUDA backend can be accessed without purchasing a license. Ingonyama is hosting a license server that will allow access to anyone.
By default CUDA backend will try to access this server if no other license is available.
TO manually specify it, set `export ICICLE_LICENSE=5053@ec2-50-16-150-188.compute-1.amazonaws.com`.
:::

5. **Acquire a license key** from the [ICICLE website](#) and follow the provided instructions to activate it.
Licenses are available for purchase [here TODO](#) . After purchasing, you will receive a license key that must be installed on the license-server or node-locked machine.
For license-server, you will have to tell the application that is using ICICLE, where the server is.

**Specify the license server address:**


### Licensing (TODO fix link)

The CUDA backend requires a valid license to function. Licenses are available for purchase [here](#). After purchasing, you will receive a license key that must be installed. **Specify the license server address:**
```
export ICICLE_LICNSE_SERVER_PATH=port@ip
export ICICLE_LICENSE=port@ip
```

For licensing instructions and detailed information, refer to the licensing documentation provided with your purchase or contact our support team for assistance.

TODO update section and the link in license part above.


For further assist , contact our support team for assistance. `support@ingonyama.com` (TODO make sure this exists).
2 changes: 1 addition & 1 deletion docs/docs/icicle/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See programmers guide for more details. [C++](./programmers_guide/cpp#device-man

ICICLE Core is a template library written in C++ that implements fundamental cryptographic operations, including field and curve arithmetic, as well as higher-level APIs such as MSM and NTT.

The Core can be [instantiated](./getting_started) for different fields, curves, and other cryptographic components, allowing you to tailor it to your specific needs. You can link your application to one or more ICICLE libraries, depending on the requirements of your project. For example, you might only need the babybear library or a combination of babybear and a Merkle tree builder.
The Core can be [instantiated](./build_from_source) for different fields, curves, and other cryptographic components, allowing you to tailor it to your specific needs. You can link your application to one or more ICICLE libraries, depending on the requirements of your project. For example, you might only need the babybear library or a combination of babybear and a Merkle tree builder.


### Rust
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/icicle/multi-device.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ icicle_runtime::set_device(&device).unwrap();
* - `SUCCESS` if the device is available.
* - `INVALID_DEVICE` if the device is not available.
*/
extern "C" eIcicleError icicle_is_device_avialable(const Device& dev);
extern "C" eIcicleError icicle_is_device_available(const Device& dev);

/**
* @brief Get number of available devices active device for thread
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/icicle/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ICICLE is also well-suited for prototyping and developing small-scale projects.

## Get Started with ICICLE

Explore the full capabilities of ICICLE by diving into the [Architecture](./arch_overview.md), [Getting Started Guide](./getting_started.md) and the [programmers guide](./programmers_guide/general.md) to learn how to integrate, deploy, and extend ICICLE across different backends.
Explore the full capabilities of ICICLE by diving into the [Architecture](./arch_overview.md), [Getting Started Guide](./install_and_use.md) and the [programmers guide](./programmers_guide/general.md) to learn how to integrate, deploy, and extend ICICLE across different backends.

If you have any questions or need support, feel free to reach out on [Discord] or [GitHub](https://github.com/ingonyama-zk). We're here to help you accelerate your ZK development with ICICLE.

Expand Down
Loading
Loading