From 3ebaaaff737a85d38d449eadefaeaf464991b602 Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Tue, 7 Jun 2022 17:00:39 -0400 Subject: [PATCH 1/2] AVM: Allow app downgrades in old protocol versions (#4086) --- config/consensus.go | 4 +++- ledger/internal/apptxn_test.go | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/config/consensus.go b/config/consensus.go index 07aa9ba84f..61ca55a2f8 100644 --- a/config/consensus.go +++ b/config/consensus.go @@ -910,6 +910,9 @@ func initConsensusProtocols() { // Enable application support v24.Application = true + // Although Inners were not allowed yet, this gates downgrade checks, which must be allowed + v24.MinInnerApplVersion = 6 + // Enable rekeying v24.SupportRekeying = true @@ -1090,7 +1093,6 @@ func initConsensusProtocols() { v31.LogicSigVersion = 6 v31.EnableInnerTransactionPooling = true v31.IsolateClearState = true - v31.MinInnerApplVersion = 6 // stat proof key registration v31.EnableStateProofKeyregCheck = true diff --git a/ledger/internal/apptxn_test.go b/ledger/internal/apptxn_test.go index 4e2b64c1a3..9194055c1e 100644 --- a/ledger/internal/apptxn_test.go +++ b/ledger/internal/apptxn_test.go @@ -2070,6 +2070,10 @@ func TestAppDowngrade(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() + two, err := logic.AssembleStringWithVersion("int 1", 2) + require.NoError(t, err) + three, err := logic.AssembleStringWithVersion("int 1", 3) + require.NoError(t, err) four, err := logic.AssembleStringWithVersion("int 1", 4) require.NoError(t, err) five, err := logic.AssembleStringWithVersion("int 1", 5) @@ -2078,6 +2082,40 @@ func TestAppDowngrade(t *testing.T) { require.NoError(t, err) genBalances, addrs, _ := ledgertesting.NewTestGenesis() + + // Confirm that in old protocol version, downgrade is legal + // Start at 28 because we want to v4 app to downgrade to v3 + testConsensusRange(t, 28, 30, func(t *testing.T, ver int) { + dl := NewDoubleLedger(t, genBalances, consensusByNumber[ver]) + defer dl.Close() + + create := txntest.Txn{ + Type: "appl", + Sender: addrs[0], + ApprovalProgram: four.Program, + ClearStateProgram: four.Program, + } + + vb := dl.fullBlock(&create) + app := vb.Block().Payset[0].ApplicationID + + update := txntest.Txn{ + Type: "appl", + ApplicationID: app, + OnCompletion: transactions.UpdateApplicationOC, + Sender: addrs[0], + ApprovalProgram: three.Program, + ClearStateProgram: three.Program, + } + + // No change - legal + dl.fullBlock(&update) + + update.ApprovalProgram = two.Program + // Also legal, and let's check mismatched version while we're at it. + dl.fullBlock(&update) + }) + testConsensusRange(t, 31, 0, func(t *testing.T, ver int) { dl := NewDoubleLedger(t, genBalances, consensusByNumber[ver]) defer dl.Close() From adb47f944bcc6b6fcddd85c963220a58d2623cef Mon Sep 17 00:00:00 2001 From: John Lee <64482439+algojohnlee@users.noreply.github.com> Date: Tue, 7 Jun 2022 17:33:23 -0400 Subject: [PATCH 2/2] Devops: Update buildnumber.dat (#4090) --- buildnumber.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildnumber.dat b/buildnumber.dat index 573541ac97..d00491fd7e 100644 --- a/buildnumber.dat +++ b/buildnumber.dat @@ -1 +1 @@ -0 +1