Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Fail with explicit error when creating proxy for missing stdlib #322

Merged
merged 2 commits into from
Jul 26, 2018

Conversation

spalladino
Copy link
Contributor

Creating a proxy for a contract that belongs to an stdlib that was
linked, but that link was not pushed to the network, would yield
a "VM Revert" error. Now it explains that the stdlib is linked but
a push is missing.

Fixes #218

@spalladino spalladino force-pushed the fix/clear-error-with-unpushed-stdlib-link branch from cb5b228 to 7dd24c3 Compare July 17, 2018 19:16
isContractDefined(contractAlias) {
return this.packageFile.hasContract(contractAlias)
}

isContractDeployed(contractAlias) {
return !this.packageFile.hasContract(contractAlias) || this.networkFile.hasContract(contractAlias);
return !this.isLocalContract(contractAlias) || this.networkFile.hasContract(contractAlias);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move all these logic somewhere else, half of the lines of this Controller are related to contract deployment verifications

Copy link
Contributor Author

@spalladino spalladino Jul 23, 2018

Choose a reason for hiding this comment

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

Not sure if I agree. All verifications require access to both package and network files (available at the controller), and are invoked by scripts which typically interact with the network controller directly. Furthermore, logic is different between app and lib, which matches nicely with the hierarchy of base/app/lib controllers.

I can give it a shot by moving this to a ContractChecker or DeploymentVerifier, but I doubt it will make the design more clear, as the Controller will need to pass-through most calls to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I was sth like that... I'm ok having the controllers talking with other objects. I see a controller as an object that knows all the objects that have to be called in order to perform an action, right now ours are a mix between that and performing the requested action by themselves. I'm ok with moving this to an issue and discuss it later if you want :)

@@ -111,48 +111,57 @@ export default class NetworkBaseController {
}

checkLocalContractsDeployed(throwIfFail = false) {
let msg;
this._handleErrorMessage(this._errorForLocalContractsDeployed(), throwIfFail);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO checking and handling are kind of disruptive here, it is kind of weird to call a handler as a first step. I would have expected a condition at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, changed it

Copy link
Contributor

@facuspagnuolo facuspagnuolo 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, however, I'd try to move some logic outside the controller

@spalladino spalladino force-pushed the fix/clear-error-with-unpushed-stdlib-link branch from 7dd24c3 to 7f51b2a Compare July 23, 2018 14:58
@spalladino
Copy link
Contributor Author

@facuspagnuolo implemented one of the changes, though I'm not sure about the other. I can give it a shot, but I'm not sure it's worthwhile atm. WDYT?

Copy link
Contributor

@facuspagnuolo facuspagnuolo left a comment

Choose a reason for hiding this comment

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

Left a small comment but let's merge it as is if you prefer, we can create an issue to discuss it later. There is a small conflict that should be fixed before merging tho

changelog.md Outdated
=======
- Fail with an explicit error when attempting to create a proxy for an stdlib that was linked but not pushed to the network ([#322](https://github.com/zeppelinos/zos-cli/pull/322))

>>>>>>> Fail with explicit error when creating proxy for missing stdlib
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you had already fixed it, a rebase from master should be enough

isContractDefined(contractAlias) {
return this.packageFile.hasContract(contractAlias)
}

isContractDeployed(contractAlias) {
return !this.packageFile.hasContract(contractAlias) || this.networkFile.hasContract(contractAlias);
return !this.isLocalContract(contractAlias) || this.networkFile.hasContract(contractAlias);
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I was sth like that... I'm ok having the controllers talking with other objects. I see a controller as an object that knows all the objects that have to be called in order to perform an action, right now ours are a mix between that and performing the requested action by themselves. I'm ok with moving this to an issue and discuss it later if you want :)

Creating a proxy for a contract that belongs to an stdlib that was
linked, but that link was not pushed to the network, would yield
a "VM Revert" error. Now it explains that the stdlib is linked but
a push is missing.
@spalladino spalladino force-pushed the fix/clear-error-with-unpushed-stdlib-link branch from 7f51b2a to 9bff8a0 Compare July 26, 2018 14:59
@spalladino spalladino merged commit 0a6006a into master Jul 26, 2018
@spalladino spalladino deleted the fix/clear-error-with-unpushed-stdlib-link branch July 26, 2018 16:17
bakaoh pushed a commit to bakaoh/zos-cli that referenced this pull request Jul 31, 2018
…elinos#322)

* Fail with explicit error when creating proxy for missing stdlib

Creating a proxy for a contract that belongs to an stdlib that was
linked, but that link was not pushed to the network, would yield
a "VM Revert" error. Now it explains that the stdlib is linked but
a push is missing.

* Improve error handling in check methods of network base controller
spalladino added a commit to OpenZeppelin/openzeppelin-sdk that referenced this pull request Aug 1, 2018
…elinos/zos-cli#322)

* Fail with explicit error when creating proxy for missing stdlib

Creating a proxy for a contract that belongs to an stdlib that was
linked, but that link was not pushed to the network, would yield
a "VM Revert" error. Now it explains that the stdlib is linked but
a push is missing.

* Improve error handling in check methods of network base controller
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants