diff --git a/config/consensus.go b/config/consensus.go index 4088083010..dfba6c3726 100644 --- a/config/consensus.go +++ b/config/consensus.go @@ -1228,19 +1228,27 @@ func initConsensusProtocols() { v33.ApprovedUpgrades[protocol.ConsensusV35] = 10000 v34.ApprovedUpgrades[protocol.ConsensusV35] = 10000 + v36 := v35 + v36.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} + + // Boxes (unlimited global storage) + v36.LogicSigVersion = 8 + v36.MaxBoxSize = 32768 + v36.BoxFlatMinBalance = 2500 + v36.BoxByteMinBalance = 400 + v36.MaxAppBoxReferences = 8 + v36.BytesPerBoxReference = 1024 + + Consensus[protocol.ConsensusV36] = v36 + + v35.ApprovedUpgrades[protocol.ConsensusV36] = 140000 + // ConsensusFuture is used to test features that are implemented // but not yet released in a production protocol version. - vFuture := v35 + vFuture := v36 vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} - vFuture.LogicSigVersion = 8 // When moving this to a release, put a new higher LogicSigVersion here - - // Boxes (unlimited global storage) - vFuture.MaxBoxSize = 32768 - vFuture.BoxFlatMinBalance = 2500 - vFuture.BoxByteMinBalance = 400 - vFuture.MaxAppBoxReferences = 8 - vFuture.BytesPerBoxReference = 1024 + vFuture.LogicSigVersion = 9 // When moving this to a release, put a new higher LogicSigVersion here Consensus[protocol.ConsensusFuture] = vFuture diff --git a/data/transactions/logic/eval_test.go b/data/transactions/logic/eval_test.go index 00b7ee1b13..9fa1753734 100644 --- a/data/transactions/logic/eval_test.go +++ b/data/transactions/logic/eval_test.go @@ -1105,6 +1105,10 @@ const globalV8TestProgram = globalV7TestProgram + ` // No new globals in v8 ` +const globalV9TestProgram = globalV8TestProgram + ` +// No new globals in v9 +` + func TestGlobal(t *testing.T) { partitiontest.PartitionTest(t) @@ -1124,6 +1128,7 @@ func TestGlobal(t *testing.T) { 6: {CallerApplicationAddress, globalV6TestProgram}, 7: {CallerApplicationAddress, globalV7TestProgram}, 8: {CallerApplicationAddress, globalV8TestProgram}, + 9: {CallerApplicationAddress, globalV9TestProgram}, } // tests keys are versions so they must be in a range 1..AssemblerMaxVersion plus zero version require.LessOrEqual(t, len(tests), AssemblerMaxVersion+1) @@ -1622,6 +1627,11 @@ assert int 1 ` +const testTxnProgramTextV9 = testTxnProgramTextV8 + ` +assert +int 1 +` + func makeSampleTxn() transactions.SignedTxn { var txn transactions.SignedTxn copy(txn.Txn.Sender[:], []byte("aoeuiaoeuiaoeuiaoeuiaoeuiaoeui00")) @@ -1733,6 +1743,7 @@ func TestTxn(t *testing.T) { 6: testTxnProgramTextV6, 7: testTxnProgramTextV7, 8: testTxnProgramTextV8, + 9: testTxnProgramTextV9, } for i, txnField := range TxnFieldNames { diff --git a/data/transactions/logic/frames_test.go b/data/transactions/logic/frames_test.go index f1c1780c3e..b02714a88a 100644 --- a/data/transactions/logic/frames_test.go +++ b/data/transactions/logic/frames_test.go @@ -178,7 +178,7 @@ main: + // This consumes the top arg. We could complain in assembly if checked stack height against pgm.fp dup; dup // But the dup;dup restores it, so it _evals_ fine. retsub -`, AssemblerMaxVersion) +`, fpVersion) } diff --git a/data/transactions/logic/langspec.json b/data/transactions/logic/langspec.json index 0b10ebdcb9..e637abedf1 100644 --- a/data/transactions/logic/langspec.json +++ b/data/transactions/logic/langspec.json @@ -1,6 +1,6 @@ { "EvalMaxVersion": 8, - "LogicSigVersion": 7, + "LogicSigVersion": 8, "Ops": [ { "Opcode": 0, diff --git a/data/transactions/logic/opcodes.go b/data/transactions/logic/opcodes.go index a392178e16..38dde2e085 100644 --- a/data/transactions/logic/opcodes.go +++ b/data/transactions/logic/opcodes.go @@ -24,7 +24,7 @@ import ( ) // LogicVersion defines default assembler and max eval versions -const LogicVersion = 8 +const LogicVersion = 9 // rekeyingEnabledVersion is the version of TEAL where RekeyTo functionality // was enabled. This is important to remember so that old TEAL accounts cannot diff --git a/ledger/apply/application_test.go b/ledger/apply/application_test.go index dd6213318b..e9e9f699c7 100644 --- a/ledger/apply/application_test.go +++ b/ledger/apply/application_test.go @@ -746,7 +746,7 @@ func TestAppCallOptIn(t *testing.T) { prevMaxAppsOptedIn := config.Consensus[protocol.ConsensusV24].MaxAppsOptedIn for _, testProtoVer := range optInCountTest { cparams, ok := config.Consensus[testProtoVer] - a.True(ok) + a.True(ok, testProtoVer) if cparams.MaxAppsOptedIn > 0 { a.LessOrEqual(prevMaxAppsOptedIn, cparams.MaxAppsOptedIn) } diff --git a/ledger/boxtxn_test.go b/ledger/boxtxn_test.go index 75b6a9fb13..a66a8a7a60 100644 --- a/ledger/boxtxn_test.go +++ b/ledger/boxtxn_test.go @@ -125,7 +125,7 @@ var passThruSource = main(` itxn_submit `) -const boxVersion = 35 +const boxVersion = 36 func boxFee(p config.ConsensusParams, nameAndValueSize uint64) uint64 { return p.BoxFlatMinBalance + p.BoxByteMinBalance*(nameAndValueSize) diff --git a/ledger/testing/consensusRange.go b/ledger/testing/consensusRange.go index 8eff9cdc72..877e03fae7 100644 --- a/ledger/testing/consensusRange.go +++ b/ledger/testing/consensusRange.go @@ -20,9 +20,7 @@ import ( "fmt" "testing" - "github.com/algorand/go-algorand/config" "github.com/algorand/go-algorand/protocol" - "github.com/algorand/go-algorand/test/partitiontest" "github.com/stretchr/testify/require" ) @@ -56,30 +54,11 @@ var consensusByNumber = []protocol.ConsensusVersion{ protocol.ConsensusV32, // unlimited assets and apps protocol.ConsensusV33, // 320 rounds protocol.ConsensusV34, // AVM v7, stateproofs + protocol.ConsensusV35, // minor, double upgrade withe v34 + protocol.ConsensusV36, // box storage protocol.ConsensusFuture, } -// TestReleasedVersion ensures that the necessary tidying is done when a new -// protocol release happens. The new version must be added to -// consensusByNumber, and a new LogicSigVersion must be added to vFuture. -func TestReleasedVersion(t *testing.T) { - partitiontest.PartitionTest(t) - t.Parallel() - - // This confirms that the proto before future has no ApprovedUpgrades. Once - // it does, that new version should be added to consensusByNumber. - require.Len(t, config.Consensus[consensusByNumber[len(consensusByNumber)-2]].ApprovedUpgrades, 0) - // And no funny business with vFuture - require.Equal(t, protocol.ConsensusFuture, consensusByNumber[len(consensusByNumber)-1]) - - // Ensure that vFuture gets a new LogicSigVersion when we promote the - // existing one. That allows TestExperimental in the logic package to - // prevent unintended releases of experimental opcodes. - relV := config.Consensus[consensusByNumber[len(consensusByNumber)-2]].LogicSigVersion - futureV := config.Consensus[protocol.ConsensusFuture].LogicSigVersion - require.Less(t, int(relV), int(futureV)) -} - // TestConsensusRange allows for running tests against a range of consensus // versions. Generally `start` will be the version that introduced the feature, // and `stop` will be 0 to indicate it should work right on up through vFuture. diff --git a/ledger/testing/consensusRange_test.go b/ledger/testing/consensusRange_test.go new file mode 100644 index 0000000000..df51ec7201 --- /dev/null +++ b/ledger/testing/consensusRange_test.go @@ -0,0 +1,58 @@ +// Copyright (C) 2019-2022 Algorand, Inc. +// This file is part of go-algorand +// +// go-algorand is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// go-algorand is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with go-algorand. If not, see . + +package testing + +import ( + "testing" + + "github.com/algorand/go-algorand/config" + "github.com/algorand/go-algorand/protocol" + "github.com/algorand/go-algorand/test/partitiontest" + "github.com/stretchr/testify/require" +) + +// TestReleasedVersion ensures that the necessary tidying is done when a new +// protocol release happens. The new version must be added to +// consensusByNumber, and a new LogicSigVersion must be added to vFuture. +func TestReleasedVersion(t *testing.T) { + partitiontest.PartitionTest(t) + t.Parallel() + + // This confirms that the proto before future has no ApprovedUpgrades. Once + // it does, that new version should be added to consensusByNumber. + require.Len(t, config.Consensus[consensusByNumber[len(consensusByNumber)-2]].ApprovedUpgrades, 0) + // And no funny business with vFuture + require.Equal(t, protocol.ConsensusFuture, consensusByNumber[len(consensusByNumber)-1]) + + // Ensure that vFuture gets a new LogicSigVersion when we promote the + // existing one. That allows TestExperimental in the logic package to + // prevent unintended releases of experimental opcodes. + relV := config.Consensus[consensusByNumber[len(consensusByNumber)-2]].LogicSigVersion + futureV := config.Consensus[protocol.ConsensusFuture].LogicSigVersion + require.Less(t, int(relV), int(futureV)) + + // Require that all are present + for _, cv := range consensusByNumber { + if cv == "" { + continue + } + params, ok := config.Consensus[cv] + require.True(t, ok, string(cv)) + require.NotZero(t, params) // just making sure an empty one didn't get put in + } + +} diff --git a/protocol/consensus.go b/protocol/consensus.go index cd03519fb4..51654ed3ff 100644 --- a/protocol/consensus.go +++ b/protocol/consensus.go @@ -192,6 +192,11 @@ const ConsensusV35 = ConsensusVersion( "https://github.com/algorandfoundation/specs/tree/433d8e9a7274b6fca703d91213e05c7e6a589e69", ) +// ConsensusV36 adds box storage +const ConsensusV36 = ConsensusVersion( + "https://github.com/algorandfoundation/specs/tree/44fa607d6051730f5264526bf3c108d51f0eadb6", +) + // ConsensusFuture is a protocol that should not appear in any production // network, but is used to test features before they are released. const ConsensusFuture = ConsensusVersion( @@ -218,7 +223,7 @@ const ConsensusVAlpha4 = ConsensusVersion("alpha4") // ConsensusCurrentVersion is the latest version and should be used // when a specific version is not provided. -const ConsensusCurrentVersion = ConsensusV35 +const ConsensusCurrentVersion = ConsensusV36 // Error is used to indicate that an unsupported protocol has been detected. type Error ConsensusVersion