Enable restake
Enable restaking feature for your validator.
Reference: https://github.com/eco-stake/restake
To check available validators that support restaking: https://restake.nodestake.org/dhealth
About REStake
REStake makes use of a new feature in Cosmos blockchains called Authz. This allows a validator (or any other wallet) to send certain pre-authorized transactions on your behalf.
When you enable REStake you authorize the validator to send Delegate messages for their own validator address. The validator cannot delegate to any other validators, and the authorisation expires automatically after one year and you can revoke at any time.
You can also optionally add a total number of tokens the validator is allowed to delegate, or adjust the expiry date.
Enable REStake
Becoming an operator is pretty easy, the overall process is as follows:
- Setup your bot wallet
- Setup the autostaking script
- Setup a cron or timer to run the script on a schedule
- Submit your operator to Validator Registry
1. Setup a hot wallet
Generate a new hot wallet you will use to automatically carry out the staking transactions. The mnemonic will need to be provided to the script so use a dedicated wallet and only keep enough funds for transaction fees. The ONLY mnemonic required here is for the hot wallet, do not put your validator operator mnemonic anywhere.
You only need a single mnemonic for multiple Cosmos chains, and the script will check each network in the networks.json file for a matching bot address.
2. 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 for 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
Docker Compose: docs.docker.com/compose/install
Clone the repository and setup .env
Clone the repository and copy the sample .env
file ready for your mnemonic.
git clone https://github.com/eco-stake/restake
cd restake
cp .env.sample .env
Populate your new .env
file with your mnemonic.
Instructions for NPM
- Install nodejs@v18
- Clone the repository and build it
git clone https://github.com/eco-stake/restake
cd restake
npm install
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:
git pull
docker-compose run --rm app npm install
docker-compose build --no-cache
or with NPM:
git pull
npm install
Running the script
Running the autostake script manually is then simple.
If you use Docker then you should prefix the below commands with docker-compose run --rm app
.
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
.
docker-compose run --rm app npm run autostake dhealth
Alternatively if you use NPM you can ignore the docker-compose run --rm app
prefix:
npm run autostake dhealth
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.
npm run dryrun dhealth
You should expect to see a warning that you are 'not an operator' until your REStake operator information is submitted in Submitting your operator.
Customise REStake and 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. Alternatively, set the NETWORKS_OVERRIDE_PATH
environment variable containing the filepath. The below is just an example, you should only override a config if you need to.
{
"dhealth": {
"prettyName": "dHealth",
"autostake": {
"correctSlip44": true
},
"restUrl": [
"https://lcd.dhealth.com",
"https://api.dhealth.nodestake.org"
],
"operator": {
"address": "OVERRIDE_BOT_ADDRESS
},
"ownerAddress": "OVERRIDE_VALIDATOR_ADDRESS_e.g._dhvaloperxx"
}
}
3. 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
.
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.
Don't forget to update often!
Using crontab
Note: A helpful calculator for determining your REStake timer for crontab can be found here: https://crontab.guru/.
Updated versions utilize docker compose
instead of docker-compose
. If you run into issues, try substituting docker compose
.
crontab -e
0 21 * * * /bin/bash -c "cd path/to/restake && docker compose run --rm app npm run autostake" > path/to/restake.log 2>&1
or with NPM:
crontab -e
0 21 * * * /bin/bash -c "cd path/to/restake && npm run autostake" > path/to/restake.log 2>&1
Warning:
Using crontab with docker without the
--rm
flag will continuously create docker images. Add another cronjob to tear down the images weekly if required:crontab -e 0 0 * * */7 /usr/bin/docker image prune -a -f
Using systemd-timer
Systemd-timer allows to run a one-off service with specified rules. This method is arguably preferable to Cron.
Follow the instructions here.
Monitoring (optional)
The REStake autostaking script can integrate with healthchecks.io to report the script status for each network. healthchecks.io can then integrate with many notification platforms like email, Discord and Slack to make sure you know about any failures.
Follow the instructions here.
4. Submitting your operator
You now need to update the 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:
{
"$schema": "../chains.schema.json",
"name": "YOUR_VALIDATOR_NAME",
"chains": [
{
"name": "dhealth",
"address": "YOUR_dhvaloper_ADDRESS",
"restake": {
"address": "YOUR_BOT_ADDRESS",
"run_time": "21:00",
"minimum_reward": 1000000
}
}
]
}
{
"$schema": "../profile.schema.json",
"name": "YOUR_VALIDATOR_NAME",
"identity": "YOUR_IDENTITY_CODE_CAN_LEAVE_BLANK"
}
File | Field | Description |
---|---|---|
chains.json | ||
address | address is your validator's address, and restake.address is the address from your new hot wallet you generated earlier. | |
restake.run_time | restake.run_time is the time in UTC that you intend to run your bot, and there are a few options. Pass a single time, e.g. 09:00 to specify a single run at 9am UTC. Use an array for multiple specified times, e.g. ["09:00", "21:00"] . Use an interval string for multiple times per hour/day, e.g. "every 15 minutes" . | |
restake.minimum_reward | restake.minimum_reward is the minimum reward to trigger autostaking, otherwise the address is skipped. This could be set higher for more frequent restaking. Note this is in the base denomination, e.g. udhp . | |
profile.json | ||
identity | identity should be the identity signature (ex. UPort or Keybase) that you created during updating validator step. This field can be left empty. |
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 to the Validator Registry
You can now submit your 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.
Updated 6 months ago