-
Notifications
You must be signed in to change notification settings - Fork 200
Libraries can link to other libraries with public functions #1252
Libraries can link to other libraries with public functions #1252
Conversation
Hey @asselstine, thanks for the contribution! We'll check why the CI is complaining (there is some error with truffle apparently). In the meantime, could we ask you to add a test for this, in order to merge it? Thanks! |
@spalladino I didn't see any tests for the NetworkController so I thought I might get away with no tests ;) I'll make sure to add one. I did notice that I had to add the CI flag when running locally; i.e. |
b380887
to
112014d
Compare
@spalladino tests added! |
Awesome, thanks so much Brendan! Will review during the week :-) |
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.
Awesome work Brendan, thanks a lot! I left a question on the loop detection. I may be wrong, but I think there is a scenario where it may yield false positives. Let me know if you have the availability to review this!
@spalladino I've improved the algorithm and added a test to ensure that it orders dependencies correctly. I think this is the one! |
Hey @asselstine! Thanks for the awesome work 🚢 |
@ylv-io Good idea; it would be a good use of recursion. I've added you as a collaborator to the fork, so feel free to push to this branch. |
@asselstine for some reason it didn't work. I can't push and not on the list of collaborators. |
@ylv-io Github's "invitations" are overly complicated, in my opinion. I've had this problem countless times. Your invite to the fork is still pending, so I'm guessing you need to check the email that is attached to your Github profile. There will be an invite email from the Github repo. Once you click that you'll be able to push to the branch. |
@asselstine That is exactly the case. Indeed, this is a confusing system. |
Come to think of it, cycle detection is needed for this function. It should throw an error if there is a library dependency ordering such as: Lib_1 requires Lib_2 While the above can be compiled, it can't be deployed all at once so OZ SDK should throw an error here. |
Hey @asselstine. I've added suggested changes. Thanks again for your amazing contribution! |
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.
@ylv-io great collaboration! I like the recursion and the tests are tight.
I realize that we are still treating loop as legit DAGs; as per Santiago's original comment. What we need is a topological sort. I'll have a look at integrating one. |
- Altered NetworkController#_getAllSolidityLibNames to recursively retrieve libraries and detect cycles - Altered NetworkController#uploadSolidityLibs to push libraries in order so that dependencies to ensure linking addresses exist - Altered NetworkController#_uploadSolidityLib to link libraries
…for hoisting dependencies
d4f2a47
to
d49cbf9
Compare
@ylv-io Ok. This should be it! It now recursively builds up a graph which is then topologically sorted.
I think we're done. |
@asselstine. It is a pleasure to collaborate with you! |
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.
Great work @asselstine and @ylv-io! Topological sorting indeed seems like the perfect solution for this problem
Co-Authored-By: Nicolás Venturo <[email protected]>
Co-Authored-By: Nicolás Venturo <[email protected]>
Co-Authored-By: Nicolás Venturo <[email protected]>
I've replaced the |
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.
Thank you very much @asselstine and @ylv-io! This looks ready to merge 😁
|
||
contractNames.forEach(contractName => { | ||
const deps = this._getContractDependencies(contractName); | ||
deps.forEach(dependencyContractName => { |
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.
Nice, I hadn't realized this loop was duplicated 👍
The CI test run is done on the branch, not on the result of the merge: it turns out this PR broke tests on the CLI due to #1288. |
Fixed in 7f641a7 |
Great collab @ylv-io! I'm pleased to help and I'm excited to have this in the build. Now I won't have to worry about our library structure. |
@nventuro this is a great example of how CI tests can be successful on a branch but break a master. |
Hey @asselstine, this PR is now part of the 2.7 RC if you want to try it! |
@spalladino Fantastic! |
I needed to deploy a library that linked to another library that had public functions. I made changes to allow the deployment of any dependent libraries.