flow-emulator icon indicating copy to clipboard operation
flow-emulator copied to clipboard

The displayed computationUsed is twice as much as the actual usage

Open script-money opened this issue 3 years ago • 2 comments

Instructions

When I was evaluating the gas consumption of the transaction, I found that the computationUsed exceeded 9999 and the transaction was still successful, and further exploration revealed that it was twice as the actual use.

Problem

The displayed computationUsed is twice as much as the actual usage

Steps to Reproduce

  1. Run flow emulator
  2. send any transaction, record the computationUsed
  3. set --gas-limt = computationUsed/2 - 1, send transaction again will fail
  4. set --gas-limt = computationUsed/2, send transaction again will success

flow version is Version: v0.30.2

script-money avatar Jan 25 '22 15:01 script-money

Thank you very much for the report.

I did notice something while I was reproducing this:

This transaction doesn't have this problem:

transaction() {
        prepare(acct: AuthAccount) {
                var i = 0
                while i<1000{
                        i = i + 1
                }
        }
        execute {}
}

while this one does:

transaction() {
        prepare(acct: AuthAccount) {
                AuthAccount(payer: acct)
                var i = 0
                while i<1000{
                        i = i + 1
                }
        }
        execute {}
}

janezpodhostnik avatar Jan 25 '22 19:01 janezpodhostnik

I though this sounded familiar https://github.com/onflow/flow-go/pull/1724.

This will be fixed with a new version of flow-go.

janezpodhostnik avatar Jan 25 '22 20:01 janezpodhostnik

can be closed I guess

bluesign avatar Sep 12 '22 08:09 bluesign