Skip to content

Commit

Permalink
Merge pull request nucypher#325 from derekpierre/minor-fix
Browse files Browse the repository at this point in the history
Minor fixes: perform strip() on provider addresses from file, print number of missing transcripts/aggregations during `ritual_state_check`
  • Loading branch information
derekpierre authored Sep 4, 2024
2 parents 23e83b4 + 89c2729 commit b294524
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/initiate_ritual.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def cli(
num_nodes,
random_seed,
handpicked,
min_version
min_version,
):
"""Initiate a ritual for a TACo domain."""

Expand All @@ -108,7 +108,9 @@ def cli(

# Get the contracts from the registry
coordinator_contract = registry.get_contract(domain=domain, contract_name="Coordinator")
access_controller_contract = registry.get_contract(domain=domain, contract_name=access_controller)
access_controller_contract = registry.get_contract(
domain=domain, contract_name=access_controller
)
fee_model_contract = registry.get_contract(domain=domain, contract_name=fee_model)

# if using a subcription, duration needs to be calculated
Expand All @@ -125,23 +127,25 @@ def cli(
if now > end_of_subscription:
raise ValueError("Subscription has already ended.")
click.echo(
"Subscription has already started. Subtracting the elapsed time from the duration."
)
"Subscription has already started. Subtracting the elapsed time from the duration."
)
elapsed = now - start_of_subscription + 100
duration -= elapsed


# Get the staking providers in the ritual cohort
if handpicked:
providers = sorted(line.lower() for line in handpicked)
providers = sorted(line.lower().strip() for line in handpicked)
if not providers:
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, min_version=min_version
domain=domain,
num_nodes=num_nodes,
duration=duration,
random_seed=random_seed,
min_version=min_version,
)


# Initiate the ritual
transactor = Transactor(account=account)
transactor.transact(
Expand Down
7 changes: 7 additions & 0 deletions scripts/ritual_state_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,23 @@ def print_ritual_state(ritual_id, coordinator) -> RitualState:
ritual = coordinator.rituals(ritual_id)
participants = coordinator.getParticipants(ritual_id)

num_missing = 0
if ritual.totalTranscripts < len(participants):
print("\t(!) Missing transcripts")
for participant in participants:
if not participant.transcript:
print(f"\t\t{participant.provider}")
num_missing += 1

elif ritual.totalAggregations < len(participants):
print("\t(!) Missing aggregated transcripts")
for participant in participants:
if not participant.aggregated:
print(f"\t\t{participant.provider}")
num_missing += 1

if num_missing > 0:
print(f"\t\t> Num Missing: {num_missing}")

return ritual_state

Expand Down

0 comments on commit b294524

Please sign in to comment.