From 17d7f95accfeee9fd4cb054ad5a486e39c4a7efe Mon Sep 17 00:00:00 2001 From: cyc60 Date: Tue, 29 Aug 2023 23:05:09 +0300 Subject: [PATCH] Move exit_signature_deadline to oracles config Signed-off-by: cyc60 --- src/common/execution.py | 6 ++++++ src/common/typings.py | 2 ++ src/config/settings.py | 4 ---- src/exits/tasks.py | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common/execution.py b/src/common/execution.py index 00963031..99ffe1c5 100644 --- a/src/common/execution.py +++ b/src/common/execution.py @@ -72,6 +72,11 @@ async def get_oracles() -> Oracles: if exit_signature_recover_threshold > validators_threshold: raise ValueError('Invalid exit signature threshold') + exit_signature_deadline = config['exit_signature_deadline'] + + if exit_signature_deadline < 0: + raise ValueError('Invalid exit signature deadline') + if len(public_keys) != len(set(public_keys)): raise ValueError('Duplicate public keys in oracles config') @@ -82,6 +87,7 @@ async def get_oracles() -> Oracles: rewards_threshold=rewards_threshold, validators_threshold=validators_threshold, exit_signature_recover_threshold=exit_signature_recover_threshold, + exit_signature_deadline=exit_signature_deadline, public_keys=public_keys, endpoints=endpoints, validators_approval_batch_limit=validators_approval_batch_limit, diff --git a/src/common/typings.py b/src/common/typings.py index ec47096a..86152ea4 100644 --- a/src/common/typings.py +++ b/src/common/typings.py @@ -8,10 +8,12 @@ @dataclass +# pylint: disable-next=too-many-instance-attributes class Oracles: rewards_threshold: int validators_threshold: int exit_signature_recover_threshold: int + exit_signature_deadline: int public_keys: list[HexStr] endpoints: list[list[str]] diff --git a/src/config/settings.py b/src/config/settings.py index 92b790c8..587947f7 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -47,7 +47,6 @@ class Settings(metaclass=Singleton): ipfs_fetch_endpoints: list[str] validators_fetch_chunk_size: int sentry_dsn: str - exit_signature_deadline: int # pylint: disable-next=too-many-arguments,too-many-locals def set( @@ -122,9 +121,6 @@ def set( 'VALIDATORS_FETCH_CHUNK_SIZE', default=100, cast=int ) self.sentry_dsn = decouple_config('SENTRY_DSN', default='') - self.exit_signature_deadline = decouple_config( - 'EXIT_SIGNATURE_DEADLINE', default=600, cast=int - ) @property def network_config(self) -> NetworkConfig: diff --git a/src/exits/tasks.py b/src/exits/tasks.py index c5e8c7a0..20e6fe96 100644 --- a/src/exits/tasks.py +++ b/src/exits/tasks.py @@ -138,7 +138,7 @@ async def get_oracles_approval( ) -> OraclesApproval: """Fetches approval from oracles.""" fork = await consensus_client.get_consensus_fork() - deadline = datetime.now(timezone.utc) + timedelta(seconds=settings.exit_signature_deadline) + deadline = datetime.now(timezone.utc) + timedelta(seconds=oracles.exit_signature_deadline) # get exit signature shards request = SignatureRotationRequest(