Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add min_version option to initiate_ritual script #303

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 13 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,11 @@ def cli(
option_name="--random-seed",
message="Cannot specify --random-seed when using --handpicked.",
)
if handpicked and min_version:
raise click.BadOptionUsage(
option_name="--min-version",
message="Cannot specify --min-version when using --handpicked.",
)

# Get the staking providers in the ritual cohort
if handpicked:
Expand All @@ -100,7 +112,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
Loading