REStake for Validators
REStake is a service that allows you to automatically re-stake your self-delegation rewards and allow your delegators to automatically re-stake their rewards. This means that they won't have to manually claim their rewards and re-delegate them to your validator.
To set up REStake, you need to authorize REStake to send transactions on your behalf. This is done by using Authz, a new feature in Cosmos blockchains.
Requirements​
- You need to have a validator set up on the ACRE Mainnet.
- Set up a separate wallet for REStake. This wallet will be used to authorize REStake to send transactions on your behalf.
- You need to have at least 1 ACRE in your REStake wallet.
Set up REStake​
The following steps will guide you through the process of setting up REStake which is based on the REStake Readme.
Install Docker and Docker Compose​
This guide assumes that you are using Docker to install REStake. To install Docker and Docker Compose, follow the instructions on the Docker website. If you do not want to use Docker, you can follow the instructions in the REStake Readme to install REStake without Docker using NPM instead.
For Ubuntu, you can also use the following guides to install Docker and Docker Compose:
Install Docker: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04
Install Docker Compose: https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-20-04
Clone and configure REStake​
Clone the REStake repository.
git clone https://github.com/eco-stake/restake
Change the directory to the
restake
folder:cd restake
Copy the
.env.example
file to.env
and fill in the values. You will need to add the mnemonic seed phrase of your REStake wallet.cp .env.example .env
nano .envCreate a new file:
echo '{"acrechain": {}}' > src/networks.local.json
Install the dependencies and build the Docker container:
docker-compose run --rm app npm install
docker-compose build --no-cache
Submitting your operator​
The REStake bot will automatically re-stake your rewards. To do this, you need to submit your operator address to the Validator Registry.
Fork and clone the Validator Registry​
Update the Validator Registry to include your operator data for auto-compounding on any desired networks.
Fork the Validator Registry repository.
Clone the Validator Registry repository fork.
git clone https://github.com/<my-github-user-name>/restake-validator-registry
Change the directory to the validator-registry folder:
cd validator-registry
Create a new directory for your validator:
mkdir <your-validator-name>
Add your validator address​
Create a new file in your favorite text editor:
nano <your-validator-name>/chains.json
Add the following JSON to the file:
{
"$schema": "../chains.schema.json",
"name": "<your-validator-name>",
"chains": [
{
"name": "acrechain",
"address": "<your-validator-address>",
"restake": {
"address": "<your-restake-wallet-address>",
"run_time": ["09:00", "21:00"],
"minimum_reward": 100000000000000000
}
}
]
}restake.run_time
is the UTC time you want your bot to run.
You can give it a single time, for example,["09:00"]
, for one run at 9 am UTC.
You can also use an array of times, for example["09:00", "21:00"]
for two runs.
And if you want multiple runs per hour/day, use an interval string, for example,"every 15 minutes"
.
Add your validator identity​
You will need to generate a public key with keybase.io and add it to your profile file.
If you do not have a keybase account, create one at keybase.io and install the keybase CLI.
Using the keybase CLI, generate a new key:
keybase pgp gen
When you run the above command you will get the output below. Record the ID shown at the end of the process, the image below only shows an example. We will need it for the next step.
Create a new file in your favorite text editor:
nano <your-validator-name>/profile.json
Add the following JSON to the file:
{
"$schema": "../profile.schema.json",
"name": "<your-validator-name>",
"identity": "<your-key-id>"
}
Submit a pull request​
Commit and push your changes to your forked repository:
git add .
git commit -m "Add <your-validator-name> to Validator Registry"
git pushSubmit a pull request to the Validator Registry repository to update your operator. REStake will then update within 15 minutes of the changes being merged.
Set REStake to run automatically on a schedule​
You can set REStake to run automatically on a schedule using systemd. First, we will create a systemd unit file and then a systemd timer file to call the unit file.
Create a systemd unit file for REStake​
Create a new file:
sudo nano /etc/systemd/system/restake.service
Add the following to the file:
[Unit]
Description=restake service with docker compose
Requires=docker.service
After=docker.service
Wants=restake.timer
[Service]
Type=oneshot
WorkingDirectory=/path/to/restake
ExecStart=/usr/local/bin/docker-compose run --rm app npm run autostake acrechain
[Install]
WantedBy=multi-user.targetEnable the service:
sudo systemctl enable restake.service
Create a systemd timer for REStake​
The time interval to run the restake.service
is specified in the timer file. The time interval you define here should match the restake.run_time
value you defined in the chains.json file.
Create a new file:
sudo nano /etc/systemd/system/restake.timer
Add the following to the file, to run twice a day at 9 am and 9 pm UTC, for example:
[Unit]
Description=restake timer
[Timer]
OnCalendar=*-*-* 09:00:00
OnCalendar=*-*-* 21:00:00
Persistent=true
[Install]
WantedBy=timers.targetOr if you want to run every hour:
[Unit]
Description=restake timer
[Timer]
OnCalendar=*-*-* *:00:00
Persistent=true
[Install]
WantedBy=timers.targetOr if you want to run every 5 minutes:
[Unit]
Description=restake timer
[Timer]
OnCalendar=*-*-* *:00/5:00
Persistent=true
[Install]
WantedBy=timers.targetYou can check variants of intervals using systemd-analyze:
systemd-analyze calendar --iterations=8 '*:00/5:00' | grep Iter
Enable the timer:
sudo systemctl enable restake.timer
Start the timer:
sudo systemctl start restake.timer
Check the status of the timer:
sudo systemctl status restake.timer
Check the logs of the timer:
sudo journalctl -u restake.timer