Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation support for ARM64 #149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Install the guardian node

Please follow the instructions below to download the lastest **Linux** binary and the necessary data. If you prefer to compile from the source code, please follow the steps [here](./COMPILE.md#install-guardian-node-from-source-code). If you are running the node on a Linux server, you'd need to run the node in a **screen or tmux** session, so that after you've logged off, the Theta node can continue to run.
Please follow the instructions below to download the lastest **Linux** binary and the necessary data. If you prefer to compile from the source code, please follow the steps [here](./COMPILE.md#install-guardian-node-from-source-code). If you are using an ARM64-based device, please follow the steps [here](./COMPILE_ARM64.md#install-guardian-node-from-source-code).

If you are running the node on a Linux server, you'd need to run the node in a **screen or tmux** session, so that after you've logged off, the Theta node can continue to run.

```
screen -S theta_mainnet # if you run the node on a Linux server
Expand Down
71 changes: 71 additions & 0 deletions docs/COMPILE_ARM64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Install Guardian Node from Source Code

The script was tested on the following device:
* Raspberry Pi OS 64 bits, Kernel Version 5.10, Debian version 11 (bullseye)
* Raspberry Pi 4 4GB RAM

## Install Go 1.17.8

Install Go and set environment variables `GOPATH` , `GOBIN`, and `PATH` following the commands below. The current code base should compile with **Go 1.17.8** on a ARM64 based architecture. Below are the steps to install Go 1.17.8 and setup the environments on Ubuntu.

```
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install gcc
sudo apt-get install make
sudo apt install libstdc++-9-dev
sudo wget https://go.dev/dl/go1.17.8.linux-arm64.tar.gz
sudo tar -C /usr/local -xzf go1.17.8.linux-arm64.tar.gz
echo 'export GOROOT=/usr/local/go' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc
echo 'export THETA_HOME=$GOPATH/src/github.com/thetatoken/theta' >> ~/.bashrc
source ~/.bashrc
```

## Checkout, fix dependences, and compile the Theta Guardian source code

Clone the `release` branch of the Theta Ledger repo https://github.com/thetatoken/theta-protocol-ledger into your `$GOPATH` with the following command. The path should look like this: `$GOPATH/src/github.com/thetatoken/theta`

```
git clone --branch release https://github.com/thetatoken/theta-protocol-ledger.git $GOPATH/src/github.com/thetatoken/theta
```

Then, we have to fix the package dependences for ARM64:
```
# Fix Go dependences
cd $THETA_HOME
sed 's/v0.0.0-20200107021104-147ed25f233e/v0.0.0-20220216073600-600054663ec1/' go.mod > aux_file
sed 's/github.com\/wedeploy\/gosocketio v0.0.7-beta/github.com\/cih-y2k\/wedeploy-gosocketio v0.0.8/' aux_file > aux_file2
rm go.mod
cp aux_file2 go.mod
rm aux_file aux_file2
go mod download github.com/cih-y2k/wedeploy-gosocketio
go get github.com/thetatoken/theta/crypto/bls

# Fix mul_arm64.h
rm ./crypto/bn256/cloudflare/mul_arm64.h
wget -O ./crypto/bn256/cloudflare/mul_arm64.h https://raw.githubusercontent.com/cloudflare/bn256/master/mul_arm64.h
```

Finally, we build the binaries:
```
cd $THETA_HOME
export GO111MODULE=on
make install
```

## Download necessary data for the Guardian Node

```
cd $THETA_HOME
mkdir -p ../guardian_mainnet/node
curl -k --output ../guardian_mainnet/node/snapshot `curl -k https://mainnet-data.thetatoken.org/snapshot`
curl -k --output ../guardian_mainnet/node/config.yaml `curl -k 'https://mainnet-data.thetatoken.org/config?is_guardian=true'`
```

## Launch the node and stake

Please continue with the instructions [here](./CLI.md#launch-the-guardian-node).