# Run a Node

Configure and run an Uptick node

## Pre-requisite Readings

* [Installation](installation)
* [`uptickd`](binary)

## Automated deployment

Run the local node by running the `init.sh` script in the base directory of the repository.

{% hint style="info" %}
The script below will remove any pre-existing binaries installed. Use the manual deploy if you want to keep your binaries and configuration files.
{% endhint %}

```bash
./init.sh
```

## Manual deployment

The instructions for setting up a brand new full node from scratch are the the same as running a [single node local testnet](../../localnet/single_node#manual-localnet).

## Start node

To start your node, just type:

```bash
uptickd start --json-rpc.enable=true --json-rpc.api="eth,web3,net"
```

## Key Management

To run a node with the same key every time: replace `uptickd keys add $KEY` in `./init.sh` with:

```bash
echo "your mnemonic here" | uptickd keys add $KEY --recover
```

{% hint style="info" %}
Uptick currently only supports 24 word mnemonics.
{% endhint %}

You can generate a new key/mnemonic with:

```bash
uptickd keys add $KEY
```

To export your uptick key as an Ethereum private key (for use with [Metamask](../keys-wallets/metamask) for example):

```bash
uptickd keys unsafe-export-eth-key $KEY
```

For more about the available key commands, use the `--help` flag

```bash
uptickd keys -h
```

### Keyring backend options

The instructions above include commands to use `test` as the `keyring-backend`. This is an unsecured keyring that doesn't require entering a password and should not be used in production. Otherwise, Uptick supports using a file or OS keyring backend for key storage. To create and use a file stored key instead of defaulting to the OS keyring, add the flag `--keyring-backend file` to any relevant command and the password prompt will occur through the command line. This can also be saved as a CLI config option with:

```bash
uptickd config keyring-backend file
```

{% hint style="info" %}
For more information about the Keyring and its backend options, click [here](../keys-wallets/keyring).
{% endhint %}

## Clearing data from chain

### Reset Data

Alternatively, you can **reset** the blockchain database, remove the node's address book files, and reset the `priv_validator.json` to the genesis state.

{% hint style="info" %}
If you are running a **validator node**, always be careful when doing `uptickd tendermint unsafe-reset-all`. You should never use this command if you are not switching `chain-id`.
{% endhint %}

{% hint style="info" %}
**IMPORTANT**: Make sure that every node has a unique `priv_validator.json`. **Do not** copy the `priv_validator.json` from an old node to multiple new nodes. Running two nodes with the same `priv_validator.json` will cause you to double sign!
{% endhint %}

First, remove the outdated files and reset the data.

```bash
rm $HOME/.uptickd/config/addrbook.json $HOME/.uptickd/config/genesis.json
uptickd tendermint unsafe-reset-all
```

Your node is now in a pristine state while keeping the original `priv_validator.json` and `config.toml`. If you had any sentry nodes or full nodes setup before, your node will still try to connect to them, but may fail if they haven't also been upgraded.

### Delete Data

Data for the uptickd binary should be stored at `~/.uptickd`, respectively by default. To **delete** the existing binaries and configuration, run:

```bash
rm -rf ~/.uptickd
```

To clear all data except key storage (if keyring backend chosen) and then you can rerun the full node installation commands from above to start the node again.

## Recording Transactions Per Second (TPS)

In order to get a progressive value of the transactions per second, we use Prometheus to return the values. The Prometheus exporter runs at address "http://localhost:8877" so please add this section to your [Prometheus installation](https://opencensus.io/codelabs/prometheus/#1) config.yaml file like this

```yaml
global:
  scrape_interval: 10s

  external_labels:
    monitor: 'uptick'

scrape_configs:
  - job_name: 'uptick'

    scrape_interval: 10s

    static_configs:
      - targets: ['localhost:8877']
```

and then run Prometheus like this

```shell
prometheus --config.file=prom_config.yaml
```

and then visit the Prometheus dashboard at http://localhost:9090/ then navigate to the expression area and enter the following expression

```shell
rate(uptickd_transactions_processed[1m])
```

which will show the rate of transactions processed.
