This approach is tested on v1.9.4
solana-test-validator
is very important for local solana program development, but if you have tried to set it up on m1, you know it's not as easy as install and done.
The official way
The official documentation states that, for MacOS, running this command and you are good to go:
sh -c "$(curl -sSfL https://release.solana.com/v1.9.4/install)"
The other command seems to work ok, but...
The problem
Running
solana-test-validator
You probably get
Version: 1.9.4
Shred Version: 22786
Gossip Address: 127.0.0.1:1024
TPU Address: 127.0.0.1:1027
JSON RPC URL: http://127.0.0.1:8899
⠒ 00:00:01 | Processed Slot: 699 | Confirmed Slot: 668 | Finalized Slot: 668 | Full Snapshot Slot: 600 | Incremental Snapshot Slot: - | Transactions: 1107 | ◎499.997707500
[1] 47143 illegal hardware instruction solana-test-validator
Prior thesis
All of them suggested that you build from source. Some suggest that you clean up everything including rust and use rosetta.
I personally used a non-rosetta approach on v1.7.x
but it does not work anymore on 1.9.x, since m1 somehow could not build tikv-jemallocator
.
The fix
For 1.9.x, we still need to build from source, but what we need to do is similar to previous non-rosetta approach
1) Clone Solana repo
$ git clone git@github.com:solana-labs/solana.git
$ git checkout v1.9.4
2) Edit validator/Cargo.toml
, remove or comment out the following lines:
[target.'cfg(not(target_env = "msvc"))'.dependencies]
jemallocator = {package = "tikv-jemallocator", version = "0.4.1", features = ["unprefixed_malloc_on_supported_platforms"]}
3) Then you can build the whole thing.
./scripts/cargo-install-all.sh .
export PATH=$PWD/bin:$PATH
Or optionally, you can just build only solana-test-validator
and use the rest of solana-cli
from prebuilt binaries.
$ cargo build --release --bin solana-test-validator
$ cd bin
$ ./solana-test-validator
Let me know if it works for you or know what exactly tikv-jemallocator
is for (I only know that it's for memory allocation but don't know why it's needed or when it is used).
Cheers.
Top comments (1)
This is a great help mate for giving the idea at least, i use version 1.9.4 using Solana's install tool and not from the source. I hope this version will always work later on activities.