# Running a PoB Challenger Client

The PoB Challenger Client Node is a DePIN Challenger node that participates in the PoB (Proof-of-Bandwidth) protocol and measures the bandwidth claims made by a DePIN Prover.

PoB Challenger Client Nodes can be run on community members’ laptops, desktops or even on cloud instances. As long as the node is running, there is a probabilistic algorithm (based on stake in the upcoming releases) that determines if the node will participate in a PoB challenge from the network.&#x20;

#### Prerequisites

Before you begin, ensure you have the following

* **Docker** (version 23.0.0 or above, refer: <https://docs.docker.com/desktop/install/linux-install/>)
* **Instance** comparable to a t2 micro (1 vcpu, 1GB RAM and 5GB harddisk), though we recommend 2 cores, 4 GB RAM and 10 GB of storage.
* Your operator key being whitelisted by Witness Chain.<br>

## Running your Challenger client

{% hint style="info" %}
Explorer: <https://blue-orangutan-blockscout.eu-north-2.gateway.fm/>&#x20;

Faucet: <https://blue-orangutan-faucet.eu-north-2.gateway.fm/>
{% endhint %}

### <mark style="color:red;">Key Points to consider before proceeding...</mark>

1. If you are an EigenLayer operator on our Witness Chain AVS, your Operator address would be already whitelisted.&#x20;
2. We have 2 sets of keys - Operator Key and Challenger Key.&#x20;
   1. **Operator Key** is the EigenLayer Operator Key that you have been using with our Witness Chain AVS. Continue to use that here too. This key is used for registering the Challenger Key(s).
   2. **Challenger Key** - This is the signing key for the PoB Challenger Client. Create a new Key for the same. **Don't reuse the Operator Key for the Challenger Key**. It has to be a ECDSA Key.&#x20;
3. **Both the Operator and the Challenger Key should be funded**. Please use the following faucet to fund it: <https://blue-orangutan-faucet.eu-north-2.gateway.fm/>
4. **Ports to be opened if using public IP:**&#x20;

```
Incoming ports to be opened (TCP & UDP ):

11112
22223
33334
44445
55556

Outgoing ports: Allow all
```

### 1. Setting up the challenger keys and the config file

{% hint style="success" %}
Use ECDSA Keypairs
{% endhint %}

1. Create a ECDSA private key using Metamask or other utilities that will be used as Challenger Key.&#x20;
2. Store the challenger's private key in the file (Make sure you keep track of the file name and its location, as it would be refered later)

```bash
echo "YOUR_CHALLENGER_PRIVATE_KEY" > my_challenger_private.key
```

4. Prepare a configuration file `my_challenger_config.json` with the following entries

```
{

"// 1" : "----- Please change the values that has TODO -----",

	"claims" : {
		"uplink_bandwidth"	: 100.0,					"// 2" : "Required - uplink_bandwidth is in Mbps",
		"downlink_bandwidth"	: 100.0,					"// 3" : "Required - downlink_bandwidth is in Mbps"
	},

	"walletPublicKey"	: {						"// 4" : "Required - The wallet addresses where your rewards go",
		"ethereum"	: "0x630391b032F444cB40B3603b579064817f312353",	"// 5" : "TODO: Please change this to your wallet address"
	},


"// 6" : "Set below two values to true - ONLY if you have public IP, but due to some issue with ISP the code is unable to detect it",

	"havePublicIPv4Address"	: false,
	"havePublicIPv6Address"	: false,

"// 7" : "CAFEFUL : Set below two values to true - ONLY if you want to force to have private IP",

	"havePrivateIPv4Address": false,
	"havePrivateIPv6Address": false,

"// 8" : "Save the login, session, and challenge related data in a .sqlite file",

	"saveResultsInDatabase" : false,

"// 9" : "Send challenge results to a contract",

	"submitResultsToContract" : true,

"// 10" : "RPC URL of the contract Where the challenger submits results",

	"rpcUrl": "https://blue-orangutan-rpc.eu-north-2.gateway.fm"
}
```

\
**Explanation:**

* The field `claims.uplink_bandwidth` and `claims.downlink_bandwidth`  (a.k.a. upload speeds and download speeds) are the  max limit of bandwidth supported by the challenger during challenges.
* `havePublicIPv4Address` (and `havePublicIPv6Address`) set them to **true** if you have a public IPv4 (or IPv6)&#x20;
* `havePrivateIPv4Address` (and `havePrivateIPv6Address`) set them to **true** if you want to force the use of private IP
* `saveResultsInDatabase` saves the login, session, and challenge related data in a .sqlite file within the container

5. Once you have the `config.json` ready, the challenger client can be started with

```sh
docker run -d \
  --network=host \
  --name pob-challenger \
  -v ./my_challenger_config.json:/app/dart/bin/pob/config/challenger.json \
  -v ./my_challenger_private.key:/root/.config/ethereum/private.key \
  witnesschain/pob-challenger
```

\
you can verify that the challenger is running by looking at the container status

```sh
docker ps 
```

**Explanation**:

1. `docker run -d`: Runs the container in detached mode (in the background).
   * ```
     --network=host
     Uses the host's network stack.
     ```
   * ```
     --name pob-challenger
     Names the container as 'pob-challenger'.
     ```
   * ```
     -v ./my_challenger_config.json:/app/dart/bin/pob/config/challenger.json 
     Mounts your local config file into the container at the specified path.
     ```
   * ```
     -v ./my_challenger_private.key:/root/.config/ethereum/private.key
     Mounts your local private key file folder into the container at the specified path.

     ```
   * ```
     witnesschain/pob-challenger: The name of the Docker image to run.
     ```

{% hint style="danger" %}
You will observe the following errors in the docker container&#x20;

"registration is required on DCL contract. Please register your challenger publicKey:"

Don't worry, this is normal. Once you [COMPLETE STEP 2](#id-2.-registering-the-challenger-key), these logs should disappear
{% endhint %}

### 2. Registering the Challenger Key

{% hint style="warning" %}
If you are already whitelisted on Witness Chain's AVS on EigenLayer's testnet, then you can move forward with registration, else write to us on our [Discord channel](https://discord.gg/Y9Eu2U5s) or Telegram to get whitelisted.&#x20;
{% endhint %}

You can register the challenger key easily with the help of our registration cli, to do so

1. Download our **dcl-operator-cli** <br>

   ```sh
   curl -sSfL https://witnesschain-com.github.io/install-dcl-cli | bash
   ```

   \
   Follow the steps as directed in the output of the script to add the CLI to the shell profile to be able to use the CLI from anywhere.<br>
2. Prepare the [config (challenger registration config)](https://github.com/witnesschain-com/dcl-operator-cli/blob/main/dcl-operator/operator-challenger-config.json.template),&#x20;
   1. The above command also downloads a template which you can refer to.
   2. <mark style="color:red;">Make sure you set the</mark> <mark style="color:red;"></mark><mark style="color:red;">`challenger_private_keys`</mark> <mark style="color:red;"></mark><mark style="color:red;">attribute in the json file with the key, that you provided in</mark> <mark style="color:red;"></mark><mark style="color:red;">`private.key`</mark>
3. Run the following command for registration

   ```sh
   dcl-operator-cli registerChallenger --config-file <path-to-challenger-registration-config.json>
   ```

{% hint style="warning" %}
Ensure the operator address is correctly set in the challenger's `config.json,`as the contributions are attributed to the operator!
{% endhint %}

## Post Setup

Once the setting up and registration is successful, you can check the logs from the challenger client ready for challenges. (`docker logs pob-challenger`). Congratulations, you are now a part of our DePIN family!<br>

{% hint style="info" %}
We publish images (x86 & arm64) with the tag `latest` and by the git tag, the `latest` will always point to the new and up to date image. In order to pull the latest image, make sure you don't have an older release of latest to avoid using cached images.&#x20;

You can remove the older images by

```bash
docker rmi witnesschain/pob-challenger
```

{% endhint %}

## Troubleshooting

As the only prerequisite is docker, make sure you are running atleast version 23.0.0 or above for the commands mentioned in the doc to work. \
\
The days might be rainy or snowy, but we've got umbrellas and sweaters!\
Join our [Discord](https://discord.gg/Y9Eu2U5s) or Telegram—we're happy to help. :D
