Skip to content

Improve nucypher-deploy allocations#1319

Merged
KPrasch merged 11 commits intonucypher:biznagafrom
cygnusv:allocations
Sep 17, 2019
Merged

Improve nucypher-deploy allocations#1319
KPrasch merged 11 commits intonucypher:biznagafrom
cygnusv:allocations

Conversation

@cygnusv
Copy link
Member

@cygnusv cygnusv commented Sep 12, 2019

Provides a minimal UX for nucypher-deploy allocations. Here's an example of the allocation process.

Steps to reproduce:

# 1. Inspect published registry
nucypher-deploy --provider /path/to/geth.ipc --poa inspect

# 2. Deploy UserEscrowProxy
(Download registry manually first and use it as input next)
nucypher-deploy --provider /path/to/geth.ipc --poa contracts --deployer-address 0xfoobar --contract-name UserEscrowProxy --registry-infile contract_registry.json

# 3. Inspect new registry
nucypher-deploy --provider /path/to/geth.ipc --poa inspect --registry-infile contract_registry.json

# 4. Deploy allocations
nucypher-deploy --provider /path/to/geth.ipc --poa allocations --allocation-infile allocations.json --registry-infile contract_registry.json

Steps 1 and 2 are needed only because our current testnet doesn't have a UserEscrowProxy.
You can skip these by using this registry, and go directly to steps 3 and 4, to try allocations. Here's an example of allocation file.

@codecov
Copy link

codecov bot commented Sep 13, 2019

Codecov Report

Merging #1319 into biznaga will decrease coverage by 2.12%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           biznaga    #1319      +/-   ##
===========================================
- Coverage    82.48%   80.36%   -2.13%     
===========================================
  Files           72       72              
  Lines        10268    10343      +75     
===========================================
- Hits          8470     8312     -158     
- Misses        1798     2031     +233
Impacted Files Coverage Δ
nucypher/characters/control/emitters.py 87.69% <ø> (ø) ⬆️
nucypher/cli/characters/stake.py 81.36% <ø> (ø) ⬆️
nucypher/blockchain/eth/deployers.py 92.3% <100%> (-0.15%) ⬇️
nucypher/cli/deploy.py 72.95% <66.66%> (-1.72%) ⬇️
nucypher/blockchain/eth/actors.py 84.66% <83.63%> (-0.49%) ⬇️
nucypher/blockchain/eth/registry.py 71.64% <87.5%> (-4.59%) ⬇️
nucypher/cli/painting.py 79.15% <88.46%> (+0.86%) ⬆️
nucypher/keystore/keystore.py 59.03% <0%> (-37.35%) ⬇️
nucypher/crypto/utils.py 68.51% <0%> (-24.08%) ⬇️
nucypher/config/base.py 85.39% <0%> (-13.49%) ⬇️
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5546055...f4214cd. Read the comment docs.

allocation_data = self.read()
except self.RegistryError:
self.log.info("Blank allocation registry encountered: enrolling {}:{}".format(beneficiary_address, contract_address))
self.log.info(f"Blank allocation registry encountered: enrolling {beneficiary_address}:{contract_address}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.log.info(f"Blank allocation registry encountered: enrolling {beneficiary_address}:{contract_address}")
self.log.info(f"Blank allocation registry encountered when enrolling {beneficiary_address}:{contract_address}")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ does RegistryError only occur if blank - is it possible there is something but the format is incorrect?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's possible since were catching a base class that another condition has occurred. Needs an eye for review - The addition of class BlankRegistry(RegistryError) will help to alleviate this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the code suggestion, not sure how to proceed here.
@KPrasch are you suggesting to add class BlankRegistry(RegistryError) now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My take would be to update the message to be more general. Blank allocation doesn't seem to be the only condition for the Error. If you want to differentiate between Blank registry and some other error scenario, then you can do the subclass thing.

Copy link
Contributor

@tuxxy tuxxy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment on classmethod vs staticmethod.


if failed:
# TODO: More with these failures: send to isolated logfile, and reattempt
self.log.critical(f"FAILED TOKEN ALLOCATION - {len(failed)} Allocations failed.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's write the failed entries to a separate JSON file for easier re-attempt.


if action == "contracts":
if contract_name and registry_infile is None: # There's a current deployment and you want to deploy a new contract on it.
message = "--registry-infile is required when deploying a contract to an existing registry."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a command to download the latest registry to disk will help prevent accidents.

name = allocation.get('name', 'No name provided')
emitter.echo(f"{beneficiary} | {name:20} | {contract_address}")
for allocation in failed:
beneficiary = allocation['beneficiary_address']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we get test coverage in this area , 🤔 ? We need a way to mock a transaction failed part of the way through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants