Skip to content

Commit

Permalink
Merge pull request #413 from lidofinance/feat/log-requests-in-ejector…
Browse files Browse the repository at this point in the history
…-module

Feat: add more logs to code and log validators request in ejector module
  • Loading branch information
F4ever authored May 23, 2024
2 parents 9146bf5 + 7d93587 commit 7019141
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/modules/ejector/ejector.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
from functools import reduce

Expand Down Expand Up @@ -105,6 +106,19 @@ def build_report(self, blockstamp: ReferenceBlockStamp) -> tuple:

EJECTOR_VALIDATORS_COUNT_TO_EJECT.set(report_data.requests_count)

try:
with open('validators_response.json', 'w') as f:
f.write(
json.dumps([{
**v.__dict__,
'validator': v.validator.__dict__,
} for v in self.w3.cc.get_validators(blockstamp)])
)
except Exception as error: # pylint: disable=W0703
logger.error({'msg': 'Failed to save get_validators response.', 'error': str(error)})
else:
logger.info({'msg': 'Response get_validators from Consensus Client written to validators_response.json.'})

return report_data.as_tuple()

def get_validators_to_eject(self, blockstamp: ReferenceBlockStamp) -> list[tuple[NodeOperatorGlobalIndex, LidoValidator]]:
Expand Down Expand Up @@ -296,6 +310,12 @@ def _get_latest_exit_epoch(self, blockstamp: BlockStamp) -> tuple[EpochNumber, i
max_exit_epoch_number = val_exit_epoch
latest_to_exit_validators_count = 1

logger.info({
'msg': 'Calculate latest exit epoch',
'value': max_exit_epoch_number,
'latest_to_exit_validators_count': latest_to_exit_validators_count,
})

return max_exit_epoch_number, latest_to_exit_validators_count

def _get_sweep_delay_in_epochs(self, blockstamp: ReferenceBlockStamp) -> int:
Expand All @@ -318,7 +338,11 @@ def _get_churn_limit(self, blockstamp: ReferenceBlockStamp) -> int:
self.w3.cc.get_validators(blockstamp),
0,
)
return max(MIN_PER_EPOCH_CHURN_LIMIT, total_active_validators // CHURN_LIMIT_QUOTIENT)
logger.info({'msg': 'Calculate total active validators.', 'value': total_active_validators})

churn_limit = max(MIN_PER_EPOCH_CHURN_LIMIT, total_active_validators // CHURN_LIMIT_QUOTIENT)
logger.info({'msg': 'Calculate churn limit.', 'value': churn_limit})
return churn_limit

def _get_processing_state(self, blockstamp: BlockStamp) -> EjectorProcessingState:
ps = named_tuple_to_dataclass(
Expand Down

0 comments on commit 7019141

Please sign in to comment.