Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVM: inner appls can call v4 #3896

Merged
merged 13 commits into from
Apr 27, 2022
Merged

AVM: inner appls can call v4 #3896

merged 13 commits into from
Apr 27, 2022

Conversation

jannotti
Copy link
Contributor

@jannotti jannotti commented Apr 19, 2022

This PR allows inner app calls to v4 and v5 teal versions. The following prohibitions were added to make this safe.

  1. Inner app calls may not do an opt-in to an app that has a pre-v4 clear state program.
  2. v4 and above programs may not be downgraded.

Rule 1 ensures that an app can call the clearstate program as an inner. Rule 2 prevents an end-run around rule #1, by preventing an app with v5 CSP from downgrading to v3 at a later time.

The PR also introduces a DoubleLedger and testConsensusRange to make it easier to write ledger tests that need to operate over different consensus versions. It also makes it easy to write the tests in such a way that they continue to test the functionality they care about as we change the consensus version, but also continue to test the behavior on old version, to prevent regressions.

@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2022

Codecov Report

Merging #3896 (f210b66) into master (b0c551a) will increase coverage by 0.04%.
The diff coverage is 34.21%.

@@            Coverage Diff             @@
##           master    #3896      +/-   ##
==========================================
+ Coverage   50.01%   50.05%   +0.04%     
==========================================
  Files         393      393              
  Lines       68295    68316      +21     
==========================================
+ Hits        34156    34196      +40     
+ Misses      30433    30415      -18     
+ Partials     3706     3705       -1     
Impacted Files Coverage Δ
data/transactions/logic/opcodes.go 81.90% <ø> (ø)
data/transactions/transaction.go 36.15% <16.66%> (-0.73%) ⬇️
data/transactions/logic/eval.go 89.35% <28.57%> (-0.46%) ⬇️
config/consensus.go 85.62% <100.00%> (+0.08%) ⬆️
data/transactions/verify/txn.go 45.02% <100.00%> (+0.86%) ⬆️
data/transactions/verify/verifiedTxnCache.go 77.55% <100.00%> (ø)
ledger/apply/application.go 72.17% <100.00%> (ø)
util/metrics/gauge.go 65.38% <0.00%> (-2.57%) ⬇️
util/metrics/counter.go 86.20% <0.00%> (-2.30%) ⬇️
data/abi/abi_type.go 87.67% <0.00%> (-0.95%) ⬇️
... and 13 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 b0c551a...f210b66. Read the comment docs.

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

Mostly just browsing

jannotti and others added 9 commits April 26, 2022 11:50
AllowV4InnerAppls also means that apps can not perform an inner opt-in
to apps with <v4 CSP (since they might then be locked in). And no app
can downgrade, as that is a straightforward rule to prevent an app
from lowering its CSP and locking other apps into it.
The DoubleLedger does a lot of double checking on ledgers produced by
rerunning transactions after creating blocks, deserializing the txns
from the block and validating the results.

testConsensusRange makes it easy for ledger tests to test behavior in
many protocol levels. A particular problem it handles is that test can
be written to run from some consensus version and in every subsequent
version. So if we change behavior in a new version, we'll find out.
also converted more tests to testConsensusRange, and t.Parallel()
Review dog found an unused variable, which was a bug.  Added tests to
check for the bug that would have existed.
@jannotti jannotti requested a review from michaeldiamant April 27, 2022 00:09
Copy link
Contributor

@michaeldiamant michaeldiamant left a comment

Choose a reason for hiding this comment

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

@jannotti Thanks for working through a few rounds of feedback from my side. ☕

@jannotti jannotti merged commit 5af8ec8 into algorand:master Apr 27, 2022
@jannotti jannotti deleted the avm-appl-v4 branch April 27, 2022 14:10
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.

4 participants