trufflesuite / ganache-ui

Personal blockchain for Ethereum development
https://www.trufflesuite.com/ganache
MIT License
4.67k stars 807 forks source link

Ganache throws on calculation w/ >53 bits #2154

Open fubuloubu opened 4 years ago

fubuloubu commented 4 years ago

Expected Behavior

Test cases pass!

Current Behavior

During test execution, ganache throws and error and spoils the test run:

...
eth_sendTransaction

  Transaction: 0xf7d661285d3b1a577fcfc4cbcade805ae0d21c4eaca75699dace0312aca8dd30
  Gas usage: 61894
  Block Number: 10
Error: Number can only safely store up to 53 bits
    at assert (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/node_modules/bn.js/lib/bn.js:6:21)
    at BN.toNumber (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/node_modules/bn.js/lib/bn.js:506:7)
    at Object.t.bufferToInt (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:148279)
    at Object.number (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:67837)
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:219900
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:48553
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2092107
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:21088
    at s (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:24209)
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:24251
    at Bt (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:33684)
    at Object.<anonymous> (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:24340)
    at Object.decode (~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2091974)
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2057355
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2062165
    at ~/.nvm/versions/node/v12.19.0/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2059465

Possible Solution

Add actual integers to JS

Steps to Reproduce (for bugs)

  1. clone branch from PR (below)
  2. brownie test test/integration
  3. ...profit!

Context

It makes me sad

Your Environment

davidmurdoch commented 4 years ago

Are you able to pin-point which test call is failing? Usually this error occurs when you accidentally pass in an ethereum address where a number is expected.

davidmurdoch commented 4 years ago

p.s. I'm very sorry we've made you sad :heart: :slightly_smiling_face:

fubuloubu commented 4 years ago

Are you able to pin-point which test call is failing? Usually this error occurs when you accidentally pass in an ethereum address where a number is expected.

Not really, no but I will check if this is the case. I doubt it, because usually eth-abi Python library is very good about detecting mismatching w/ call types, but you never know.

fubuloubu commented 4 years ago

So, the current iteration of tests/integration/test_calculation.py is actually mining a ton of blocks (2.3m), this could be what causes it to fail. I actually need to update it to no longer be mining all those blocks due to a change we made to use timestamps instead.

fubuloubu commented 4 years ago

I figured it out! I was setting the timestamp to an invalid value using evm_increaseTime. I was setting it to a number w/ 188 bits! This causes ganache to throw and fail.