Quorum Ethereum Truffle) Error: Number can only safely store up to 53 bits

放肆的年华 提交于 2019-12-06 15:21:05

So the problem was that the Block Timestamp was in Nanoseconds.

@edgraaff wrote a Proxy who converts the Timestamp from Nanoseconds to Seconds. You can find the code here -> https://github.com/edgraaff/quorum-rpc-proxy

What I had to do is to clone the proxy and change the config.js file to:

module.exports = {
  rpcUrl: 'http://localhost:22000',
  port: 7545
};

And in the truffle-config.js file i had to change the port. Here's the code:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545, // was 8545
      network_id: "*", // Match any network id
      gasPrice: 0,
      gas: 4500000
    },
    nodefour:  {
      host: "127.0.0.1",
      port: 22003,
      network_id: "*", // Match any network id
      gasPrice: 0,
      gas: 4500000
    },
    nodeseven:  {
      host: "127.0.0.1",
      port: 22006,
      network_id: "*", // Match any network id
      gasPrice: 0,
      gas: 4500000
    }
  },
  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      version: "0.4.25",    // Fetch exact version from solc-bin (default: truffle's version)
    }
  }
}

Thanks to @edgraaff

The proxy is not enough, because web3.js can get block in subscribtion via ws

Also in quorum getting block by number is broken, it accept only hex, however web3.js assume hex as blockhash

Here is my solution

web3.extend({
  property: 'eth',
  methods: [new web3.extend.Method({
    name: 'getBlockByNumber',
    call: 'eth_getBlockByNumber',
    params: 2,
    inputFormatter: [web3.extend.formatters.inputBlockNumberFormatter, v => !!v],
    outputFormatter: web3.extend.formatters.outputBlockFormatter
  })]
});
web3.utils.hexToNumber = v => {
  if (!v) return v;
  try {
    return numberToBN(v).toNumber();
  } catch (e) {
    return numberToBN(v).toString();
  }
};

Just take care that timestamp is string now

Here is related issue in web3.js repo https://github.com/ethereum/web3.js/issues/1215

You don't need to use any proxy if you downgrade your truffle version to 4.1.15. If you do that everything will work fine. Just don't downgrade to 4.1.14 because truffle init it's broken in that package!.

Rahul Bishnoi

Easy fix: Just add type: "quorum" in your truffle-config for the network which is supposed to run on quorum.

@QuorumPrivateBlockChain hey mate.

So this is my truffle-config.js file:

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*",
      gasPrice: 0,
      gas: 4500000
    },
    nodefour:  {
      host: "127.0.0.1",
      port: 7546,
      network_id: "*",
      gasPrice: 0,
      gas: 4500000
    },
    nodeseven:  {
      host: "127.0.0.1",
      port: 7547,
      network_id: "*",
      gasPrice: 0,
      gas: 4500000
    }
  },
  compilers: {
    solc: {
      version: "0.4.25",   
    }
  }
}

And this is my config.js file from the proxy:

module.exports = [
  {
    rpcUrl: 'http://localhost:22000',
    port: 7545
  },
  {
    rpcUrl: 'http://localhost:22003',
    port: 7546
  },
  {
    rpcUrl: 'http://localhost:22006',
    port: 7547
  },
];

So what you do, you send the requests from your truffle to your proxy and the proxy then converts the timestamp and sends the request further to the node.

The proxy is a program by itself, you don't have to copy the config.js file form the proxy code. Look into the github how you can start the proxy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!