Skip to content

Commit

Permalink
Merge pull request #510 from lidofinance/feat/improve-logs
Browse files Browse the repository at this point in the history
Feat/improve logs
  • Loading branch information
F4ever authored Aug 14, 2024
2 parents cb2cf2a + 1cba421 commit bec116f
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/modules/accounting/accounting.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _get_consensus_lido_state(self, blockstamp: ReferenceBlockStamp) -> tuple[Va
count = len(lido_validators)
total_balance = Gwei(sum(int(validator.balance) for validator in lido_validators))

logger.info({'msg': 'Calculate consensus lido state.', 'value': (count, total_balance)})
logger.info({'msg': 'Calculate lido state on CL. (Validators count, Total balance in gwei)', 'value': (count, total_balance)})
return ValidatorsCount(count), ValidatorsBalance(total_balance)

def _get_finalization_data(self, blockstamp: ReferenceBlockStamp) -> tuple[FinalizationShareRate, FinalizationBatches]:
Expand Down
7 changes: 4 additions & 3 deletions src/modules/ejector/ejector.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from functools import reduce

from more_itertools import ilen
from web3.types import Wei

from src.constants import (
Expand Down Expand Up @@ -142,7 +143,7 @@ def get_validators_to_eject(self, blockstamp: ReferenceBlockStamp) -> list[tuple
if consensus_version != 1:
forced_validators = validators_iterator.get_remaining_forced_validators()
if forced_validators:
logger.info({'msg': 'Eject forced to exit validators.', 'value': len(forced_validators)})
logger.info({'msg': 'Eject forced to exit validators.', 'len': len(forced_validators)})
validators_to_eject.extend(forced_validators)

return validators_to_eject
Expand Down Expand Up @@ -290,10 +291,10 @@ def _get_sweep_delay_in_epochs(self, blockstamp: ReferenceBlockStamp) -> int:
return int(full_sweep_in_epochs * self.AVG_EXPECTING_WITHDRAWALS_SWEEP_DURATION_MULTIPLIER)

def _get_total_withdrawable_validators(self, blockstamp: ReferenceBlockStamp) -> int:
total_withdrawable_validators = len(list(filter(lambda validator: (
total_withdrawable_validators = ilen(filter(lambda validator: (
is_partially_withdrawable_validator(validator) or
is_fully_withdrawable_validator(validator, blockstamp.ref_epoch)
), self.w3.cc.get_validators(blockstamp))))
), self.w3.cc.get_validators(blockstamp)))

logger.info({'msg': 'Calculate total withdrawable validators.', 'value': total_withdrawable_validators})
return total_withdrawable_validators
Expand Down
1 change: 1 addition & 0 deletions src/providers/execution/contracts/accounting_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def get_processing_state(self, block_identifier: BlockIdentifier = 'latest') ->
'msg': 'Call `getProcessingState()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand Down
12 changes: 9 additions & 3 deletions src/providers/execution/contracts/base_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ def get_consensus_contract(self, block_identifier: BlockIdentifier = 'latest') -
Returns the address of the HashConsensus contract.
"""
response = self.functions.getConsensusContract().call(block_identifier=block_identifier)
logger.info({
logger.debug({
'msg': 'Call `getConsensusContract()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -37,6 +38,7 @@ def submit_data_role(self, block_identifier: BlockIdentifier = 'latest') -> Hash
'msg': 'Call `SUBMIT_DATA_ROLE()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -50,6 +52,7 @@ def has_role(self, role: Hash32, address: ChecksumAddress, block_identifier: Blo
'msg': f'Call `hasRole({role.hex()}, {address})`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -59,10 +62,11 @@ def get_contract_version(self, block_identifier: BlockIdentifier = 'latest') ->
Returns the current contract version.
"""
response = self.functions.getContractVersion().call(block_identifier=block_identifier)
logger.info({
logger.debug({
'msg': 'Call `getContractVersion().',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -74,10 +78,11 @@ def get_consensus_version(self, block_identifier: BlockIdentifier = 'latest') ->
an oracle looking at the same reference slot would calculate a different hash.
"""
response = self.functions.getConsensusVersion().call(block_identifier=block_identifier)
logger.info({
logger.debug({
'msg': 'Call `getConsensusVersion().',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand Down Expand Up @@ -113,5 +118,6 @@ def get_last_processing_ref_slot(self, block_identifier: BlockIdentifier = 'late
'msg': 'Call `getLastProcessingRefSlot().',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return SlotNumber(response)
1 change: 1 addition & 0 deletions src/providers/execution/contracts/burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ def get_shares_requested_to_burn(self, block_identifier: BlockIdentifier = 'late
'msg': 'Call `getSharesRequestedToBurn()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response
7 changes: 5 additions & 2 deletions src/providers/execution/contracts/exit_bus_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def is_paused(self, block_identifier: BlockIdentifier = 'latest') -> bool:
'msg': 'Call `isPaused()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -41,6 +42,7 @@ def get_processing_state(self, block_identifier: BlockIdentifier = 'latest') ->
'msg': 'Call `getProcessingState()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -64,9 +66,10 @@ def get_last_requested_validator_indices(
).call(block_identifier=block_identifier)

logger.info({
'msg': f'Call `getLastRequestedValidatorIndices({module_id}, {no_list})`.',
'value': response,
'msg': f'Call `getLastRequestedValidatorIndices({module_id}, {len(no_list)})`.',
'len': len(response),
'block_identifier': repr(block_identifier),
'to': self.address,
})

result.extend(response)
Expand Down
10 changes: 8 additions & 2 deletions src/providers/execution/contracts/hash_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def get_members(self, block_identifier: BlockIdentifier = 'latest') -> tuple[lis
'msg': 'Call `getMembers()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})

return response
Expand All @@ -41,10 +42,11 @@ def get_chain_config(self, block_identifier: BlockIdentifier = 'latest') -> Chai
response = self.functions.getChainConfig().call(block_identifier=block_identifier)
response = named_tuple_to_dataclass(response, ChainConfig)

logger.info({
logger.debug({
'msg': 'Call `getChainConfig()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})

return response
Expand All @@ -69,6 +71,7 @@ def get_current_frame(self, block_identifier: BlockIdentifier = 'latest') -> Cur
'msg': 'Call `getCurrentFrame()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})

return response
Expand All @@ -85,6 +88,7 @@ def get_initial_ref_slot(self, block_identifier: BlockIdentifier = 'latest') ->
'msg': 'Call `getInitialRefSlot()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})

return response
Expand All @@ -101,10 +105,11 @@ def get_frame_config(self, block_identifier: BlockIdentifier = 'latest') -> Fram
response = self.functions.getFrameConfig().call(block_identifier=block_identifier)
response = named_tuple_to_dataclass(response, FrameConfig)

logger.info({
logger.debug({
'msg': 'Call `getFrameConfig()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})

return response
Expand All @@ -122,6 +127,7 @@ def get_consensus_state_for_member(self, address: ChecksumAddress, block_identif
'msg': f'Call `getConsensusStateForMember({address})`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})

return response
Expand Down
4 changes: 4 additions & 0 deletions src/providers/execution/contracts/lido.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def handle_oracle_report(
),
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand All @@ -85,6 +86,7 @@ def get_buffered_ether(self, block_identifier: BlockIdentifier = 'latest') -> We
'msg': 'Call `getBufferedEther()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return Wei(response)

Expand All @@ -102,6 +104,7 @@ def total_supply(self, block_identifier: BlockIdentifier = 'latest') -> Wei:
'msg': 'Call `totalSupply()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return Wei(response)

Expand All @@ -121,5 +124,6 @@ def get_beacon_stat(self, block_identifier: BlockIdentifier = 'latest') -> Beaco
'msg': 'Call `getBeaconStat()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response
30 changes: 20 additions & 10 deletions src/providers/execution/contracts/lido_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,108 +17,118 @@ class LidoLocatorContract(ContractInterface):
def lido(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.lido().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `lido()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def accounting_oracle(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.accountingOracle().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `accountingOracle()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def staking_router(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.stakingRouter().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `stakingRouter()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def validator_exit_bus_oracle(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.validatorsExitBusOracle().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `validatorsExitBusOracle()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def withdrawal_queue(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.withdrawalQueue().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `withdrawalQueue()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def oracle_report_sanity_checker(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.oracleReportSanityChecker().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `oracleReportSanityChecker()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def oracle_daemon_config(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.oracleDaemonConfig().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `oracleDaemonConfig()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def burner(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.burner().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `burner()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def withdrawal_vault(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.withdrawalVault().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `withdrawalVault()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

@lru_cache(maxsize=1)
def el_rewards_vault(self, block_identifier: BlockIdentifier = 'latest') -> ChecksumAddress:
response = self.functions.elRewardsVault().call(block_identifier=block_identifier)

logger.info({
logger.debug({
'msg': 'Call `elRewardsVault()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response
1 change: 1 addition & 0 deletions src/providers/execution/contracts/oracle_daemon_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def _get(self, param: str, block_identifier: BlockIdentifier = 'latest') -> int:
'msg': f'Call `get({param})`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ def get_oracle_report_limits(self, block_identifier: BlockIdentifier = 'latest')
'msg': 'Call `getOracleReportLimits()`.',
'value': response,
'block_identifier': repr(block_identifier),
'to': self.address,
})
return response
Loading

0 comments on commit bec116f

Please sign in to comment.