Skip to content

Commit

Permalink
Add min_version option to initiate_ritual script
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Aug 14, 2024
1 parent f92cce4 commit 1b87318
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 7 additions & 1 deletion deployment/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down
13 changes: 12 additions & 1 deletion scripts/initiate_ritual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -76,6 +82,7 @@ def cli(
num_nodes,
random_seed,
handpicked,
min_version
):
"""Initiate a ritual for a TACo domain."""

Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 1b87318

Please sign in to comment.