trufflesuite / ganache-cli-archive

Fast Ethereum RPC client for testing and development. See https://github.com/trufflesuite/ganache for current development.
https://www.trufflesuite.com/ganache
MIT License
3.36k stars 695 forks source link

Ganache rejecting transaction at the socket level with an RST packet resulting in "Invalid JSON RPC response" #611

Closed roschler closed 5 years ago

roschler commented 5 years ago

I did not post the question on the Gitter Truffle channel because my success rate in getting a response for difficult questions is very low there. Please see this issue I posted initially on the Web3 JS repo and have linked to at the bottom of this post, since at first that appeared to be where the problem was located. Now the maintainer of the Web3 repo and I believe it's a Ganache CLI or Core problem.

This hypothesis is strengthened by a test I recently ran that shows that ganache-cli rejects my request at the raw socket level with an immediate RST response. My request never reaches the event handler in httpServer.js within ganache-cli. I know this because I have forked that repo and have it running in an IDE along with my dApp. In that IDE I have a breakpoint set on the request on-data handler in the httpServer.js module and that breakpoint is never hit when I execute the smart contract method call that is failing. This make sense because as I just said, Ganache is rejecting the request at the socket level. The breakpoint does get hit when I execute several of the other smart contract methods calls I can make successfully, and when Metamask executes a transaction, but not with the specific method I call that is failing for me.

Please see this Github issue linked to below in the Web3 repo for full details on the problem and some screenshots showing the Wireshark captures I made:

https://github.com/ethereum/web3.js/issues/2135

davidmurdoch commented 5 years ago

@roschler Thanks for filing the issue! Can you provide the implementation details of the function that is failing for you? If not, can you provide a minimal reproduction of the issue?

roschler commented 5 years ago

@davidmurdoch Hi David. I am working on a minimal repo now. I also have just downloaded Ganache 2.0 and will be creating the test around that version instead of v 1.2.2. It will take a while because the smart contract method that fails occurs after several other different smart contract methods have executed before it. Unfortunately each method call is dependent on the previous call having executed properly since they each affect the state of the smart contract, which is why this will take a little while. In other words, I am creating a test case that extracts all the transactions that occur during the execution of a game in my dApp, into a linear sequence of Ethereum transactions that all occur in a single pass. Once I've completed this I'll post here again with a link to the repo containing the code.

Thanks for replying.

roschler commented 5 years ago

@davidmurdoch Hello David. I have just finished a private repo and added you and Samuel as collaborators. Let me know if you got the invite. Thanks in advance for your help.

roschler commented 5 years ago

@davidmurdoch Did you ever get a chance to look at the private repo I made for you? My dApp development is on hold because I can't get past this error. I really want to finish the dApp. It's a really fun game and helps raise money for musicians so I believe the Ethereum community will really like it.

roschler commented 5 years ago

I'm cross-posting this solution to this problem because it involves several important fundamental Ethereum/Ganache development issues, and I want to make sure other developers can benefit from the information that solved the issue for me, along with @seesemichaelj Mike's tremendous help:

https://github.com/trufflesuite/ganache/issues/1057#issuecomment-453770649