Skip to content

Dryrun return cost#2746

Merged
algojohnlee merged 12 commits into
masterfrom
dryrunCost
Aug 26, 2021
Merged

Dryrun return cost#2746
algojohnlee merged 12 commits into
masterfrom
dryrunCost

Conversation

@AyAggarwal
Copy link
Copy Markdown
Contributor

This PR adds a Cost Parameter to DryrunResponse. It is calculated by giving the evalParams object in dryrun.go the maximum budget allowed (maxappcost * maxgroupsize) and checking the difference after stateful evaluation. LogicSig dryruns will return cost of 0.

Added a single test with sqrt and default opcodes

@jannotti
Copy link
Copy Markdown
Contributor

Seems like there's a gofmt error.

Make sure you have a test that uses more than 700 units.

I don't think cost should be returned at all in the json for logic sigs. That seems misleading. (It's possible it isn't, as we often omit 0s in responses.)

Comment thread daemon/algod/api/server/v2/dryrun.go
Comment on lines +127 to +128
t.Log("App Cost:")
t.Log(response.Cost)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed debug output

Copy link
Copy Markdown
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protocol modification does not look correct

Comment thread daemon/algod/api/server/v2/dryrun.go
Copy link
Copy Markdown
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need to decide how to handle some protocol parmater things, and test that the api response is updated to include cost.

Comment thread daemon/algod/api/server/v2/dryrun.go Outdated
Comment thread daemon/algod/api/server/v2/dryrun.go Outdated
Comment thread daemon/algod/api/server/v2/dryrun_test.go
Comment thread daemon/algod/api/server/v2/generated/types.go Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 18, 2021

Codecov Report

Merging #2746 (1f2817f) into master (80bd5ed) will decrease coverage by 0.00%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2746      +/-   ##
==========================================
- Coverage   47.14%   47.14%   -0.01%     
==========================================
  Files         349      349              
  Lines       56322    56345      +23     
==========================================
+ Hits        26553    26563      +10     
- Misses      26800    26813      +13     
  Partials     2969     2969              
Impacted Files Coverage Δ
cmd/goal/clerk.go 9.11% <0.00%> (-0.03%) ⬇️
daemon/algod/api/server/v2/dryrun.go 61.53% <84.61%> (+2.54%) ⬆️
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
agreement/cryptoVerifier.go 75.73% <0.00%> (-2.21%) ⬇️
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) ⬇️
data/transactions/verify/txn.go 45.08% <0.00%> (-0.90%) ⬇️
network/requestTracker.go 70.25% <0.00%> (-0.87%) ⬇️
catchup/service.go 69.35% <0.00%> (-0.78%) ⬇️
ledger/acctupdates.go 62.63% <0.00%> (+0.16%) ⬆️
cmd/tealdbg/debugger.go 73.86% <0.00%> (+1.00%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80bd5ed...1f2817f. Read the comment docs.

Comment thread daemon/algod/api/algod.oas3.yml Outdated
Comment thread daemon/algod/api/server/v2/dryrun.go
Comment thread daemon/algod/api/server/v2/dryrun.go Outdated
Comment thread daemon/algod/api/server/v2/dryrun.go Outdated
@AyAggarwal
Copy link
Copy Markdown
Contributor Author

AyAggarwal commented Aug 20, 2021

did 3 things:

  1. added better commenting to explain what is going on
  2. preserved user's EnableAppCostPooling choice and added logic to reject if any program is above maxAppCost if the user did not enable originally
  3. implemented maxCost estimate by using appCost * numAppCalls, and REJECT programs that surpass this. added tests for this case

Comment thread daemon/algod/api/algod.oas2.json Outdated
algorandskiy
algorandskiy previously approved these changes Aug 25, 2021
Copy link
Copy Markdown
Contributor

@shiqizng shiqizng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple questions, but others look fine to me.

require.Empty(t, response.Error)
require.Equal(t, 2, len(response.Txns))

//dryrun call will execute but fail because the first program exceeds max possible cost
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true for the test case 2, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I'll remove this old comment

-re {(ApprovalProgram)} {set PROGRAM_TYPE $expect_out(1,string); exp_continue}
"PASS" {set PASSED 1; close}
}
if { $COST == 0 } {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this always be true as long as line 12 is executed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks for "cost:" string in the output. if it is there then COST = 1 and this condition does trigger termination.

shiqizng
shiqizng previously approved these changes Aug 25, 2021
Copy link
Copy Markdown
Contributor

@shiqizng shiqizng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

jasonpaulos
jasonpaulos previously approved these changes Aug 25, 2021
Copy link
Copy Markdown
Contributor

@jasonpaulos jasonpaulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I have a suggestion to improve the cost budget exceeded message

Comment thread daemon/algod/api/server/v2/dryrun.go Outdated
@algorandskiy algorandskiy dismissed stale reviews from jasonpaulos and shiqizng via 1f2817f August 25, 2021 21:18
@onetechnical onetechnical dismissed jannotti’s stale review August 26, 2021 14:13

Ouddated, goal clerk changed and emits cost

@algojohnlee algojohnlee merged commit 2b03a60 into master Aug 26, 2021
@onetechnical onetechnical deleted the dryrunCost branch August 26, 2021 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants