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

BUG: EXTCODESIZE returns 0 on newly deployed contract in forking mode #454

Closed
niklasb opened this issue Jul 17, 2019 · 2 comments · Fixed by #488
Closed

BUG: EXTCODESIZE returns 0 on newly deployed contract in forking mode #454

niklasb opened this issue Jul 17, 2019 · 2 comments · Fixed by #488

Comments

@niklasb
Copy link
Contributor

niklasb commented Jul 17, 2019

Ganache in fork mode should allow for deployment of contracts and subsequent querying via EXTCODESIZE, but this is currently broken, as pointed by @elenadimitrova in #652 (comment). I have seen the same behavior in my personal experiments with ganache forking mode for testing mainnet deployments.

Expected Behavior

EXTCODESIZE on newly deployed contracts should work as expected.

Current Behavior

EXTCODESIZE on newly deployed contracts returns 0.

Steps to Reproduce (for bugs)

See https://github.com/niklasb/ganache-fork-bugs for an example and reproduction setup.

Context

This pretty much renders fork mode useless to test or replay live transactions that involve contract deployments.

@niklasb
Copy link
Contributor Author

niklasb commented Jul 17, 2019

Now in theory this could also mean the contract is not deployed at all, hard to say without digging into the implementation

@davidmurdoch
Copy link
Member

Finally looked into this one, @niklasb (cc @elenadimitrova - this should fix your related bug too). The issue is that forking's getCode implementation is not currently aware of the VM's internal cache, and only aware of the currently committed state. We have an a fix which passes your EXTCODESIZE test and all of our other tests, but it removes a whole lot of our existing code that apparently does nothing at all or just was never actually being tested in the first place. Either way, we'll need to take some time to validate this code before merging and shipping.

We hope to tackle all these forking-related bugs over the next few weeks ahead of DevCon 5!

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

Successfully merging a pull request may close this issue.

3 participants