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

Error: Number can only safely store up to 53 bits #114

Open
aakilfernandes opened this Issue Dec 29, 2016 · 10 comments

Comments

Projects
None yet
10 participants
@aakilfernandes

aakilfernandes commented Dec 29, 2016

Getting this while running the tests on a fresh clone.

OSX Yosemite
Node v6.3.0

# [bcInvalidRLPTest] BLOCK_gasLimit_TooLarge
ok 186 correct pre stateRoot
/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:6
    if (!val) throw new Error(msg || 'Assertion failed');
              ^

Error: Number can only safely store up to 53 bits
    at assert (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:6:21)
    at BN.toNumber (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:506:7)
    at Object.exports.bufferToInt (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/node_modules/ethereumjs-util/index.js:199:40)
    at BlockHeader.validateGasLimit (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/header.js:146:26)
    at /Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/header.js:196:15
    at /Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-blockchain/index.js:326:7
    at /Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/levelup/lib/levelup.js:230:7
    at Immediate.callNext (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/memdown/memdown.js:173:5)
    at runCallback (timers.js:566:20)
    at tryOnImmediate (timers.js:546:5)
npm ERR! Test failed.  See above for more details.
@DevNebulae

This comment has been minimized.

Show comment
Hide comment
@DevNebulae

DevNebulae Jun 8, 2017

Getting the same error with no clue on how to fix it. Does anybody have a fix for this or an explanation as to why this happens?

DevNebulae commented Jun 8, 2017

Getting the same error with no clue on how to fix it. Does anybody have a fix for this or an explanation as to why this happens?

@assafmo

This comment has been minimized.

Show comment
Hide comment
@assafmo

assafmo Jun 29, 2017

This happened to me when I tried to index string type in an event.
https://ethereum.stackexchange.com/a/7170/12112

assafmo commented Jun 29, 2017

This happened to me when I tried to index string type in an event.
https://ethereum.stackexchange.com/a/7170/12112

@DevNebulae

This comment has been minimized.

Show comment
Hide comment
@DevNebulae

DevNebulae Jul 1, 2017

I actually figured it out and it is REALLY stupid... It occurred to me when I actually used a value for the gas field which is greater than 53 bits. I actually set it to half an Ether and that works out to be greater than 53 bits...

DevNebulae commented Jul 1, 2017

I actually figured it out and it is REALLY stupid... It occurred to me when I actually used a value for the gas field which is greater than 53 bits. I actually set it to half an Ether and that works out to be greater than 53 bits...

@sdtsui sdtsui referenced this issue Jul 3, 2017

Closed

EIP150 - Part II #129

@axic axic added the type: bug label Sep 7, 2017

@axic

This comment has been minimized.

Show comment
Hide comment
@axic

axic Dec 9, 2017

Member

This actually seems to be a bug in ethereumjs-block.

Member

axic commented Dec 9, 2017

This actually seems to be a bug in ethereumjs-block.

@hugo-dc

This comment has been minimized.

Show comment
Hide comment
@hugo-dc

hugo-dc Dec 15, 2017

Contributor

@axic recently I submitted a new PR to the tests repository, the tests I submitted is related to this problem.

ethereum/tests#381

I think this is something that the bn.js library validates, here is an example of the validation in the iaddn function

https://github.com/indutny/bn.js/blob/master/lib/bn.js#L2145

Contributor

hugo-dc commented Dec 15, 2017

@axic recently I submitted a new PR to the tests repository, the tests I submitted is related to this problem.

ethereum/tests#381

I think this is something that the bn.js library validates, here is an example of the validation in the iaddn function

https://github.com/indutny/bn.js/blob/master/lib/bn.js#L2145

@axic

This comment has been minimized.

Show comment
Hide comment
@axic

axic Dec 17, 2017

Member

This seems to be a problem in ethereumjs-block and that the block gas limit is higher than 53bits:

Error: Number can only safely store up to 53 bits
    at assert (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:6:21)
    at BN.toNumber (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:506:7)
    at Object.exports.bufferToInt (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/node_modules/ethereumjs-util/index.js:199:40)
    at BlockHeader.validateGasLimit (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/header.js:146:26)
Member

axic commented Dec 17, 2017

This seems to be a problem in ethereumjs-block and that the block gas limit is higher than 53bits:

Error: Number can only safely store up to 53 bits
    at assert (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:6:21)
    at BN.toNumber (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/bn.js/lib/bn.js:506:7)
    at Object.exports.bufferToInt (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/node_modules/ethereumjs-util/index.js:199:40)
    at BlockHeader.validateGasLimit (/Users/aakilfernandes/projects/safemarket/ethereumjs-vm/node_modules/ethereumjs-block/header.js:146:26)
@riordant

This comment has been minimized.

Show comment
Hide comment
@riordant

riordant Dec 20, 2017

having the same problem where gasLimit in testrpc is set greater than 9007199254740991 (2^53 -1) and tests are ran.

riordant commented Dec 20, 2017

having the same problem where gasLimit in testrpc is set greater than 9007199254740991 (2^53 -1) and tests are ran.

@greggootz

This comment has been minimized.

Show comment
Hide comment
@greggootz

greggootz Feb 24, 2018

Make sure your {gas: xxxx} is a round number.

Bad: {gas: 40000.0000001}
Good: {gas: 40000}

Math.floor() to the rescue.

Example of usage:

const estGas = Math.floor(await instance.myMethod.estimateGas({ from: wallet })

Good luck!

greggootz commented Feb 24, 2018

Make sure your {gas: xxxx} is a round number.

Bad: {gas: 40000.0000001}
Good: {gas: 40000}

Math.floor() to the rescue.

Example of usage:

const estGas = Math.floor(await instance.myMethod.estimateGas({ from: wallet })

Good luck!

@shrugs

This comment has been minimized.

Show comment
Hide comment
@shrugs

shrugs Apr 8, 2018

(sorry for the notification, but this is for future searchers)

I got this issue when I attempted to issue a evm_increaseTime call against ganache while using a duration argument that was stupidly large. It was hard to track down because I was accidentally using a BigNumber in a traditional 30 + myBigNumber way.

shrugs commented Apr 8, 2018

(sorry for the notification, but this is for future searchers)

I got this issue when I attempted to issue a evm_increaseTime call against ganache while using a duration argument that was stupidly large. It was hard to track down because I was accidentally using a BigNumber in a traditional 30 + myBigNumber way.

@etherpan

This comment has been minimized.

Show comment
Hide comment
@etherpan

etherpan Apr 25, 2018

@assafmo solution worked for me. Just don't index strings in your events

etherpan commented Apr 25, 2018

@assafmo solution worked for me. Just don't index strings in your events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment