2020-07-11 08:55:13 +00:00
# Lotus Worker
2019-12-13 15:05:22 +00:00
2020-07-11 08:55:13 +00:00
The **Lotus Worker** is an extra process that can offload heavy processing tasks from your **Lotus Miner** . The sealing process automatically runs in the **Lotus Miner** process, but you can use the Worker on another machine communicating over a fast network to free up resources on the machine running the mining process.
2019-12-13 15:05:22 +00:00
2020-08-31 15:11:01 +00:00
## Installation
2019-12-23 05:39:26 +00:00
2020-08-31 15:11:01 +00:00
The `lotus-worker` application is installed along with the others when running `sudo make install` as shown in the [Installation section ](en+install-linux ). For simplicity, we recommend following the same procedure in the machines that will run the Lotus Workers (even if the Lotus miner and the Lotus daemon are not used there).
2019-12-13 15:05:22 +00:00
2020-07-11 08:55:13 +00:00
## Setting up the Miner
2019-12-13 15:05:22 +00:00
2020-08-31 15:11:01 +00:00
### Allow external connections to the miner API
2020-07-08 10:38:59 +00:00
First, you will need to ensure your `lotus-miner` 's API is accessible over the network.
2019-12-13 15:05:22 +00:00
2020-07-08 10:53:04 +00:00
To do this, open up `~/.lotusminer/config.toml` (Or if you manually set `LOTUS_MINER_PATH` , look under that directory) and look for the API field.
2019-12-13 15:05:22 +00:00
2019-12-18 19:25:57 +00:00
Default config:
2019-12-18 18:40:47 +00:00
2019-12-13 15:05:22 +00:00
```toml
[API]
ListenAddress = "/ip4/127.0.0.1/tcp/2345/http"
2020-05-12 19:09:40 +00:00
RemoteListenAddress = "127.0.0.1:2345"
2019-12-13 15:05:22 +00:00
```
2020-08-31 15:11:01 +00:00
To make your node accessible over the local area network, you will need to determine your machine's IP on the LAN (`ip a`), and change the `127.0.0.1` in the file to that address.
2019-12-18 18:40:47 +00:00
2020-08-31 15:11:01 +00:00
A more permissive and less secure option is to change it to `0.0.0.0` . This will allow anyone who can connect to your computer on that port to access the miner's API, though they will still need an auth token.
2019-12-13 15:05:22 +00:00
2020-06-09 18:57:21 +00:00
`RemoteListenAddress` must be set to an address which other nodes on your network will be able to reach.
2020-05-12 19:09:40 +00:00
2020-08-31 15:11:01 +00:00
### Create an authentication token
2019-12-18 18:40:47 +00:00
2020-08-31 15:11:01 +00:00
Write down the output of:
```sh
lotus-miner auth api-info --perm admin
```
2019-12-13 15:05:22 +00:00
2020-08-31 15:11:01 +00:00
The Lotus Workers will need this token to connect to the miner.
2019-12-13 15:05:22 +00:00
2020-08-31 15:11:01 +00:00
## Connecting the Lotus Workers
On each machine that will run the `lotus-worker` application you will need to define the following *environment variable* :
```sh
export MINER_API_INFO:< TOKEN > :/ip4/< miner_api_address > /tcp/2345`
```
If you are trying to use `lotus-worker` from China. You should additionally set:
```sh
export IPFS_GATEWAY="https://proof-parameters.s3.cn-south-1.jdcloud-oss.com/ipfs/"
```
Once that is done, you can run the Worker with:
2019-12-13 15:05:22 +00:00
2019-12-18 19:25:57 +00:00
```sh
2020-08-06 00:54:00 +00:00
lotus-worker run
2019-12-18 19:25:57 +00:00
```
2019-12-13 15:05:22 +00:00
2020-08-31 15:11:01 +00:00
> If you are running multiple workers on the same host, you will need to specify the `--listen` flag and ensure each worker is on a different port.
2020-06-09 18:57:21 +00:00
2020-08-31 15:11:01 +00:00
On your Lotus miner, check that the workers are correctly connected:
2019-12-13 15:05:22 +00:00
2019-12-18 18:48:15 +00:00
```sh
2020-08-31 15:11:01 +00:00
lotus-miner sealing workers
2020-05-12 19:37:23 +00:00
Worker 0, host computer
CPU: [ ] 0 core(s) in use
RAM: [|||||||||||||||||| ] 28% 18.1 GiB/62.7 GiB
VMEM: [|||||||||||||||||| ] 28% 18.1 GiB/62.7 GiB
GPU: GeForce RTX 2080, not used
Worker 1, host othercomputer
CPU: [ ] 0 core(s) in use
RAM: [|||||||||||||| ] 23% 14 GiB/62.7 GiB
VMEM: [|||||||||||||| ] 23% 14 GiB/62.7 GiB
GPU: GeForce RTX 2080, not used
2019-12-18 01:19:46 +00:00
```
2020-06-10 09:41:58 +00:00
2020-08-31 15:11:01 +00:00
## Running locally for manually managing process priority
2020-06-10 09:41:58 +00:00
2020-07-11 08:55:13 +00:00
You can also run the **Lotus Worker** on the same machine as your **Lotus Miner** , so you can manually manage the process priority.
2020-08-31 15:11:01 +00:00
2020-06-10 09:44:35 +00:00
To do so you have to first __disable all seal task types__ in the miner config. This is important to prevent conflicts between the two processes.
2020-06-10 09:41:58 +00:00
2020-07-11 08:55:13 +00:00
You can then run the miner on your local-loopback interface;
2020-06-10 09:41:58 +00:00
```sh
2020-08-06 00:54:00 +00:00
lotus-worker run
```