From fb1b0adc96ff117ccfc0884de4122dd3c0b84569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Thu, 14 Nov 2024 20:57:46 +0000 Subject: [PATCH 01/17] update short guide --- docs/guides/setup-dev.md | 47 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/docs/guides/setup-dev.md b/docs/guides/setup-dev.md index 43350ac3314d..b7fa457ae43f 100644 --- a/docs/guides/setup-dev.md +++ b/docs/guides/setup-dev.md @@ -8,54 +8,49 @@ initializing the workspace, it's recommended that you read the whole guide below If you run on 'clean' Ubuntu on GCP: ```bash -# For VMs only! They don't have SSH keys, so we override SSH with HTTPS -git config --global url."https://github.com/".insteadOf git@github.com: -git config --global url."https://".insteadOf git:// +# All necessary stuff +sudo apt update +sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common # Rust curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +# For running unit tests +cargo install cargo-nextest --locked +# SQL tools +cargo install sqlx-cli --version 0.8.1 -# NVM -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash - -# All necessary stuff -sudo apt-get update -sudo apt-get install -y build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common - -# Install docker +# Install Docker curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" sudo apt install docker-ce + +# Optional: If you wish to run Docker commands without sudo, you can run this command. +# Otherwise, just ignore this line and run all Docker commands with sudo. +# After this command, you might need to re-connect (due to usermod change). sudo usermod -aG docker ${USER} -# Start docker. +# Start Docker sudo systemctl start docker -## You might need to re-connect (due to usermod change). - -# Node & yarn +# NVM +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash nvm install 20 -# Important: there will be a note in the output to load -# new paths in your local session, either run it or reload the terminal. -npm install -g yarn -yarn set version 1.22.19 -# For running unit tests -cargo install cargo-nextest -# SQL tools -cargo install sqlx-cli --version 0.8.1 +# Yarn +npm install -g yarn | bash +yarn set version 1.22.19 -# Foundry ZKsync +# Foundry ZK sync curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash foundryup-zksync # Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers # Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. echo "export ZKSYNC_USE_CUDA_STUBS=true" >> ~/.bashrc -# You will need to reload your `*rc` file here +source ~/.bashrc # Clone the repo to the desired location -git clone git@github.com:matter-labs/zksync-era.git +git clone https://github.com/matter-labs/zksync-era.git cd zksync-era git submodule update --init --recursive ``` From 56d519d2278a64de3fde1fc5f1263799000732f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 00:20:01 +0000 Subject: [PATCH 02/17] Changed to correct shell after Rust install. --- docs/guides/setup-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/setup-dev.md b/docs/guides/setup-dev.md index b7fa457ae43f..48b5d618b05d 100644 --- a/docs/guides/setup-dev.md +++ b/docs/guides/setup-dev.md @@ -13,7 +13,7 @@ sudo apt update sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common # Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash # For running unit tests cargo install cargo-nextest --locked # SQL tools From 2bb53aa3b6c63847af551deacbedb73123a246ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 01:22:47 +0000 Subject: [PATCH 03/17] update guide --- docs/guides/setup-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/setup-dev.md b/docs/guides/setup-dev.md index 48b5d618b05d..b5e80ed553e6 100644 --- a/docs/guides/setup-dev.md +++ b/docs/guides/setup-dev.md @@ -22,7 +22,7 @@ cargo install sqlx-cli --version 0.8.1 # Install Docker curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" -sudo apt install docker-ce +sudo apt install --yes docker-ce # Optional: If you wish to run Docker commands without sudo, you can run this command. # Otherwise, just ignore this line and run all Docker commands with sudo. From 008164ee5dcfdba31fcfc1f665a8e5d32694d880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 04:01:32 +0000 Subject: [PATCH 04/17] changes for script --- docs/guides/setup-dev.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/guides/setup-dev.md b/docs/guides/setup-dev.md index b5e80ed553e6..698b48b85ac9 100644 --- a/docs/guides/setup-dev.md +++ b/docs/guides/setup-dev.md @@ -13,7 +13,8 @@ sudo apt update sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common # Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +source "$HOME/.cargo/env" # For running unit tests cargo install cargo-nextest --locked # SQL tools @@ -21,38 +22,38 @@ cargo install sqlx-cli --version 0.8.1 # Install Docker curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" +sudo add-apt-repository --yes "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" sudo apt install --yes docker-ce -# Optional: If you wish to run Docker commands without sudo, you can run this command. -# Otherwise, just ignore this line and run all Docker commands with sudo. -# After this command, you might need to re-connect (due to usermod change). -sudo usermod -aG docker ${USER} - # Start Docker sudo systemctl start docker # NVM curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 # Yarn -npm install -g yarn | bash +npm install -g yarn yarn set version 1.22.19 # Foundry ZK sync curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash -foundryup-zksync +./foundryup-zksync # Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers # Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. -echo "export ZKSYNC_USE_CUDA_STUBS=true" >> ~/.bashrc -source ~/.bashrc +echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" # Clone the repo to the desired location git clone https://github.com/matter-labs/zksync-era.git cd zksync-era git submodule update --init --recursive + +# Reload shell +exec bash ``` Don't forget to look at [tips](#tips). From 87a9f2f211cf6a7eacd98a6ec975200b606217bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 04:05:31 +0000 Subject: [PATCH 05/17] automated rust install --- docs/guides/setup-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/setup-dev.md b/docs/guides/setup-dev.md index 698b48b85ac9..597ad7deb7b7 100644 --- a/docs/guides/setup-dev.md +++ b/docs/guides/setup-dev.md @@ -13,7 +13,7 @@ sudo apt update sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common # Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source "$HOME/.cargo/env" # For running unit tests cargo install cargo-nextest --locked From c3da4f2316c72807586079b56d404dbeed8de3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 04:30:38 +0000 Subject: [PATCH 06/17] added zk stack cli --- docs/guides/setup-dev.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/guides/setup-dev.md b/docs/guides/setup-dev.md index 597ad7deb7b7..b01a6d59e3d7 100644 --- a/docs/guides/setup-dev.md +++ b/docs/guides/setup-dev.md @@ -13,7 +13,7 @@ sudo apt update sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common # Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y source "$HOME/.cargo/env" # For running unit tests cargo install cargo-nextest --locked @@ -43,15 +43,17 @@ yarn set version 1.22.19 curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash ./foundryup-zksync +# ZK Stack CLI +curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash +"$HOME/.local/bin/zkstackup" + +# Clone the repo +git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git + # Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers # Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" -# Clone the repo to the desired location -git clone https://github.com/matter-labs/zksync-era.git -cd zksync-era -git submodule update --init --recursive - # Reload shell exec bash ``` From 249477e9318a7b2ccc1581e651aa9c331648db8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 15:46:25 +0000 Subject: [PATCH 07/17] Removed foundryup call, unnecessary. --- docs/src/guides/setup-dev.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index b01a6d59e3d7..799170fd8fab 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -41,7 +41,6 @@ yarn set version 1.22.19 # Foundry ZK sync curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash -./foundryup-zksync # ZK Stack CLI curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash @@ -54,8 +53,8 @@ git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git # Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" -# Reload shell -exec bash +echo "Installation of Dev setup complete!" +echo "Please reload your terminal. You can do so by running `exec bash`." ``` Don't forget to look at [tips](#tips). From 603f31fc41ab9718892585cb09a62be0a3f79576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 16:34:41 +0000 Subject: [PATCH 08/17] Created script. --- docs/src/guides/setup-dev.md | 48 +------------------------ docs/src/guides/setup-dev.sh | 69 ++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 47 deletions(-) create mode 100644 docs/src/guides/setup-dev.sh diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index 799170fd8fab..bed28b8b3cb0 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -8,53 +8,7 @@ initializing the workspace, it's recommended that you read the whole guide below If you run on 'clean' Ubuntu on GCP: ```bash -# All necessary stuff -sudo apt update -sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common - -# Rust -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y -source "$HOME/.cargo/env" -# For running unit tests -cargo install cargo-nextest --locked -# SQL tools -cargo install sqlx-cli --version 0.8.1 - -# Install Docker -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -sudo add-apt-repository --yes "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" -sudo apt install --yes docker-ce - -# Start Docker -sudo systemctl start docker - -# NVM -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -nvm install 20 - -# Yarn -npm install -g yarn -yarn set version 1.22.19 -# Foundry ZK sync -curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash - -# ZK Stack CLI -curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash -"$HOME/.local/bin/zkstackup" - -# Clone the repo -git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git - -# Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers -# Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. -echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" - -echo "Installation of Dev setup complete!" -echo "Please reload your terminal. You can do so by running `exec bash`." ``` Don't forget to look at [tips](#tips). @@ -219,7 +173,7 @@ SQLx is a Rust library we use to interact with Postgres, and its CLI is used to features of the library. ```bash -cargo install --locked sqlx-cli --version 0.8.1 +cargo install sqlx-cli --version 0.8.1 ``` ## Easier method using `nix` diff --git a/docs/src/guides/setup-dev.sh b/docs/src/guides/setup-dev.sh new file mode 100644 index 000000000000..c54a0641ef07 --- /dev/null +++ b/docs/src/guides/setup-dev.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +main() { + say "Setting up the development environment for ZKSync" + + # All necessary stuff + say "Installing apt dependencies..." + sudo apt update + sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common + + # Rust + say "Installing Rust..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y + source "$HOME/.cargo/env" + # For running unit tests + say "Installing Nextest..." + cargo install cargo-nextest --locked + # SQL tools + say "Installing SQLx CLI..." + cargo install sqlx-cli --version 0.8.1 + + # Install Docker + say "Installing Docker..." + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository --yes "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" + sudo apt install --yes docker-ce + + # Start Docker + say "Starting Docker..." + sudo systemctl start docker + + # NVM + say "Installing NVM..." + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + nvm install 20 + + # Yarn + say "Installing Yarn..." + npm install -g yarn + yarn set version 1.22.19 + + # Foundry ZK sync + say "Installing Foundry ZK Sync..." + curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash + + # ZK Stack CLI + say "Installing ZK Stack CLI..." + curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash + "$HOME/.local/bin/zkstackup" + + # Clone the repo + say "Cloning the ZK Sync repository..." + git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git + + # Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers + # Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. + say "Setting up the non-CUDA setup..." + echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" + + say "Installation of the development environment for ZKSync complete!" + say "Please reload your shell configuration by running 'source ~/.bashrc'" +} + +say() { + echo -e "\033[1;32m$1\033[0m" +} \ No newline at end of file From 04f5d9a3d5c3444577ed935d0f478d2029777bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 16:41:34 +0000 Subject: [PATCH 09/17] Fix script --- docs/src/guides/setup-dev.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/guides/setup-dev.sh b/docs/src/guides/setup-dev.sh index c54a0641ef07..3155098f68b9 100644 --- a/docs/src/guides/setup-dev.sh +++ b/docs/src/guides/setup-dev.sh @@ -66,4 +66,6 @@ main() { say() { echo -e "\033[1;32m$1\033[0m" -} \ No newline at end of file +} + +main "$@" \ No newline at end of file From 457c4f2bf6feefc485fe80fb84426b07a15f98a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 17:11:22 +0000 Subject: [PATCH 10/17] Updated docs --- docs/src/guides/setup-dev.md | 172 +++++++++++++++-------------------- docs/src/guides/setup-dev.sh | 10 +- 2 files changed, 80 insertions(+), 102 deletions(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index bed28b8b3cb0..52aa5aaa866e 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -1,19 +1,21 @@ -# Installing dependencies +# Installing development setup for ZKsync ## TL;DR -This is a shorter version of setup guide to make it easier subsequent initializations. If it's the first time you're +This is a shorter version of setup guide to make it easier for initializations. If it's the first time you're initializing the workspace, it's recommended that you read the whole guide below, as it provides more context and tips. -If you run on 'clean' Ubuntu on GCP: +Just run the following command on Linux: ```bash - +curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/docs/src/guides/setup-dev.sh | bash ``` Don't forget to look at [tips](#tips). -## Supported operating systems +## Installation guide + +### Supported operating systems ZKsync currently can be launched on any \*nix operating system (e.g. any linux distribution or macOS). @@ -28,84 +30,26 @@ Rosetta may cause problems that are hard to spot and debug, so make sure to chec If you are a NixOS user or would like to have a reproducible environment, skip to the section about `nix`. -## Docker - -Install `docker`. It is recommended to follow the instructions from the -[official site](https://docs.docker.com/install/). - -Note: currently official site proposes using Docker Desktop for Linux, which is a GUI tool with plenty of quirks. If you -want to only have CLI tool, you need the `docker-ce` package and you can follow -[this guide](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04) for Ubuntu. - -Installing `docker` via `snap` or from the default repository can cause troubles. - -You need to install both `docker` and `docker compose`. - -**Note:** `docker compose` is installed automatically with `Docker Desktop`. - -**Note:** On linux you may encounter the following error when you’ll try to work with `zksync`: - -``` -ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`. -``` - -If so, you **do not need** to install `docker-machine`. Most probably, it means that your user is not added to -the`docker` group. You can check it as follows: - -```bash -docker-compose up # Should raise the same error. -sudo docker-compose up # Should start doing things. -``` - -If the first command fails, but the second succeeds, then you need to add your user to the `docker` group: - -```bash -sudo usermod -a -G docker your_user_name -``` - -After that, you should logout and login again (user groups are refreshed after the login). The problem should be solved -at this step. - -If logging out does not resolve the issue, restarting the computer should. - -## Node.js & Yarn - -1. Install `Node` (requires version `v20`). The recommended way is via [nvm](https://github.com/nvm-sh/nvm). -2. Install `yarn`. Can be done via `npm install -g yarn`. Make sure to get version 1.22.19 - you can change the version - by running `yarn set version 1.22.19`. +### Basic packages -## clang - -In order to compile RocksDB, you must have LLVM available. On debian-based linux it can be installed as follows: +Install the basic packages: On debian-based linux: ```bash -sudo apt-get install build-essential pkg-config cmake clang lldb lld +sudo apt install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common ``` -On macOS: - -You need to have an up-to-date `Xcode`. You can install it directly from `App Store`. With Xcode command line tools, you -get the Clang compiler installed by default. Thus, having XCode you don't need to install `clang`. - -## OpenSSL - -Install OpenSSL: - On mac: ```bash -brew install openssl +brew install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common ``` -On debian-based linux: +Note that in order to install `clang` on MacOS you need to have an up-to-date `Xcode`. You can install it directly from `App Store`. +With `Xcode` command line tools, you get the Clang compiler installed by default. Thus, having `Xcode` you don't need to install `clang`. -```bash -sudo apt-get install libssl-dev -``` - -## Rust +### Rust Install `Rust`'s toolchain version reported in `/rust-toolchain.toml` (also a later stable version should work). @@ -141,54 +85,71 @@ If you see `x86_64` mentioned in the output, probably you're running (or used to that's the case, you should probably change the way you run terminal, and/or reinstall your IDE, and then reinstall the Rust toolchain as well. -## PostgreSQL Client Library - -For development purposes, you typically only need the PostgreSQL client library, not the full server installation. -Here's how to install it: +#### Cargo nextest -On macOS: +[cargo-nextest](https://nexte.st/) is the next-generation test runner for Rust projects. `zkstack dev test rust` uses +`cargo nextest` by default. ```bash -brew install libpq +cargo install cargo-nextest --locked ``` -On Debian-based Linux: +#### SQLx CLI + +SQLx is a Rust library we use to interact with Postgres, and its CLI is used to manage DB migrations and support several +features of the library. ```bash -sudo apt-get install libpq-dev +cargo install sqlx-cli --version 0.8.1 ``` -### Cargo nextest +### Docker -[cargo-nextest](https://nexte.st/) is the next-generation test runner for Rust projects. `zkstack dev test rust` uses -`cargo nextest` by default. +Install `docker`. It is recommended to follow the instructions from the +[official site](https://docs.docker.com/install/). -```bash -cargo install cargo-nextest -``` +Note: currently official site proposes using Docker Desktop for Linux, which is a GUI tool with plenty of quirks. If you +want to only have CLI tool, you need the `docker-ce` package and you can follow +[this guide](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04) for Ubuntu. -### SQLx CLI +Installing `docker` via `snap` or from the default repository can cause troubles. -SQLx is a Rust library we use to interact with Postgres, and its CLI is used to manage DB migrations and support several -features of the library. +You need to install both `docker` and `docker compose`. + +**Note:** `docker compose` is installed automatically with `Docker Desktop`. + +**Note:** On linux you may encounter the following error when you’ll try to work with `zksync`: + +``` +ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`. +``` + +If so, you **do not need** to install `docker-machine`. Most probably, it means that your user is not added to +the`docker` group. You can check it as follows: ```bash -cargo install sqlx-cli --version 0.8.1 +docker-compose up # Should raise the same error. +sudo docker-compose up # Should start doing things. ``` -## Easier method using `nix` +If the first command fails, but the second succeeds, then you need to add your user to the `docker` group: -Nix is a tool that can fetch _exactly_ the right dependencies specified via hashes. The current config is Linux-only but -it is likely that it can be adapted to Mac. +```bash +sudo usermod -a -G docker your_user_name +``` -Install `nix`. Enable the nix command and flakes. +After that, you should logout and login again (user groups are refreshed after the login). The problem should be solved +at this step. -Install docker, rustup and use rust to install SQLx CLI like described above. If you are on NixOS, you also need to -enable nix-ld. +If logging out does not resolve the issue, restarting the computer should. -Go to the zksync folder and run `nix develop`. After it finishes, you are in a shell that has all the dependencies. +### Node.js & Yarn + +1. Install `Node` (requires version `v20`). The recommended way is via [nvm](https://github.com/nvm-sh/nvm). +2. Install `yarn`. Can be done via `npm install -g yarn`. Make sure to get version 1.22.19 - you can change the version + by running `yarn set version 1.22.19`. -## Foundry ZKsync +### Foundry ZKsync ZKSync depends on Foundry ZKsync (which is is a specialized fork of Foundry, tailored for ZKsync). Please follow this [installation guide](https://foundry-book.zksync.io/getting-started/installation) to get started with Foundry ZKsync. @@ -196,7 +157,12 @@ ZKSync depends on Foundry ZKsync (which is is a specialized fork of Foundry, tai Foundry ZKsync can also be used for deploying smart contracts. For commands related to deployment, you can pass flags for Foundry integration. -## Non-GPU setup +### ZK Stack CLI + +Toolkit for creating and managing ZK Stack chains. `ZK Stack CLI` facilitates the creation and management of ZK Stacks. +Commands are interactive but can also accept arguments via the command line. Follow the installation instructions [here](https://github.com/matter-labs/zksync-era/tree/main/zkstack_cli#installation). + +### Non-GPU setup Circuit Prover requires a CUDA bindings to run. If you still want to be able to build everything locally on non-CUDA setup, you'll need use CUDA stubs. @@ -221,6 +187,18 @@ RUSTFLAGS as env var, or pass it in `config.toml` (either project level or globa rustflags = ["--cfg=no_cuda"] ``` +## Easier method using `nix` + +Nix is a tool that can fetch _exactly_ the right dependencies specified via hashes. The current config is Linux-only but +it is likely that it can be adapted to Mac. + +Install `nix`. Enable the nix command and flakes. + +Install docker, rustup and use rust to install SQLx CLI like described above. If you are on NixOS, you also need to +enable nix-ld. + +Go to the zksync folder and run `nix develop`. After it finishes, you are in a shell that has all the dependencies. + ## Tips ### Tip: `mold` diff --git a/docs/src/guides/setup-dev.sh b/docs/src/guides/setup-dev.sh index 3155098f68b9..d6d927dc8d9f 100644 --- a/docs/src/guides/setup-dev.sh +++ b/docs/src/guides/setup-dev.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash main() { say "Setting up the development environment for ZKSync" @@ -51,15 +51,15 @@ main() { curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/zkstack_cli/zkstackup/install | bash "$HOME/.local/bin/zkstackup" - # Clone the repo - say "Cloning the ZK Sync repository..." - git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git - # Non CUDA (GPU) setup, can be skipped if the machine has a CUDA installed for provers # Don't do that if you intend to run provers on your machine. Check the prover docs for a setup instead. say "Setting up the non-CUDA setup..." echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" + # Clone the repo + say "Cloning the ZK Sync repository..." + git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git + say "Installation of the development environment for ZKSync complete!" say "Please reload your shell configuration by running 'source ~/.bashrc'" } From 8ea5d1c569cbf01a6fdc52cff45c57c0fb181deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 17:16:58 +0000 Subject: [PATCH 11/17] docs --- zkstack_cli/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/zkstack_cli/README.md b/zkstack_cli/README.md index e81165088218..57adad2820d4 100644 --- a/zkstack_cli/README.md +++ b/zkstack_cli/README.md @@ -3,11 +3,6 @@ Toolkit for creating and managing ZK Stack chains. `ZK Stack CLI` facilitates the creation and management of ZK Stacks. Commands are interactive but can also accept arguments via the command line. -### Dependencies - -Follow [these instructions](https://github.com/matter-labs/zksync-era/blob/main/docs/guides/setup-dev.md) to set up -dependencies on your machine. Ignore the Environment section for now. - ### Installation You can use `zkstackup` to install and manage `zkstack`: From 51efffd9e1b49014fcf23a795082afa86195f310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 17:28:46 +0000 Subject: [PATCH 12/17] consistent naming --- docs/src/guides/setup-dev.md | 2 +- docs/src/guides/setup-dev.sh | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index 52aa5aaa866e..8bf3311ec2e3 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -151,7 +151,7 @@ If logging out does not resolve the issue, restarting the computer should. ### Foundry ZKsync -ZKSync depends on Foundry ZKsync (which is is a specialized fork of Foundry, tailored for ZKsync). Please follow this +ZKsync depends on Foundry ZKsync (which is is a specialized fork of Foundry, tailored for ZKsync). Please follow this [installation guide](https://foundry-book.zksync.io/getting-started/installation) to get started with Foundry ZKsync. Foundry ZKsync can also be used for deploying smart contracts. For commands related to deployment, you can pass flags diff --git a/docs/src/guides/setup-dev.sh b/docs/src/guides/setup-dev.sh index d6d927dc8d9f..9cdf313ad7f8 100644 --- a/docs/src/guides/setup-dev.sh +++ b/docs/src/guides/setup-dev.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash main() { - say "Setting up the development environment for ZKSync" + say "Setting up the development environment for ZKsync" # All necessary stuff say "Installing apt dependencies..." @@ -42,8 +42,8 @@ main() { npm install -g yarn yarn set version 1.22.19 - # Foundry ZK sync - say "Installing Foundry ZK Sync..." + # Foundry ZKsync + say "Installing Foundry ZKsync..." curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash # ZK Stack CLI @@ -57,10 +57,10 @@ main() { echo "export ZKSYNC_USE_CUDA_STUBS=true" >> "$HOME/.bashrc" # Clone the repo - say "Cloning the ZK Sync repository..." + say "Cloning the ZKsync repository..." git clone --recurse-submodules https://github.com/matter-labs/zksync-era.git - say "Installation of the development environment for ZKSync complete!" + say "Installation of the development environment for ZKsync complete!" say "Please reload your shell configuration by running 'source ~/.bashrc'" } From 2435467314e21e4fa71a5ff5ce228738ebdd0076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Fri, 15 Nov 2024 18:41:47 +0000 Subject: [PATCH 13/17] fmt --- docs/src/guides/setup-dev.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index 8bf3311ec2e3..e48cf389cdfb 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -46,8 +46,9 @@ On mac: brew install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common ``` -Note that in order to install `clang` on MacOS you need to have an up-to-date `Xcode`. You can install it directly from `App Store`. -With `Xcode` command line tools, you get the Clang compiler installed by default. Thus, having `Xcode` you don't need to install `clang`. +Note that in order to install `clang` on MacOS you need to have an up-to-date `Xcode`. You can install it directly from +`App Store`. With `Xcode` command line tools, you get the Clang compiler installed by default. Thus, having `Xcode` you +don't need to install `clang`. ### Rust @@ -160,7 +161,8 @@ for Foundry integration. ### ZK Stack CLI Toolkit for creating and managing ZK Stack chains. `ZK Stack CLI` facilitates the creation and management of ZK Stacks. -Commands are interactive but can also accept arguments via the command line. Follow the installation instructions [here](https://github.com/matter-labs/zksync-era/tree/main/zkstack_cli#installation). +Commands are interactive but can also accept arguments via the command line. Follow the installation instructions +[here](https://github.com/matter-labs/zksync-era/tree/main/zkstack_cli#installation). ### Non-GPU setup From e7042e61ed364dd2dcdbe52d96ae60fc671adc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Tue, 19 Nov 2024 15:18:42 +0000 Subject: [PATCH 14/17] Update docs/src/guides/setup-dev.md Co-authored-by: Igor Aleksanov --- docs/src/guides/setup-dev.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index e48cf389cdfb..d56000fe2a1a 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -5,7 +5,7 @@ This is a shorter version of setup guide to make it easier for initializations. If it's the first time you're initializing the workspace, it's recommended that you read the whole guide below, as it provides more context and tips. -Just run the following command on Linux: +Just run the following command on Debian-based Linux: ```bash curl -L https://raw.githubusercontent.com/matter-labs/zksync-era/main/docs/src/guides/setup-dev.sh | bash From 1f36e793dbcb2c9156f2b22aeb4940ee982b5782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Tue, 19 Nov 2024 18:05:56 +0000 Subject: [PATCH 15/17] newline --- docs/src/guides/setup-dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/setup-dev.sh b/docs/src/guides/setup-dev.sh index 9cdf313ad7f8..b0e79838685f 100644 --- a/docs/src/guides/setup-dev.sh +++ b/docs/src/guides/setup-dev.sh @@ -68,4 +68,4 @@ say() { echo -e "\033[1;32m$1\033[0m" } -main "$@" \ No newline at end of file +main "$@" From e4ce183dac6846314b3a86adfc1a18d3989cec71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Wed, 20 Nov 2024 15:48:19 +0000 Subject: [PATCH 16/17] Removed curl --- docs/src/guides/setup-dev.md | 4 ++-- docs/src/guides/setup-dev.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index d56000fe2a1a..473c046ba0a9 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -37,13 +37,13 @@ Install the basic packages: On debian-based linux: ```bash -sudo apt install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common +sudo apt install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates software-properties-common ``` On mac: ```bash -brew install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common +brew install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates software-properties-common ``` Note that in order to install `clang` on MacOS you need to have an up-to-date `Xcode`. You can install it directly from diff --git a/docs/src/guides/setup-dev.sh b/docs/src/guides/setup-dev.sh index b0e79838685f..b87d5a4de7be 100644 --- a/docs/src/guides/setup-dev.sh +++ b/docs/src/guides/setup-dev.sh @@ -6,7 +6,7 @@ main() { # All necessary stuff say "Installing apt dependencies..." sudo apt update - sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates curl software-properties-common + sudo apt install --yes git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates software-properties-common # Rust say "Installing Rust..." From 26609c6a323e07d581ce83e88c249359497bcea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Fran=C3=A7a?= Date: Tue, 26 Nov 2024 23:22:23 +0000 Subject: [PATCH 17/17] brew --- docs/src/guides/setup-dev.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/src/guides/setup-dev.md b/docs/src/guides/setup-dev.md index 473c046ba0a9..d722ae7405fd 100644 --- a/docs/src/guides/setup-dev.md +++ b/docs/src/guides/setup-dev.md @@ -43,13 +43,9 @@ sudo apt install git build-essential pkg-config cmake clang lldb lld libssl-dev On mac: ```bash -brew install git build-essential pkg-config cmake clang lldb lld libssl-dev libpq-dev apt-transport-https ca-certificates software-properties-common +brew install openssl ``` -Note that in order to install `clang` on MacOS you need to have an up-to-date `Xcode`. You can install it directly from -`App Store`. With `Xcode` command line tools, you get the Clang compiler installed by default. Thus, having `Xcode` you -don't need to install `clang`. - ### Rust Install `Rust`'s toolchain version reported in `/rust-toolchain.toml` (also a later stable version should work).