Skip to main content

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 and is based on the REStake Readme.

Install Docker and Docker Compose

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.

REStake is a Docker container that runs on your server. To install Docker and Docker Compose, follow the instructions on the Docker website.

For Ubuntu, you can also use the following guides:

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

Start the Docker container

  1. Start the Docker container in the background:

    docker-compose up -d

    If you reboot the server, you will need to start the Docker container again.

  2. Check the logs of the container:

     docker-compose logs -f

Clone and configure REStake

  1. Clone the REStake repository.

    git clone https://github.com/eco-stake/restake
  2. Change the directory to the restake folder:

    cd restake
  3. 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 .env
  4. Install the dependencies and build the Docker container:

     docker-compose run --rm app npm install
    docker-compose build --no-cache
  5. Create a new file:

    echo '{"acrechain": {}}' > src/networks.local.json

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.

  1. Fork the Validator Registry repository.

  2. Clone the Validator Registry repository fork.

    git clone https://github.com/<my-github-user-name>/restake-validator-registry
  3. Change the directory to the validator-registry folder:

    cd validator-registry
  4. Create a new directory for your validator:

    mkdir <your-validator-name>

Add your validator address

  1. Create a new file in your favorite text editor:

    nano <your-validator-name>/chains.json
  2. 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 9am 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.

  1. If you do not have a keybase account, create one at keybase.io.

  2. Using the keybase CLI, generate a new key:

    keybase pgp gen

    In the next step we will add the key ID to your profile file. The Validator Registry Readme is not clear whether the key ID is the full fingerprint, which can be viewed by running keybase pgp list or the ID that is shown at the end of running the previous command. We will be using the latter since the format conforms to the example in the readme (5992A6D423A406D6).

  3. Create a new file in your favourite text editor:

    nano <your-validator-name>/profile.json
  4. Add the following JSON to the file:

    {
    "$schema": "../profile.schema.json",
    "name": "<your-validator-name>",
    "identity": "<your-key-id>"
    }

Submit a pull request

  1. Commit and push your changes to your forked repository:

    git add .
    git commit -m "Add <your-validator-name> to Validator Registry"
    git push
  2. Submit 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

  1. Create a new file:

    sudo nano /etc/systemd/system/restake.service
  2. 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

    [Install]
    WantedBy=multi-user.target
  3. Enable the service:

    sudo systemctl enable restake.service

Create a systemd timer for REStake

  1. Create a new file:

    sudo nano /etc/systemd/system/restake.timer
  2. Add the following to the file, to run twice a day at 9am and 9pm UTC:

     [Unit]
    Description=restake timer

    [Timer]
    OnCalendar=*-*-* 09:00:00
    OnCalendar=*-*-* 21:00:00
    Persistent=true

    [Install]
    WantedBy=timers.target

    Or if you want to run every hour:

     [Unit]
    Description=restake timer

    [Timer]
    OnCalendar=*-*-* *:00:00
    Persistent=true

    [Install]
    WantedBy=timers.target

    Or if you want to run every 5 minutes:

     [Unit]
    Description=restake timer

    [Timer]
    OnCalendar=*-*-* *:00/5:00
    Persistent=true

    [Install]
    WantedBy=timers.target
  3. You can check variants of intervals using systemd-analyze:

    systemd-analyze calendar --iterations=8 '*:00/5:00' | grep Iter
  4. Enable the timer:

    sudo systemctl enable restake.timer
  5. Start the timer:

     sudo systemctl start restake.timer
  6. Check the status of the timer:

     sudo systemctl status restake.timer
  7. Check the logs of the timer:

     sudo journalctl -u restake.timer