Improve nucypher-deploy allocations#1319
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
3640c61 to
849ad0b
Compare
nucypher/blockchain/eth/registry.py
Outdated
| 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}") |
There was a problem hiding this comment.
| 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}") |
There was a problem hiding this comment.
^ does RegistryError only occur if blank - is it possible there is something but the format is incorrect?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Apart from the code suggestion, not sure how to proceed here.
@KPrasch are you suggesting to add class BlankRegistry(RegistryError) now?
There was a problem hiding this comment.
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.
|
|
||
| if failed: | ||
| # TODO: More with these failures: send to isolated logfile, and reattempt | ||
| self.log.critical(f"FAILED TOKEN ALLOCATION - {len(failed)} Allocations failed.") |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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'] |
There was a problem hiding this comment.
How can we get test coverage in this area , 🤔 ? We need a way to mock a transaction failed part of the way through.
Provides a minimal UX for
nucypher-deploy allocations. Here's an example of the allocation process.Steps to reproduce:
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.