Git Product home page Git Product logo

interchain-security-gravity's Introduction

Gravity Delegations Tool

A convenience tool designed to periodically run delegations for a wallet. the script can execute via cli or github actions. Please refer to the .github/workflows/automation.yml for details.

Github actions

Configured to run at 12 noon on every 1st and 15th.

# Install `act`
brew install act

# arch
yay -S act

create .secrets file in repo root add following variables as secrets in file. e.g.

...
NODE='https://localhost:26657'
CHAIN_ID=chain-id-1
AUTHZ_PHRASES='key key key'
...

run on local:

act

Development

Follow local setup, run following command to get a live reloading runner

act -w

Environment Variables

NOTE: For multiple wallet integration please configure new environments in setting for the repository.

Key Default Description Required
SLACK_WEBHOOK_UR Bot webhook url. Refer slack roles [x]
BINARY simd binary of undrelying chain [x]
NODE address of mainnet node of target chain [x]
DENOM stake Denomination of chain currency [x]
CHAIN_ID current chain id of target chain [x]
FROM_ADDRESS alice the complete address of the wallet holding the tokens [x]
AUTHZ_PHRASES memonic of authz enabled wallet [x]
GRANTEE bob Human readable authz wallet name as registered on the server [x]
GRANTER alice the human readable wallet name as registered on the server []
MAX_AMOUNT if set the delegation amount will be []

NOTE: if using github actions please set variables as secrets in settings the script requires for the FROM_ADDRESS to be set or the GRANTER to be passed. Future update would extend the same functionality to AUTHZ_PHRASES and GRANTEE if MAX_AMOUNT is not set the total amount held by the granter will get delegated

Executables

Make sure the file is executable

chmod +x gen.py

Make sure the delegation script is executable

chmod +x delegate.sh

Prerequisites

  • Ensure a list of validators can be found at the root dir named validators.json
  • In order to allow for smooth functioning of this script an authz GRANTEE needs to be configured

This key requires the following permissions

  • MsgDelegation
$BINARY tx authz grant $($BINARY keys show $GRANTEE -a) generic --msg-type=/cosmos.gov.v1beta1.MsgDelegation --from $GRANTER --fees 200$DENOM
  • MsgWithdrawAll
$BINARY tx authz grant $($BINARY keys show $GRANTEE -a) generic --msg-type=/cosmos.gov.v1beta1.MsgWithdrawAll --from $GRANTER --fees 200$DENOM

Github actions

The script executes at a fixed interval via github actions refer .github/workflows/automation.yml

Manual Configuration

Running the delegation script

Use the command as follows:

./delegate.sh

The script should withdraw all rewards for the GRANTER Divide the current balance of the Delegator by the number of validators they plan to delegate to Generate the message for this TX Make an authz tx sing the GRANTEE to sign the transaction

Running python script

NOTE delegate.sh is a wrapper for gen.py, thus if you use it there is no need to run the script directly

python3 gen.py

For help try the --help flag:

> python3 gen.py --help
usage: gen.py [-h] [--amount AMOUNT] [--from-address FROM_ADDRESS] [--output-file OUTPUT_FILE]

Delegate to Cosmos Hub validators

optional arguments:
  -h, --help            show this help message and exit
  --amount AMOUNT       Amount to delegate to each
  --from-address FROM_ADDRESS*
                        Address to send grav from (default new-new-bom)
  --output-file OUTPUT_FILE
                        Filename to write

Default values for the flags are as follows:

  • --amount = 1
  • --from-address = gravity1zk4uwzygs4k2k5cz7y759sxcnv6qt3pd4g3pqq (new-new-bom)
  • --output-file = today's date in format %d-%m-%Y/unsigned.json

Examples:

python gen.py --amount 1000000000000
python gen.py --amount 1000000000000 --from $(gravity keys show new-new-bom -a)
python gen.py --amount 1000000000000 --output-file output/unsigned.json

interchain-security-gravity's People

Contributors

tokamak-git avatar okwme avatar crodriguezvega avatar

Stargazers

rhcproc avatar Will Pankiewicz avatar  avatar Eric Bravick avatar Golden Ratio Staking avatar Prasert Jaipet avatar

Watchers

James Cloos avatar Eric Bravick avatar 0xnr avatar  avatar  avatar  avatar

interchain-security-gravity's Issues

gravity re-delegation script

essentially with this script we want to have the ability to simulate shared security with our delegations on the gravity bridge chain. by delegating to all validators who are part of the cosmos hub val set, we encourage an overlap between the val sets. This will help ensure interchain security is adopted when it is ready, because otherwise validators who are not in both sets will be removed after the upgrade and only participate in governance.

To do this we should have a script that re-delegates every 2 weeks (limit for making 2 re-delegations). This could be combined with withdrawing rewards so that we are essentially compounding our rewards as well. I started a script here: https://github.com/interchainio/grav-tokens that will create a batch of re-delegations. Instead of requiring these messages to be signed in a transaction by the multi-sig account (which is hard to coordinate). We should use authz to authorize a new private key the ability to execute re-delegation msg types on behalf of the multisig account.

So the flow could be as follows:

  • create a new private key account on gravity bridge chain
  • create a multisig transaction on behalf of the two ICF multisig accounts that hold grav token that authorize the new key the following msg types:
    • delegate
    • redelegate
    • withdraw-rewards
    • vote
  • use the script above as a starting point (or propose a new architecture) that can do the following:
    • be run by a cron job every two weeks
    • checks the list of validators on the cosmos hub
    • checks the list of validators on gravity bridge chain
    • confirms overlap either via the same pubkey or the name of the valdator or an external resource that is manually maintained like a google spreadsheet where we can manually confirm the validators are the same
    • withdraw all rewards from all currently delegated validators
    • check the currently delegated amount to all eligible gravity chain validators
    • calculate how much should be delegated to each validator so that they all have the same delegation amount afterwards
    • create the necessary delegation and re-delegation messages that will re-allocated delegations so they are all equal again
  • this process needs to happen for both accounts, the rewards need to continue to be associated with the account that the delegations came from (eventually one of the accounts rewards and balances will be donated to the community pool)
  • this script should be possible to load on a server with a cron job and run automatically
  • would be good to have the results output to a log or to a slack channel
  • possibly we make this a marketing tool and output aspects of it to a twitter bot or something similar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.