Run Substrate/Polkadot on Apple M1 🍏

Viki Val
2 min readFeb 23, 2021

--

On my old Macbook Pro, I used to run a local node with a docker container. However, this approach is unusable on M1, so I need to find an alternative solution. I tried to build the node using Rosetta 2 but without any success.
So then along with @JakPannik, we found a way how to run Substrate natively on M1.
Update: I also managed to run Polkadot natively. The setup can be found at the end of this article.

Photo by Martin Katler on Unsplash

I hope that you have Brew and Xcode Command Line Tools ready installed.

First, we need to install the following dependencies from brew:

brew install python@3.9 protobuf llvm cmake openssl

Now install rust

# Install
curl https://sh.rustup.rs -sSf | sh
# Configure
source ~/.cargo/env

Use rustup nightly

rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
Your rustup should use the nightly-aarch64 toolchain

So let’s clone the Substrate node now

git clone git@github.com:substrate-developer-hub/substrate-node-template.git

Now open Cargo.toml in your favorite code editor and on the top of the file add these lines:

[patch.crates-io]
librocksdb-sys = { git = "https://github.com/hdevalence/rust-rocksdb", branch = "master" }

Open Cargo.lock find libc package and replace the package with:

[[package]]
name = "libc"
version = "0.2.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"

🧨 Compile-time

make init
make build

Ideally, you should not get any errors at this time.

πŸ‘Ÿ Time to run

make run
Running Substrate node on M1 🍏

Update: Running Polkadot node

The setup is similar to the Substrate.
Download the latest release of Polkadot from the link below (use zip format).

https://github.com/paritytech/polkadot/releases

Unzip, go to the folder, and then execute:

./scripts/init.sh

Now edit the Cargo.toml

[patch.crates-io]
librocksdb-sys = { git = "https://github.com/hdevalence/rust-rocksdb", branch = "master" }

Moreover, we need to update two libraries πŸ“š

cargo update -p ring fs-swap

After the update, we can build the node πŸ—

cargo build --release

πŸ‘Ÿ Let it run

./target/release/polkadot --dev
Running Polkadot node on Apple M1

Conclusion

I hope that everything is running. In case you have any feedback, please reach me on my Twitter.

--

--