diff options
author | Pavel Zbitskiy <65323360+algorandskiy@users.noreply.github.com> | 2022-08-09 13:28:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-09 13:28:27 -0400 |
commit | 60fb4f6d323fc67254d6ac24fa4ae4438ae113e4 (patch) | |
tree | f11c367c9f7c28e0efed598d1e48310f07584434 | |
parent | 9a03260c8bf1824dbe8a9ca62d93e751939cb95e (diff) |
consensus: introduce v33, v34 (#4334)algobarb/60fb4f6
* State proofs
* TEAL v7
* 5 MiB blocks
* 3.4s FilterTimeout
-rw-r--r-- | agreement/service_test.go | 2 | ||||
-rw-r--r-- | catchup/service_test.go | 7 | ||||
-rw-r--r-- | config/consensus.go | 62 | ||||
-rw-r--r-- | crypto/merklesignature/kats_test.go | 2 | ||||
-rw-r--r-- | daemon/algod/api/server/v2/test/handlers_test.go | 2 | ||||
-rw-r--r-- | data/account/participationRegistry_test.go | 5 | ||||
-rw-r--r-- | data/bookkeeping/txn_merkle_test.go | 2 | ||||
-rw-r--r-- | data/pools/transactionPool_test.go | 10 | ||||
-rw-r--r-- | data/transactions/logic/assembler_test.go | 1 | ||||
-rw-r--r-- | data/transactions/logic/eval_test.go | 8 | ||||
-rw-r--r-- | data/transactions/logic/langspec.json | 2 | ||||
-rw-r--r-- | data/transactions/logic/opcodes.go | 2 | ||||
-rw-r--r-- | data/transactions/transaction_test.go | 2 | ||||
-rw-r--r-- | ledger/acctonline_test.go | 2 | ||||
-rw-r--r-- | ledger/blockHeaderCache_test.go | 3 | ||||
-rw-r--r-- | ledger/internal/apptxn_test.go | 12 | ||||
-rw-r--r-- | ledger/internal/eval_blackbox_test.go | 14 | ||||
-rw-r--r-- | ledger/ledger_test.go | 16 | ||||
-rw-r--r-- | ledger/voters_test.go | 50 | ||||
-rw-r--r-- | protocol/consensus.go | 13 | ||||
-rw-r--r-- | stateproof/stateproofMessageGenerator_test.go | 30 | ||||
-rw-r--r-- | stateproof/worker_test.go | 67 |
22 files changed, 181 insertions, 133 deletions
diff --git a/agreement/service_test.go b/agreement/service_test.go index 453403eb3..b5ec2ce61 100644 --- a/agreement/service_test.go +++ b/agreement/service_test.go @@ -1968,7 +1968,7 @@ func TestAgreementSlowPayloadsPostDeadline(t *testing.T) { activityMonitor.waitForQuiet() zeroes = expectNoNewPeriod(clocks, zeroes) - triggerGlobalTimeout(FilterTimeout(0, version), clocks, activityMonitor) + triggerGlobalTimeout(FilterTimeout(1, version), clocks, activityMonitor) zeroes = expectNewPeriod(clocks, zeroes) } diff --git a/catchup/service_test.go b/catchup/service_test.go index 972370180..679ee3239 100644 --- a/catchup/service_test.go +++ b/catchup/service_test.go @@ -977,10 +977,11 @@ func TestSynchronizingTime(t *testing.T) { func TestDownloadBlocksToSupportStateProofs(t *testing.T) { partitiontest.PartitionTest(t) + // make sure we download enough blocks to verify state proof 512 topBlk := bookkeeping.Block{} topBlk.BlockHeader.Round = 1500 - topBlk.BlockHeader.CurrentProtocol = protocol.ConsensusFuture + topBlk.BlockHeader.CurrentProtocol = protocol.ConsensusCurrentVersion trackingData := bookkeeping.StateProofTrackingData{StateProofNextRound: 512} topBlk.BlockHeader.StateProofTracking = make(map[protocol.StateProofType]bookkeeping.StateProofTrackingData) topBlk.BlockHeader.StateProofTracking[protocol.StateProofBasic] = trackingData @@ -993,7 +994,7 @@ func TestDownloadBlocksToSupportStateProofs(t *testing.T) { // instead, we will download blocks to confirm only the recovery period lookback. topBlk = bookkeeping.Block{} topBlk.BlockHeader.Round = 8000 - topBlk.BlockHeader.CurrentProtocol = protocol.ConsensusFuture + topBlk.BlockHeader.CurrentProtocol = protocol.ConsensusCurrentVersion trackingData = bookkeeping.StateProofTrackingData{StateProofNextRound: 512} topBlk.BlockHeader.StateProofTracking = make(map[protocol.StateProofType]bookkeeping.StateProofTrackingData) topBlk.BlockHeader.StateProofTracking[protocol.StateProofBasic] = trackingData @@ -1001,7 +1002,7 @@ func TestDownloadBlocksToSupportStateProofs(t *testing.T) { lookback = lookbackForStateproofsSupport(&topBlk) oldestRound = topBlk.BlockHeader.Round.SubSaturate(basics.Round(lookback)) - lowestRoundToRetain := 8000 - (8000 % 256) - (config.Consensus[protocol.ConsensusFuture].StateProofInterval * (config.Consensus[protocol.ConsensusFuture].StateProofMaxRecoveryIntervals + 1)) + lowestRoundToRetain := 8000 - (8000 % 256) - (config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval * (config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals + 1)) assert.Equal(t, uint64(oldestRound), lowestRoundToRetain) topBlk = bookkeeping.Block{} diff --git a/config/consensus.go b/config/consensus.go index 5896f97d9..af0b50e53 100644 --- a/config/consensus.go +++ b/config/consensus.go @@ -1150,37 +1150,59 @@ func initConsensusProtocols() { // v31 can be upgraded to v32, with an update delay of 7 days ( see calculation above ) v31.ApprovedUpgrades[protocol.ConsensusV32] = 140000 - // ConsensusFuture is used to test features that are implemented - // but not yet released in a production protocol version. - vFuture := v32 - vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} + v33 := v32 + v33.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} // Make the accounts snapshot for round X at X-CatchpointLookback - vFuture.CatchpointLookback = 320 + // order to guarantee all nodes produce catchpoint at the same round. + v33.CatchpointLookback = 320 // Require MaxTxnLife + X blocks and headers preserved by a node - vFuture.DeeperBlockHeaderHistory = 1 + v33.DeeperBlockHeaderHistory = 1 + + v33.MaxTxnBytesPerBlock = 5 * 1024 * 1024 + + Consensus[protocol.ConsensusV33] = v33 + + // v32 can be upgraded to v33, with an update delay of 7 days ( see calculation above ) + v32.ApprovedUpgrades[protocol.ConsensusV33] = 140000 + + v34 := v33 + v34.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} // Enable state proofs. - vFuture.StateProofInterval = 256 - vFuture.StateProofTopVoters = 1024 - vFuture.StateProofVotersLookback = 16 - vFuture.StateProofWeightThreshold = (1 << 32) * 30 / 100 - vFuture.StateProofStrengthTarget = 256 - vFuture.StateProofMaxRecoveryIntervals = 10 + v34.StateProofInterval = 256 + v34.StateProofTopVoters = 1024 + v34.StateProofVotersLookback = 16 + v34.StateProofWeightThreshold = (1 << 32) * 30 / 100 + v34.StateProofStrengthTarget = 256 + v34.StateProofMaxRecoveryIntervals = 10 - vFuture.LogicSigVersion = 7 // When moving this to a release, put a new higher LogicSigVersion here - vFuture.MinInnerApplVersion = 4 + v34.LogicSigVersion = 7 + v34.MinInnerApplVersion = 4 - vFuture.UnifyInnerTxIDs = true + v34.UnifyInnerTxIDs = true - vFuture.EnableSHA256TxnCommitmentHeader = true - vFuture.EnableOnlineAccountCatchpoints = true + v34.EnableSHA256TxnCommitmentHeader = true + v34.EnableOnlineAccountCatchpoints = true - vFuture.UnfundedSenders = true + v34.UnfundedSenders = true + + v34.AgreementFilterTimeoutPeriod0 = 3400 * time.Millisecond + + Consensus[protocol.ConsensusV34] = v34 + + // v33 can be upgraded to v34, with an update delay of 12h: + // 10046 = (12 * 60 * 60 / 4.3) + // for the sake of future manual calculations, we'll round that down a bit : + v33.ApprovedUpgrades[protocol.ConsensusV34] = 10000 + + // ConsensusFuture is used to test features that are implemented + // but not yet released in a production protocol version. + vFuture := v34 + vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} - vFuture.AgreementFilterTimeoutPeriod0 = 3400 * time.Millisecond - vFuture.MaxTxnBytesPerBlock = 5 * 1024 * 1024 + vFuture.LogicSigVersion = 8 // When moving this to a release, put a new higher LogicSigVersion here Consensus[protocol.ConsensusFuture] = vFuture } diff --git a/crypto/merklesignature/kats_test.go b/crypto/merklesignature/kats_test.go index 8a48d699b..bc61ec47b 100644 --- a/crypto/merklesignature/kats_test.go +++ b/crypto/merklesignature/kats_test.go @@ -60,7 +60,7 @@ func generateMssKat(startRound, atRound, numOfKeys uint64, messageToSign []byte) return mssKat{}, fmt.Errorf("error: Signature round cann't be smaller then start round") } - interval := config.Consensus[protocol.ConsensusFuture].StateProofInterval + interval := config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval stateProofSecrets, err := New(startRound, startRound+(interval*numOfKeys)-1, interval) if err != nil { return mssKat{}, fmt.Errorf("error: %w", err) diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index 10e89deaf..f8b7e4eb5 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -1030,7 +1030,7 @@ func insertRounds(a *require.Assertions, h v2.Handlers, numRounds int) { for i := 0; i < numRounds; i++ { blk := newEmptyBlock(a, lastBlk, genBlk, ledger) blk = addStateProofIfNeeded(blk) - blk.BlockHeader.CurrentProtocol = protocol.ConsensusFuture + blk.BlockHeader.CurrentProtocol = protocol.ConsensusCurrentVersion a.NoError(ledger.(*data.Ledger).AddBlock(blk, agreement.Certificate{})) lastBlk = blk } diff --git a/data/account/participationRegistry_test.go b/data/account/participationRegistry_test.go index 61b78adac..8e02ff4e4 100644 --- a/data/account/participationRegistry_test.go +++ b/data/account/participationRegistry_test.go @@ -47,8 +47,7 @@ import ( "github.com/algorand/go-algorand/util/db" ) -// TODO: change to ConsensusCurrentVersion when updated -var stateProofIntervalForTests = config.Consensus[protocol.ConsensusFuture].StateProofInterval +var stateProofIntervalForTests = config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval func getRegistry(t testing.TB) (registry *participationDB, dbfile string) { return getRegistryImpl(t, true, false) @@ -1222,7 +1221,7 @@ func TestParticipationDB_Locking(t *testing.T) { const targetFlushes = 5 go func() { for i := 0; i < 25; i++ { - registry.DeleteExpired(basics.Round(i), config.Consensus[protocol.ConsensusFuture]) + registry.DeleteExpired(basics.Round(i), config.Consensus[protocol.ConsensusCurrentVersion]) registry.Flush(defaultTimeout) if atomic.LoadInt32(&flushCount) < targetFlushes { atomic.AddInt32(&flushCount, 1) diff --git a/data/bookkeeping/txn_merkle_test.go b/data/bookkeeping/txn_merkle_test.go index 977af620d..30a34ab7f 100644 --- a/data/bookkeeping/txn_merkle_test.go +++ b/data/bookkeeping/txn_merkle_test.go @@ -94,7 +94,7 @@ func TestBlock_TxnMerkleTreeSHA256(t *testing.T) { for ntxn := uint64(0); ntxn < 128; ntxn++ { var b Block - b.CurrentProtocol = protocol.ConsensusFuture + b.CurrentProtocol = protocol.ConsensusCurrentVersion crypto.RandBytes(b.BlockHeader.GenesisHash[:]) var elems []txnMerkleElem diff --git a/data/pools/transactionPool_test.go b/data/pools/transactionPool_test.go index d4c863d44..7dcc4c6ba 100644 --- a/data/pools/transactionPool_test.go +++ b/data/pools/transactionPool_test.go @@ -1281,10 +1281,10 @@ func TestTxPoolSizeLimits(t *testing.T) { } } -func TestTStateProofLogging(t *testing.T) { +func TestStateProofLogging(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] cfg := config.GetDefaultLocal() cfg.TxPoolSize = testPoolSize @@ -1331,7 +1331,7 @@ func TestTStateProofLogging(t *testing.T) { logger.SetOutput(&buf) // Set the ledger and the transaction pool - mockLedger := makeMockLedgerFuture(t, initAccounts) + mockLedger := makeMockLedger(t, initAccounts) transactionPool := MakeTransactionPool(mockLedger, cfg, logger) transactionPool.logAssembleStats = true @@ -1339,7 +1339,7 @@ func TestTStateProofLogging(t *testing.T) { var b bookkeeping.Block b.BlockHeader.GenesisID = "pooltest" b.BlockHeader.GenesisHash = mockLedger.GenesisHash() - b.CurrentProtocol = protocol.ConsensusFuture + b.CurrentProtocol = protocol.ConsensusCurrentVersion b.BlockHeader.Round = 1 phdr, err := mockLedger.BlockHdr(0) @@ -1472,7 +1472,7 @@ func generateProofForTesting( } // Prepare the builder - stateProofStrengthTargetForTests := config.Consensus[protocol.ConsensusFuture].StateProofStrengthTarget + stateProofStrengthTargetForTests := config.Consensus[protocol.ConsensusCurrentVersion].StateProofStrengthTarget b, err := cryptostateproof.MakeBuilder(data, round, provenWeight, partArray, partTree, stateProofStrengthTargetForTests) require.NoError(t, err) diff --git a/data/transactions/logic/assembler_test.go b/data/transactions/logic/assembler_test.go index 9bd1fc91f..24d9dffd0 100644 --- a/data/transactions/logic/assembler_test.go +++ b/data/transactions/logic/assembler_test.go @@ -423,6 +423,7 @@ var compiled = map[uint64]string{ 5: "052004010002b7a60c26050242420c68656c6c6f20776f726c6421070123456789abcd208dae2087fbba51304eb02b91f656948397a7946390e8cb70fc9ea4d95f92251d047465737400320032013202320380021234292929292b0431003101310231043105310731083109310a310b310c310d310e310f3111311231133114311533000033000133000233000433000533000733000833000933000a33000b33000c33000d33000e33000f3300113300123300133300143300152d2e01022581f8acd19181cf959a1281f8acd19181cf951a81f8acd19181cf1581f8acd191810f082209240a220b230c240d250e230f23102311231223132314181b1c28171615400003290349483403350222231d4a484848482b50512a632223524100034200004322602261222704634848222862482864286548482228246628226723286828692322700048482371004848361c0037001a0031183119311b311d311e311f312023221e312131223123312431253126312731283129312a312b312c312d312e312f447825225314225427042455220824564c4d4b0222382124391c0081e80780046a6f686e2281d00f23241f880003420001892224902291922494249593a0a1a2a3a4a5a6a7a8a9aaabacadae24af3a00003b003c003d816472064e014f012a57000823810858235b235a2359b03139330039b1b200b322c01a23c1001a2323c21a23c3233e233f8120af06002a494905002a49490700b53a03", 6: "06" + v6Compiled, 7: "07" + v7Compiled, + 8: "08" + v8Compiled, } func pseudoOp(opcode string) bool { diff --git a/data/transactions/logic/eval_test.go b/data/transactions/logic/eval_test.go index 734f4ba6c..ba7df73e9 100644 --- a/data/transactions/logic/eval_test.go +++ b/data/transactions/logic/eval_test.go @@ -1064,6 +1064,10 @@ const globalV7TestProgram = globalV6TestProgram + ` // No new globals in v7 ` +const globalV8TestProgram = globalV7TestProgram + ` +// No new globals in v7 +` + func TestGlobal(t *testing.T) { partitiontest.PartitionTest(t) @@ -1082,6 +1086,7 @@ func TestGlobal(t *testing.T) { 5: {GroupID, globalV5TestProgram}, 6: {CallerApplicationAddress, globalV6TestProgram}, 7: {CallerApplicationAddress, globalV7TestProgram}, + 8: {CallerApplicationAddress, globalV8TestProgram}, } // tests keys are versions so they must be in a range 1..AssemblerMaxVersion plus zero version require.LessOrEqual(t, len(tests), AssemblerMaxVersion+1) @@ -1558,6 +1563,8 @@ assert int 1 ` +const testTxnProgramTextV8 = testTxnProgramTextV7 + func makeSampleTxn() transactions.SignedTxn { var txn transactions.SignedTxn copy(txn.Txn.Sender[:], []byte("aoeuiaoeuiaoeuiaoeuiaoeuiaoeui00")) @@ -1660,6 +1667,7 @@ func TestTxn(t *testing.T) { 5: testTxnProgramTextV5, 6: testTxnProgramTextV6, 7: testTxnProgramTextV7, + 8: testTxnProgramTextV8, } for i, txnField := range TxnFieldNames { diff --git a/data/transactions/logic/langspec.json b/data/transactions/logic/langspec.json index 0095a6e25..4e29b9a88 100644 --- a/data/transactions/logic/langspec.json +++ b/data/transactions/logic/langspec.json @@ -1,6 +1,6 @@ { "EvalMaxVersion": 7, - "LogicSigVersion": 6, + "LogicSigVersion": 7, "Ops": [ { "Opcode": 0, diff --git a/data/transactions/logic/opcodes.go b/data/transactions/logic/opcodes.go index 5b31e5d86..dc5627422 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 = 7 +const LogicVersion = 8 // 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/data/transactions/transaction_test.go b/data/transactions/transaction_test.go index 45fd1ca49..bac43c22c 100644 --- a/data/transactions/transaction_test.go +++ b/data/transactions/transaction_test.go @@ -614,7 +614,7 @@ func TestWellFormedKeyRegistrationTx(t *testing.T) { selectionPKValue := crypto.VRFVerifier{0x7, 0xda, 0xcb, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x22, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21} stateProofPK := merklesignature.Commitment([merklesignature.MerkleSignatureSchemeRootSize]byte{1}) - maxValidPeriod := config.Consensus[protocol.ConsensusFuture].MaxKeyregValidPeriod // TODO: change to curProto.MaxKeyregValidPeriod + maxValidPeriod := config.Consensus[protocol.ConsensusCurrentVersion].MaxKeyregValidPeriod runTestCase := func(testCase keyRegTestCase) error { diff --git a/ledger/acctonline_test.go b/ledger/acctonline_test.go index f4c4fc0b1..c1d14b43e 100644 --- a/ledger/acctonline_test.go +++ b/ledger/acctonline_test.go @@ -1135,7 +1135,7 @@ func TestAcctOnlineVotersLongerHistory(t *testing.T) { addSinkAndPoolAccounts(genesisAccts) testProtocolVersion := protocol.ConsensusVersion("test-protocol-TestAcctOnlineCacheDBSync") - protoParams := config.Consensus[protocol.ConsensusFuture] + protoParams := config.Consensus[protocol.ConsensusCurrentVersion] protoParams.MaxBalLookback = maxBalLookback protoParams.SeedLookback = seedLookback protoParams.SeedRefreshInterval = seedInteval diff --git a/ledger/blockHeaderCache_test.go b/ledger/blockHeaderCache_test.go index 6c8973435..a5fac5ae6 100644 --- a/ledger/blockHeaderCache_test.go +++ b/ledger/blockHeaderCache_test.go @@ -90,6 +90,5 @@ func TestCacheSizeConsensus(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - // TODO Stateproof: change to CurrentVersion when feature is enabled - a.Equal(uint64(latestHeaderCacheSize), config.Consensus[protocol.ConsensusFuture].StateProofInterval*2) + a.Equal(uint64(latestHeaderCacheSize), config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*2) } diff --git a/ledger/internal/apptxn_test.go b/ledger/internal/apptxn_test.go index 5f6d4b26a..fdbc64aca 100644 --- a/ledger/internal/apptxn_test.go +++ b/ledger/internal/apptxn_test.go @@ -1890,7 +1890,7 @@ func TestInnerAppVersionCalling(t *testing.T) { genBalances, addrs, _ := ledgertesting.NewTestGenesis() - // 31 allowed inner appls. v33 lowered proto.MinInnerApplVersion + // 31 allowed inner appls. v34 lowered proto.MinInnerApplVersion testConsensusRange(t, 31, 0, func(t *testing.T, ver int) { dl := NewDoubleLedger(t, genBalances, consensusByNumber[ver]) defer dl.Close() @@ -1977,7 +1977,7 @@ itxn_begin itxn_submit`, } - if ver <= 32 { + if ver <= 33 { dl.txn(&call, "inner app call with version v5 < v6") call.ForeignApps[0] = v6id dl.txn(&call, "overspend") // it tried to execute, but test doesn't bother funding @@ -1986,7 +1986,7 @@ itxn_submit`, createAndOptin.ApplicationArgs = [][]byte{three.Program, three.Program} dl.txn(&createAndOptin, "inner app call with version v3 < v6") - // nor v5 in proto ver 32 + // nor v5 in proto ver 33 createAndOptin.ApplicationArgs = [][]byte{five.Program, five.Program} dl.txn(&createAndOptin, "inner app call with version v5 < v6") @@ -1994,7 +1994,7 @@ itxn_submit`, createAndOptin.ApplicationArgs = [][]byte{six.Program, six.Program} dl.txn(&createAndOptin, "overspend") // passed the checks, but is an overspend } else { - // after 32 proto.MinInnerApplVersion is lowered to 4, so calls and optins to v5 are ok + // after 33 proto.MinInnerApplVersion is lowered to 4, so calls and optins to v5 are ok dl.txn(&call, "overspend") // it tried to execute, but test doesn't bother funding dl.txn(&optin, "overspend") // it tried to execute, but test doesn't bother funding optin.ForeignApps[0] = v5withv3csp // but we can't optin to a v5 if it has an old csp @@ -2152,7 +2152,7 @@ func TestAppDowngrade(t *testing.T) { // Downgrade (allowed for pre 6 programs until MinInnerApplVersion was lowered) update.ClearStateProgram = four.Program - if ver <= 32 { + if ver <= 33 { dl.fullBlock(update.Noted("actually a repeat of first upgrade")) } else { dl.txn(update.Noted("actually a repeat of first upgrade"), "clearstate program version downgrade") @@ -3146,7 +3146,7 @@ itxn_submit } dl.beginBlock() - if ver <= 32 { + if ver <= 33 { dl.txgroup("invalid Account reference", &fund0, &fund1, &callTx) dl.endBlock() return diff --git a/ledger/internal/eval_blackbox_test.go b/ledger/internal/eval_blackbox_test.go index a296f6539..5a533ba8f 100644 --- a/ledger/internal/eval_blackbox_test.go +++ b/ledger/internal/eval_blackbox_test.go @@ -898,6 +898,8 @@ var consensusByNumber = []protocol.ConsensusVersion{ protocol.ConsensusV30, // AVM v5 (inner txs) protocol.ConsensusV31, // AVM v6 (inner txs with appls) protocol.ConsensusV32, // unlimited assets and apps + protocol.ConsensusV33, // 320 rounds + protocol.ConsensusV34, // AVM v7, stateproofs protocol.ConsensusFuture, } @@ -969,8 +971,8 @@ func TestHeaderAccess(t *testing.T) { t.Parallel() genBalances, addrs, _ := ledgertesting.NewTestGenesis() - // Added in v33 - testConsensusRange(t, 33, 0, func(t *testing.T, ver int) { + // Added in v34 + testConsensusRange(t, 34, 0, func(t *testing.T, ver int) { cv := consensusByNumber[ver] dl := NewDoubleLedger(t, genBalances, cv) defer dl.Close() @@ -1177,9 +1179,9 @@ func TestUnfundedSenders(t *testing.T) { }, } - // v33 is the likely version for UnfundedSenders. Change if that doesn't happen. + // v34 is the likely version for UnfundedSenders. Change if that doesn't happen. var problem string - if ver < 33 { + if ver < 34 { // In the old days, balances.Move would try to increase the rewardsState on the unfunded account problem = "balance 0 below min" } @@ -1232,9 +1234,9 @@ func TestAppCallAppDuringInit(t *testing.T) { ForeignApps: []basics.AppIndex{approveID}, Fee: 2000, // Enough to have the inner fee paid for } - // v33 is the likely version for UnfundedSenders. Change if that doesn't happen. + // v34 is the likely version for UnfundedSenders. Change if that doesn't happen. var problem string - if ver < 33 { + if ver < 34 { // In the old days, balances.Move would try to increase the rewardsState on the unfunded account problem = "balance 0 below min" } diff --git a/ledger/ledger_test.go b/ledger/ledger_test.go index d925cec61..114057f50 100644 --- a/ledger/ledger_test.go +++ b/ledger/ledger_test.go @@ -1659,9 +1659,9 @@ func TestLedgerKeepsOldBlocksForStateProof(t *testing.T) { // since the first state proof is expected to happen on stateproofInterval*2 we would start give-up on state proofs we would // give up on old state proofs only after stateproofInterval*3 - maxBlocks := int((config.Consensus[protocol.ConsensusFuture].StateProofMaxRecoveryIntervals + 2) * config.Consensus[protocol.ConsensusFuture].StateProofInterval) + maxBlocks := int((config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals + 2) * config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval) dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64()) - genesisInitState, initKeys := ledgertesting.GenerateInitState(t, protocol.ConsensusFuture, 10000000000) + genesisInitState, initKeys := ledgertesting.GenerateInitState(t, protocol.ConsensusCurrentVersion, 10000000000) // place real values on the participation period, so we would create a commitment with some stake. accountsWithValid := make(map[basics.Address]basics.AccountData) @@ -2656,10 +2656,10 @@ func verifyVotersContent(t *testing.T, expected map[basics.Round]*ledgercore.Vot func TestVotersReloadFromDisk(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64()) genesisInitState := getInitState() - genesisInitState.Block.CurrentProtocol = protocol.ConsensusFuture + genesisInitState.Block.CurrentProtocol = protocol.ConsensusCurrentVersion const inMem = true cfg := config.GetDefaultLocal() cfg.Archival = false @@ -2702,11 +2702,11 @@ func TestVotersReloadFromDisk(t *testing.T) { func TestVotersReloadFromDiskAfterOneStateProofCommitted(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64()) genesisInitState := getInitState() - genesisInitState.Block.CurrentProtocol = protocol.ConsensusFuture + genesisInitState.Block.CurrentProtocol = protocol.ConsensusCurrentVersion const inMem = true cfg := config.GetDefaultLocal() cfg.Archival = false @@ -2761,11 +2761,11 @@ func TestVotersReloadFromDiskAfterOneStateProofCommitted(t *testing.T) { func TestVotersReloadFromDiskPassRecoveryPeriod(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] dbName := fmt.Sprintf("%s.%d", t.Name(), crypto.RandUint64()) genesisInitState := getInitState() - genesisInitState.Block.CurrentProtocol = protocol.ConsensusFuture + genesisInitState.Block.CurrentProtocol = protocol.ConsensusCurrentVersion const inMem = true cfg := config.GetDefaultLocal() cfg.Archival = false diff --git a/ledger/voters_test.go b/ledger/voters_test.go index 9c65e7366..b13b11d97 100644 --- a/ledger/voters_test.go +++ b/ledger/voters_test.go @@ -40,9 +40,9 @@ func TestVoterTrackerDeleteVotersAfterStateproofConfirmed(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - intervalForTest := config.Consensus[protocol.ConsensusFuture].StateProofInterval - numOfIntervals := config.Consensus[protocol.ConsensusFuture].StateProofMaxRecoveryIntervals - 1 - lookbackForTest := config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback + intervalForTest := config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval + numOfIntervals := config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals - 1 + lookbackForTest := config.Consensus[protocol.ConsensusCurrentVersion].StateProofVotersLookback accts := []map[basics.Address]basics.AccountData{ledgertesting.RandomAccounts(20, true)} @@ -56,7 +56,7 @@ func TestVoterTrackerDeleteVotersAfterStateproofConfirmed(t *testing.T) { sinkdata.Status = basics.NotParticipating accts[0][testSinkAddr] = sinkdata - ml := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusFuture, accts) + ml := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusCurrentVersion, accts) defer ml.Close() conf := config.GetDefaultLocal() @@ -68,7 +68,7 @@ func TestVoterTrackerDeleteVotersAfterStateproofConfirmed(t *testing.T) { // adding blocks to the voterstracker (in order to pass the numOfIntervals*stateproofInterval we add 1) for ; i < (numOfIntervals*intervalForTest)+1; i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } @@ -77,7 +77,7 @@ func TestVoterTrackerDeleteVotersAfterStateproofConfirmed(t *testing.T) { block := randomBlock(basics.Round(i)) i++ - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion // committing stateproof that confirm the (numOfIntervals - 1)th interval var stateTracking bookkeeping.StateProofTrackingData @@ -94,7 +94,7 @@ func TestVoterTrackerDeleteVotersAfterStateproofConfirmed(t *testing.T) { a.Equal(basics.Round((numOfIntervals-2)*intervalForTest-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) block = randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion stateTracking.StateProofNextRound = basics.Round(numOfIntervals * intervalForTest) block.block.BlockHeader.StateProofTracking = make(map[protocol.StateProofType]bookkeeping.StateProofTrackingData) block.block.BlockHeader.StateProofTracking[protocol.StateProofBasic] = stateTracking @@ -108,9 +108,9 @@ func TestLimitVoterTracker(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - intervalForTest := config.Consensus[protocol.ConsensusFuture].StateProofInterval - recoveryIntervalForTests := config.Consensus[protocol.ConsensusFuture].StateProofMaxRecoveryIntervals - lookbackForTest := config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback + intervalForTest := config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval + recoveryIntervalForTests := config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals + lookbackForTest := config.Consensus[protocol.ConsensusCurrentVersion].StateProofVotersLookback accts := []map[basics.Address]basics.AccountData{ledgertesting.RandomAccounts(20, true)} @@ -124,7 +124,7 @@ func TestLimitVoterTracker(t *testing.T) { sinkdata.Status = basics.NotParticipating accts[0][testSinkAddr] = sinkdata - ml := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusFuture, accts) + ml := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusCurrentVersion, accts) defer ml.Close() conf := config.GetDefaultLocal() @@ -140,7 +140,7 @@ func TestLimitVoterTracker(t *testing.T) { // should not give up on any state proof for ; i < intervalForTest*(recoveryIntervalForTests+2); i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } @@ -149,52 +149,52 @@ func TestLimitVoterTracker(t *testing.T) { // + 1 - since votersForRoundCache would contain the votersForRound for the next state proof to come // + 1 - in order to confirm recoveryIntervalForTests number of state proofs we need recoveryIntervalForTests + 1 headers (for the commitment) a.Equal(recoveryIntervalForTests+2, uint64(len(ao.voters.votersForRoundCache))) - a.Equal(basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) + a.Equal(basics.Round(config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) // after adding the round intervalForTest*(recoveryIntervalForTests+3)+1 we expect the voter tracker to remove voters for ; i < intervalForTest*(recoveryIntervalForTests+3)+1; i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } a.Equal(recoveryIntervalForTests+2, uint64(len(ao.voters.votersForRoundCache))) - a.Equal(basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval*2-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) + a.Equal(basics.Round(config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*2-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) // after adding the round intervalForTest*(recoveryIntervalForTests+3)+1 we expect the voter tracker to remove voters for ; i < intervalForTest*(recoveryIntervalForTests+4)+1; i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } a.Equal(recoveryIntervalForTests+2, uint64(len(ao.voters.votersForRoundCache))) - a.Equal(basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval*3-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) + a.Equal(basics.Round(config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*3-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) // if the last round of the intervalForTest has not been added to the ledger the votersTracker would // retain one more element for ; i < intervalForTest*(recoveryIntervalForTests+5); i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } a.Equal(recoveryIntervalForTests+3, uint64(len(ao.voters.votersForRoundCache))) - a.Equal(basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval*3-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) + a.Equal(basics.Round(config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*3-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) for ; i < intervalForTest*(recoveryIntervalForTests+5)+1; i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } a.Equal(recoveryIntervalForTests+2, uint64(len(ao.voters.votersForRoundCache))) - a.Equal(basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval*4-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) + a.Equal(basics.Round(config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*4-lookbackForTest), ao.voters.lowestRound(basics.Round(i))) } func TestTopNAccountsThatHaveNoMssKeys(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - intervalForTest := config.Consensus[protocol.ConsensusFuture].StateProofInterval - lookbackForTest := config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback + intervalForTest := config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval + lookbackForTest := config.Consensus[protocol.ConsensusCurrentVersion].StateProofVotersLookback accts := []map[basics.Address]basics.AccountData{ledgertesting.RandomAccounts(20, true)} @@ -208,7 +208,7 @@ func TestTopNAccountsThatHaveNoMssKeys(t *testing.T) { sinkdata.Status = basics.NotParticipating accts[0][testSinkAddr] = sinkdata - ml := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusFuture, accts) + ml := makeMockLedgerForTracker(t, true, 1, protocol.ConsensusCurrentVersion, accts) defer ml.Close() conf := config.GetDefaultLocal() @@ -219,7 +219,7 @@ func TestTopNAccountsThatHaveNoMssKeys(t *testing.T) { i := uint64(1) for ; i < (intervalForTest)+1; i++ { block := randomBlock(basics.Round(i)) - block.block.CurrentProtocol = protocol.ConsensusFuture + block.block.CurrentProtocol = protocol.ConsensusCurrentVersion addBlockToAccountsUpdate(block.block, ao) } diff --git a/protocol/consensus.go b/protocol/consensus.go index 14017385b..11a5c5f07 100644 --- a/protocol/consensus.go +++ b/protocol/consensus.go @@ -176,6 +176,17 @@ const ConsensusV32 = ConsensusVersion( "https://github.com/algorandfoundation/specs/tree/d5ac876d7ede07367dbaa26e149aa42589aac1f7", ) +// ConsensusV33 enables large blocks, the deeper block history for TEAL +// and catchpoint generation round after lowering in-memory deltas size (320 -> 4). +const ConsensusV33 = ConsensusVersion( + "https://github.com/algorandfoundation/specs/tree/830a4e673148498cc7230a0d1ba1ed0a5471acc6", +) + +// ConsensusV34 enables the TEAL v7 opcodes, stateproofs, shorter lambda. +const ConsensusV34 = ConsensusVersion( + "https://github.com/algorandfoundation/specs/tree/2dd5435993f6f6d65691140f592ebca5ef19ffbd", +) + // 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( @@ -188,7 +199,7 @@ const ConsensusFuture = ConsensusVersion( // ConsensusCurrentVersion is the latest version and should be used // when a specific version is not provided. -const ConsensusCurrentVersion = ConsensusV32 +const ConsensusCurrentVersion = ConsensusV34 // Error is used to indicate that an unsupported protocol has been detected. type Error ConsensusVersion diff --git a/stateproof/stateproofMessageGenerator_test.go b/stateproof/stateproofMessageGenerator_test.go index ab3399e51..1b909d775 100644 --- a/stateproof/stateproofMessageGenerator_test.go +++ b/stateproof/stateproofMessageGenerator_test.go @@ -78,7 +78,7 @@ func (s *workerForStateProofMessageTests) BlockHdr(round basics.Round) (bookkeep func (s *workerForStateProofMessageTests) VotersForStateProof(round basics.Round) (*ledgercore.VotersForRound, error) { voters := &ledgercore.VotersForRound{ - Proto: config.Consensus[protocol.ConsensusFuture], + Proto: config.Consensus[protocol.ConsensusCurrentVersion], AddrToPos: make(map[basics.Address]uint64), } @@ -121,7 +121,7 @@ func (s *workerForStateProofMessageTests) addBlockWithStateProofHeaders(ccNextRo hdr := bookkeeping.BlockHeader{} hdr.Round = s.w.latest - hdr.CurrentProtocol = protocol.ConsensusFuture + hdr.CurrentProtocol = protocol.ConsensusCurrentVersion var ccBasic = bookkeeping.StateProofTrackingData{ StateProofVotersCommitment: make([]byte, stateproof.HashSize), @@ -192,13 +192,13 @@ func TestStateProofMessage(t *testing.T) { dbs, _ := dbOpenTest(t, true) w := NewWorker(dbs.Wdb, logging.TestingLog(t), s, s, s, s) + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.w.latest-- - s.addBlockWithStateProofHeaders(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlockWithStateProofHeaders(2 * basics.Round(proto.StateProofInterval)) w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] s.advanceLatest(proto.StateProofInterval + proto.StateProofInterval/2) var lastMessage stateproofmsg.Message @@ -263,8 +263,9 @@ func TestGenerateStateProofMessageForSmallRound(t *testing.T) { } s := newWorkerForStateProofMessageStubs(keys[:], len(keys)) + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.w.latest-- - s.addBlockWithStateProofHeaders(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlockWithStateProofHeaders(2 * basics.Round(proto.StateProofInterval)) _, err := GenerateStateProofMessage(s, 240, s.w.blocks[s.w.latest]) a.ErrorIs(err, errInvalidParams) @@ -284,10 +285,11 @@ func TestMessageLnApproxError(t *testing.T) { } s := newWorkerForStateProofMessageStubs(keys[:], len(keys)) + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.w.latest-- - s.addBlockWithStateProofHeaders(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlockWithStateProofHeaders(2 * basics.Round(proto.StateProofInterval)) - s.advanceLatest(2*config.Consensus[protocol.ConsensusFuture].StateProofInterval + config.Consensus[protocol.ConsensusFuture].StateProofInterval/2) + s.advanceLatest(2*proto.StateProofInterval + proto.StateProofInterval/2) tracking := s.w.blocks[512].StateProofTracking[protocol.StateProofBasic] tracking.StateProofOnlineTotalWeight = basics.MicroAlgos{} newtracking := tracking @@ -312,9 +314,10 @@ func TestMessageMissingHeaderOnInterval(t *testing.T) { s := newWorkerForStateProofMessageStubs(keys[:], len(keys)) s.w.latest-- - s.addBlockWithStateProofHeaders(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + proto := config.Consensus[protocol.ConsensusCurrentVersion] + s.addBlockWithStateProofHeaders(2 * basics.Round(proto.StateProofInterval)) - s.advanceLatest(2*config.Consensus[protocol.ConsensusFuture].StateProofInterval + config.Consensus[protocol.ConsensusFuture].StateProofInterval/2) + s.advanceLatest(2*proto.StateProofInterval + proto.StateProofInterval/2) delete(s.w.blocks, 510) _, err := GenerateStateProofMessage(s, 256, s.w.blocks[512]) @@ -338,13 +341,13 @@ func TestGenerateBlockProof(t *testing.T) { dbs, _ := dbOpenTest(t, true) w := NewWorker(dbs.Wdb, logging.TestingLog(t), s, s, s, s) + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.w.latest-- - s.addBlockWithStateProofHeaders(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlockWithStateProofHeaders(2 * basics.Round(proto.StateProofInterval)) w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] s.advanceLatest(proto.StateProofInterval + proto.StateProofInterval/2) for iter := uint64(0); iter < 5; iter++ { @@ -391,10 +394,11 @@ func TestGenerateBlockProofOnSmallArray(t *testing.T) { } s := newWorkerForStateProofMessageStubs(keys, len(keys)) + proto := config.Consensus[protocol.ConsensusCurrentVersion] + s.w.latest-- - s.addBlockWithStateProofHeaders(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlockWithStateProofHeaders(2 * basics.Round(proto.StateProofInterval)) - proto := config.Consensus[protocol.ConsensusFuture] s.advanceLatest(2 * proto.StateProofInterval) headers, err := FetchLightHeaders(s, proto.StateProofInterval, basics.Round(2*proto.StateProofInterval)) a.NoError(err) diff --git a/stateproof/worker_test.go b/stateproof/worker_test.go index 0034b45b0..4c35c8c69 100644 --- a/stateproof/worker_test.go +++ b/stateproof/worker_test.go @@ -79,7 +79,7 @@ func newWorkerStubs(t testing.TB, keys []account.Participation, totalWeight int) deletedStateProofKeys: map[account.ParticipationID]basics.Round{}, } s.latest-- - s.addBlock(2 * basics.Round(config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlock(2 * basics.Round(config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval)) return s } @@ -88,7 +88,7 @@ func (s *testWorkerStubs) addBlock(spNextRound basics.Round) { hdr := bookkeeping.BlockHeader{} hdr.Round = s.latest - hdr.CurrentProtocol = protocol.ConsensusFuture + hdr.CurrentProtocol = protocol.ConsensusCurrentVersion var stateProofBasic = bookkeeping.StateProofTrackingData{ StateProofVotersCommitment: make([]byte, stateproof.HashSize), @@ -173,7 +173,7 @@ func (s *testWorkerStubs) BlockHdr(r basics.Round) (bookkeeping.BlockHeader, err func (s *testWorkerStubs) VotersForStateProof(r basics.Round) (*ledgercore.VotersForRound, error) { voters := &ledgercore.VotersForRound{ - Proto: config.Consensus[protocol.ConsensusFuture], + Proto: config.Consensus[protocol.ConsensusCurrentVersion], AddrToPos: make(map[basics.Address]uint64), TotalWeight: basics.MicroAlgos{Raw: uint64(s.totalWeight)}, } @@ -277,7 +277,8 @@ func newPartKey(t testing.TB, parent basics.Address) account.PersistedParticipat partDB, err := db.MakeAccessor(fn, false, true) require.NoError(t, err) - part, err := account.FillDBWithParticipationKeys(partDB, parent, 0, basics.Round(15*config.Consensus[protocol.ConsensusFuture].StateProofInterval), config.Consensus[protocol.ConsensusFuture].DefaultKeyDilution) + proto := config.Consensus[protocol.ConsensusCurrentVersion] + part, err := account.FillDBWithParticipationKeys(partDB, parent, 0, basics.Round(15*proto.StateProofInterval), proto.DefaultKeyDilution) require.NoError(t, err) return part @@ -300,7 +301,7 @@ func TestWorkerAllSigs(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(proto.StateProofInterval + proto.StateProofInterval/2) // Go through several iterations, making sure that we get @@ -369,7 +370,7 @@ func TestWorkerPartialSigs(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(proto.StateProofInterval + proto.StateProofInterval/2) s.advanceLatest(proto.StateProofInterval) @@ -434,7 +435,7 @@ func TestWorkerInsufficientSigs(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(3 * proto.StateProofInterval) for i := 0; i < len(keys); i++ { @@ -465,7 +466,7 @@ func TestWorkerRestart(t *testing.T) { s := newWorkerStubs(t, keys, 10) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(3*proto.StateProofInterval - 1) dbRand := crypto.RandUint64() @@ -511,7 +512,7 @@ func TestWorkerHandleSig(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(3 * proto.StateProofInterval) for i := 0; i < len(keys); i++ { @@ -547,7 +548,7 @@ func TestSignerDeletesUnneededStateProofKeys(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(3 * proto.StateProofInterval) // Expect all signatures to be broadcast. @@ -578,7 +579,7 @@ func TestSignerDoesntDeleteKeysWhenDBDoesntStoreSigs(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(3 * proto.StateProofInterval) // Expect all signatures to be broadcast. @@ -612,7 +613,7 @@ func TestWorkerRemoveBuildersAndSignatures(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(proto.StateProofInterval + proto.StateProofInterval/2) for iter := 0; iter < expectedStateProofs; iter++ { @@ -635,7 +636,7 @@ func TestWorkerRemoveBuildersAndSignatures(t *testing.T) { // add block that confirm a state proof for interval: expectedStateProofs - 1 s.mu.Lock() - s.addBlock(basics.Round((expectedStateProofs - 1) * config.Consensus[protocol.ConsensusFuture].StateProofInterval)) + s.addBlock(basics.Round((expectedStateProofs - 1) * config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval)) s.mu.Unlock() err = waitForBuilderAndSignerToWaitOnRound(s) @@ -654,7 +655,7 @@ func TestWorkerBuildersRecoveryLimit(t *testing.T) { partitiontest.PartitionTest(t) a := require.New(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] var keys []account.Participation for i := 0; i < 10; i++ { var parent basics.Address @@ -762,7 +763,7 @@ func getSignaturesInDatabase(t *testing.T, numAddresses int, sigFrom sigOrigin) // Some tests rely on having only one signature being broadcast at a single round. // for that we need to make sure that addresses won't fall into the same broadcast round. // For that same reason we can't have more than StateProofInterval / 2 address - require.LessOrEqual(t, uint64(numAddresses), config.Consensus[protocol.ConsensusFuture].StateProofInterval/2) + require.LessOrEqual(t, uint64(numAddresses), config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval/2) // Prepare the addresses and the keys signatureBcasted = make(map[basics.Address]int) @@ -849,7 +850,7 @@ func TestSigBroacastTwoPerSig(t *testing.T) { func sendReceiveCountMessages(t *testing.T, tns *testWorkerStubs, signatureBcasted map[basics.Address]int, fromThisNode map[basics.Address]bool, spw *Worker, periods int) { - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] // Collect the broadcast messages var wg sync.WaitGroup @@ -900,7 +901,7 @@ func TestBuilderGeneratesValidStateProofTXN(t *testing.T) { w.Start() defer w.Shutdown() - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] s.advanceLatest(proto.StateProofInterval + proto.StateProofInterval/2) s.advanceLatest(proto.StateProofInterval) @@ -924,7 +925,7 @@ func TestForwardNotFromThisNodeSecondHalf(t *testing.T) { _, _, tns, spw := getSignaturesInDatabase(t, 10, sigNotFromThisNode) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] for brnd := 0; brnd < int(proto.StateProofInterval*10); brnd++ { spw.broadcastSigs(basics.Round(brnd), proto) select { @@ -943,7 +944,7 @@ func TestForwardNotFromThisNodeFirstHalf(t *testing.T) { signatureBcasted, fromThisNode, tns, spw := getSignaturesInDatabase(t, 10, sigAlternateOrigin) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] for brnd := 0; brnd < int(proto.StateProofInterval*10); brnd++ { spw.broadcastSigs(basics.Round(brnd), proto) select { @@ -971,7 +972,7 @@ func TestForwardNotFromThisNodeFirstHalf(t *testing.T) { } func setBlocksAndMessage(t *testing.T, sigRound basics.Round) (s *testWorkerStubs, w *Worker, msg sigFromAddr, msgBytes []byte) { - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] var address basics.Address crypto.RandBytes(address[:]) @@ -998,7 +999,7 @@ func setBlocksAndMessage(t *testing.T, sigRound basics.Round) (s *testWorkerStub func TestWorkerHandleSigOldRounds(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] intervalRound := basics.Round(proto.StateProofInterval) _, w, msg, msgBytes := setBlocksAndMessage(t, intervalRound) @@ -1016,7 +1017,7 @@ func TestWorkerHandleSigOldRounds(t *testing.T) { func TestWorkerHandleSigRoundNotInLedger(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] intervalRound := basics.Round(proto.StateProofInterval) _, w, msg, msgBytes := setBlocksAndMessage(t, intervalRound*10) @@ -1039,7 +1040,7 @@ func TestWorkerHandleSigRoundNotInLedger(t *testing.T) { func TestWorkerHandleSigWrongSignature(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] intervalRound := basics.Round(proto.StateProofInterval) _, w, msg, msgBytes := setBlocksAndMessage(t, intervalRound*2) @@ -1060,7 +1061,7 @@ func TestWorkerHandleSigWrongSignature(t *testing.T) { func TestWorkerHandleSigAddrsNotInTopN(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] proto.StateProofTopVoters = 2 addresses := make([]basics.Address, 0) @@ -1105,7 +1106,7 @@ func TestWorkerHandleSigAddrsNotInTopN(t *testing.T) { func TestWorkerHandleSigAlreadyIn(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] lastRound := proto.StateProofInterval * 2 s, w, msg, _ := setBlocksAndMessage(t, basics.Round(lastRound)) @@ -1148,7 +1149,7 @@ func TestWorkerHandleSigAlreadyIn(t *testing.T) { func TestWorkerHandleSigExceptionsDbError(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] lastRound := proto.StateProofInterval * 2 s, w, msg, _ := setBlocksAndMessage(t, basics.Round(lastRound)) latestBlockHeader, err := w.ledger.BlockHdr(basics.Round(lastRound)) @@ -1177,13 +1178,13 @@ func TestWorkerHandleSigExceptionsDbError(t *testing.T) { func TestWorkerHandleSigCantMakeBuilder(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] origProto := proto defer func() { - config.Consensus[protocol.ConsensusFuture] = origProto + config.Consensus[protocol.ConsensusCurrentVersion] = origProto }() proto.StateProofInterval = 512 - config.Consensus[protocol.ConsensusFuture] = proto + config.Consensus[protocol.ConsensusCurrentVersion] = proto var address basics.Address crypto.RandBytes(address[:]) @@ -1225,13 +1226,13 @@ func TestWorkerHandleSigCantMakeBuilder(t *testing.T) { func TestWorkerHandleSigIntervalZero(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] origProto := proto defer func() { - config.Consensus[protocol.ConsensusFuture] = origProto + config.Consensus[protocol.ConsensusCurrentVersion] = origProto }() proto.StateProofInterval = 0 - config.Consensus[protocol.ConsensusFuture] = proto + config.Consensus[protocol.ConsensusCurrentVersion] = proto intervalRound := basics.Round(proto.StateProofInterval) _, w, msg, msgBytes := setBlocksAndMessage(t, intervalRound*2) @@ -1252,7 +1253,7 @@ func TestWorkerHandleSigIntervalZero(t *testing.T) { func TestWorkerHandleSigNotOnInterval(t *testing.T) { partitiontest.PartitionTest(t) - proto := config.Consensus[protocol.ConsensusFuture] + proto := config.Consensus[protocol.ConsensusCurrentVersion] _, w, msg, msgBytes := setBlocksAndMessage(t, basics.Round(600)) reply := w.handleSigMessage(network.IncomingMessage{ |