From dce3cf8a18805c0277115964395fba8d0cc1307a Mon Sep 17 00:00:00 2001 From: Dmitri Tsumak Date: Mon, 28 Mar 2022 18:34:24 +0400 Subject: [PATCH] Fix gnosis validator registration (#76) * Fix gnosis validator registration * Update versions --- deploy/gnosis/docker-compose.yml | 6 +++--- deploy/goerli/docker-compose.yml | 4 ++-- deploy/mainnet/docker-compose.yml | 4 ++-- deploy/perm_goerli/docker-compose.yml | 4 ++-- oracle/oracle/rewards/controller.py | 7 ++----- oracle/oracle/validators/controller.py | 8 +++++++- oracle/settings.py | 4 ++++ pyproject.toml | 2 +- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/deploy/gnosis/docker-compose.yml b/deploy/gnosis/docker-compose.yml index afba410..7e78367 100644 --- a/deploy/gnosis/docker-compose.yml +++ b/deploy/gnosis/docker-compose.yml @@ -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"] @@ -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"] @@ -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 diff --git a/deploy/goerli/docker-compose.yml b/deploy/goerli/docker-compose.yml index 3de8c0b..eb0f05e 100644 --- a/deploy/goerli/docker-compose.yml +++ b/deploy/goerli/docker-compose.yml @@ -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"] @@ -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"] diff --git a/deploy/mainnet/docker-compose.yml b/deploy/mainnet/docker-compose.yml index 6eb6306..73f9fc1 100644 --- a/deploy/mainnet/docker-compose.yml +++ b/deploy/mainnet/docker-compose.yml @@ -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"] @@ -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"] diff --git a/deploy/perm_goerli/docker-compose.yml b/deploy/perm_goerli/docker-compose.yml index 858d90d..aa5c0f8 100644 --- a/deploy/perm_goerli/docker-compose.yml +++ b/deploy/perm_goerli/docker-compose.yml @@ -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"] @@ -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"] diff --git a/oracle/oracle/rewards/controller.py b/oracle/oracle/rewards/controller.py index c7c35f5..4febfe2 100644 --- a/oracle/oracle/rewards/controller.py +++ b/oracle/oracle/rewards/controller.py @@ -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 ( @@ -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.""" @@ -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) diff --git a/oracle/oracle/validators/controller.py b/oracle/oracle/validators/controller.py index cbc59c4..2a62738 100644 --- a/oracle/oracle/validators/controller.py +++ b/oracle/oracle/validators/controller.py @@ -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, @@ -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 diff --git a/oracle/settings.py b/oracle/settings.py index ec717f1..1bd5a7e 100644 --- a/oracle/settings.py +++ b/oracle/settings.py @@ -1,4 +1,5 @@ from decouple import Csv, config +from web3 import Web3 from oracle.networks import MAINNET @@ -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") diff --git a/pyproject.toml b/pyproject.toml index efb2357..c6e5f59 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "AGPL-3.0-only"