无法运行truffle@2.1.2迁移 - 网络直播。 "超过阻塞气体限制"

时间:2017-03-21 10:36:14

标签: ethereum truffle consensys-truffle parity-io

我正在使用truffle@2.1.2针对localhost:8545 geth@1.5.9-stable rpc部署智能合约,使用以太网资助的帐户已使用geth控制台上的personal.unlockAccount解锁

我也通过RPC对远程奇偶校验节点尝试了相同的操作,但这是我最近坚持的最新版本。

truffle.js

module.exports = {
  build: {
    "index.html": "index.html",
    "app.js": [
      "javascripts/app.js"
    ],
    "app.css": [
      "stylesheets/app.css"
    ],
    "images/": "images/"
  },
  rpc: {
    host: "localhost",
    port: 8545
  },
  networks: {
    "ropsten": {
      network_id: 3,
      port: 8548, // ssh tunnelled to AWS geth/parity node localhost:8545
      from: "0x4f000Bcf4641E2fDcE85BF26A694b053996850D4"
    },
    "live": {
      network_id: 1,
      port: 8545,
      from: "0x00269400181f1B379784BD8cDF786bb20e91Bdef",
      gas: 4612388,
      gasPrice: 2776297000 // taken from Parity startup log message "Updated conversion rate to Ξ1 = US$42.88 (2776297000 wei/gas)"
    }
  }
};

松露迁移 - 网络直播

Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Exceeds block gas limit
    at Object.module.exports.InvalidResponse (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
    at /home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
    at request.onreadystatechange (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
    at dispatchEvent (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (/home/ubuntu/.nvm/versions/node/v6.2.1/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:926:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

我曾尝试调整gas和gasPrice,但无法找到有任何影响的值。

我该如何解决这个问题,还是应该考虑其他合同部署方法?

亲切的问候。

4 个答案:

答案 0 :(得分:3)

我只需在网络配置中设置gas: 3000000即可解决此问题。

"live": {
  network_id: 1,
  port: 8545,
  from: "0x00269400181f1B379784BD8cDF786bb20e91Bdef",
  gas: 3000000
}

运行迁移需要大约0.5 ETH并花费几分钟。

答案 1 :(得分:2)

在我的情况下,问题是由用户的空余额产生的。

所以请使用以下功能检查您的余额:

function checkAllBalances() {
    var totalBal = 0;
    for (var acctNum in eth.accounts) {
        var acct = eth.accounts[acctNum];
        var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
        totalBal += parseFloat(acctBal);
        console.log("  eth.accounts[" + acctNum + "]: \t" + acct + " \tbalance: " + acctBal + " ether");
    }
    console.log("  Total balance: " + totalBal + " ether");
};
 checkAllBalances();

如果余额为0则为某些块或编辑您的创世纪文件。

答案 2 :(得分:1)

我通过在调用truffle时指示网络ID来解决同样的问题,如:

truffle migrate --network live

您应该使用未锁定的帐户修改truffle.js中的“from”标签。

答案 3 :(得分:1)

  

简单解决方案::在 truffle.js

中添加气体:500000,(不要忘记在最后添加逗号)
module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8001,
      network_id: 1234, // Match any network id
      gas: 500000
    }
  }
};