diff --git a/src/config/settings.py b/src/config/settings.py index 0013c325..de766f04 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -54,6 +54,7 @@ class Settings(metaclass=Singleton): validators_fetch_chunk_size: int sentry_dsn: str pool_size: int | None + log_indexes_max_len: int # pylint: disable-next=too-many-arguments,too-many-locals def set( @@ -153,6 +154,7 @@ def set( self.pool_size = decouple_config( 'POOL_SIZE', default=None, cast=lambda x: int(x) if x else None ) + self.log_indexes_max_len = decouple_config('LOG_INDEXES_MAX_LEN', default=3, cast=int) @property def network_config(self) -> NetworkConfig: diff --git a/src/exits/tasks.py b/src/exits/tasks.py index 6dd04ce9..2182cdd3 100644 --- a/src/exits/tasks.py +++ b/src/exits/tasks.py @@ -203,6 +203,8 @@ async def _get_oracles_request( exit_signature_shards=[], deadline=get_current_timestamp() + oracles.signature_validity_period, ) + failed_indexes = [] + for validator_index, public_key in validators.items(): if len(keystores) > 0 and public_key in keystores: shards = get_exit_signature_shards( @@ -221,15 +223,27 @@ async def _get_oracles_request( fork=fork, ) else: - logger.warning( - 'Failed to rotate validator exit signature: ' - 'public key %s not found in keystores or remote signer', - public_key, - ) + failed_indexes.append(validator_index) continue request.public_keys.append(public_key) request.public_key_shards.append(shards.public_keys) request.exit_signature_shards.append(shards.exit_signatures) + if failed_indexes: + logger.warning( + 'Failed to rotate validator exit signature for indexes: %s. ' + 'Reason: public key not found in keystores or remote signer', + _format_indexes(failed_indexes), + ) + return request + + +def _format_indexes(indexes: list[int]) -> str: + max_len = settings.log_indexes_max_len + + if len(indexes) <= max_len: + return ', '.join(str(i) for i in indexes) + + return f"{', '.join(str(i) for i in indexes)}..."