-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
block timestamp - "Error: Number can only safely store up to 53 bits" #1905
Comments
I'm having the same issue when using Truffle and Ganache. I fast forward time to simulate things happening in the future, and then hit this error. |
I am having the same problem with "block.gasLimit".
|
Does this error still occur with the latest version of Web3? |
This bug still exists. It happens for us when we launched geth with |
Hi @nivida , this issue still exists for me in beta.55 on Quorum with this block:
Could you please double check? Thank you in advance, |
Hi, this issue is related to 1,2. And because it is a problem related to 3rd parties implementation of the blockchain, must be the responsibility of them to manage the particular implementation of the precision related to the timestamp.
As the documentation defines, the timestamp must be interpreted as unix time, but currently, an error breaks the execution of the application (if the timestamp value is bigger than expected) throwing an error.
It is expected that the block timestamp data could change over time --given the limitations of unix time spec-- but the behavior of the web3 must not break because of it.
Finally, the problem is related to a timestamp value bigger than a 32bit representation value. So, the right solution must be managing the timestamp as BN (in little endian) and then convert it to the first 32bit representable values by the developer.
This means that a decimal number with more than 10 digits must be truncated to be interpreted as 32bit length.
My solution at release @beta.35 file web3-core-helpers/src/formatters.js 235
at relase @beta.36 file web3-core-helpers/src/formatters.js:185
a substring(0,10) operation is not recomended here to avoid problems with big-endian implementations
Example:
Phisical block: {"difficulty":"0x20000","extraData":"0x","gasLimit":"0xdee8afcd","gasUsed":"0xc705","hash":"0x71ef9a9e5e3575b9861e81da7ebd0fe465879602f6aff27964d9de6bd62e8bdd","logsBloom":"0x00000000000000000000000000000000000000080000000000000000000000000000000008000000000000000000000000000000000000000000400000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000010000000080000000000000000000000000000000000000000000000000021000000000002000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000","miner":"0x0000000000000000000000000000000000000000","mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000","nonce":"0x0000000000000000","number":"0x5","parentHash":"0xcc0cd85704ccee6615b5d4a182c18d98080685acee0eb6aeb2816b5c14ebb26e","receiptsRoot":"0x90889007d6b3836f3bbdaa22ed5cae062ccfc6c5758fc92e9e042b715f10cc26","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x2ae","stateRoot":"0xdf0a5715a8e861f689d3262b84fd02a95bbe76c536501cc34b519a3d051813a6","timestamp":"0x154f146681969c9e","totalDifficulty":"0xa0000","transactions":["0x406cdd51e197c04cc31b9bf0548d61f411375b7c63791f155d297e14402ed0bc"],"transactionsRoot":"0x513fe6d019912f97352635b19bb0144d035752c320a41e17680382237289c878","uncles":[]}
Help Logs:
timestamp (orig): 0x154f146681969c9e
BigNumber: 1535468428449979550 timestamp: 1535468428 (equal to BigNumber.substring(0,10))
timestamp date: 2018-08-28T15:00:28.000Z
jstimestamp: 1535468428449
At the application level: Using a wrapper to override the buggy function.
wrapperFile.js
The text was updated successfully, but these errors were encountered: