-
Notifications
You must be signed in to change notification settings - Fork 20.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
Greater than or equal operator not working correctly #2093
Comments
Update: I can easily duplicate this. Using the simple contract code above and sending transactions using the 'Ethereum Wallet' Linux x64 0.3.7 client. I can deposit 10 ether, confirm the transaction, attempt to withdraw 10 ether and it will fail. If instead I attempt to withdraw 9,999,999,999,999,999,999 wei, it will succeed, leaving 1e-18 in the account when queried afterwards. Note: this does NOT happen using the truffle/testrpc server. I only observe this running geth on my private testnet. |
What version of solidity are you using for compiling the contract? Geth really just runs the EVM bytecode generated by solidity. Also just to note, the EVM does not have combined ">=" and "<=" opcodes, so Solidity needs to generate a more complex code to emulate these using ">" and "==". Could there be a bug in your locally installed Solidity? Not sure whether truffle uses its own Solidity compiler or the one on the machine. Might be worth a shot to update it and see. |
@chriseth Do you know anything about a potential bug in the Solidity compiler with complex comparison operators? ^ |
Thanks for the feedback. I checked the versions of solidity - for the geth deploy (not working) the solc version installed in /usr/local/bin on my system is '0.2.0-0/Release-Linux/g++/int linked to libethereum-1.1.0-0/Release-Linux/g++/int'. The truffle package.json shows ""solc": "^0.1.5", but that appears to be referring to a different artifact: 'soljson-latest.js'. I'll experiment around with versions and report back if I discover anything new. Thanks.. |
@mjackson001 any news? |
Got sidetracked with the holidays. I just attempted to duplicate from a fresh deploy and it's been working - with the same version of solc as mentioned above. It was easily duplicated previously, so I'm not sure what changed. The symptoms were so specific that I still feel like it's possible there may be a bug somewhere. At the time, I was playing with the BigNumber library so it could be there was something broken there as well. Here's my setup: Geth: Solc: |
I can't imagine this being a Solidity issue, it is just too basic usage. |
Update: I am seeing this again and have some better information. It appears to be specifically related to using the Mist-based 'Ethereum Wallet' Linux x64 0.3.7 client to send the transactions. I can use a node.js command-line prompt to issue the web3 commands directly to geth over RPC and it works. The procedure to duplicate is to compile the contract above to get the ABI, and deploy it. Then use the address and ABI to create a contract 'watch' in Ethereum Wallet. It should then be easy to observe, using the GUI to send transactions. In the geth logs, it appears the transaction fails due to running out of gas. The Ethereum Wallet client tries to calculate the exact amount of gas (in this case 29018) and the 'out of gas' check in the geth logs also shows the gas consumed was exactly 29018 (cgas=29018). So, in theory it shouldn't be failing. Could the check for gas consumption be failing the equality check???? Why would sending 1 Wei less as a transaction parameter make a difference???? Note that there's no way to adjust the amount of gas from within the Ethereum Wallet gui so I'm not sure where to go from here. I'm guessing if I bumped it up to 29,019 gas the transaction might go through. Ethereum GUI: geth logs (verbosity 5): |
I tried the identical function call directly from web3: contract.withdraw(1000000000000000000, {gas: 50000}) and it succeeds with total gas consumed == 22082. So the 29018 gas above should have been more than enough. Very confused now :) |
Running geth on a private network, had a contract account with 10 ether (simple contract, testing deposits / withdrawals). Tried to withdraw exactly 10 ether and it failed. This is the contract:
The contract failed when using 10,000,000,000,000,000,000. However, it succeeded when using 9,999,999,999,999,999,999. Confirmed the account had exactly 10 ether. Therefore, it appears the geth >= operator in the EVM is failing the == part of the test.
The text was updated successfully, but these errors were encountered: