Skip to content

Conversation

@jannotti
Copy link
Contributor

@jannotti jannotti commented Feb 3, 2022

Prevents inner txns and bad opcode budget use in clear state programs.

Should also implement the "CSP requires 700 budget and can't spend
more than 700 budget" rule, but tests still required.
Co-authored-by: Michael Diamant <michaeldiamant@users.noreply.github.com>
}

func (e ClearStateBudgetError) Error() string {
return fmt.Sprintf("ClearState execution with only %d", e.offered)
Copy link
Contributor

@tzaffi tzaffi Feb 4, 2022

Choose a reason for hiding this comment

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

nit: can the error message refer to PooledApplicationBudget or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed:
return fmt.Sprintf("Attempted ClearState execution with low OpcodeBudget %d", e.offered)
That should call to mind the global OpcodeBudget which is the problem.

Copy link
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 correct, I just have questions/comments on tests.

Additionally, I don't think there's any tests for the changes in clear state budget? One suggestion would be a test where an app calls an inner clear state that has an infinite loop and we verify the global OpcodeBudget only decreases by ~700. Another test I'd like to see is one that makes sure ClearStateBudgetError actually fails the txn.

@jannotti
Copy link
Contributor Author

jannotti commented Feb 4, 2022

Looks correct, I just have questions/comments on tests.

Additionally, I don't think there's any tests for the changes in clear state budget? One suggestion would be a test where an app calls an inner clear state that has an infinite loop and we verify the global OpcodeBudget only decreases by ~700. Another test I'd like to see is one that makes sure ClearStateBudgetError actually fails the txn.

Correct, I still need both tests. Going into csp with less than 700 should NOT clear, but should fail. A csp that tries to take 701 should fail, but not kill caller, and should clear state.

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2022

Codecov Report

Merging #3556 (ecefe2b) into feature/contract-to-contract (84b52e7) will increase coverage by 0.07%.
The diff coverage is 60.00%.

Impacted file tree graph

@@                       Coverage Diff                        @@
##           feature/contract-to-contract    #3556      +/-   ##
================================================================
+ Coverage                         47.80%   47.88%   +0.07%     
================================================================
  Files                               370      370              
  Lines                             59959    60019      +60     
================================================================
+ Hits                              28665    28740      +75     
+ Misses                            27994    27977      -17     
- Partials                           3300     3302       +2     
Impacted Files Coverage Δ
data/transactions/logic/opcodes.go 100.00% <ø> (ø)
ledger/apply/application.go 79.52% <33.33%> (-0.67%) ⬇️
data/transactions/transaction.go 32.38% <46.15%> (+1.40%) ⬆️
data/transactions/logic/eval.go 85.60% <68.42%> (-0.32%) ⬇️
config/consensus.go 84.74% <100.00%> (+0.04%) ⬆️
ledger/internal/appcow.go 81.36% <100.00%> (+0.11%) ⬆️
ledger/blockqueue.go 82.18% <0.00%> (-2.88%) ⬇️
catchup/service.go 68.88% <0.00%> (-0.50%) ⬇️
data/transactions/msgp_gen.go 41.35% <0.00%> (+0.49%) ⬆️
network/wsPeer.go 68.61% <0.00%> (+0.55%) ⬆️
... and 9 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 84b52e7...ecefe2b. Read the comment docs.

@jannotti jannotti merged commit abe3c6a into algorand:feature/contract-to-contract Feb 6, 2022
Copy link
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.

Changes look good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants