-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Internal: build Stone separately from the SDK (#4)
Problem: the build time of the SDK reaches ~20 minutes, which is not acceptable to users. This is due to the compilation of Stone in the `build.rs` file. Solution: we now build and install Stone from a Shell script that is isolated from the Rust compilation process. Developers must now run this script before attempting to run tests, but this accelerates the build process significantly.
- Loading branch information
1 parent
d4111ae
commit d5926ea
Showing
9 changed files
with
160 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
# Stone Prover SDK | ||
|
||
Rust SDK for the Starkware Stone prover and verifier. | ||
|
||
## Install | ||
|
||
To use this SDK, you will need the Stone prover and verifier binaries. | ||
You can either follow the instructions on the [Stone repository](https://github.com/starkware-libs/stone-prover), | ||
download them from the [latest SDK release](https://github.com/Moonsong-Labs/stone-prover-sdk/releases/latest) | ||
or run the following commands: | ||
|
||
```shell | ||
git clone --recurse-submodules https://github.com/Moonsong-Labs/stone-prover-sdk.git | ||
cd stone-prover-sdk | ||
bash scripts/install-stone.sh | ||
``` | ||
|
||
This will install the prover and verifier in `${HOME}/.stone` and add this directory to your `PATH`. | ||
|
||
## Features | ||
|
||
### Prove and verify Cairo programs | ||
|
||
The `prover` and `verifier` modules contain thin abstractions on top of the prover and verifier. | ||
They allow the user to prove and verify the execution of any Cairo program from Rust code. | ||
|
||
### Execute Cairo programs | ||
|
||
The `cairo_vm` module provides utility functions over the [cairo-vm](https://github.com/Moonsong-Labs/cairo-vm) | ||
crate to execute Cairo programs using the Rust Cairo VM. | ||
|
||
## Contribute | ||
|
||
### Set up the development environment | ||
|
||
First, clone the repository and install Stone: | ||
|
||
```shell | ||
git clone --recurse-submodules https://github.com/Moonsong-Labs/stone-prover-sdk.git | ||
cd stone-prover-sdk | ||
bash scripts/install-stone.sh | ||
``` | ||
|
||
This step takes several minutes. The script adds the install directory (`$HOME/.stone` by default) to your `PATH` | ||
for supported shells. Make sure that this is the case: | ||
|
||
```shell | ||
which cpu_air_prover | ||
# Should print <install-dir>/cpu_air_prover | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
OUTPUT_DIR="$(pwd)" | ||
|
||
while true; do | ||
case "$1" in | ||
-o | --output-dir ) OUTPUT_DIR="$2"; shift 2 ;; | ||
* ) break ;; | ||
esac | ||
done | ||
|
||
mkdir -p "${OUTPUT_DIR}" | ||
|
||
STONE_DIR="${SCRIPT_DIR}/../dependencies/stone-prover" | ||
|
||
STONE_GIT_TAG=$(cat .git/modules/dependencies/stone-prover/HEAD) | ||
IMAGE_NAME="stone-prover-build:${STONE_GIT_TAG}" | ||
ARCH_NAME=$(uname -m) | ||
|
||
BUILD_FLAGS="" | ||
if [ "${ARCH_NAME}" == "arm64" ]; then BUILD_FLAGS="--build-arg CMAKE_ARGS=-DNO_AVX=1"; fi | ||
|
||
docker build -t "${IMAGE_NAME}" ${BUILD_FLAGS} "${STONE_DIR}" | ||
|
||
CONTAINER=$(docker create "${IMAGE_NAME}") | ||
docker cp -L "${CONTAINER}:/bin/cpu_air_prover" "${OUTPUT_DIR}" | ||
docker cp -L "${CONTAINER}:/bin/cpu_air_verifier" "${OUTPUT_DIR}" | ||
|
||
docker rm "${CONTAINER}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
INSTALL_DIR="${HOME}/.stone" | ||
|
||
while true; do | ||
case "$1" in | ||
-i | --install-dir ) INSTALL_DIR="$2"; shift 2 ;; | ||
* ) break ;; | ||
esac | ||
done | ||
|
||
echo "Installing Stone in ${INSTALL_DIR}..." | ||
mkdir -p "${INSTALL_DIR}" | ||
bash "${SCRIPT_DIR}/build-stone.sh" --output-dir "${INSTALL_DIR}" | ||
|
||
# Add the tool to the PATH | ||
|
||
echo "Configuring PATH..." | ||
if [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then | ||
PROFILE_FILE="" | ||
# ZSH_NAME is set on zsh | ||
if [ -v ZSH_NAME ]; then | ||
PROFILE_FILE="${HOME}/.zsh" | ||
elif [ -v BASH ]; then | ||
PROFILE_FILE="${HOME}/.bashrc" | ||
else | ||
echo "Unsupported shell, you will need to add the export PATH statement in the right configuration file manually." | ||
fi | ||
|
||
if [ -n "${PROFILE_FILE}" ]; then | ||
echo -e "\n# Stone prover and verifier\nexport PATH=\"${INSTALL_DIR}:\$PATH\"" >> "${PROFILE_FILE}" | ||
fi | ||
fi | ||
|
||
# Notify the user to update the PATH immediately | ||
echo "Done!" | ||
echo "Stone was added to ${PROFILE_FILE} and will be available the next time you open a shell." | ||
echo "To add Stone to your PATH immediately, run the following command:" | ||
echo "export PATH=\"${INSTALL_DIR}:\$PATH\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.