Skip to content

Commit

Permalink
Merge pull request #590 from eco-stake/release-v2.5.0
Browse files Browse the repository at this point in the history
Release v2.5.0
  • Loading branch information
tombeynon authored Sep 13, 2022
2 parents fc2c138 + 5d7ac00 commit d739553
Show file tree
Hide file tree
Showing 37 changed files with 3,055 additions and 4,611 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ yarn-debug.log*
yarn-error.log*

.vim
.iml

# Parcel related files
dist/
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# dev env
FROM node:17-alpine
FROM node:17-slim

RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
RUN apt-get update && apt-get install -y python3 make g++

ENV NODE_ENV=development

Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.production
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# build env
FROM node:17-alpine as build
FROM node:17-slim as build

RUN apt-get update && apt-get install -y python3 make g++

WORKDIR /app
COPY package*.json ./
Expand Down
209 changes: 139 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ A script is also provided which allows a validator to automatically search their
- As of writing, Ledger is unable to send the necessary transactions to enable Authz. This is purely due to the way transactions are sent to a Ledger device and a workaround should be possible soon.
- Authz is also not fully supported yet. Many chains are yet to update. The REStake UI will fall back to being a manual staking app with useful manual compounding features.
- Currently REStake needs the browser extension version of Keplr, but WalletConnect and Keplr iOS functionality will be added ASAP.
- RESTake requires Nodejs version 17.x or later, it will not work with earlier versions.
- REStake requires Nodejs version 17.x or later, it will not work with earlier versions.

## Become an operator

Becoming an operator is extremely easy. You need to do three things:
Becoming an operator is pretty easy, the overall process is as follows:

1. Setup your bot wallet
2. Setup the autostaking script
3. Setup a cron or timer to run the script on a schedule
4. Submit your operator to Validator Registry

### Setup a hot wallet

