# RPC providers

## Lava - providers

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FV4OUpabrGMhCjD9fgCZf%2Flava.jpg?alt=media&#x26;token=b66cbeee-3218-4fab-a24e-50ce8121f911" alt=""><figcaption></figcaption></figure>

[**Web**](https://lavanet.xyz/) [**Discord**](https://discord.gg/p3TzpyE7kq) [**Github**](https://github.com/lavanet/lava/releases)

* Docs providers - <https://docs.lavanet.xyz/provider/>
* Dashboard - <https://info.lavanet.xyz/#providers>

Providers are the backbone of the Lava network, servicing relay requests by staking on the network and managing RPC nodes on relay chains (e.g. Cosmos, Ethereum, Osmosis, Polygon, etc.). In return, providers receive payment in the form of LAVA tokens for servicing these requests.

***

It is necessary to configure TLS certificates for the provider - more details here -<https://docs.lavanet.xyz/provider-tls/?utm_source=lava-discord&utm_medium=discord&utm_campaign=testnet-fork>

***

### **General points**

* whether a validator is in an active or inactive network does not affect the work of the provider. You can start the provider without running the validator
* To bind tokens, you can use either a separate wallet or a validator wallet
* the wallet must have at least **50,000 LAVA**
* public access points can be either remote or local on your own server. Ensure that **RPC, API, and gRPC** access points are up and running
* you can use a simplified installation system and use only the lava binary with RPC without synchronizing the node

**A provider can get jail status** if during the last 3 epochs (1.5 hours) consumers complain about it and they have more than 95% errors in the first 10 messages or if the connection is lost

***

**When placing bets as a provider, transactions use four main parameters:**

1. **Stake**: the amount of **LAVA** that will be sent to stake. For a test network, this value should be a minimum of **50,000 LAVA** per network. The value may be greater, but not less
2. **Geolocation**: indicates the geolocation of your server. **US** corresponds to 1 and **EU** corresponds to 2
3. **ChainID**: ID of the target blockchain network such as Cosmos Mainnet, Ethereum Ropsten, etc.
4. **Endpoints**: a list of endpoints, each of which defines an address, geolocation, and an API such as REST, JSON-RPC, etc. It is important to note that all provider requests are made using gRPC

There are several ways to find out **ChainID** - going to [dashboard](https://info.lavanet.xyz/#providers) or using information from [RPC](https://public-rpc-testnet2.lavanet.xyz/rest/lavanet/lava/spec/show_all_chains) or using the following command

```bash
lavap q spec list-spec --node https://public-rpc.lavanet.xyz:443/rpc/ | grep index
```

## **Setting up the LAV1 provider**

**IMPORTANT** - in the commands below, we change everything in <> to our value and remove <> ourselves

**LAV1 -** is a chain identifier that allows you to become a provider using the LAVA test network. This network is ideal for getting started as a provider. Afterwards you can easily add other networks

In this guide we will be using a validator wallet for stake and a synchronized lava node, so it is assumed that we already have the latest version of lava and other networks installed on our server. Our server is located in **Europe**, so we will use `--geolocation 2`

**1.** Download the lavap binary file

You can also configure lavavisor (analogous to cosmovisor). More details here

A separate **lavap** binary must be used for the provider.  You can also configure  [lavavisor](https://github.com/lavanet/lava/tree/main/ecosystem/lavavisor) (analogous to cosmovisor).

```bash
git clone https://github.com/lavanet/lava && cd lava
export LAVA_BINARY=lavap
make install
lavap version
#v2.0.1
```

**2.** Create or restore a wallet and replenish it with at least **50,000 LAVA**

For the testnet, you must use `--keyring-backend test` because transactions need to be signed. This will be fixed in mainnet

```bash
# create a wallet
lavap keys add <name_wallet> --keyring-backend test

# restore wallet (after the command insert seed)
lavap keys add <name_wallet> --recover --keyring-backend test

# check balance
lavap q bank balances <address>
```

**3.** Registration of stake for the network we need. In this case **LAV1 (lava-testnet-2)**

For the example below, we have created a subdomain `lava-provider.stavr.tech` with the port used being **12345**. This port number is intended to inform others that your ISP services will operate at this address with this specific port number. Please do not confuse `provider_port` with **RPC, API or gRPC** **port numbers!**<br>

## **IMPORTANT - before you begin, you must configure a TLS certificate**

You can change this port(12345) to the value you need, but do not forget to make this port open to the outside world. Also change `<name_wallet> <moniker>` `<lava.your-site:443>`  to your values

```bash
lavap tx pairing stake-provider "LAV1" \
    "50000000000ulava" \
    "<lava.your-site:443>,2,tendermintrpc,rest,grpc" 2 \
    --from "<name_wallet>" \
    --provider-moniker "<moniker>" \
    --keyring-backend "test" \
    --gas="auto" \
    --gas-adjustment "1.5" \
    --fees 5000ulava
```

**Congratulations** - you have officially declared yourself as a **service provider in LAVA!**

To register other networks, send another transaction replacing LAV1 and subdomain with your values"

`For example, the transaction for osmosis testnet would look like this`

```bash
lavap tx pairing stake-provider "COS4" \
    "50000000000ulava" \
    "<osmosis.your-site:443>,2,tendermintrpc,rest,grpc" 2 \
    --from "<name_wallet>" \
    --provider-moniker "<moniker>" \
    --keyring-backend "test" \
    --gas="auto" \
    --gas-adjustment "1.5" \
    --fees 5000ulava
```

Now is the time to check the status of your provider

```bash
# check registered provider
lavap query pairing account-info <lava@1sdx...>

# check all providers in the LAV1 network
lavap query pairing providers LAV1
```

### Settings rpcprovider.yml <a href="#id-3n8x" id="id-3n8x"></a>

We need to create separate config files for each provider network. In this case, it is necessary to create different service files to launch

### Create a config

```bash
nano $HOME/.lava/config/lava-provider.yml
```

*Use exactly **0.0.0.0:12345** to successfully catch incoming traffic. Also in the config, if necessary, change ports **26657, 9090 and 1317** to your **RPC, gRPC and API** values, respectively*

```bash
endpoints:
  - api-interface: tendermintrpc
    chain-id: LAV1
    network-address:
      address: 0.0.0.0:12345
      disable-tls: true
    node-urls:
      - url: ws://127.0.0.1:26657/websocket
      - url: http://127.0.0.1:26657
  - api-interface: grpc
    chain-id: LAV1
    network-address:
      address: 0.0.0.0:12345
      disable-tls: true
    node-urls: 
      - url: 127.0.0.1:9090
  - api-interface: rest
    chain-id: LAV1
    network-address:
      address: 0.0.0.0:12345
      disable-tls: true
    node-urls: 
      - url: http://127.0.0.1:1317
```

[Lava's caching ](https://docs.lavanet.xyz/provider-features/#caching)service is used to reduce costs and improve overall network performance. Both providers and consumers benefit from a caching service. Providers that have caching enabled may return responses faster than providers that do not have caching enabled

**Create a cashe service file**

```bash
tee /etc/systemd/system/lava-cache.service > /dev/null << EOF
[Unit]
Description=Lava cache service
After=network-online.target
[Service]
User=$USER
ExecStart=$(which lavap) cache 127.0.0.1:7777 --metrics_address 127.0.0.1:5747 --log_level debug
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
```

```bash
systemctl daemon-reload
systemctl enable lava-cache.service
systemctl start lava-cache.service
journalctl -fu lava-cache.service -o cat
```

Create a service file. Replace `<name_wallet>` with your value

```bash
tee /etc/systemd/system/provider-lava.service > /dev/null <<EOF
[Unit]
Description=Provider Lava
After=network-online.target

[Service]
User=$USER
WorkingDirectory=/root/.lava/config
ExecStart=/root/go/bin/lavap rpcprovider lava-provider.yml --geolocation 2 --from <name_wallet> --chain-id lava-testnet-2 --keyring-backend test --cache-be 127.0.0.1:7777
Restart=on-failure
RestartSec=3
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target
EOF
```

```bash
systemctl daemon-reload
systemctl enable provider-lava
systemctl restart provider-lava && journalctl -fu provider-lava -o cat
```

**After the service starts, we make sure in the logs that cashe is working**

<figure><img src="https://img3.teletype.in/files/a7/0f/a70f395d-7ef9-4fe1-9402-507c0296f75f.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://img3.teletype.in/files/a7/0f/a70f395d-7ef9-4fe1-9402-507c0296f75f.png" alt="" height="74" width="670"><figcaption></figcaption></figure>

**Next we see similar logs**

<figure><img src="https://img4.teletype.in/files/fe/0c/fe0c7e91-e575-4c86-959b-fc2bef0b13b1.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://img4.teletype.in/files/fe/0c/fe0c7e91-e575-4c86-959b-fc2bef0b13b1.png" alt="" height="280" width="974"><figcaption></figcaption></figure>

**You can also use the configuration check command**

```bash
lavap test rpcprovider --from <name_wallet> --keyring-backend test
```

<figure><img src="https://img2.teletype.in/files/97/4e/974e43e4-a394-4c2f-a2bc-a916812978b6.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://img2.teletype.in/files/97/4e/974e43e4-a394-4c2f-a2bc-a916812978b6.png" alt="" height="254" width="962"><figcaption></figcaption></figure>

**Useful commands**

```bash
# check logs for successful transactions
journalctl -fn 100 -u lava-provider | grep succeeded
```

```bash
# check registered provider
lavap query pairing account-info <lava@1sdx...>
```

```bash
# unstake
lavap tx pairing unstake-provider "LAV1" \
    --from "<name_wallet>" \
    --keyring-backend "test" \
    --gas="auto" \
    --gas-adjustment "1.5" \
    --fees 5000ulava
```

```bash
# unfreeze
lavap tx pairing unfreeze EVMOS --from WALLET --fees 20000ulava --gas-adjustment "1.5" --gas "auto" -y  --node "tcp://localhost:26657" --keyring-backend test
```

```bash
# delete provider
systemctl stop provider-lava
systemctl disable provider-lava
rm /etc/systemd/system/provider-lava.service
systemctl daemon-reload
cd $HOME/.lava/config/
rm lava-provider.yml
```
