Deploying the 0chain locally on mac m1
While trying to get the working chain set up on my local machine, I saw that the official documentation misses out on a few things for mac OS, especially for mac running on m1 chips. This story should help you get up to speed with the development and don't trudge otherwise in the endless information labyrinth of the internet.
Let's start with installing the prerequisites
- Docker — Get docker desktop from the official docker website.
- Docker compose
brew install docker-compose
- Clone the 0chain repositories from Github and try to keep them in a single parent folder
git clone https://github.com/0chain/0chain.git
git clone https://github.com/0chain/blobber.git
git clone https://github.com/0chain/0dns.git
Setting up the local network and the DNS
You can follow the entire step 2 mentioned in the official documentation for this.
Initialise and build the 0chain components i.e miners, sharders and blobbers
For the miners and sharders, the guide is just good enough and elaborate to help you get started.
For the blobbers, you might face problems when setting up the docker containers since there seems to be some issue with blobber docker registry. So in order to set up this entity, we will be taking a different route.
Below is the list of commands we need to execute to start a local build of blobbers.
- Change the log levels of both the files namely 0chain_blobber.yaml and 0chain_validator.yaml you will find inside the blobber config to
info
cd blobber/dev.local/config
ls
0chain_blobber.yaml 0chain_validator.yamlvi 0chain_blobber.yaml
vi 0chain_validator.yaml
The changed configurations should look something like below
2. You will be entering a CLI application that might look a bit like this
In the above figure, 1, 2 and 3 represent the set of entities that combines to form a complete blobber setup. These are the storage, validators and blobbers themselves.
Enter 1 and you should see something like below
Now we need to sequentially execute the installation of Postgres, the validator and the blobber.
Enter 1 and you should see a Postgres container getting set up in your docker dashboard. Once this is done, you can go on installing other entities by again repeating the above steps from ./cli.sh
You should start a blobber and a validator both. A working setup of blobber and validator looks something like this
Registering the zbox wallet is similar to the documentation. Next where we need to make changes is when we move to creating allocations using the zwallet cli.
Setting up zwallet cli in m1 mac
The steps provided in the documentation does not work for m1 mac. We have found a workaround for the same to get you started.
Enter the below commands in sequence
cd zwalletcli
- replace the contents of go.mod file present in the directory with the below text
module github.com/0chain/zwalletcli
require (
github.com/0chain/gosdk v1.2.5
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.1.1
github.com/spf13/viper v1.7.0
gopkg.in/cheggaaa/pb.v1 v1.0.28
)
go 1.13
// temporary, for development
replace github.com/0chain/gosdk => ../gosdk
replace github.com/herumi/bls-go-binary => ../bls-go-binary
3. Go to the parent folder (one level above zwallet cli folder) and run git clone https://github.com/herumi/bls-go-binary
.
4. In the same parent folder run git clone https://github.com/0chain/gosdk.git
4. make install
You should be able to install the zwallet cli in your local now. Now follow the steps in the documentation to generate the ZCN token and create the allocation.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
This is the complete guide to help you set up the 0chain successfully on your mac m1. If you face issues while following any of the mentioned steps, do comment below and we will try to get to you asap.
To explore more about 0chain visit https://github.com/0chain