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

Migrate to Buidler plugin #1131

Merged
merged 37 commits into from
Aug 14, 2020
Merged

Migrate to Buidler plugin #1131

merged 37 commits into from
Aug 14, 2020

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented Apr 14, 2020

Fixes #1111

This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and interacts with real chains. It also has ganache configured to be use as an alternative local development chain (use with --network ganache).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually for now as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

TODO:

Move to address on a future PR:

  • Migrate smart contract lint rules from .solium to .solhint (afterwards we should remove .soliumrc.json)

@0xGabi 0xGabi marked this pull request as ready for review August 10, 2020 21:58
@auto-assign auto-assign bot requested review from bpierre and Evalir August 10, 2020 21:58
Copy link
Contributor Author

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Couple more notes, mainly about using ganache.

The failing tests seem to point to ganache or the truffle integration with buidler being an issue, as the transaction or receipts aren't being handled well (testing with ganache seems to be really slow).

I'm not really sure what's going on, but somehow the coverage plugin is using ganache and:

  1. Is faster than vanilla ganache?
  2. Works correctly 🤷

Since all of these test environments are backed by ethereumjs-vm anyway, I think we'd only be able to hedge implementation risk by running tests against a real geth node anyway.


Finally, with solidity-coverage 0.7.x, I think we should be able to remove a bunch of options and/or use the new skip syntax. See upgrade nodes (note that some of these won't apply anymore because we can use the buidler plugin, which does a lot of this automatically).

apps/agent/package.json Show resolved Hide resolved
apps/agent/buidler.config.js Show resolved Hide resolved
"test:gas": "GAS_REPORTER=true npm test",
"coverage": "npx truffle run coverage",
"ganache-cli:test": "./node_modules/@aragon/contract-helpers-test/scripts/ganache-cli.sh",
"abi:extract": "truffle-extract --output abi/ --keys abi",
Copy link
Contributor Author

@sohkai sohkai Aug 11, 2020

Choose a reason for hiding this comment

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

Right, we may want to replace this with something else. Not sure if there's a buidler plugin to replicate this, but truffle-extract supports a buildDir input argument so we can switch to artifacts.

Copy link
Contributor

@0xGabi 0xGabi Aug 11, 2020

Choose a reason for hiding this comment

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

Maybe we can update it to be a super simple plugin? Otherwise, if I update this line as well: https://github.com/sohkai/truffle-extract/blob/master/index.js#L36 with npx buidler compile the package keep working fine. I don't have a strong preference, do you?

Copy link
Contributor

Choose a reason for hiding this comment

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

I decide to fork your package and publish a new version for buidler instead: https://github.com/0xGabi/buidler-extract

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good! Honestly not sure if this fits well as a small buidler plugin, but I can see it being useful!

I was thinking about this earlier, and in reality, we may actually want to have a tool that lets us configure what we publish. For most apps, there's a lot of extra fluff in the artifacts (e.g. Voting only needs Voting.json, not all the other artifacts).

apps/agent/scripts/ganache-cli.sh Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
"coverage": "SOLIDITY_COVERAGE=true npm run ganache-cli:test",
"ganache-cli:test": "./scripts/ganache-cli.sh"
"test": "buidler test",
"test:gas": "REPORT_GAS=true buidler test --network localhost",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, but I don't think the localhost network exists anymore in the buidler config?

Copy link
Contributor

@0xGabi 0xGabi Aug 12, 2020

Choose a reason for hiding this comment

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

As we are using the gas reporter with the buidlerevm and they don't yet handle the start and stop of the chain. We need to manually ran npx buidler node and then connect to the chain with --network localhost. As explained on:

Copy link
Contributor

Choose a reason for hiding this comment

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

I include a comment to give more context about it: 1114631#diff-31b24dc429d79c5898460ef28314ee00R38

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, so the --network local flag would tell it to connect to the separately run buidlerevm instance?

Copy link
Contributor

@0xGabi 0xGabi Aug 13, 2020

Choose a reason for hiding this comment

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

Yes. The buidlerevm chain starts a JSON-RPC and WebSocket server and expose the gateway at http://localhost:8545. Then the buidler default configuration object has the following format:

{
    localhost: {
      url: "http://127.0.0.1:8545"
    },
    buidlerevm: {
      // See its defaults
    }
}

That's why you can use --network localhost. Maybe we should be explicit about localhost network?

apps/agent/buidler.config.js Outdated Show resolved Hide resolved
apps/agent/buidler.config.js Outdated Show resolved Hide resolved
apps/agent/buidler.config.js Show resolved Hide resolved
"coverage": "SOLIDITY_COVERAGE=true npm run ganache-cli:test",
"ganache-cli:test": "./scripts/ganache-cli.sh"
"test": "buidler test",
"test:gas": "REPORT_GAS=true buidler test --network localhost",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, so the --network local flag would tell it to connect to the separately run buidlerevm instance?

@coveralls
Copy link

coveralls commented Aug 13, 2020

Coverage Status

Coverage increased (+0.2%) to 97.554% when pulling d0c0991 on buidler into 7a2ae95 on master.

@0xGabi
Copy link
Contributor

0xGabi commented Aug 13, 2020

We have a green CI 🎉

@sohkai if you consider it's ok, we can merge.

Copy link
Contributor Author

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Amazing, this is fantastic! Let's get this innnn 🍾!

@@ -734,11 +734,14 @@ module.exports = (agentName, { accounts, artifacts, web3 }) => {
context('> Designated signer', () => {
const ethSign = async (hash, signer) => {
const packedSig = await web3.eth.sign(hash, signer)
const chainId = await web3.eth.net.getId()
// If we detect buidlerevm we don't use ganache encoding
const offset = chainId === 31337 ? 0 : 27
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohhh interesting, are there docs for this? I'd like to leave a few more comments :).

We may also want to push something like this into the contract-helpers (we can do it later though)

Copy link
Contributor

Choose a reason for hiding this comment

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

This was pointing out by Pato from buidler. He told me that ganache encodes the v value of the signature as 0 or 1, while it should be 27 or 28. But buidler uses the same values as geth.

Related discussions about the topic:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting, let's leave these in the inline code!

apps/voting/.solcover.js Show resolved Hide resolved
@0xGabi 0xGabi merged commit d631fd6 into master Aug 14, 2020
@0xGabi 0xGabi deleted the buidler branch August 14, 2020 15:58
willjgriff pushed a commit to 1Hive/agreement-app that referenced this pull request Nov 9, 2020
This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and to interacts with real chains. It also has ganache configured to be used as an alternative local development chain (use with `--network ganache`).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

The changes include:
- Support buidlerevm as default test chain. Depends on aragon/contract-helpers#55.
- Make coverage work with buidler and update to latest solidity-coverage
- Bump to use node 12
- Update `truffle-extract` to support buidler. As discussed in aragon/aragon-apps#1131 (comment).
sembrestels pushed a commit to 1Hive/token-manager-app that referenced this pull request Nov 9, 2020
This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and to interacts with real chains. It also has ganache configured to be used as an alternative local development chain (use with `--network ganache`).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

The changes include:
- Support buidlerevm as default test chain. Depends on aragon/contract-helpers#55.
- Make coverage work with buidler and update to latest solidity-coverage
- Bump to use node 12
- Update `truffle-extract` to support buidler. As discussed in aragon/aragon-apps#1131 (comment).
nickhabets added a commit to nickhabets/aragon that referenced this pull request Dec 29, 2020
This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and to interacts with real chains. It also has ganache configured to be used as an alternative local development chain (use with `--network ganache`).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

The changes include:
- Support buidlerevm as default test chain. Depends on aragon/contract-helpers#55.
- Make coverage work with buidler and update to latest solidity-coverage
- Bump to use node 12
- Update `truffle-extract` to support buidler. As discussed in aragon/aragon-apps#1131 (comment).
nickhabets pushed a commit to nickhabets/aragon that referenced this pull request Dec 29, 2020
This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and to interacts with real chains. It also has ganache configured to be used as an alternative local development chain (use with `--network ganache`).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

The changes include:
- Support buidlerevm as default test chain. Depends on aragon/contract-helpers#55.
- Make coverage work with buidler and update to latest solidity-coverage
- Bump to use node 12
- Update `truffle-extract` to support buidler. As discussed in aragon/aragon-apps#1131 (comment).
ramilexe pushed a commit to ConsiderItDone/aragon-apps that referenced this pull request Dec 9, 2021
This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and to interacts with real chains. It also has ganache configured to be used as an alternative local development chain (use with `--network ganache`).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

The changes include:
- Support buidlerevm as default test chain. Depends on aragon/contract-helpers#55.
- Make coverage work with buidler and update to latest solidity-coverage
- Bump to use node 12
- Update `truffle-extract` to support buidler. As discussed in aragon#1131 (comment).
sembrestels pushed a commit to BlossomLabs/tao-voting-aragon-app that referenced this pull request Aug 29, 2022
This PR introduces a vanilla setup of buidler development tool. It includes several network configurations both for local development and to interacts with real chains. It also has ganache configured to be used as an alternative local development chain (use with `--network ganache`).

Note the gas reporter packages don't yet support handling the start and stop of the chain. We need to start it manually as explained in https://github.com/cgewecke/buidler-gas-reporter/tree/master#using-buidlerevm-warning.

The changes include:
- Support buidlerevm as default test chain. Depends on aragon/contract-helpers#55.
- Make coverage work with buidler and update to latest solidity-coverage
- Bump to use node 12
- Update `truffle-extract` to support buidler. As discussed in aragon/aragon-apps#1131 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to buidler-aragon
3 participants