From 5a342269fbec964bceb1e48efa649d73240ff839 Mon Sep 17 00:00:00 2001 From: Kirill Varlamov Date: Sat, 9 Jan 2021 15:40:40 +0300 Subject: [PATCH] Fix codestyle * Remove unneccessary imports * Remove formatter for strings without placeholders * Remove unused epochs_per_frame variable * Commas and blanklines --- app/beacon.py | 3 +-- app/contracts.py | 4 ++-- app/metrics.py | 5 ++--- app/oracle.py | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/beacon.py b/app/beacon.py index 5fdc0b343..abb26107f 100644 --- a/app/beacon.py +++ b/app/beacon.py @@ -8,7 +8,6 @@ import logging import math from datetime import timezone -import json import requests from requests.compat import urljoin @@ -66,7 +65,7 @@ def _convert_key_list_to_str_arr(self, key_list): def get_balances(self, slot, key_list): pubkeys = self._convert_key_list_to_str_arr(key_list) - logging.info(f'Fetching validators from Beacon node...') + logging.info('Fetching validators from Beacon node...') response_json = requests.get(urljoin(self.url, self.api_get_balances.format(slot))).json() balance_list = [] found_on_beacon_pubkeys = [] diff --git a/app/contracts.py b/app/contracts.py index faf9e47d6..a7ec45637 100644 --- a/app/contracts.py +++ b/app/contracts.py @@ -16,7 +16,7 @@ def dedup_validators_keys(validators_keys_list): def get_validators_keys(contract): node_operators_count = contract.functions.getNodeOperatorsCount().call() - logging.info(f'Quering NodeOperatorsRegistry...') + logging.info('Quering NodeOperatorsRegistry...') logging.info(f'Node operators in registry: {node_operators_count}') validators_keys_list = [] @@ -35,6 +35,6 @@ def get_validators_keys(contract): dedupped = dedup_validators_keys(validators_keys_list) if len(dedupped) != len(validators_keys_list): - logging.error(f'Alert! Validators keys contain duplicates.') + logging.error('Alert! Validators keys contain duplicates.') return dedupped diff --git a/app/metrics.py b/app/metrics.py index cd0eb37ad..4c579f769 100644 --- a/app/metrics.py +++ b/app/metrics.py @@ -30,11 +30,10 @@ def getTransientBalance(self): return self.getTransientValidators() * self.DEPOSIT_SIZE -def get_previous_metrics(w3, pool, oracle, beacon_spec, from_block = 0): +def get_previous_metrics(w3, pool, oracle, beacon_spec, from_block=0): """Since the contract lacks a method that returns the time of last report and the reported numbers we are using web3.py filtering to fetch it from the contract events.""" logging.info('Getting previously reported numbers (will be fetched from events)...') - epochs_per_frame = beacon_spec[0] genesis_time = beacon_spec[3] result = PoolMetrics() result.depositedValidators, result.beaconValidators, result.beaconBalance = pool.functions.getBeaconStat().call() @@ -122,7 +121,7 @@ def compare_pool_metrics(previous, current): if not previous.getTotalPooledEther(): logging.info('The Lido has no funds under its control. Probably the system has been just deployed and has never been deposited') return - + if not delta_seconds: logging.info('No time delta between current and previous epochs. Skip APR calculations.') assert(reward == 0) diff --git a/app/oracle.py b/app/oracle.py index c74185cc6..8e5d7a107 100644 --- a/app/oracle.py +++ b/app/oracle.py @@ -85,7 +85,7 @@ networks = { 1: {'name': 'Mainnet', 'engine': 'PoW'}, 5: {'name': 'Goerli', 'engine': 'PoA'}, - 1337: {'name': 'E2E', 'engine': 'PoA'} + 1337: {'name': 'E2E', 'engine': 'PoA'}, } network_id = w3.eth.chainId @@ -94,6 +94,7 @@ if networks[network_id]['engine'] == 'PoA': logging.info("Injecting PoA compatibility middleware") from web3.middleware import geth_poa_middleware + w3.middleware_onion.inject(geth_poa_middleware, layer=0) if dry_run: