Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Double msg.value amount on payable call (possibly) #362

Closed
OFRBG opened this issue Jan 30, 2019 · 3 comments
Closed

Double msg.value amount on payable call (possibly) #362

OFRBG opened this issue Jan 30, 2019 · 3 comments

Comments

@OFRBG
Copy link

OFRBG commented Jan 30, 2019

Expected Behavior

When calling a payable fallback, the msg.value is equal to the wei attached as value.

Current Behavior

When calling a payable fallback, the msg.value is equal to twice the wei attached as value.

(Running npx ganache-cli --fork https://mainnet.infura.io/metamask with version Ganache CLI v6.3.0 (ganache-core: 2.4.0), the msg.value seems to double.)

Possible Solution

I can't find the issue.

Steps to Reproduce (for bugs)

  1. Run npx ganache-cli --fork https://mainnet.infura.io/metamask
  2. Deploy the bugged contract https://gist.github.com/OFRBG/5930687e7e1da856ef604f9a00f3cc27
  3. Call the fallback with 1 ether value.
  4. Call balanceOf for the address that deposited. The balance is 2000000000000000000 wei.

Context

The error isn't present when connecting to Kovan or Mainnet.

Your Environment

  • Version used: Ganache CLI v6.3.0 (ganache-core: 2.4.0)
  • Version of Truffle/Remix/Other tools used: Remix 0.7.5, Sol 0.5.2
  • NodeJS Version: [ ] 6.x, [ ] 7.x (unsupported), [x] 8.x, [ ] 9.x
  • Operating System and version (include distro if Linux): OSX 10.13
  • Link to your project or repro gist: https://gist.github.com/OFRBG/5930687e7e1da856ef604f9a00f3cc27
  • Commit hash to use with above link for reproduction:
  • I intend to submit a pull request to fix this issue: [ ]
@davidmurdoch
Copy link
Member

Thanks @OFRBG for filing this issue! I've confirmed that this is an issue when forking on v6.3.0 and v6.2.5.

@davidmurdoch
Copy link
Member

Just jotting down some of the research i've done on this one... This issue is caused by ForkedBlockchain.js's storageTrieCache object being shared between eth_sendTransaction and eth_estimateGas calls. eth_estimateGas essentially poison's the live cache instead of cloning and using it's own.

@davidmurdoch
Copy link
Member

This should now be fixed in our latest beta https://github.com/trufflesuite/ganache-core/releases/tag/v2.5.5-beta.0 Let me know if you have any more issues or if the fix doesn't work for you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants