From 1b873183e727066164faffd629f3c7f2bf657b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Wed, 14 Aug 2024 18:23:41 +0200 Subject: [PATCH] Add min_version option to initiate_ritual script --- deployment/utils.py | 8 +++++++- scripts/initiate_ritual.py | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/deployment/utils.py b/deployment/utils.py index 0d731be1..591ef777 100644 --- a/deployment/utils.py +++ b/deployment/utils.py @@ -169,7 +169,11 @@ def get_chain_name(chain_id: int) -> str: def sample_nodes( - domain: str, num_nodes: int, random_seed: Optional[int] = None, duration: Optional[int] = None + domain: str, + num_nodes: int, + random_seed: Optional[int] = None, + duration: Optional[int] = None, + min_version: Optional[str] = None, ): porter_endpoint = PORTER_SAMPLING_ENDPOINTS.get(domain) if not porter_endpoint: @@ -184,6 +188,8 @@ def sample_nodes( if domain != MAINNET: raise ValueError("'random_seed' is only a valid parameter for mainnet") params["random_seed"] = random_seed + if min_version: + params["min_version"] = min_version response = requests.get(porter_endpoint, params=params) data = response.json() diff --git a/scripts/initiate_ritual.py b/scripts/initiate_ritual.py index 9dd80e65..2eb60fc3 100644 --- a/scripts/initiate_ritual.py +++ b/scripts/initiate_ritual.py @@ -48,6 +48,12 @@ required=True, type=ChecksumAddress(), ) +@click.option( + "--min-version", + "-mv", + help="Minimum version to sample", + type=str, +) @click.option( "--num-nodes", "-n", @@ -76,6 +82,7 @@ def cli( num_nodes, random_seed, handpicked, + min_version ): """Initiate a ritual for a TACo domain.""" @@ -92,6 +99,10 @@ def cli( option_name="--random-seed", message="Cannot specify --random-seed when using --handpicked.", ) + + # TODO: Think what to do if you do something silly like requirin a min version + # but handpicking nodes that do not run that min version. + # Maybe just don't allow both flags together? # Get the staking providers in the ritual cohort if handpicked: @@ -100,7 +111,7 @@ def cli( raise ValueError(f"No staking providers found in the handpicked file {handpicked.name}") else: providers = sample_nodes( - domain=domain, num_nodes=num_nodes, duration=duration, random_seed=random_seed + domain=domain, num_nodes=num_nodes, duration=duration, random_seed=random_seed, min_version=min_version ) # Get the contracts from the registry