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

Revamp Initializable and remove Migratable #12

Merged
merged 14 commits into from
Aug 24, 2018

Conversation

frangio
Copy link
Contributor

@frangio frangio commented Aug 9, 2018

Fixes #2.

Enhances Initializable to make it usable with multiple inheritance, with the purpose of removing Migratable (which was our current solution) because it leads to a confusing developer experience.

Marking in progress because I should update the docs to reflect the new usage, but the code and tests can already be reviewed.

  • Fix contracts
  • Fix rest of test suite
  • Document changes

@frangio frangio added kind:enhancement Enhancement to an existing feature topic:dx Issue that affects developer experience status:in-progress Under development, do not merge this PR topic:contracts Smart contracts in SDK labels Aug 9, 2018
@frangio frangio requested a review from spalladino August 9, 2018 21:55
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.

Looks good! Can you move the PR to next instead of master, though?

});
});

describe('complex testing with inheritance', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add another suite where mother inherits from gramps as well, so we test a diamond-like inheritance graph?

@frangio frangio changed the base branch from master to next August 10, 2018 16:36
@frangio
Copy link
Contributor Author

frangio commented Aug 12, 2018

Rebased on next.

@frangio
Copy link
Contributor Author

frangio commented Aug 12, 2018

@spalladino I changed the tested contracts into a diamond shaped inheritance as you suggested (kind of, as I didn't add a new suite, heh). I'm not sure how I feel about it though, because as we talked offline it will run the initializer twice, and although in this scenario the result ends up being correct, it might not always be the case. I suppose the warning on the Initializable contract coupled with the documentation will make it clear to be on the lookout for those problems...

spalladino
spalladino previously approved these changes Aug 13, 2018
@frangio
Copy link
Contributor Author

frangio commented Aug 15, 2018

@spalladino There's something we didn't think through: if we're removing Migratable, what should we do about upgradeAndCall? I apparently broke the tests for upgradeAndCall because they were using a Migratable contract as the mock implementation. This makes sense because the function you call via upgradeAndCall needs some mechanism to prevent it running more than once, and Migratable was that mechanism.

For the record, we had agreed on removing Migratable on the basis that the need for migrations really hasn't come up yet and we don't want to design it in advance of knowing the requirements of a real situation.

What do you suggest we do?

@spalladino
Copy link
Contributor

@frangio upgradeAndCall still makes sense, the same way createAndCall makes sense even if we didn't provide any Initializable options. It now becomes the user's responsibility to ensure that a migration method is only called once, since we are not imposing any "best practice" to do so. We can keep the upgradeAndCall tests which call a regular migrate method, that simply relies on a hasBeenMigrated flag managed manually, instead of an isMigration(,,) modifier.

@frangio
Copy link
Contributor Author

frangio commented Aug 17, 2018

@spalladino I think the only error remaining is one in complex-example which I'm not sure how to fix. (To be honest I haven't looked into it yet but it looks kinda hairy.)

Error: Could not find zos-lib/contracts/migrations/Migratable.sol from any sources; imported from openzeppelin-zos/contracts/ownership/Ownable.sol

spalladino
spalladino previously approved these changes Aug 23, 2018
@frangio
Copy link
Contributor Author

frangio commented Aug 23, 2018

I added Migratable back in because due to Truffle's wrong handling of nested dependencies, there was no way to make the openzeppelin-zos package in lib-complex compile.

I removed the bump to 2.0.0-alpha because that wasn't going to fix anything.

One last thing. Currently Initializable is in the contracts/migrations/ directory. We cannot rename the directory because of the same reason we had to keep Migratable, but we could move Initializable somewhere else. @spalladino What do you think?

@spalladino
Copy link
Contributor

spalladino commented Aug 23, 2018 via email

@frangio frangio removed the status:in-progress Under development, do not merge this PR label Aug 23, 2018
@spalladino spalladino added the status:ready-to-merge Order mergify to merge label Aug 24, 2018
@mergify mergify bot merged commit bc8ae3f into OpenZeppelin:next Aug 24, 2018
@frangio frangio deleted the revamp-initializable branch August 24, 2018 17:22
spalladino pushed a commit that referenced this pull request Sep 24, 2018
* update auto-generated package-lock.json

* update Initializable tu support multiple inheritance

* add more complex testing of Initializable with multiple inheritance

* remove Migratable and move Initializable

* change migratable to initializable in test comment

* test diamond shaped inheritance

* rename isInitializer to initializer

* change docs to use new Initializable

* fix tests

* fix more docs

* Revert "remove Migratable and move Initializable"

This reverts commit fa54395.

* finish adding back Migratable

* add deprecation notice to Migratable

* move Initializable to contracts root
spalladino pushed a commit that referenced this pull request Sep 24, 2018
* update auto-generated package-lock.json

* update Initializable tu support multiple inheritance

* add more complex testing of Initializable with multiple inheritance

* remove Migratable and move Initializable

* change migratable to initializable in test comment

* test diamond shaped inheritance

* rename isInitializer to initializer

* change docs to use new Initializable

* fix tests

* fix more docs

* Revert "remove Migratable and move Initializable"

This reverts commit fa54395.

* finish adding back Migratable

* add deprecation notice to Migratable

* move Initializable to contracts root
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind:enhancement Enhancement to an existing feature status:ready-to-merge Order mergify to merge topic:contracts Smart contracts in SDK topic:dx Issue that affects developer experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants