diff --git a/scripts/initiate_ritual.py b/scripts/initiate_ritual.py index f6e64b38..99d8c20d 100644 --- a/scripts/initiate_ritual.py +++ b/scripts/initiate_ritual.py @@ -44,21 +44,27 @@ "--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) @@ -66,6 +72,11 @@ def cli(domain, duration, account, access_controller, fee_model, num_nodes, rand 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] @@ -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,