truffle icon indicating copy to clipboard operation
truffle copied to clipboard

Total Cost reports inaccurate

Open wbt opened this issue 6 years ago • 6 comments

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

wbt avatar Feb 19 '19 21:02 wbt

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 avatar Mar 25 '19 19:03 CruzMolina

@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.

wbt avatar Mar 28 '19 18:03 wbt

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?

MicaiahReid avatar May 12 '22 18:05 MicaiahReid

I'll likely be doing migrations again in a few months, and would be able to dive back into it then.

wbt avatar May 16 '22 15:05 wbt

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.

wbt avatar May 18 '22 12:05 wbt

Might be related to #1885.

cds-amal avatar Nov 17 '22 19:11 cds-amal