algorand / go-algorand

Algorand's official implementation in Go.
https://developer.algorand.org/
Other
1.35k stars 473 forks source link

DryrunTxnResult reports cost near MaxUint64 #3789

Closed barnjamin closed 1 year ago

barnjamin commented 2 years ago

Subject of the issue

Running some dryrun request against the algod /v2/teal/dryrun endpoint results in a cost close to MaxUint64.

Dryrun Request and Dryrun Response included in zipped file dryruns.zip

Its likely the uint64 cast of the cost determined rolled some negative number past zero https://github.com/algorand/go-algorand/blob/master/daemon/algod/api/server/v2/dryrun.go#L542

Your environment

sandbox with go-algorand 3.5.0

Steps to reproduce

curl -XPOST "http://localhost:4001/v2/teal/dryrun" \
    -H "X-Algo-API-Token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
    --data-binary @dryrun_request.msgp

Expected behaviour

Actual cost up to error is reported

Actual behaviour

Wild cost reported

jannotti commented 2 years ago

Yes, that cast is giving the huge u64. The underlying problem is that the way we track the cost of a transaction doesn't work in the new world in which transactions can increased their budget by issuing inner app calls. We calculate cost as "starting budget - ending budget". So, if a call adds more budget that it consumes, the answer is negative.

I think I'm actually in favor of reporting this as a negative cost. That would mean changing the type of the return value to i64 or just int. Not sure how much that messes with backward compatibility.