# Testnet

## Run a Validator Node from Binaries:

### Prerequisites: <a href="#prerequisites" id="prerequisites"></a>

`build-essential` installed on both the sentry and the validator machines.

To install:

```
sudo apt-get install build-essential
```

Go 1.18 installed on validator machine.

To install:

```
wget https://raw.githubusercontent.com/Ramestta-Blockchain/launch/master/go-install.sh
bash go-install.sh
sudo ln -nfs ~/.go/bin/go /usr/bin/go
```

Docker and RabbitMQ to install on validator machines.

```
sudo apt-get update
sudo apt install rabbitmq-server
```

To install sublime-text:

```
sudo snap install sublime-text --classic
```

#### Installing Heimdall: <a href="#installing-heimdall" id="installing-heimdall"></a>

Heimdall is the proof-of-stake verifier layer responsible for checkpointing the representation of the Plasma blocks to the Ramestta mainnet.

Clone the [Heimdall repository](https://github.com/Ramestta-Blockchain/heimdall):thumbsup:

```
git clone https://github.com/Ramestta-Blockchain/heimdall
```

```
cd heimdall
```

```
make build
make install
```

```
cd ~
source ~/.bashrc
```

Check the Heimdall installation:

```
heimdalld version --long
```

note

Before proceeding, Heimdall should be installed on both the sentry and validator machines.

#### Installing Bor​ <a href="#installing-bor" id="installing-bor"></a>

Bor is the sidechain operator that acts as the block production layer, which syncs with Heimdall to select block producers and verifiers for each span and sprint.

Clone the [Bor repository](https://github.com/Ramestta-Blockchain/bor):thumbsup:

```
git clone https://github.com/Ramestta-Blockchain/bor
```

```
cd bor
```

**Install Bor:**

```
make bor-all
```

**Create symlinks:**

```
sudo ln -nfs ~/bor/build/bin/bor /usr/bin/bor
sudo ln -nfs ~/bor/build/bin/bootnode /usr/bin/bootnode
```

**Check the Bor installation:**

```
bor version
```

Change directory

```
cd ~
```

Before proceeding, Bor should be installed on both the sentry and validator machines.

### Setting Up Node Files: <a href="#setting-up-node-files" id="setting-up-node-files"></a>

Node files need to be set up on both the sentry and validator machines.

#### Fetching the launch repository​ <a href="#fetching-the-launch-repository" id="fetching-the-launch-repository"></a>

Clone the [launch repository](https://github.com/Ramestta-Blockchain/launch):thumbsup:

```
git clone https://github.com/Ramestta-Blockchain/launch
```

#### Setting up the launch directory​ <a href="#setting-up-the-launch-directory" id="setting-up-the-launch-directory"></a>

**On the validator machine​**

Create a `node` directory:

```
mkdir -p node
```

Copy the files and scripts from the `launch` directory to the `node` directory:

```
cp -rf launch/testnet-v1/sentry/validator/* ~/node
cp launch/testnet-v1/service.sh ~/node
```

#### Setting up the network directories: <a href="#setting-up-the-network-directories" id="setting-up-the-network-directories"></a>

Run this section both on the sentry and validator machines.

**Setting up Heimdall​**

Change to the `node` directory:

```
cd ~/node/heimdall
```

Run the setup script:

```
bash setup.sh
```

**Setting up Bor​**

Change to the `node` directory:

```
cd ~/node/bor
```

Run the setup script:

```
bash setup.sh
```

### Setting Up the Services: <a href="#setting-up-the-services" id="setting-up-the-services"></a>

Run this section both on the sentry and validator machines.

**Navigate to the `node` directory:**

```
cd ~/node
```

**Run the setup script:**

```
bash service.sh
```

**Copy the service file to the system directory:**

```
sudo cp *.service /etc/systemd/system/
```

### Configuring the Validator Node​ <a href="#configuring-the-validator-node" id="configuring-the-validator-node"></a>

### Set the owner and signer key <a href="#set-the-owner-and-signer-key" id="set-the-owner-and-signer-key"></a>

On Ramestta, you should keep the owner and signer keys different. Generate New wallet, and use its private key in next step as POLYGON`_PRIVATE_KEY`

* Signer — the address that signs the checkpoint transactions. The recommendation is to keep at least 1 MATIC on the signer address.
* Owner — the address that does the staking transactions. The recommendation is to keep the RAMA tokens on the owner address.

#### Generating a Heimdall private key​ <a href="#generating-a-heimdall-private-key" id="generating-a-heimdall-private-key"></a>

You must generate a Heimdall private key only on the validator machine. Do not generate a Heimdall private key on the sentry machine.

To generate the private key, run:

```
heimdallcli generate-validatorkey POLYGON_PRIVATE_KEY[0x prefix]
```

where

* POLYGON`_PRIVATE_KEY` — your Polygon wallet’s private key.

This will generate `priv_validator_key.json`. Move the generated JSON file to the Heimdall configuration directory:

```
mv ./priv_validator_key.json ~/.heimdalld/config
```

#### Generating a Bor keystore file​ <a href="#generating-a-bor-keystore-file" id="generating-a-bor-keystore-file"></a>

You must generate a Bor keystore file only on the validator machine. Do not generate a Bor keystore file on the sentry machine.

To generate the private key, run:

```
heimdallcli generate-keystore POLYGON_PRIVATE_KEY[0x prefix]
```

where

* POLYGON`_PRIVATE_KEY` — your Polygon wallet’s private key.

When prompted, set up a password to the keystore file.

This will generate a `UTC-<time>-<address>` keystore file.

Move the generated keystore file to the Bor configuration directory:

```
mv ./UTC-<time>-<address> ~/.bor/keystore/
```

#### Add password.txt​ <a href="#add-passwordtxt" id="add-passwordtxt"></a>

Make sure to create a `password.txt` file then add the Bor keystore file password right in the `~/.bor/password.txt` file.

`mv password.txt ~/.bor/password.txt`

```
mkdir /etc/rama
```

```
cd ~/node
```

#### Add your Polygon address​ <a href="#add-your-ethereum-address" id="add-your-ethereum-address"></a>

Open for editing.

```
sudo nano metadata
```

In `metadata`, add your Polygon address. Example: `VALIDATOR_ADDRESS=0xca67a8D767e45056DC92384b488E9Af654d78DE2`.

Save the changes in `metadata`.

mv metadata /etc/rama/

### Starting the Validator Node​ <a href="#starting-the-validator-node" id="starting-the-validator-node"></a>

At this point, you must have:

* The Heimdall service on the sentry machine syncs and is running.
* The Bor service on the sentry machine running.
* The Heimdall service and the Bor service on the validator machine configured.
* Your owner and signer keys configured.

#### Starting the Heimdall service​ <a href="#starting-the-heimdall-service-1" id="starting-the-heimdall-service-1"></a>

You will now start the Heimdall service on the validator machine. Once the Heimdall service syncs, you will start the Bor service on the validator machine.

**Start the Heimdall service:**

```
sudo service heimdalld start
```

**Start the Heimdall rest-server:**

```
sudo service heimdalld-rest-server start
```

**Start the Heimdall bridge:**

```
sudo service heimdalld-bridge start
```

**Check the Heimdall service logs:**

```
journalctl -u heimdalld.service -f
```

**Check the Heimdall rest-server logs:**

```
journalctl -u heimdalld-rest-server.service -f
```

**Check the Heimdall bridge logs:**

```
journalctl -u heimdalld-bridge.service -f
```

**Check the sync status of Heimdall:**

```
curl localhost:26657/status
```

In the output, the `catching_up` value is:

* `true` — the Heimdall service is syncing.
* `false` — the Heimdall service is synced.

Wait for the Heimdall service to fully sync.

#### Starting the Bor service​ <a href="#starting-the-bor-service-1" id="starting-the-bor-service-1"></a>

Once the Heimdall service on the validator machine syncs, start the Bor service on the validator machine.

**Start the Bor service:**

```
sudo service bor start
```

**Check the Bor service logs:**

```
journalctl -u bor.service -f
```

### Service to Auto Start After Server Crash/Reboot <a href="#health-checks-with-the-community" id="health-checks-with-the-community"></a>

```
sudo systemctl enable heimdalld
sudo systemctl enable heimdalld-rest-server
sudo systemctl enable heimdalld-bridge
sudo systemctl enable bor
```

### Next Steps: Staking​ <a href="#next-steps-staking" id="next-steps-staking"></a>

Now that you have your sentry and validator nodes are health-checked, proceed to the Staking guide to start backing the network.