Expand Down Expand Up @@ -54,21 +59,21 @@ The correct path can be set in one of two ways using a [config override](#overri

In the future, `correctSlip44` will become the default and you will need to set `slip44` explicitely if you want to use the 118 path.

### Setup the autostaking script and run daily
### Setup the autostaking script

You can run the autostaking script using `docker-compose` or using `npm` directly. In both cases you will need to provide your mnemonic in a `MNEMONIC` environment variable.

Instructions are provided for Docker Compose and will be expanded later.
#### Instructions for Docker Compose

### Install Docker and Docker Compose
##### Install Docker and Docker Compose

Best bet is to follow the Docker official guides. Install Docker first, then Docker Compose. In recent versions, Docker and Docker Compose may combined into a single installation.

Docker: [docs.docker.com/get-docker](https://docs.docker.com/get-docker/)

Docker Compose: [docs.docker.com/compose/install](https://docs.docker.com/compose/install/)

### Clone the repository and setup .env
##### Clone the repository and setup .env

Clone the repository and copy the sample `.env` file ready for your mnemonic.

Expand All @@ -80,46 +85,132 @@ cp .env.sample .env

**Populate your new .env file with your mnemonic.**

### Running the script manually
#### Instructions for NPM

##### Install nodejs@v17

```bash
curl -sL https://deb.nodesource.com/setup_17.x -o /tmp/nodesource_setup.sh
# read the script file and when you're sure it's safe run it
chmod +x /tmp/nodesource_setup.sh
/tmp/nodesource_setup.sh
apt install nodejs -y
node --version
> v17.9.0
npm --version
> 8.5.5

```

##### Clone the repository and build it

```bash
git clone https://github.com/eco-stake/restake
cd restake
npm install && npm run build
cp .env.sample .env
```

**Populate your new .env file with your mnemonic.**

#### Updating your local version

REStake is MVP. Very MVP. Updates are happening all the time and there are bugs that still need fixing. Make sure you update often.

Update your local repository and pre-build your Docker containers with the following commands:

```bash
git pull
docker-compose run --rm app npm install
docker-compose build --no-cache
```

or with NPM:

```bash
git pull
npm install
```

#### Running the script

Running the autostake script manually is then simple.

Note you might need `sudo` depending on your docker install.
**If you use Docker then you should prefix the below commands with `docker-compose run --rm app`.**

Some docker versions utilize `docker compose` instead of `docker-compose`. If you run into issues, try substituting `docker compose`.
Note you might need `sudo` depending on your docker install, and some docker versions utilize `docker compose` instead of `docker-compose`. If you run into issues, try substituting `docker compose`.

```bash
docker-compose run --rm app npm run autostake
```

Alternatively if you use NPM you can ignore the `docker-compose run --rm app` prefix:

```bash
npm run autostake
```

Pass network names to restrict the script to certain networks.

```bash
docker-compose run --rm app npm run autostake osmosis akash regen
npm run autostake osmosis akash regen
```

A _Dry Run_ script is also included, which runs the normal autostake script but skips sending the final TXs, and skips any health check pings.

```bash
docker-compose run --rm app npm run dryrun osmosis
npm run dryrun osmosis
```

### Updating your local version
**You should expect to see a warning that you are 'not an operator' until your REStake operator information is submitted in [Submitting your operator](#submitting-your-operator)**

REStake is MVP. Very MVP. Updates are happening all the time and there are bugs that still need fixing. Make sure you update often.

Update your local repository and pre-build your Docker containers with the following commands:
### Customise REStake and use your own node

```bash
git pull
docker-compose run --rm app npm install
docker-compose build --no-cache
You will likely want to customise your networks config, e.g. to set your own node URLs to ensure your autocompounding script completes successfully.

Create a `src/networks.local.json` file and specify the networks you want to override. The below is just an example, **you should only override a config if you need to**.

```json
{
"osmosis": {
"prettyName": "Osmosis",
"restUrl": [
"https://rest.cosmos.directory/osmosis"
],
"gasPrice": "0.0025uosmo",
"autostake": {
"retries": 3,
"batchTxs": 50,
"batchQueries": 50,
"delegatorTimeout": 5000,
"gasModifier": 1.1
},
"healthCheck": {
"uuid": "XXXXX-XXX-XXXX"
}
},
"desmos": {
"prettyName": "Desmos 118",
"autostake": {
"correctSlip44": true
}
},
"cosmoshub": {
"enabled": false
}
}
```

### Setting up Cron to make sure the script runs daily
Any values you specify will override the `networks.json` file. These are examples, you can override as much or little as you need.

Arrays will be replaced and not merged. The file is `.gitignore`'d so it won't affect upstream updates.

Note that REStake requires a node with indexing enabled and minimum gas prices matching the `networks.json` gas price (or your local override).

### Setting up cron/timers to run the script on a schedule

You should setup your script to run at the same time each day.
2 methods are described below; using `crontab` or using `systemd-timer`.
You should setup your script to run at the same time each day. 2 methods are described below; using `crontab` or using `systemd-timer`.

In both cases, ensure your system time is correct and you know what time the script will run in UTC, as that will be required later. Both examples below are for 21:00.

Expand All @@ -137,9 +228,17 @@ crontab -e
0 21 * * * /bin/bash -c "cd restake && docker compose run --rm app npm run autostake" > ./restake.log 2>&1
```

or with NPM:

```bash
crontab -e

0 21 * * * /bin/bash -c "cd restake && npm run autostake" > ./restake.log 2>&1
```

#### Using `systemd-timer`

Systemd-timer allow to run a one-off service with specified rules. This can be used instead, if you run into issues with implementing `crontab`.
Systemd-timer allow to run a one-off service with specified rules. This method is arguably preferable to Cron.

##### Create a systemd unit file

Expand All @@ -151,7 +250,7 @@ sudo vim /etc/systemd/system/restake.service

```bash
[Unit]
Description=stakebot service with docker compose
Description=restake service with docker compose
Requires=docker.service
After=docker.service
Wants=restake.timer
Expand All @@ -165,9 +264,11 @@ ExecStart=/usr/bin/docker-compose run --rm app npm run autostake
WantedBy=multi-user.target
```

For NPM installs, remove `Requires` and `After` directives, and change `ExecStart` to `ExecStart=/usr/bin/npm run autostake`.

##### Create a systemd timer file

The timer file defines the rules for running the restake service every day. All rules are described in the [systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.timer.html).
The timer file defines the rules for running the restake service every day. All rules are described in the [systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.timer.html).

Note: Helpful calculator for determining restake times for `OnCalendar` can also be found at https://crontab.guru/.

Expand Down Expand Up @@ -204,6 +305,7 @@ systemctl start restake.timer
Trigger: Wed 2022-03-09 21:00:00 UTC; 7h left
Triggers: ● restake.service
</pre>

`$ systemctl status restake.service`
<pre>● restake.service - stakebot service with docker compose
Loaded: loaded (/etc/systemd/system/restake.service; enabled; vendor preset: enabled)
Expand All @@ -213,45 +315,7 @@ TriggeredBy: <font color="#8AE234"><b>●</b></font> restake.timer
Main PID: 86925 (code=exited, status=0/SUCCESS)
</pre>

### Overriding networks config locally/use your own node

You will likely want to customise your networks config, e.g. to set your own node URLs to ensure your autocompounding script completes successfully.

Create a `src/networks.local.json` file and specify the networks you want to override. The below is just an example, **you should only override a config if you need to**.

```json
{
"osmosis": {
"prettyName": "Osmosis with Fees",
"restUrl": [
"https://rest.validator.com/osmosis"
],
"gasPrice": "0.001uosmo",
"autostake": {
"batchTxs": 69,
"batchQueries": 50,
"delegatorTimeout": 5000
}
},
"desmos": {
"prettyName": "Desmos 118",
"autostake": {
"correctSlip44": true
}
},
"cosmoshub": {
"enabled": false
}
}
```

Any values you specify will override the `networks.json` file. These are examples, you can override as much or little as you need.

Arrays will be replaced and not merged. The file is `.gitignore`'d so it won't affect upstream updates.

Note that REStake requires a node with indexing enabled and minimum gas prices matching the `networks.json` gas price (or your local override).

### Monitoring
### Monitoring

The REStake autostaking script can integrate with [healthchecks.io](https://healthchecks.io/) to report the script status for each network. [healthchecks.io](https://healthchecks.io/) can then integrate with many notification platforms like email, Discord and Slack to make sure you know about any failures.

Expand All @@ -271,9 +335,9 @@ Add your Check UUID to the relevant network in your `networks.local.json` config
}
```

## Submitting your operator
### Submitting your operator

### Setup your REStake operator
#### Setup your REStake operator

You now need to update the [Validator Registry](https://github.com/eco-stake/validator-registry) to add your operator information to any networks you want to auto-compound for. Check the README and existing validators for examples, but the config for a network looks like this:

Expand Down Expand Up @@ -302,27 +366,32 @@ Repeat this config for all networks you want to REStake for.

Note that the `restake.address` is the address which will be granted by the delegator in the UI to carry out their restaking transactions.

#### Submit your operator
#### Submit your operator to the Validator Registry

You can now submit your [Validator Registry](https://github.com/eco-stake/validator-registry) update to that repository in a pull request which will be merged as soon as possible. REStake automatically updates within 15 minutes of changes being merged.

## Adding/updating a network
## Contributing

### Adding/updating a network

Network information is sourced from the [Chain Registry](https://github.com/cosmos/chain-registry) via the [registry.cosmos.directory](https://registry.cosmos.directory) API. Chains in the master branch are automatically added to REStake assuming enough basic information is provided.

Network information is sourced from the [Chain Registry](https://github.com/cosmos/chain-registry) via the [registry.cosmos.directory](https://registry.cosmos.directory) API. The `networks.json` defines which chains appear in REStake; so long as the chain name matches the directory name from the Chain Registry, all chain information will be sourced automatically.
The `networks.json` file defines which chains appear as 'supported' in REStake; so long as the chain name matches the directory name from the Chain Registry, all chain information will be sourced automatically. Alternatively chains _can_ be supported in `networks.json` alone, but this is not a documented feature.

To add a network to REStake, add the required information to `networks.json` as follows:
To add or override a chain in REStake, add the required information to `networks.json` as follows:

```json
{
"name": "osmosis",
"prettyName": "Osmosis",
"gasPrice": "0.025uosmo",
"authzSupport": true
}
```

Note that most attributes from Chain Registry can be overriden by defining the camelCase version in networks.json.

## Running the UI
### Running the UI

Run the UI using docker with one line:

Expand Down
Loading

0 comments on commit d739553

Please sign in to comment.