Skip to content

Conversation

@jakub-wojciechowski
Copy link
Contributor

@jakub-wojciechowski jakub-wojciechowski commented Sep 6, 2017

This PR is connected to Decouple Crowdsale from MintableToken #351 issue.
Fixes #351

It is intended to drive discussion about using composition pattern in OpenZeppelin contract. The proposed changes aren't final and need updated and more testing before are ready to be merged to production code. Tests currently produce output that shows amount of gas consumed by different approaches:

*** COMPOSITION FIXED RATE: 98094 gas used.
*** INHERITANCE: 97461 gas used. 

It's still to decide whether we want to use an approach based on composition?

Should we decide to favour either composition or inheritance or should we maintain two separate versions to allow beginners to use simpler approach based on inheritance and offer more advanced users a better customisation via composition?

I'll be very grateful for all of the feedback from you guys.

@SylTi
Copy link
Contributor

SylTi commented Sep 6, 2017

also linked with #317

to use simpler approach based on composition and offer more advanced user better customisation via composition?

I think you didn't mean to say twice composition :)

Composition seems a good fit in my opinion.

@jakub-wojciechowski
Copy link
Contributor Author

Thx @SylTi for catching that, I've updated the description.

@SylTi
Copy link
Contributor

SylTi commented Sep 6, 2017

Also concerning this:

Should we decide to favour either composition or inheritance or should we maintain two separate versions to allow beginners to use simpler approach based on inheritance and offer more advanced users a better customisation via composition?

A single version is a better in my opinion: easier to maintain & less error prone
Maybe providing examples for both strategies or bases class from which they can inherit is a better solution?

@androolloyd
Copy link

I really like the approach this is taking. Kudos!

@SylTi
Copy link
Contributor

SylTi commented Sep 20, 2017

It would be nice to merge this before the next release! 🥇
If you need help with something .. just say the words :)

@SylTi
Copy link
Contributor

SylTi commented Oct 15, 2017

@frangio what need's to be done to merge this in the next release? This will greatly improve the flexibility of the current Crowdsales contract in my opinion.

@spalladino
Copy link
Contributor

I think we are all in the same page regarding the benefits of composition over inheritance (both here and in smart contracts in general). Besides, another strong argument for composition that was brought up is that it better fits the on-chain-libraries model that we will be following in the near future with zeppelin_os. As such, it seems a good start to begin imposing that pattern here in OZ.

@jakub-wojciechowski what would be missing for this to move out of WIP? After a quick look I'd say that the largest missing feature is a PricingStrategy to go along with the DistributionStrategy. Is there anything else on your mind?

@spalladino
Copy link
Contributor

Something else I'd like to discuss is how to manage the shift from the current Crowdsale to this one. Today, most crowdsale contracts in the wild inherit from Crowdsale, and would be broken by shifting to a CompositeCrowdsale. My suggestion would be:

  1. Merge CompositeCrowdsale as soon as it's finished, and mark Crowdsale as deprecated in the next release
  2. Remove Crowdsale and rename CompositeCrowdsale to Crowdsale in OZ 2.0

@frangio @maraoz WDYT?

@spalladino
Copy link
Contributor

Also, we should try out implementing known Crowdsale patterns to see how they fit with this composable model: with global cap, with per-user caps, with phases, with whitelists, with different pricing, etc.

import '../math/SafeMath.sol';

/**
* @title FixedRateTokenDistributionStrategy
Copy link
Contributor

Choose a reason for hiding this comment

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

not the good title

@SylTi
Copy link
Contributor

SylTi commented Nov 15, 2017

Also, we should try out implementing known Crowdsale patterns to see how they fit with this composable model: with global cap, with per-user caps, with phases, with whitelists, with different pricing, etc.

@spalladino This shouldn't be hard if we add a PricingStrategy like you mentioned before (in combination with DistributionStrategy)
Maybe we can start implementing some of them once this is merged into master?

@spalladino
Copy link
Contributor

Following @SylTi 's suggestion in the OpenZeppelin Slack, I've pulled Kuba's branch as feature/composite-crowdsale in this repo, so we can start testing implementing crowdsale models there. Once we are satisfied with the result, we can merge that into master. I'm leaving this PR open to keep the general discussion here.

function getToken() constant returns(ERC20) {
return token;
}
}
Copy link
Contributor

@SylTi SylTi Nov 27, 2017

Choose a reason for hiding this comment

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

We probably will need to dissociate ownership from minting right as we talked about in slack.
We can't ever finish the minting with the current version.

@spalladino
Copy link
Contributor

spalladino commented Apr 10, 2018

@shakkaist, @jakub-wojciechowski thanks for your contributions! After playing around with many flavors of the models involving inheritance and composition, we reached the solution in #739, published in v1.7.0.

@spalladino spalladino closed this Apr 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants