trufflesuite / ganache-ui

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

Duplicate transaction hashes in the chain #931

Open dolencd opened 5 years ago

dolencd commented 5 years ago

Hi!

I wrote some software to test the performance of Ethereum networks. As a baseline I used Ganache. During testing I got some very strange results, so I decided to do some digging. There were indeed serious problems with the data in the chain and in the logs.

First, here are some log and output files: In order:

testerOutputTx5.txt Transaction data. When the transaction is sent it gets the txHash into the callback. During the test I record the time and this txHash, then, after the last transaction is sent and 5 empty blocks pass I get the data about the transactions. This is a .tsv file (i had to change the extension to upload it) with the following column order:

testerOutputBl5.txt Blocks in the chain. From the earliest transaction in the test to the latest transaction in the test. It's also a .tsv file and has the following column order:

ganache log.txt log from ganache (the LOGS tab)

web3 log.txt log from web3.js. I added logging to the code where requests are sent and responses received to see what is sent by and returned to web3.js

Let's take a look at the few cases:

The first transaction: 0x39de74d625c6d066886071a6ce2efd089e24f6bbddede38088cd3b4dfd2d460a in testerOutputTx it shows as the 1. and 12. transaction and it's the same in both the web3 and ganache logs. The ganache log places the transaction in blocks 2 and 24, while testerOutputBl shows it in 21 (it doesn't show the earlier one. Presumably because it's too early), but there's a 3 block difference. From the web3 log we can also see that the transactions originated from a different account, therefore the hash should be different

Another case: 0x94c5d9371a6cc69ee81ccf1f4e10cf65bff8bc4a9cd0ef480c28e9199d7fc36b

testerOutputTx places it as the 7., 16. and 27. transaction. testerOutputBl places it in blocks 10, 33 and 70, while the ganache log places it in 13, 36 and 73. All 3 transactions were sent from different accounts, but sent to the same account.

Yet another: 0xda07ce3c32b37e143592c73ab5999c08cd87a78912fff6b79083fa468adbe3df

Exactly the same as the last one. Just different block and transaction numbers. One important note is that they while they were all sent to the same account, it was a different one than last time.

Last one: 0x8e3c6a82afdb85c8f6f68f3890b5cc5d673ec3f76a37fbaaa36c89298081b4e7

Same as the last one.

There are lots of cases like this in the test which only has 100 transactions. I don't know how or why the constant 3-block difference happens (keep in mind testerOutputBl gets the data AFTER all the transactions are processed) The worse part is the fact that these transactions have the same txHash. I don't understand how this can happen and I'm sure it's not because of my tester.

i'm using Ganache 1.2.2 on Windows 10 and Web3.js 1.0.0 beta 35 with NodeJS 8.12.0 LTS

benjamincburns commented 5 years ago

@dolencd are you running these with truffle test? If so, I think what's happening is the evm_snapshot and evm_revert functionality is causing you to create transactions which (correctly) wind up with the same tx hash, and the UI is (for some reason) showing the old (reverted) versions of the transaction.

Can you please share a minimum viable reproduction project? That would help us quite a bit to validate & fix this bug.

dolencd commented 5 years ago

@benjamincburns I'm not using truffle at all, just ganache I have a Ganache instance started up and l connect to it using Web3JS in a NodeJS script.

I don't think it's a GUI issue. The only results I took from the GUI is the log from Ganache. The rest is from my software and was all gathered via the JSON RPC.

I'll try to get you some code that reproduces the issue.

dolencd commented 5 years ago

Here's the GitHub repo: https://github.com/LTFE/NetworkTester and the test file: E0001_1000_C.txt

Start Ganache, then follow the instructions in the readme and use this file as the input.

dolencd commented 5 years ago

Any progress on this? I'd really like to get it working.