Total Cost reports inaccurate
Issue
In Truffle 5, the "migrate" command is much more verbose, and at the end of each migration a "Total cost" is reported, with a "final cost" at the end. These amounts are incorrect.
Steps to Reproduce
Use this repo and its readme for steps to reproduce. Use a relatively low value, like 500, for transactionsToRun in migration 3 (step 4), to avoid the other errors that repo helps illustrate.
Expected Behavior
The sum of migration "total cost" reports should equal the difference in account balance before - after the migration.
Actual Results
The reported "total cost" and "final cost" are much less than the amount the account balanced has decreased during the execution of that migration.
Environment
- Operating System: Windows 10 Pro
- Ethereum client: Ganache, tested with versions 1.3.0 and 2.0.0-beta2
- Truffle version (
truffle version): 5.0.4 - node version (
node --version): 9.3.0 - npm version (
npm --version): 6.8.0
Wow, really good find @wbt. I see you've already opened an issue for this at trufflesuite/ganache#1131. So far this looks more like a Ganache issue than truffle.
@CruzMolina These are different issues, with incorrect totals being reported in different places. The Ganache issue is that the account balance and transaction account shown in Ganache is temporarily incorrect while a set of transactions is processing, and the user has no way to know the display is currently incorrect and just needs a few minutes to catch up.
This Issue is about the line output by Truffle at the end of a migration and/or set of migrations, after Truffle has had as much opportunity as it wants to for calculation and summing up the total. Without having done a deep dive into the code, the appearance is that Truffle is calculating this output figure incorrectly, maybe omitting transactions that neither send ETH nor create new contract instances.
I think it is a separate issue with a separate fix, and that the fix for this is in Truffle code, more specifically in Truffle code that was new for v5.
Hi @wbt! We've been going through some of the older issues in our backlog and came across this. Do you have a way to confirm if this is still an issue?
I'll likely be doing migrations again in a few months, and would be able to dive back into it then.
Due to unexpected circumstances, I wound up doing migrations again much sooner than expected, and find that the issue still exists. On a deeper re-read, there is also a repro repo linked to above that others can use to test in case Covid-19 kills me off or something like that.
Might be related to #1885.