-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Block timestamp bigNumber coversion issue (WebSocket connection) #1215
Comments
I'm facing the same issue. Any solution yet ? |
Here's a hack you can do while you wait: Go into: https://github.com/ethereum/web3.js/blob/develop/lib/web3/formatters.js#L171 This also occurs when using the HTTP provider. |
Proposed, fix is to down sample into MS, for this formatter if it's above 53 bytes. |
#1351 might be an even better fix. |
Hmmm fishy, works as of cd1cfd9
My timestamp |
EH, scratch that.
|
Since Ethereum can and will have numbers larger than
@frozeman seems like a regular issue with a drastic solution. Do you have any maintainer insight that might simplify this? |
A few points on this.
let Web3Helpers = require('web3-core-helpers');
let Web3Utils = require('web3-utils');
web3.extend({
property: 'quorum_raft',
methods: [{
name: 'getBlock',
call: (args) => {
return (_.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
},
params: 2,
inputFormatter: [Web3Helpers.formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
outputFormatter: this.outputBlockFormatter
}]
}); An example implementation of outputBlockFormatter: try {
// check to see if we have an issue with timestamp
Web3Utils.hexToNumber(block.timestamp);
}
catch (err) {
// WARNING this implementation assumes RAFT timestamp (precision is nanoseconds)
// You should not simply assume RAFT if it is not successful rather take a consensus specific
// action
// we are being extra cautious here and converting it back to the same format it was in after dropping
// the nanoseconds (i.e. a hex string prefixed with 0x)
block.timestamp = '0x' + Math.floor(block.timestamp / 1e6).toString(16);
}
return Web3Helpers.formatters.outputBlockFormatter(block); Now, you can simply call: web3.quorum_raft.getBlock(...)
Hope it helps someone out there. :) |
Also hitting this issue when using Truffle beta (uses Web3 1.0) with Ganache, then fast forwarding into the future. This is the timestamp that breaks running my tests: |
This will be fixed with #2144 |
Duplication of: #1905 |
Hello,
I am using "web3": "~1.0.0-beta.26" to make connection to JPMorgan Quorum (https://github.com/jpmorganchase/quorum). Quorum network is configured to use Raft consensus algorithm. Raft algorithm is making changes to block timestamp value, so it is larger (Unix nanoseconds - 1506355254821575394 e.g.) then default - Consensys/quorum#190. Due to this, when I am trying to deploy contract, using WebSocket provider, I receive error from bigNumber.js library:
Error: Number can only safely store up to 53 bits
This error is caused by https://github.com/ethereum/web3.js/blob/develop/lib/web3/formatters.js#L171; looks like Raft timestamp is too big for converting it to the number.
Timestamp value from failing block object:
As I understood outputBlockFormatter is only used during WebSocket connection (ws provider), Rpc connection (http provider) is deploying fine. It was OK to use only RPC connection, but, with recent updates, subscription is possible only using WebSocket.
I understand, that nonstandard ethereum networks is not Your main field; however, would be cool to hear some thoughts about this issue.
The text was updated successfully, but these errors were encountered: