Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
* Remove unneccessary imports
* Remove formatter for strings without placeholders
* Remove unused epochs_per_frame variable
* Commas and blanklines
  • Loading branch information
ongrid committed Jan 9, 2021
1 parent 1ef0ea8 commit 5a34226
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions app/beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import logging
import math
from datetime import timezone
import json

import requests
from requests.compat import urljoin
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions app/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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
5 changes: 2 additions & 3 deletions app/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion app/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 5a34226

Please sign in to comment.