-
Notifications
You must be signed in to change notification settings - Fork 200
Conversation
@spalladino I think we should add a warning message in case we indentify that an enum or a struct is being used, at least until #113 and #114 are solved. Do you agree? |
I'm afraid it could be a bit annoying, since any warnings halt the |
@spalladino yes, I meant to do it that way, I think that simply printing a message to let the user know we are not performing full validations on structs and enums is ok for now, otherwise it could be a false positive |
@facuspagnuolo added the following warning:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left some minor comments
const newVersion = this._newVersionRequired() | ||
return _(this.packageFile.contracts) | ||
.toPairs() | ||
.filter(([contractAlias, _contractName]) => newVersion || !onlyChanged || this.hasContractChanged(contractAlias)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would mean that contracts of different versions are going to be always pushed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at least until we implement zeppelinos/zos-cli#94
import { getBuildArtifacts } from "../utils/BuildArtifacts"; | ||
|
||
export function getStorageLayout(contract, artifacts) { | ||
if (!artifacts) artifacts = getBuildArtifacts(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this works for every scenario where this function is called, I'll remove the artifacts
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I'd rather keep it for simplicity of use. I wouldn't rule out extracting these methods for external usage, so I'd prefer the API to be as easy to use as possible.
@@ -50,6 +54,11 @@ export default { | |||
return this._getFromPath(this.getNodeModulesPath(dependency, contractName)) | |||
}, | |||
|
|||
listBuildArtifacts() { | |||
const buildDir = this.getLocalBuildDir() | |||
return glob.sync(`${buildDir}/*.json`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs
cannot solve this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at the moment. I could move it to fs later, though.
@spalladino I think there are some integration tests failing, would you mind looking at them? |
It was the StatusFetcher/StatusComparator, due to the PR we merged recently that re-enabled them. I'll look into this later, but I really want to get this PR merged! |
5910f7b
to
d2abe8b
Compare
This is a new iteration of #92, which github is not allowing me to reopen.
When running zos-push, validate that the storage layout is compatible with the previous version of the contract, and abort push otherwise. All warnings are displayed to the user, eg:
Storage layout is extracted from the contract's AST by the Storage class in lib, and is stored along with other contract data (such as bytecode hash) in the zos.network.json file. It is then retrieved for comparison on the next zos push. The format is a tuple
(storage, types)
, similar to the format discussed in ethereum/solidity#4017, wherestorage
contains the array of variables, with references to thetypes
dictionary with detailed info on each type.Comparison is handled by the Layout class in lib, and uses a modified levenshtein algorithm for calculating the minimum change between both storages. Changes are identified as additions (either at the end or mid-contract, with additions at the end computed at zero cost for the algorithm), deletions (end or mid-contract), or substitutions (renames, typechanges, or both).
Fixes #37
Spawns issues #112, #113, and #114
TBD: Should we add a feature toggle to disable it until the 3 issues above are ready?