# Worker Installation

## Overview

The NuLink Worker is the node to provide cryptographic service in the NuLink network. It provides Proxy Re-encryption service in the Horus network and it will provide more services such as ABE, IBE, ZKP and FHE in NuLink mainnet. The staker needs running a Worker node to be eligible for token reward.

### There are four steps to run a NuLink Worker:

1. Create Worker Account
2. Install NuLink Worker
3. Configure and Run a Worker node
4. Bond the Worker node with your staking account

## Minimum System Requirements

* Debian/Ubuntu (Recommended)
* 30GB available storage
* 4GB RAM
* x86 architecture
* Static IP address
* Exposed TCP port 9151, make sure it's not occupied
* Nodes can be run on cloud infrastructure.

For this worker node im using CPX21 from Hetzner

## Installation

### Update Depencies

```bash
sudo apt update && sudo apt upgrade -y
sudo apt install ufw
```

### Install Latest Docker Engine and Pull Latest Horus Image

```bash
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
docker pull nulink/nulink:latest
```

### Setup Firewall

```bash
sudo ufw allow ssh
sudo ufw allow 9151/tcp
sudo ufw enable
```

And press `y` then enter.

### Setup Password Variable

```bash
export NULINK_KEYSTORE_PASSWORD=YOUR NULINK STORAGE PASSWORD
export NULINK_OPERATOR_ETH_PASSWORD=YOUR WORKER ACCOUNT PASSWORD
```

Change both to the password you preffered

### Create Worker Account

Download GETH and Extract

```bash
wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.23-d901d853.tar.gz && tar -xvzf geth-linux-amd64-1.10.23-d901d853.tar.gz
```

I like to rename it to `geth` , you can skip this if you want

Rename the directory

```bash
mv geth-linux-amd64-1.10.23-d901d853 geth
```

Go to the `geth` dir

```bash
cd geth/
```

Now Create the worker account key by running the command below inside the dir `geth`

```bash
./geth account new --keystore ./keystore
```

You will be prompted to enter the password and confirm the password. **Please remember this password for late use.**

Example:

```bash
INFO [09-08|15:30:11.904] Maximum peer count                       ETH=50 LES=0 total=50
INFO [09-08|15:30:11.905] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
Your new account is locked with a password. Please give a password. Do not forget this password.
Password: 
Repeat password: 

Your new key was generated


Public address of the key:   0x8B1819341BEc211a45a2186C4D0030681cccE0Ee
Path of the secret key file: /root/geth-linux-amd64-1.10.23-d901d853/keystore/UTC--2022-09-13T01-14-32.465358210Z--8b1819341bec211a45a2186c4d0030681ccce0ee

- You can share your public address with anyone. Others need it to interact with you.
- You must NEVER share the secret key with anyone! The key controls access to your funds!
- You must BACKUP your key file! Without the key, it's impossible to access account funds!
- You must REMEMBER your password! Without the password, it's impossible to decrypt the key!
```

### Create Nulink Directory

```bash
cd $HOME
sudo mkdir nulink
```

Copy the keystore file of the Worker account to the host directory. The private file generated by NuLink Worker will also be stored in this directory.

```bash
cp $HOME/geth/keystore/* $HOME/nulink
```

Give the directory 777 Permission

```bash
sudo chmod -R 777 $HOME/nulink
```

### Init Worker

DONT CHANGE THE VALUE OF :

-e NULINK\_KEYSTORE\_PASSWORD \\

**Change the --signer and --operator-address to your own!**

```bash
docker run -it --rm \
-p 9151:9151 \
-v $HOME/nulink:/code \
-v $HOME/nulink:/home/circleci/.local/share/nulink \
-e NULINK_KEYSTORE_PASSWORD \
nulink/nulink nulink ursula init \
--signer keystore:///code/UTC--2022-09-13T01-14-32.465358210Z--8b1819341bec211a45a2186c4d0030681cccXXXX \
--eth-provider https://data-seed-prebsc-2-s2.binance.org:8545 \
--network horus \
--payment-provider https://data-seed-prebsc-2-s2.binance.org:8545 \
--payment-network bsc_testnet \
--operator-address Operator Address \
--max-gas-price 10000000000
```

Example Output :

```bash
# step 1
 Detected IPv4 address (8.219.186.xxx) - Is this the public-facing address of Ursula? [y/N]: y

 Please provide a password to lock Operator keys.
 Do not forget this password, and ideally store it using a password manager.

 # step 2
 Enter nulink keystore password (8 character minimum): xxxxxx
 Repeat for confirmation: xxxxxx

 Backup your seed words, you will not be able to view them again.

 xxxxxxxxxxxxxxxxxxxxxxxx

 # step 3
 Have you backed up your seed phrase? [y/N]: y

 # step 4
 Confirm seed words: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Public Key:   02bb2067d21a677ce928967c0ece79a9
Path to Keystore: /home/circleci/.local/share/nulink/keystore

- You can share your public key with anyone. Others need it to interact with you.
- Never share secret keys with anyone! 
- Backup your keystore! Character keys are required to interact with the protocol!
- Remember your password! Without the password, it's impossible to decrypt the key!
Generated configuration file at default filepath /home/circleci/.local/share/nulink/ursula.json
* Review configuration  -> nulink ursula config
* Start working         -> nulink ursula run
```

**Backup your Seed!**

### Run the worker

**Before running the worker make sure you have tBNB, if not request** [**BNB Testnet Faucet**](https://www.bnbchain.org/en/testnet-faucet) Run Worker

DONT CHANGE THE VALUE OF :

-e NULINK\_KEYSTORE\_PASSWORD \\

-e NULINK\_OPERATOR\_ETH\_PASSWORD \\

```bash
docker run --restart on-failure -d \
--name ursula \
-p 9151:9151 \
-v $HOME/nulink:/code \
-v $HOME/nulink:/home/circleci/.local/share/nulink \
-e NULINK_KEYSTORE_PASSWORD \
-e NULINK_OPERATOR_ETH_PASSWORD \
nulink/nulink nulink ursula run --no-block-until-ready
```

And Voila! Your worker is now running To check the logs you can type

```bash
docker logs -f ursula
```

Example output:

```bash
Authenticating Ursula
Loaded Ursula (horus)
✓ External IP matches configuration
Starting services
✓ Node Discovery (Horus)
✓ Work Tracking
✓ Start Operator Bonded Tracker
✓ Rest Server https://8.219.186.xxx:9151
Working ~ Keep Ursula Online!
```

To check running container you can run

```bash
docker ps
```

To stop container you can run

```bash
docker stop ursula
```

To Restart container

```bash
docker restart ursula
```

Now you can go to the next step which is Bonding the worker to provider.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.indonode.net/testnet/nulink/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
