Update nucypher_dkg script to accomodate naming/philosophy changes regarding not needing redundant parameters for associated polygon network.

pull/3262/head
derekpierre 2023-10-02 10:43:55 -04:00
parent 74517534f5
commit d3e175a800
1 changed files with 29 additions and 39 deletions

View File

@ -11,6 +11,7 @@ from nucypher.blockchain.eth.agents import (
CoordinatorAgent, CoordinatorAgent,
TACoApplicationAgent, TACoApplicationAgent,
) )
from nucypher.blockchain.eth.networks import NetworksInventory
from nucypher.blockchain.eth.registry import ContractRegistry from nucypher.blockchain.eth.registry import ContractRegistry
from nucypher.blockchain.eth.signers import InMemorySigner, Signer from nucypher.blockchain.eth.signers import InMemorySigner, Signer
from nucypher.characters.lawful import Bob, Enrico from nucypher.characters.lawful import Bob, Enrico
@ -43,33 +44,26 @@ def get_transacting_power(signer: Signer):
@click.command() @click.command()
@click.option( @click.option(
"--eth-provider", "--network",
"eth_provider_uri", "network",
help="TACo Network",
type=click.Choice(["tapir", "lynx"]),
default="lynx",
)
@click.option(
"--eth-endpoint",
"eth_endpoint",
help="ETH staking network provider URI", help="ETH staking network provider URI",
type=click.STRING, type=click.STRING,
required=True, required=True,
) )
@click.option( @click.option(
"--eth-staking-network", "--polygon-endpoint",
"eth_staking_network", "polygon_endpoint",
help="ETH staking network", help="Polygon network provider URI",
type=click.Choice(["tapir", "lynx"]),
default="lynx",
)
@click.option(
"--coordinator-provider",
"coordinator_provider_uri",
help="Coordinator network provider URI",
type=click.STRING, type=click.STRING,
required=True, required=True,
) )
@click.option(
"--coordinator-network",
"coordinator_network",
help="Coordinator network",
type=click.Choice(["mumbai"]),
default="mumbai",
)
@click.option( @click.option(
"--ritual-id", "--ritual-id",
"ritual_id", "ritual_id",
@ -117,10 +111,9 @@ def get_transacting_power(signer: Signer):
default=False, default=False,
) )
def nucypher_dkg( def nucypher_dkg(
eth_provider_uri, network,
eth_staking_network, eth_endpoint,
coordinator_provider_uri, polygon_endpoint,
coordinator_network,
ritual_id, ritual_id,
signer_uri, signer_uri,
dkg_size, dkg_size,
@ -161,22 +154,20 @@ def nucypher_dkg(
), ),
) )
coordinator_network_registry = ContractRegistry.from_latest_publication( taco_network = NetworksInventory.get_network(network)
domain=coordinator_network registry = ContractRegistry.from_latest_publication(
domain=network
) )
coordinator_agent = ContractAgency.get_agent( coordinator_agent = ContractAgency.get_agent(
agent_class=CoordinatorAgent, agent_class=CoordinatorAgent,
registry=coordinator_network_registry, registry=registry,
provider_uri=coordinator_provider_uri, provider_uri=polygon_endpoint,
) # type: CoordinatorAgent ) # type: CoordinatorAgent
staking_network_registry = ContractRegistry.from_latest_publication(
domain=eth_staking_network
)
application_agent = ContractAgency.get_agent( application_agent = ContractAgency.get_agent(
agent_class=TACoApplicationAgent, agent_class=TACoApplicationAgent,
registry=staking_network_registry, registry=registry,
provider_uri=eth_provider_uri, provider_uri=eth_endpoint,
) # type: TACoApplicationAgent ) # type: TACoApplicationAgent
# #
@ -188,7 +179,7 @@ def nucypher_dkg(
# Get GlobalAllowList contract # Get GlobalAllowList contract
blockchain = coordinator_agent.blockchain blockchain = coordinator_agent.blockchain
allow_list = blockchain.get_contract_by_name( allow_list = blockchain.get_contract_by_name(
registry=coordinator_network_registry, contract_name=GLOBAL_ALLOW_LIST registry=registry, contract_name=GLOBAL_ALLOW_LIST
) )
# #
@ -202,7 +193,7 @@ def nucypher_dkg(
emitter.echo("--------- Initiating Ritual ---------", color="yellow") emitter.echo("--------- Initiating Ritual ---------", color="yellow")
emitter.echo( emitter.echo(
f"Commencing DKG Ritual(s) on {coordinator_network} using {account_address}", f"Commencing DKG Ritual(s) on {taco_network.poly_network.chain_name} using {account_address}",
color="green", color="green",
) )
@ -389,11 +380,10 @@ def nucypher_dkg(
# #
emitter.echo("--------- Threshold Decryption ---------") emitter.echo("--------- Threshold Decryption ---------")
bob = Bob( bob = Bob(
eth_provider_uri=eth_provider_uri, domain=network,
domain=eth_staking_network, eth_endpoint=eth_endpoint,
registry=staking_network_registry, polygon_endpoint=polygon_endpoint,
coordinator_network=coordinator_network, registry=registry,
coordinator_provider_uri=coordinator_provider_uri,
) )
bob.start_learning_loop(now=True) bob.start_learning_loop(now=True)