Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating deployment process for better external use of the project #489

Merged
merged 7 commits into from
Jan 22, 2020

Conversation

josojo
Copy link
Contributor

@josojo josojo commented Jan 21, 2020

This PR modifies the way artifacts are handled in the migration process. This enables the batch exchange deployment from external projects, without publishing the contracts in the npm package.

closes: #449

An example of how this repo can be used for an external project can be found here:
https://github.com/gnosis/dex-contracts-integration-example


testplan:
Run the commands from the readme on
https://github.com/gnosis/dex-contracts-integration-example

@josojo josojo marked this pull request as ready for review January 21, 2020 22:39
Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

Smallish comments.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/dex-contracts",
"version": "0.1.3",
"version": "0.1.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the version bump be its own commit?

Copy link
Contributor

@nlordell nlordell Jan 22, 2020

Choose a reason for hiding this comment

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

I also notice that 0.1.4 tag was pushed and auto-deployed to NPM. I think we should include a check deploy will fail if the tag is not on master.

Should I yank the version from NPM?

Copy link
Contributor Author

@josojo josojo Jan 22, 2020

Choose a reason for hiding this comment

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

How would I test the deployment scripts for
https://github.com/gnosis/dex-contracts-integration-example, I need the package in there... Having it published only locally makes it testable for me, but not for the others.

Should I do a manual 0.1.4-dev npm release?

src/migration/utilities.js Outdated Show resolved Hide resolved
src/migration/utilities.js Outdated Show resolved Hide resolved
src/migration/utilities.js Outdated Show resolved Hide resolved
src/migration/utilities.js Outdated Show resolved Hide resolved
Copy link
Contributor

@nlordell nlordell left a comment

Choose a reason for hiding this comment

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

I like the changes, but I wonder if we have to fix our dependencies to make this work. We might have to include the solidity libraries as dependencies as well as truffle contract.

@@ -1,14 +1,32 @@
function getDependency(artifacts, network, deployer, path) {
function initializeContract(path, deployer, accounts) {
const contract = require("truffle-contract")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we might need to add truffle-contract to the dependencies or peerDependencies? That might be a "heavy" dependency that we were trying to avoid. @anxolin what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I tried to avoid it and put it all just in the npm package.json of
https://github.com/gnosis/dex-contracts-integration-example
While this is not "very clean", it keeps the size down of dex-contracts npm package.

For which applications is the small size important?

Copy link
Contributor

@anxolin anxolin Jan 22, 2020

Choose a reason for hiding this comment

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

Yes, agree with Nick.

@josojo , super nice that you are doing an example on how to deploy the contracts from another project.

I expect that many projects won't even do this, and they will just use an interface or the original contract and use the rinkeby/mainnet deployments. Sometimes that approach is more straightforward.

Alex, for https://github.com/gnosis/dex-contracts-integration-example I think it would be better if you define the steps in the README to add it to any project.

npm install dex-contracts
npm install <dependencies like truffle>
...

This way is more explicit what we depend on.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree.
For every other project, owl-token, solidity-datastructures, etc, we always create the npm modules, such that later on others can easily build on them.
And we benefit from that a lot. For example, imagine the OWL contracts, all libraries, and all the other things are would be in this dex-contracts project. Then it would be harder to navigate for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I expect that many projects won't even do this, and they will just use an interface or the original contract and use the rinkeby/mainnet deployments. Sometimes that approach is more straightforward.

If you wanna write any meaningful tests, then you need to have the deployment scripts etc...

Copy link
Contributor

@anxolin anxolin Jan 22, 2020

Choose a reason for hiding this comment

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

I've got a bit lost.

My understanding is that we want to decide if we add the dependencies: For example truffle-contracts in our dependencies.

I would say to not do this, even as peerDependencies. A simplistic integration might be interested ONLY in the networks.json and the ABI, so we don't want to bring all the dependencies.

This is why, I thought of adding additional manual npm install. An alternative would be to create another npm-package or using yarn workspaces to create a package that depends on dex-contracts and all the other stuff

Copy link
Contributor

@anxolin anxolin Jan 22, 2020

Choose a reason for hiding this comment

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

If you wanna write any meaningful tests, then you need to have the deployment scripts etc..

I agree, for some people.
Other people can be happy with dex-contracts tests already (nice job), so in their project, they just mock dFusion contracts, and test their own and the interactions with the mocked dFusion contracts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, @anxolin :) then we are on the same page. Sorry, I was also a little bit confused. But actually we were in favor of the same thing!

I will not list all the dependencies in a readme in https://github.com/gnosis/dex-contracts-integration-example, they just go into the package.json of the dex-contracts-integration-example.

src/migration/utilities.js Outdated Show resolved Hide resolved
Copy link
Contributor

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I wouldn't mind seeing some comments in the scripts describing what is happening in some places.

@bh2smith
Copy link
Contributor

I have tried to run the test plan on the example repo as follows;

  • Clone the integration repo
  • run the commands from the readme

And have run into several problems:

missing truffle dependency, no mention of need for ganache in readme, some other missing dependencies required by truffle-config (i.e. dotenv). I am have reported a few issues in the new repo and still working towards making this work. Will report back with, hopefully, some answers soon.

Copy link
Contributor

@fedgiac fedgiac left a comment

Choose a reason for hiding this comment

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

I can't compile dex-contracts-integration-example, otherwise it looks good.

@josojo josojo merged commit 647875d into master Jan 22, 2020
@josojo josojo deleted the newMigrationLogic branch January 22, 2020 14:29
@@ -1,6 +1,6 @@
{
"name": "@gnosis.pm/dex-contracts",
"version": "0.1.3",
"version": "0.1.5-dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

It's pretty annoying having to publish versions to test this PR that are then public for the rest of time. Can we not use something like https://stackoverflow.com/questions/15806241/how-to-specify-local-modules-as-npm-package-dependencies to test this locally without publicly pushing new versions?

Can we please revert and delete those releases?

josojo pushed a commit that referenced this pull request Jan 22, 2020
#489 introduced that change

Version bumps should always happen in their own PR (and once that PR is merged to master, it should be tagged with the version). Moreover this skipped v0.1.4 and was likely just merged to master by accident.
josojo added a commit that referenced this pull request Jan 22, 2020
In the last PR: #489
a bug was introduced as the for nonDevelopment networks, also the BatchExchange as a dependency would be tried to be pulled, although we have to get it from the usual build artifacts.
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.

Create README on how external projects should depend/migrate on dex-contracts
6 participants