Skip to content

Commit

Permalink
support for handpicked nodes file
Browse files Browse the repository at this point in the history
  • Loading branch information
KPrasch committed Aug 6, 2024
1 parent 0cef156 commit 974ebdd
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions scripts/initiate_ritual.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,39 @@
"--num-nodes",
help="Number of nodes to use for the ritual.",
type=int,
required=True,
)
@click.option(
"--random-seed",
help="Random seed integer for sampling.",
required=False,
type=int
)
@click.option("--random-seed", help="Random seed integer for sampling.", required=False, type=int)
@click.option("--authority", help="The address of the ritual authority.", required=False, type=str)
@click.option(
"--authority",
help="The address of the ritual authority.",
"--handpicked",
help="The filepath of a file containing staking provider addresses.",
required=False,
type=str
type=click.Path(exists=True, readable=True),
)
def cli(domain, duration, account, access_controller, fee_model, num_nodes, random_seed, authority):
def cli(
domain,
duration,
account,
access_controller,
fee_model,
num_nodes,
random_seed,
authority,
handpicked,
):
check_plugins()
transactor = Transactor(account=account)
registry_filepath = registry_filepath_from_domain(domain=domain)
chain_id = project.chain_manager.chain_id
deployments = contracts_from_registry(filepath=registry_filepath, chain_id=chain_id)
coordinator = deployments[project.Coordinator.contract_type.name]

if handpicked and num_nodes:
raise ValueError("Cannot specify both --num-nodes and --handpicked.")
if not handpicked and not num_nodes:
raise ValueError("Must specify either --num-nodes or --handpicked.")

try:
access_controller = deployments[getattr(project, access_controller).contract_type.name]
fee_model = deployments[getattr(project, fee_model).contract_type.name]
Expand All @@ -76,9 +87,13 @@ def cli(domain, duration, account, access_controller, fee_model, num_nodes, rand
authority = transactor.get_account().address
click.confirm(f"Using {authority} as the ritual authority. Continue?", abort=True)

providers = sample_nodes(
domain=domain, num_nodes=num_nodes, duration=duration, random_seed=random_seed
)
if handpicked:
with open(handpicked, "r") as f:
providers = sorted([line.strip() for line in f], key=lambda x: x.lower())
else:
providers = sample_nodes(
domain=domain, num_nodes=num_nodes, duration=duration, random_seed=random_seed
)

transactor.transact(
coordinator.initiateRitual,
Expand Down

0 comments on commit 974ebdd

Please sign in to comment.