From db02f52eb72d57afc74d7c7f7a560dc1b8ed3363 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 5 Aug 2025 17:32:57 -0300 Subject: [PATCH] fix doc + dockerfiles --- Dockerfile | 2 +- Dockerfile-localnet | 2 +- docs/consensus.md | 9 ++++---- docs/rust-setup.md | 50 ++++++++++++++--------------------------- scripts/init.sh | 3 +-- scripts/install_rust.sh | 4 ++-- shell.nix | 4 ++-- 7 files changed, 28 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index 06b7075b2a..efa124db33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ LABEL ai.opentensor.image.authors="operations@opentensor.ai" \ # Rust targets RUN rustup update stable && \ - rustup target add wasm32-unknown-unknown --toolchain stable + rustup target add wasm32v1-none --toolchain stable # Build prerequisites ENV RUST_BACKTRACE=1 diff --git a/Dockerfile-localnet b/Dockerfile-localnet index d95a2f1a2c..bb548782b5 100644 --- a/Dockerfile-localnet +++ b/Dockerfile-localnet @@ -27,7 +27,7 @@ WORKDIR /build RUN set -o pipefail && curl https://sh.rustup.rs -sSf | sh -s -- -y ENV PATH="/root/.cargo/bin:${PATH}" RUN rustup toolchain install -RUN rustup target add wasm32-unknown-unknown +RUN rustup target add wasm32v1-none ## Build fast-blocks node RUN ./scripts/localnet.sh --build-only diff --git a/docs/consensus.md b/docs/consensus.md index c3a04c380f..6678b4f52f 100644 --- a/docs/consensus.md +++ b/docs/consensus.md @@ -297,11 +297,10 @@ ssh -L 8888:localhost:8888 root@ -p -i ~/.s ```bash sudo apt-get update && sudo apt install -y build-essential clang curl git make libssl-dev llvm libudev-dev protobuf-compiler python3 python3-pip \ && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ - && source ~/.cargo/env && rustup default stable && rustup update \ - && rustup target add wasm32-unknown-unknown \ - && rustup toolchain install nightly \ - && rustup target add --toolchain nightly wasm32-unknown-unknown - + && source ~/.cargo/env \ + && rustup default stable \ + && rustup update \ + && rustup target add wasm32v1-none ``` 3. **Clone the Subtensor repository and checkout the relevant branch:** diff --git a/docs/rust-setup.md b/docs/rust-setup.md index fedff7b381..a3e4a952d7 100644 --- a/docs/rust-setup.md +++ b/docs/rust-setup.md @@ -2,7 +2,7 @@ title: Installation --- This guide is for reference only, please check the latest information on getting starting with Substrate -[here](https://docs.polkadot.com/main-docs/install/). +[here](https://docs.polkadot.com/develop/parachains/install-polkadot-sdk/). This page will guide you through the **2 steps** needed to prepare a computer for **Substrate** development. Since Substrate is built with [the Rust programming language](https://www.rust-lang.org/), the first @@ -65,18 +65,15 @@ Open the Terminal application and execute the following commands: # Install Homebrew if necessary https://brew.sh/ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" -# Make sure Homebrew is up-to-date, install openssl +# Make sure Homebrew is up-to-date, install protobuf and openssl brew update -brew install openssl +brew install protobuf openssl ``` ### Windows **_PLEASE NOTE:_** Native Windows development of Substrate is _not_ very well supported! It is _highly_ -recommend to use [Windows Subsystem Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) -(WSL) and follow the instructions for [Ubuntu/Debian](#ubuntudebian). -Please refer to the separate -[guide for native Windows development](https://docs.polkadot.com/main-docs/install/windows/). +recommend to use [Windows Subsystem Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) (WSL) and follow the following [instructions](https://docs.polkadot.com/develop/parachains/install-polkadot-sdk/#windows-wsl). ## Rust developer environment @@ -90,13 +87,12 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source ~/.cargo/env ``` -Configure the Rust toolchain to default to the latest stable version, add nightly and the nightly wasm target: +Configure the Rust toolchain to default to the latest stable version: ```bash rustup default stable rustup update -rustup update nightly -rustup target add wasm32-unknown-unknown --toolchain nightly +rustup target add wasm32v1-none ``` ## Test your set-up @@ -125,38 +121,26 @@ rustup home: /home/user/.rustup installed toolchains -------------------- - stable-x86_64-unknown-linux-gnu (default) -nightly-2020-10-06-x86_64-unknown-linux-gnu nightly-x86_64-unknown-linux-gnu -installed targets for active toolchain --------------------------------------- - -wasm32-unknown-unknown -x86_64-unknown-linux-gnu - active toolchain ---------------- - -stable-x86_64-unknown-linux-gnu (default) -rustc 1.50.0 (cb75ad5db 2021-02-10) +name: stable-x86_64-unknown-linux-gnu +active because: it's the default toolchain +installed targets: + x86_64-unknown-linux-gnu + wasm32v1-none ``` As you can see above, the default toolchain is stable, and the -`nightly-x86_64-unknown-linux-gnu` toolchain as well as its `wasm32-unknown-unknown` target is installed. -You also see that `nightly-2020-10-06-x86_64-unknown-linux-gnu` is installed, but is not used unless explicitly defined as illustrated in the [specify your nightly version](#specifying-nightly-version) +`stable-x86_64-unknown-linux-gnu` toolchain as well as its `wasm32v1-none` target is installed. +You also see that `nightly-x86_64-unknown-linux-gnu` is installed, but is not used unless explicitly defined as illustrated in the [specify your nightly version](#specifying-nightly-version) section. ### WebAssembly compilation -Substrate uses [WebAssembly](https://webassembly.org) (Wasm) to produce portable blockchain -runtimes. You will need to configure your Rust compiler to use -[`nightly` builds](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) to allow you to -compile Substrate runtime code to the Wasm target. - -> There are upstream issues in Rust that need to be resolved before all of Substrate can use the stable Rust toolchain. -> [This is our tracking issue](https://github.com/paritytech/substrate/issues/1252) if you're curious as to why and how this will be resolved. +Substrate uses [WebAssembly](https://webassembly.org) (Wasm) to produce portable blockchain runtimes. #### Latest nightly for Substrate `master` @@ -168,7 +152,7 @@ To ensure your Rust compiler is always up to date, you should run: ```bash rustup update rustup update nightly -rustup target add wasm32-unknown-unknown --toolchain nightly +rustup target add wasm32v1-none --toolchain nightly ``` > NOTE: It may be necessary to occasionally rerun `rustup update` if a change in the upstream Substrate @@ -197,7 +181,7 @@ rustup install nightly- Now, configure the nightly version to work with the Wasm compilation target: ```bash -rustup target add wasm32-unknown-unknown --toolchain nightly- +rustup target add wasm32v1-none --toolchain nightly- ``` ### Specifying nightly version @@ -220,6 +204,6 @@ specific nightly version, follow these steps: ```bash rustup uninstall nightly rustup install nightly- -rustup target add wasm32-unknown-unknown --toolchain nightly- +rustup target add wasm32v1-none --toolchain nightly- ``` diff --git a/scripts/init.sh b/scripts/init.sh index 767c61357f..8d15ad3842 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -5,8 +5,7 @@ set -e echo "*** Initializing WASM build environment" if ! (( ${#CI_PROJECT_NAME} )) ; then - rustup update nightly rustup update stable fi -rustup target add wasm32-unknown-unknown --toolchain nightly +rustup target add wasm32v1-none diff --git a/scripts/install_rust.sh b/scripts/install_rust.sh index f28a5eb878..753aa3245b 100755 --- a/scripts/install_rust.sh +++ b/scripts/install_rust.sh @@ -36,7 +36,7 @@ curl https://sh.rustup.rs -sSf | sh -s -- -y source "$HOME/.cargo/env" rustup default stable -rustup update nightly -rustup target add wasm32-unknown-unknown --toolchain nightly +rustup update +rustup target add wasm32v1-none echo "*** Rust installation complete" diff --git a/shell.nix b/shell.nix index c08005c163..698a4a4edd 100644 --- a/shell.nix +++ b/shell.nix @@ -13,9 +13,9 @@ let rev = "1fe6ed37fd9beb92afe90671c0c2a662a03463dd"; }; nixpkgs = import pinned { overlays = [ mozillaOverlay ]; }; - toolchain = with nixpkgs; (rustChannelOf { date = "2021-09-14"; channel = "nightly"; }); + toolchain = with nixpkgs; (rustChannelOf { date = "2025-06-23"; channel = "stable"; }); rust-wasm = toolchain.rust.override { - targets = [ "wasm32-unknown-unknown" ]; + targets = [ "wasm32v1-none" ]; }; in with nixpkgs; pkgs.mkShell {