Skip to content

"Resume" and single-contract deployments via CLI.#1131

Merged
KPrasch merged 3 commits intonucypher:sekanjabinfrom
KPrasch:resume
Jul 25, 2019
Merged

"Resume" and single-contract deployments via CLI.#1131
KPrasch merged 3 commits intonucypher:sekanjabinfrom
KPrasch:resume

Conversation

@KPrasch
Copy link
Member

@KPrasch KPrasch commented Jul 23, 2019

Based on #1130

Uses Agency and Deployer methods to deploy a single contract by it's registry name form the CLI. This may act as a good secondary means of managing failed deployments as part of an automated series.

@KPrasch KPrasch requested review from derekpierre, jMyles, michwill, tuxxy and vepkenez and removed request for tuxxy July 23, 2019 20:35
@KPrasch KPrasch marked this pull request as ready for review July 23, 2019 20:35
@KPrasch KPrasch changed the title [WIP] "Resume" and single-contract deployments via CLI. "Resume" and single-contract deployments via CLI. Jul 23, 2019
@KPrasch KPrasch added CLI This effects the nucypher CLI Enhancement New or improved features labels Jul 23, 2019

@staticmethod
def __collect_deployment_secret(deployer) -> str:
def collect_deployment_secret(deployer) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

No more privacy?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I needed to use this function outside of the" automated series of deployments" (deploy_network_contracts) method below this one in the CLI when deploying an individual upgradeable contract, and collecting it's secret.

duration = (last_update - start_time).seconds
if duration > t:
raise self.SyncTimeout
return True # Just continue on. # TODO: does this make sense?
Copy link
Contributor

Choose a reason for hiding this comment

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

Eh? I don't understand why.
Neither do I understand sleep(0) below

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay - I restored the exception here.

Copy link
Member Author

Choose a reason for hiding this comment

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

With regard to time.sleep(0) - Take a look at this stack overflow: https://stackoverflow.com/questions/7273474/behavior-of-pythons-time-sleep0-under-linux-does-it-cause-a-context-switch.

A comment may be helpful here.

if not scheme:
scheme = self.IPC_PROTOCOL
if scheme == 'file':
if scheme in ('file', 'ipc'):
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

secret = deployer.collect_deployment_secret(deployer=contract_deployer)
receipts, agent = deployer.deploy_contract(contract_name=contract_name, plaintext_secret=secret)
else:
receipts, agent = deployer.deploy_contract(contract_name=contract_name, gas_limit=gas)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

… TImeout. Mock ChainId RPC Endpoint in some client integration tests.
@codecov
Copy link

codecov bot commented Jul 24, 2019

Codecov Report

Merging #1131 into sekanjabin will decrease coverage by 0.01%.
The diff coverage is 60%.

Impacted file tree graph

@@              Coverage Diff              @@
##           sekanjabin   #1131      +/-   ##
=============================================
- Coverage       83.62%   83.6%   -0.02%     
=============================================
  Files              72      72              
  Lines            9642    9643       +1     
=============================================
- Hits             8063    8062       -1     
- Misses           1579    1581       +2
Impacted Files Coverage Δ
nucypher/blockchain/eth/actors.py 84.27% <100%> (ø) ⬆️
nucypher/blockchain/eth/interfaces.py 80.44% <100%> (+0.07%) ⬆️
nucypher/crypto/powers.py 94.96% <100%> (+0.49%) ⬆️
nucypher/cli/stake.py 80.31% <100%> (+0.15%) ⬆️
nucypher/cli/deploy.py 70.21% <18.75%> (-0.3%) ⬇️
nucypher/blockchain/eth/clients.py 57.77% <85.71%> (+0.77%) ⬆️
nucypher/network/nodes.py 81.69% <0%> (-0.62%) ⬇️

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 54a5684...15461d7. Read the comment docs.

@michwill
Copy link
Contributor

🤠

Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

Looking good!
Just some minor comments:

  1. When deploying contracts individually, it's not printing the registry path at the end.
  2. The gas limit is ignored sometimes: for instance, when deploying all contracts (i.e., no contract name is given), or when a deploying a named contract but it's upgradeable. See my comments above.
    3)Something perhaps not specific to this PR but that I've just realized:nucypher stake set-worker asks you to select the stake, but in reality the stake itself is irrelevant here, just the staker. So it may be the case that you have 5 stakes with the same staker, and once you set a worker, all 5 stakes will show the same worker (which is the correct behavior, btw). Question: Is is possible that nucypher stake list shows stakes for different stakers? I guess that was the point of Stakeholder, but I don't know how to try it.

click.secho(f"Deploying {contract_name}")
if contract_deployer._upgradeable:
secret = deployer.collect_deployment_secret(deployer=contract_deployer)
receipts, agent = deployer.deploy_contract(contract_name=contract_name, plaintext_secret=secret)
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
receipts, agent = deployer.deploy_contract(contract_name=contract_name, plaintext_secret=secret)
receipts, agent = deployer.deploy_contract(contract_name=contract_name, plaintext_secret=secret, gas_limit=gas)

It also needs to be passed to deployer.deploy_network_contracts(secrets=secrets) in line 243:
https://github.com/nucypher/nucypher/pull/1131/files#diff-4809c009687ec0119c014880f31f9111R243

# Support older and newer versions of web3 py in-test
version = 5
chainID = 5
chainId = hex(5)
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity: why hex here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just following what geth nodes return as a type on this endpoint for mocking

@KPrasch
Copy link
Member Author

KPrasch commented Jul 25, 2019

When deploying contracts individually, it's not printing the registry path at the end.
✔️

The gas limit is ignored sometimes: for instance, when deploying all contracts (i.e., no contract name is given), or when a deploying a named contract but it's upgradeable. See my comments above.

Yeah, I am aware of this, I think gas management is generally outside the scope of this PR. If you prefer a higher degree of precision here I can remove these lines for now. (#842 )

Is is possible that nucypher stake list shows stakes for different stakers? I guess that was the point of Stakeholder, but I don't know how to try it.

Yes - you can run nucypher stake accounts or nucypher stake list; However, there is not presently an interactive "staker" selection menu. This is a God suggestion perhaps for an Issue. (#1143)

@KPrasch KPrasch merged commit 5a4d320 into nucypher:sekanjabin Jul 25, 2019
@KPrasch KPrasch deleted the resume branch March 22, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI This effects the nucypher CLI Enhancement New or improved features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants