Skip to content

Commit

Permalink
Fix gnosis validator registration (#76)
Browse files Browse the repository at this point in the history
* Fix gnosis validator registration

* Update versions
  • Loading branch information
tsudmi authored Mar 28, 2022
1 parent 5c89983 commit dce3cf8
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
6 changes: 3 additions & 3 deletions deploy/gnosis/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ networks:
services:
oracle:
container_name: oracle_gnosis
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/oracle/main.py"]
Expand All @@ -34,7 +34,7 @@ services:

keeper:
container_name: keeper_gnosis
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/keeper/main.py"]
Expand Down Expand Up @@ -90,7 +90,7 @@ services:

subgraphs:
container_name: subgraphs_gnosis
image: europe-west4-docker.pkg.dev/stakewiselabs/public/subgraphs:v1.2.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/subgraphs:v1.2.1
command: >
/bin/sh -c "until nc -vz graph-node 8020; do echo 'Waiting graph-node'; sleep 2; done
&& yarn build:gnosis
Expand Down
4 changes: 2 additions & 2 deletions deploy/goerli/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ networks:
services:
oracle:
container_name: oracle_goerli
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/oracle/main.py"]
Expand All @@ -36,7 +36,7 @@ services:

keeper:
container_name: keeper_goerli
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/keeper/main.py"]
Expand Down
4 changes: 2 additions & 2 deletions deploy/mainnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ networks:
services:
oracle:
container_name: oracle_mainnet
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/oracle/main.py"]
Expand All @@ -36,7 +36,7 @@ services:

keeper:
container_name: keeper_mainnet
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/keeper/main.py"]
Expand Down
4 changes: 2 additions & 2 deletions deploy/perm_goerli/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ networks:
services:
oracle:
container_name: oracle_perm_goerli
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/oracle/main.py"]
Expand All @@ -36,7 +36,7 @@ services:

keeper:
container_name: keeper_perm_goerli
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.0
image: europe-west4-docker.pkg.dev/stakewiselabs/public/oracle:v2.3.1
restart: always
entrypoint: ["python"]
command: ["oracle/keeper/main.py"]
Expand Down
7 changes: 2 additions & 5 deletions oracle/oracle/rewards/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from oracle.networks import GNOSIS_CHAIN, NETWORKS
from oracle.oracle.eth1 import submit_vote
from oracle.settings import REWARD_VOTE_FILENAME
from oracle.settings import MGNO_RATE, REWARD_VOTE_FILENAME, WAD

from .eth1 import get_registered_validators_public_keys
from .eth2 import (
Expand All @@ -25,9 +25,6 @@
logger = logging.getLogger(__name__)
w3 = Web3()

WAD = Web3.toWei(1, "ether")
MGNO_RATE = Web3.toWei(32, "ether")


class RewardsController(object):
"""Updates total rewards and activated validators number."""
Expand Down Expand Up @@ -122,7 +119,7 @@ async def process(
)

if self.network == GNOSIS_CHAIN:
# apply GNO <-> mGNO exchange rate
# apply mGNO <-> GNO exchange rate
total_rewards = Wei(int(total_rewards * WAD // MGNO_RATE))

pretty_total_rewards = self.format_ether(total_rewards)
Expand Down
8 changes: 7 additions & 1 deletion oracle/oracle/validators/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from web3 import Web3
from web3.types import Wei

from oracle.networks import GNOSIS_CHAIN
from oracle.oracle.eth1 import submit_vote
from oracle.settings import VALIDATOR_VOTE_FILENAME
from oracle.settings import MGNO_RATE, VALIDATOR_VOTE_FILENAME, WAD

from .eth1 import (
get_validators_deposit_root,
Expand Down Expand Up @@ -36,6 +37,11 @@ async def process(self) -> None:
voting_params = await get_voting_parameters(self.network)
latest_block_number = voting_params["latest_block_number"]
pool_balance = voting_params["pool_balance"]

if self.network == GNOSIS_CHAIN:
# apply GNO <-> mGNO exchange rate
pool_balance = Wei(int(pool_balance * MGNO_RATE // WAD))

if pool_balance < self.validator_deposit:
# not enough balance to register next validator
return
Expand Down
4 changes: 4 additions & 0 deletions oracle/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from decouple import Csv, config
from web3 import Web3

from oracle.networks import MAINNET

Expand Down Expand Up @@ -52,3 +53,6 @@
KEEPER_PROCESS_INTERVAL = config("KEEPER_PROCESS_INTERVAL", default=10, cast=int)

TRANSACTION_TIMEOUT = config("TRANSACTION_TIMEOUT", default=900, cast=int)

WAD = Web3.toWei(1, "ether")
MGNO_RATE = Web3.toWei(32, "ether")
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "oracle"
version = "2.3.0"
version = "2.3.1"
description = "StakeWise Oracles are responsible for submitting off-chain data."
authors = ["Dmitri Tsumak <[email protected]>"]
license = "AGPL-3.0-only"
Expand Down

0 comments on commit dce3cf8

Please sign in to comment.