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

Support solidity 0.6 in Initializable contract #1413

Merged
merged 3 commits into from
Jan 31, 2020

Conversation

spalladino
Copy link
Contributor

@spalladino spalladino commented Jan 28, 2020

Modifies Initializable so it is compatible with Solidity 0.5 and 0.6. Adds a set of tests that run on the 0.6 version to verify its behaviour (note that the 0.6 compiled contracts are committed into source control to simplify the setup).

I suggest reviewing commits separately. The 2nd is somewhat unrelated to this PR, but required for the tests to pass (it was either that, or manually killing the CircleCI cache).

Modifies Initializable so it is compatible with Solidity 0.5 and 0.6. Adds a set of tests that run on the 0.6 version to verify its behaviour (note that the 0.6 compiled contracts are committed into source control to simplify the setup).
@spalladino spalladino force-pushed the feature/initializable-solidity-06 branch from d1a44d2 to 65993b0 Compare January 28, 2020 22:15
Both mock-solc and mock-dependency where being copied instead of symlinked into packages/lib by yarn. Even worse, they were not re-copied if they were modified, requiring to rm-rf them, or update the cache in the CI.

By defining mock-solc and mock-dependency as workspaces, yarn will symlink them from where they are requested, instead of copying them. This required moving them outside the packages/lib workspace, as yarn does not support nested workspaces.
Copy link
Contributor

@ylv-io ylv-io left a comment

Choose a reason for hiding this comment

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

I love how you used the same code to test both 0.5 and 0.6 version of the same contract. I have a few questions but they are probably me missing something. Except that all seems good!

I can't compile mock-solc-0.6 with oz compile because of an error Could not find file /Users/iYalovoy/repo/sdk-review/tests/mocks/mock-solc-0.6/contracts/initializable/Initializable.sol in the project (imported from contracts). It seems symlink Initializable.sol is broken. Does it works for you?

I also couldn't compile it with Remix they have issue at that moment with solc 0.6 so no playing with code for me.

Comment on lines 74 to 79
function initialize(uint256 _mother, uint256 _gramps, uint256 _father, uint256 _child) initializer public {
SampleMother.initialize(_mother);
SampleFather.initialize(_gramps, _father);
child = _child;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, couldn't run the code so my question is why this doesn't cause to a duplicated call at SampleHuman. initialize? Since both SampleMother and SampleFather are children of SampleHuman.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it does, and it's one of the things tested here (note that this test existed from before, I just moved it and migrated it to 0.6). There was a bug in Initializable that caused it to fail in these scenarios with an already initialized error. This test checks that it's ok to call a base initializer more than once during the initialization process, to accommodate for structures like this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Didn't know that our current approach is that your init method might be called twice. This is certainly tricky and not many devs would expect that. I like the direction we are moving with Transpiler.

@spalladino
Copy link
Contributor Author

spalladino commented Jan 30, 2020

It seems symlink Initializable.sol is broken. Does it works for you?

Hmm it works for me, and also works on the CI. Do you know if OSX handles symlinks differently? Or could this be related to this git setting?

@ylv-io
Copy link
Contributor

ylv-io commented Jan 31, 2020

OSX should handle them fine but if it works on CI and your machine it is fine. I've got all the answer I wanted. Thanks!

@ylv-io ylv-io self-requested a review January 31, 2020 03:53
Copy link
Contributor

@ylv-io ylv-io left a comment

Choose a reason for hiding this comment

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

This is a proper PR 🚢

@ylv-io ylv-io added the status:ready-to-merge Order mergify to merge label Jan 31, 2020
@ylv-io ylv-io merged commit c65e72c into release/2.7 Jan 31, 2020
@mergify mergify bot deleted the feature/initializable-solidity-06 branch January 31, 2020 07:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:ready-to-merge Order mergify to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants