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.
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
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
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
Conclusion
I hope that everything is running. In case you have any feedback, please reach me on my Twitter.