Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate operators to validator registry #390

Merged
merged 11 commits into from
Mar 29, 2022
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,36 +237,42 @@ Any values you specify will override the `networks.json` file. These are example

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).
Note that REStake requires a node with indexing enabled and minimum gas prices matching the `networks.json` gas price (or your local override).

## Submiting your operator

### Setup your REStake operator

You now need to update the [networks.json](./src/networks.json) file at `./src/networks.json` to add your operator to any networks you want to auto-compound for. Check the existing file for examples, but the operators array is simple:
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:

```json
"operators": [{
"address": "osmovaloper1u5v0m74mql5nzfx2yh43s2tke4mvzghr6m2n5t",
"botAddress": "osmo1yxsmtnxdt6gxnaqrg0j0nudg7et2gqczed559y",
"runTime": ["09:00", "21:00"],
"minimumReward": 1000
{
"name": "akash",
"address": "akashvaloper1xgnd8aach3vawsl38snpydkng2nv8a4kqgs8hf",
"restake": {
"address": "akash1yxsmtnxdt6gxnaqrg0j0nudg7et2gqczud2r2v",
"run_time": [
"09:00",
"21:00"
],
"minimum_reward": 1000
}
},
```

`address` is your validator's address, and `botAddress` is the address from your new hot wallet you generated earlier.
`address` is your validator's address, and `restake.address` is the address from your new hot wallet you generated earlier.

`runTime` 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.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"`.

`minimumReward` is the minimum reward to trigger autostaking, otherwise the address be skipped. This could be set higher for more frequent restaking. Note this is in the base denomination, e.g. `uosmo`.
`restake.minimum_reward` is the minimum reward to trigger autostaking, otherwise the address be skipped. This could be set higher for more frequent restaking. Note this is in the base denomination, e.g. `uosmo`.

Repeat this config for all networks you want to REStake for.

Note that the `botAddress` is the address which will be granted by the delegator in the UI to carry out their restaking transactions.
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

You can now submit your `networks.json` update to the repository in a pull request which will be merged and deployed as soon as possible.
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

Expand All @@ -277,17 +283,7 @@ To add a network to REStake, add the required information to `networks.json` as
```json
{
"name": "osmosis",
"restUrl": [
"https://rest.cosmos.directory/osmosis",
],
"rpcUrl": [
"https://rpc.cosmos.directory/osmosis",
],
"gasPrice": "0.025uosmo",
"testAddress": "osmo1yxsmtnxdt6gxnaqrg0j0nudg7et2gqczed559y",
"ownerAddress": "osmovaloper1u5v0m74mql5nzfx2yh43s2tke4mvzghr6m2n5t",
"operators": [
],
"authzSupport": true
}
```
Expand All @@ -308,9 +304,9 @@ Alternative run from source using `docker-compose up` or `npm start`.

The REStake UI is both validator and network agnostic. Any validator can be added as an operator and run this tool to provide an auto-compounding service to their delegators, but they can also run their own UI if they choose and adjust the branding to suit themselves.

For this to work, we need a common source of chain information, and a common source of 'operator' information. Chain information is sourced from the [Chain Registry](https://github.com/cosmos/chain-registry), via an API provided by [cosmos.directory](https://registry.cosmos.directory). Operator information currently lives in the [networks.json](./src/networks.json) file in this repository.
For this to work, we need a common source of chain information, and a common source of 'operator' information. Chain information is sourced from the [Chain Registry](https://github.com/cosmos/chain-registry), via an API provided by [cosmos.directory](https://github.com/eco-stake/cosmos-directory). Operator information lives in the [Validator Registry](https://github.com/eco-stake/validator-registry).

If you fork this repository to provide your own UI, please keep up to date with the upstream to ensure you have the latest [networks.json](./src/networks.json) to include all operators. Some honesty is needed until we have a more decentralised solution.
Now we have a common source of operator information, applications can integrate with REStake validators easier using the data directly from GitHub, or via the [cosmos.directory](https://github.com/eco-stake/cosmos-directory) project.

## Disclaimer

Expand Down
2 changes: 1 addition & 1 deletion scripts/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class Autostake {
timeStamp("!! You should switch to the correct path unless you have grants. Check the README !!")
}

const operatorData = data.operators.find(el => el.botAddress === botAddress)
const operatorData = network.operators.find(el => el.botAddress === botAddress)

if (!operatorData) return timeStamp('Not an operator')
if (!network.authzSupport) return timeStamp('No Authz support')
Expand Down
21 changes: 16 additions & 5 deletions src/components/NetworkSelect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useReducer, useEffect } from 'react';

import CosmosDirectory from '../utils/CosmosDirectory.mjs';
import Network from '../utils/Network.mjs'

import {
Expand All @@ -17,6 +18,7 @@ function NetworkSelect(props) {
const [error, setError] = useState(false);
const [selectedNetwork, setSelectedNetwork] = useState();
const [validators, setValidators] = useState([]);
const [operatorCounts, setOperatorCounts] = useState({});
const [options, setOptions] = useReducer(
(state, newState) => ({...state, ...newState}),
{networks: [], operators: [], network: {value: ''}}
Expand All @@ -25,6 +27,9 @@ function NetworkSelect(props) {
const handleOpen = () => {
setSelectedNetwork(props.network)
setValidators(props.validators)
CosmosDirectory().getOperatorCounts().then(counts => {
setOperatorCounts(counts)
})
setShow(true)
}

Expand Down Expand Up @@ -52,17 +57,23 @@ function NetworkSelect(props) {
const networks = Object.values(props.networks).sort((a, b) => a.name > b.name ? 1 : -1)
setOptions({
networks: networks.map(el => {
return {value: el.name, label: el.pretty_name, image: el.image, operators: el.operators, authz: el.authzSupport}
return {
value: el.name,
label: el.pretty_name,
image: el.image,
operatorCount: el.operators?.length || operatorCounts[el.name],
authz: el.authzSupport
}
}),
network: selectedNetwork && {
value: selectedNetwork.name,
label: selectedNetwork.prettyName,
image: selectedNetwork.image,
operators: selectedNetwork.operators,
operatorCount: selectedNetwork.operators.length,
authz: selectedNetwork.authzSupport
}
})
}, [props.networks, selectedNetwork])
}, [props.networks, selectedNetwork, operatorCounts])

const selectNetwork = (newValue) => {
const data = props.networks[newValue.value]
Expand Down Expand Up @@ -133,8 +144,8 @@ function NetworkSelect(props) {
<span className="ms-1">{network.label}</span>
</div>
<div className="col text-end pt-1">
{network.operators.length > 0 &&
<small>{network.operators.length} Operator{network.operators.length > 1 ? 's' : ''}</small>
{network.operatorCount > 0 &&
<small>{network.operatorCount} Operator{network.operatorCount > 1 ? 's' : ''}</small>
}
{network.authz
? <Badge className="ms-3 rounded-pill" bg="success">Authz</Badge>
Expand Down
Loading