embarklabs / embark

Framework for serverless Decentralized Applications using Ethereum, IPFS and other platforms
https://framework.embarklabs.io/
MIT License
3.79k stars 495 forks source link

Embark with Ganache - Error: Provider not set or invalid #1648

Open piavgh opened 5 years ago

piavgh commented 5 years ago

Bug Report

Summary

I tried to deploy smart contracts with Embark, and I connect to Ganache. The smart contracts seem to be deployed correctly but there are some error logs that I think I need to report

Current behavior

After embark run, I got these errors: Screenshot from 2019-05-31 10-54-07

This is the screenshot when everything is done: Screenshot 2019-05-31 11:02:57

How to reproduce

Setup a normal embark project and connect to Ganache on port 7545. You can see the contracts here https://github.com/tomochain/tomorelayer/tree/master/contracts

Expected behavior

I think it's better that we don't have any error here

If you encounter an error, please create a logfile using the following command and post the output here

$ embark run --nodashboard --logfile log.txt --loglevel trace

Please provide additional information about your system

OS: Ubuntu 18.04 Embark Version: 3.2.7 Node Version: 10.15.0 NPM Version: 6.4.1

Sometimes issues are related to Embark's installation. Can you provide information on how Embark was installed?

There are 2 lines in devDependencies:

"embark": "^4.0.2",
"embarkjs-connector-web3": "^4.0.0",

Then yarn install

jrainville commented 5 years ago

Hi @piavgh , thanks for reporting. Could you run again with embark run --nodashboard --loglevel=trace and paste le logs here (mostly the error and it's surrounding). It will be easier to debug that way. Thank you

piavgh commented 5 years ago

@jrainville : Hi, sorry for the delay, this is the log:

/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/lib/core/plugin.js:87
  (this.pluginModule.call(this, this));
                     ^

TypeError: Class constructor EmbarkJSConnectorWeb3 cannot be invoked without 'new'
    at Plugin.loadPlugin (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/lib/core/plugin.js:87:22)
    at Plugins.loadPlugin (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/lib/core/plugins.js:92:17)
    at Plugins.loadPlugins (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/lib/core/plugins.js:21:10)
    at Config.loadConfigFiles (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/lib/core/config.js:59:16)
    at Engine.init (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/lib/core/engine.js:34:17)
    at initEngine (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/cmd/cmd_controller.js:95:16)
    at nextTask (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/node_modules/async/dist/async.js:5324:14)
    at Object.waterfall (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/node_modules/async/dist/async.js:5334:5)
    at EmbarkController.run (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/cmd/cmd_controller.js:93:11)
    at Command.<anonymous> (/home/piavgh/.nvm/versions/node/v10.15.0/lib/node_modules/embark/cmd/cmd.js:182:16)
jrainville commented 5 years ago

Hi @piavgh , I just tried testing the repo you linked (https://github.com/tomochain/tomorelayer), and it worked for me. Maybe it's your connection to Ganache that is not done correctly. I see in your setup that you start Ganache on port 7545, but no where in the config you specify that port, could it be you have your own branch or you maybe just forgot?

Also, the last error about EmbarkJSConnectorWeb3 seems to say that you may have an old version of it installed. Try to re-run npm install or npm instal embarkjs-connector-web3 to make sure you have the latest version.

piavgh commented 5 years ago

Hi @jrainville , sorry, in blockchain.js I updated it and didn't push to git

  default: {
    enabled: true,
    rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
    rpcPort: 7545, // HTTP-RPC server listening port (default: 8545)
    rpcCorsDomain: '*',
    wsRPC: true, // Enable the WS-RPC server
    wsOrigins: '*',
    wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
    wsPort: 7545, // WS-RPC server listening port (default: 8546)
  },

Also, in contracts.js, I updated it:

default: {
    // Blockchain node to deploy the contracts
    deployment: {
      host: "localhost", // Host of the blockchain node
      port: 7545, // Port of the blockchain node
      type: "ws", // Type of connection (ws or rpc),
      accounts: [
        {
          mnemonic: process.env.MNEMONIC,
          addressIndex: 0,
          numAddresses: 8,
          balance: "900000 ether",
        }
      ]
    },

Other than that, nothing is changed compares to my master branch

I also tried to update embarkjs-connector-web3 to latest version (4.0.0) but it didn't work also.

Can you please tell me how did you setup Ganache?

Thank you.

jrainville commented 5 years ago

I tried your latest master with the changes above, and it still worked for me (other than the deployment reverting).

I started Ganache using embark simulator and it gave:

running: ganache-cli -p 7545 -h localhost -l 8000000 -a 10 -e 100 --networkId 1337
Ganache CLI v6.2.3 (ganache-core: 2.3.1)

And then embark run --nodashboard --nobrowser:

========================
Welcome to Embark 4.0.2
========================
loaded plugins: embarkjs-connector-web3
ready to watch file changes
Cockpit UI available at http://localhost:55555
Ethereum node detected..
loading solc compiler...
compiling solidity contracts...
assuming ERC20 to be an interface
assuming DetailedERC20 to be an interface
assuming ERC20Basic to be an interface
deploying contracts
Executing pre-deploy actions...
Pre-deploy actions done. Deploying contracts
[TokenB]: Returned error: VM Exception while processing transaction: revert
[TokenA]: Returned error: VM Exception while processing transaction: revert
[TokenC]: Returned error: VM Exception while processing transaction: revert
[TokenD]: Returned error: VM Exception while processing transaction: revert
[RelayerRegistration]: error deploying =RelayerRegistration= due to error: Returned error: sender doesn't have enough funds to send tx. The upfront cost is: 47237080000000000 and the sender's account only has: 0
[Ownable]: error deploying =Ownable= due to error: Returned error: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 1
[BasicToken]: error deploying =BasicToken= due to error: Returned error: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 2
[MintableToken]: error deploying =MintableToken= due to error: Returned error: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 3
[StandardToken]: error deploying =StandardToken= due to error: Returned error: the tx doesn't have the correct nonce. account has nonce of: 0 tx has nonce of: 4
Error deploying contracts. Please fix errors to continue.
Deployment Done

I think the revert might be because my account doesn't have funds. Anyway, I don't have the connector error nor web3 error.

piavgh commented 5 years ago

I'm using Ganache GUI. Maybe that's the reason why.

I will try using ganache-cli and will let you know