Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Fix status checker, comparator and fetcher #99

Closed
wants to merge 13 commits into from

Conversation

jbcarpanelli
Copy link
Contributor

@jbcarpanelli jbcarpanelli commented Sep 18, 2018

  • Adapt StatusChecker, StatusComparator and StatusFetcher classes to work with the new contracts architecture and lib models implemented by @spalladino to support multiple dependencies.
  • Implement multiple dependencies checker, fetcher and comparator functions.

  - Fixed status pull for lib projects
  - Fixed status comparator for app projects
Implemented dependencies methods in StatusChecker, StatusComparator and
StatusFetcher to verify local and on chain dependencies status
Refatored proxy functions in StatusChecker and StatusFetcher to make
them clearer
Tested dependencies behavior in both StatusFetcher and StatusComparator
models
Copy link
Contributor

@spalladino spalladino left a comment

Choose a reason for hiding this comment

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

Hell of a PR! Awesome work @jcarpanelli. I spotted only two issues to fix, after which I think we should be good to merge.

@@ -63,34 +69,33 @@ export default class StatusChecker {
}

async checkVersion() {
const observed = (await this.app()).version
const observed = this._project.version
const expected = this.networkFile.version
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this test is working properly: the project's version is set in the constructor, which is set here in L36 with the value of networkFile.version, so it will never fail. The observed value should actually be taken by querying project.getDependencyVersion(networkFile.name).

Copy link
Contributor Author

@jbcarpanelli jbcarpanelli Sep 21, 2018

Choose a reason for hiding this comment

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

You are right, L72 won't work for lib projects, but as far as I understand, we are not validating the version (and we were not validating it in the old model 🤔) for lib projects. That being said, we should totally check it! But I would prefer to do it in a future PR as it would be a "new feature".

this.data.proxies[fullname][index] = fn(this.data.proxies[fullname][index]);
}

proxyFromIndex(thepackage, alias, index) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Though we are not enforcing it everywhere, we're often using leading underscore to denote private functions in classes. Could you add them for these new helper methods, so proxyFromIndex becomes _proxyFromIndex and so forth? This way it's clearer which functions are part of the public interface, and which aren't.

const expected = this.networkFile.contract(alias).bodyBytecodeHash
const observed = bytecodeDigest(web3.eth.getCode(address))
const observed = bytecodeDigest(await promisify(web3.eth.getCode.bind(web3.eth))(address))
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch :-)

package: event.args.package
}));

return _.uniqWith(filteredEvents, _.isEqual)
Copy link
Contributor

Choose a reason for hiding this comment

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

This may return repeated packages. For instance, if an app registers under the name "OZ", a package at 0x20 with version "1.0", and later registers under the same name a package at 0x20 with version "2.0", this method returns two different events. Since the "truth" is only the latest event (ie the one with version "2.0"), this would always yield a mismatch between the current version in the network.json file (which should correctly read "2.0"), and the old event (with version "1.0").

Instead of using uniqWith isEqual, we should use a comparator that checks only name, and ensures that the element with the highest index in the array (ie more recent) is kept. Using a reduce that builds a map indexed by name, and then returns the values on the map, should do the trick.

})

testVersion();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have a linter that removes semicolons, or it's just OCD? :-P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just OCD 😂

@facuspagnuolo facuspagnuolo added topic:eth-packages Dependencies & Ethereum Packages and removed topic:stdlibs labels Sep 20, 2018
@facuspagnuolo
Copy link
Contributor

@jcarpanelli there are some files conflicting, would you mind fixing those?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic:eth-packages Dependencies & Ethereum Packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants