Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

compiler hang when using openzeppelin-solidity #5

Closed
cedricwalter opened this issue Jan 21, 2019 · 15 comments
Closed

compiler hang when using openzeppelin-solidity #5

cedricwalter opened this issue Jan 21, 2019 · 15 comments
Assignees

Comments

@cedricwalter
Copy link

cedricwalter commented Jan 21, 2019

Using your dev-tools-truffle-example sample project and changing metacoin.sol to use openzeppelin

import {Ownable} from "openzeppelin-solidity/contracts/ownership/Ownable.sol";
contract MetaCoin is Ownable {

and adding in package.json in dependencies
"openzeppelin-solidity": "^2.1.2"

run
npm run trace

Stacktrace

$ npm run trace
> MODE=trace truffle test

Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/SafeMath.sol...
Compiling openzeppelin-solidity/contracts/ownership/Ownable.sol...

Interestingly, truffle compile work as expected

@nachomazzara
Copy link

Same here

@nachomazzara
Copy link

nachomazzara commented Jan 24, 2019

Workaround:

Create a new file: test.sh

#!/usr/bin/env bash

# Exit script as soon as a command fails.
set -o errexit

# Executes cleanup function at script exit.
trap cleanup EXIT

cleanup() {
  # Kill the ganache instance that we started (if we started one and if it's still running).
  if [ -n "$ganache_pid" ] && ps -p $ganache_pid > /dev/null; then
    kill -9 $ganache_pid
  fi
}

ganache_port=8545

ganache_running() {
  nc -z localhost "$ganache_port"
}

start_ganache() {
  # We define 10 accounts with balance 1M ether, needed for high-value tests.
  local accounts=(
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000"
    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000"
  )

  ganache-cli --gasLimit 0xfffffffffff "${accounts[@]}" --port "$ganache_port" > /dev/null &

  ganache_pid=$!
}

if ganache_running; then
  echo "Using existing ganache instance"
else
  echo "Starting our own ganache instance"
  start_ganache
fi

truffle test "$@"

package.json

...
scripts: {
  "trace": "MODE=trace test.sh",
  "coverage": "MODE=coverage test.sh; istanbul report html && open coverage/index.html",
  "profile": "MODE=profile test.sh; istanbul report html && open coverage/index.html"
}

And change your contract from ./0x-artifacts

"sources": {
    "node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol": {
      "id": 0
    }
  },

to

"sources": {
    "../node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol": {
      "id": 0
    }
  },

@LogvinovLeon
Copy link
Contributor

Hi @cedricwalter @nachomazzara .
I've just updated the dependencies versions to include some bug fixes. Could you please confirm that it resolves that issue for you? I've just tried doing that locally and it works for me.

@NoahMarconi
Copy link

This is not limited to open zeppelin. Just did a fresh clone of your repo and have two separate projects that hang when running npm run coverage.

The beforeEach were I redeploy the contract hangs sporadically

@LogvinovLeon
Copy link
Contributor

@NoahMarconi Which projects? I'd like to debug that, but I don't have a repro.

@NoahMarconi
Copy link

NoahMarconi commented Feb 14, 2019

It's the beforeEach causing it to hang. Even try using your current repo but add a before each and 10 or so tests. It will hang before hitting the 10th.

I got it to hang with this gist https://gist.github.com/NoahMarconi/cc58948ce86efbf325b34119df8ac9ee

@LogvinovLeon
Copy link
Contributor

@NoahMarconi Thanks. I have a repro now. Will work on that

@LogvinovLeon
Copy link
Contributor

Ok. I figured it out. Truffle uses eth_subscribe. Geth only supports it over WS, not HTTP. I'll update our Geth node to export WS endpoint and update the repo to use WS.

@NoahMarconi
Copy link

awesome, that was fast! :)

@PaulRBerg
Copy link

I switched to use WebSocket in my branch: https://github.com/PaulRBerg/dev-tools-truffle-example/blob/master/truffle-config.js

However, I get the following error:

Error: socket hang up
    at createHangUpError (_http_client.js:323:15)
    at Socket.socketOnEnd (_http_client.js:426:23)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1094:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

This is how I start my @0xorg/devnet container:

docker run -it -d --rm -p 8545:8501 -p 8546:8546 0xorg/devnet:latest /bin/bash

@LogvinovLeon
Copy link
Contributor

After trufflesuite/ganache#280 got fixed - the only tool that still requires Geth is sol-profiler. Tracing and coverage should work with ganache. I've updated the example repo.

@LogvinovLeon
Copy link
Contributor

To all the people in the thread. If the tools you're interested in are sol-trace of sol-coverage (not sol-profiler) - you can now use those with Ganache. It should solve your issues. I've upgraded the example repo.

@PaulRBerg
Copy link

That is awesome, thanks @LogvinovLeon!

@LogvinovLeon
Copy link
Contributor

@cedricwalter Do you still experience that with Ganache?

@cedricwalter
Copy link
Author

@cedricwalter Do you still experience that with Ganache?
It run now as expected! thanks @LogvinovLeon!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants