From a1137a29a1008624c0424be619cd1d1d63c072ef Mon Sep 17 00:00:00 2001 From: Gary Malouf <982483+gmalouf@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:23:02 -0500 Subject: [PATCH] Consensus: Consensus version v40, set major release to 4 and reset minor. (#6207) Co-authored-by: cce <51567+cce@users.noreply.github.com> --- config/consensus.go | 50 ++++++++++++------- config/version.go | 4 +- data/bookkeeping/block_test.go | 12 ++++- data/pools/transactionPool_test.go | 1 + data/transactions/logic/langspec_v1.json | 2 +- data/transactions/logic/langspec_v10.json | 2 +- data/transactions/logic/langspec_v11.json | 2 +- data/transactions/logic/langspec_v2.json | 2 +- data/transactions/logic/langspec_v3.json | 2 +- data/transactions/logic/langspec_v4.json | 2 +- data/transactions/logic/langspec_v5.json | 2 +- data/transactions/logic/langspec_v6.json | 2 +- data/transactions/logic/langspec_v7.json | 2 +- data/transactions/logic/langspec_v8.json | 2 +- data/transactions/logic/langspec_v9.json | 2 +- ledger/applications_test.go | 3 ++ ledger/catchpointfilewriter.go | 4 +- ledger/catchpointfilewriter_test.go | 12 ++--- ledger/catchpointtracker.go | 4 +- ledger/catchupaccessor.go | 9 ++-- ledger/eval_simple_test.go | 5 +- ledger/ledger_test.go | 6 +++ .../store/trackerdb/dualdriver/dualdriver.go | 4 +- ledger/store/trackerdb/generickv/reader.go | 4 +- .../store/trackerdb/sqlitedriver/kvsIter.go | 17 +++++-- .../trackerdb/sqlitedriver/sqlitedriver.go | 8 +-- ledger/store/trackerdb/store.go | 4 +- ledger/testing/consensusRange.go | 1 + ledger/testing/consensusRange_test.go | 2 +- node/follower_node_test.go | 26 ++++------ protocol/consensus.go | 7 ++- .../catchup/catchpointCatchup_test.go | 6 +-- .../catchup/stateproofsCatchup_test.go | 2 +- 33 files changed, 128 insertions(+), 85 deletions(-) diff --git a/config/consensus.go b/config/consensus.go index 7e79e9b8e5..32343ed154 100644 --- a/config/consensus.go +++ b/config/consensus.go @@ -1516,32 +1516,44 @@ func initConsensusProtocols() { // but our current max is 150000 so using that : v38.ApprovedUpgrades[protocol.ConsensusV39] = 150000 - // ConsensusFuture is used to test features that are implemented - // but not yet released in a production protocol version. - vFuture := v39 - vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} + v40 := v39 + v40.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} - vFuture.LogicSigVersion = 11 // When moving this to a release, put a new higher LogicSigVersion here + v40.LogicSigVersion = 11 - vFuture.EnableLogicSigSizePooling = true + v40.EnableLogicSigSizePooling = true - vFuture.Payouts.Enabled = true - vFuture.Payouts.Percent = 50 - vFuture.Payouts.GoOnlineFee = 2_000_000 // 2 algos - vFuture.Payouts.MinBalance = 30_000_000_000 // 30,000 algos - vFuture.Payouts.MaxBalance = 70_000_000_000_000 // 70M algos - vFuture.Payouts.MaxMarkAbsent = 32 - vFuture.Payouts.ChallengeInterval = 1000 - vFuture.Payouts.ChallengeGracePeriod = 200 - vFuture.Payouts.ChallengeBits = 5 + v40.Payouts.Enabled = true + v40.Payouts.Percent = 50 + v40.Payouts.GoOnlineFee = 2_000_000 // 2 algos + v40.Payouts.MinBalance = 30_000_000_000 // 30,000 algos + v40.Payouts.MaxBalance = 70_000_000_000_000 // 70M algos + v40.Payouts.MaxMarkAbsent = 32 + v40.Payouts.ChallengeInterval = 1000 + v40.Payouts.ChallengeGracePeriod = 200 + v40.Payouts.ChallengeBits = 5 - vFuture.Bonus.BaseAmount = 10_000_000 // 10 Algos + v40.Bonus.BaseAmount = 10_000_000 // 10 Algos // 2.9 sec rounds gives about 10.8M rounds per year. - vFuture.Bonus.DecayInterval = 1_000_000 // .99^(10.8M/1M) ~ .897. So ~10% decay per year + v40.Bonus.DecayInterval = 1_000_000 // .99^(10.8M/1M) ~ .897. So ~10% decay per year + + v40.Heartbeat = true + + v40.EnableCatchpointsWithOnlineAccounts = true - vFuture.Heartbeat = true + Consensus[protocol.ConsensusV40] = v40 + + // v39 can be upgraded to v40, with an update delay of 7d: + // 208000 = (7 * 24 * 60 * 60 / 2.9 ballpark round times) + // our current max is 250000 + v39.ApprovedUpgrades[protocol.ConsensusV40] = 208000 + + // ConsensusFuture is used to test features that are implemented + // but not yet released in a production protocol version. + vFuture := v40 + vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{} - vFuture.EnableCatchpointsWithOnlineAccounts = true + vFuture.LogicSigVersion = 12 // When moving this to a release, put a new higher LogicSigVersion here Consensus[protocol.ConsensusFuture] = vFuture diff --git a/config/version.go b/config/version.go index 94a82a6ca8..08f6cae898 100644 --- a/config/version.go +++ b/config/version.go @@ -29,11 +29,11 @@ import ( // VersionMajor is the Major semantic version number (#.y.z) - changed when first public release (0.y.z -> 1.y.z) // and when backwards compatibility is broken. -const VersionMajor = 3 +const VersionMajor = 4 // VersionMinor is the Minor semantic version number (x.#.z) - changed when backwards-compatible features are introduced. // Not enforced until after initial public release (x > 0). -const VersionMinor = 28 +const VersionMinor = 0 // Version is the type holding our full version information. type Version struct { diff --git a/data/bookkeeping/block_test.go b/data/bookkeeping/block_test.go index bc8aec6a7a..9b2608cd1d 100644 --- a/data/bookkeeping/block_test.go +++ b/data/bookkeeping/block_test.go @@ -39,12 +39,22 @@ import ( var delegatesMoney = basics.MicroAlgos{Raw: 1000 * 1000 * 1000} var proto1 = protocol.ConsensusVersion("Test1") +var proto1NoBonus = protocol.ConsensusVersion("Test1NoBonus") var proto2 = protocol.ConsensusVersion("Test2") var proto3 = protocol.ConsensusVersion("Test3") var protoUnsupported = protocol.ConsensusVersion("TestUnsupported") var protoDelay = protocol.ConsensusVersion("TestDelay") func init() { + verBeforeBonus := protocol.ConsensusV39 + params1NB := config.Consensus[verBeforeBonus] + params1NB.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{ + proto2: 0, + } + params1NB.MinUpgradeWaitRounds = 0 + params1NB.MaxUpgradeWaitRounds = 0 + config.Consensus[proto1NoBonus] = params1NB + params1 := config.Consensus[protocol.ConsensusCurrentVersion] params1.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{ proto2: 0, @@ -263,7 +273,7 @@ func TestBonus(t *testing.T) { t.Parallel() var prev Block - prev.CurrentProtocol = proto1 + prev.CurrentProtocol = proto1NoBonus prev.BlockHeader.GenesisID = t.Name() crypto.RandBytes(prev.BlockHeader.GenesisHash[:]) diff --git a/data/pools/transactionPool_test.go b/data/pools/transactionPool_test.go index 01b851f86d..518358d809 100644 --- a/data/pools/transactionPool_test.go +++ b/data/pools/transactionPool_test.go @@ -1453,6 +1453,7 @@ func TestStateProofLogging(t *testing.T) { b.BlockHeader.GenesisHash = mockLedger.GenesisHash() b.CurrentProtocol = protocol.ConsensusCurrentVersion b.BlockHeader.Round = 1 + b.BlockHeader.Bonus = basics.MicroAlgos{Raw: 10000000} phdr, err := mockLedger.BlockHdr(0) require.NoError(t, err) diff --git a/data/transactions/logic/langspec_v1.json b/data/transactions/logic/langspec_v1.json index 5fd347507d..10ff7909f7 100644 --- a/data/transactions/logic/langspec_v1.json +++ b/data/transactions/logic/langspec_v1.json @@ -1,6 +1,6 @@ { "Version": 1, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v10.json b/data/transactions/logic/langspec_v10.json index 1a8986436a..dffcd9e328 100644 --- a/data/transactions/logic/langspec_v10.json +++ b/data/transactions/logic/langspec_v10.json @@ -1,6 +1,6 @@ { "Version": 10, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v11.json b/data/transactions/logic/langspec_v11.json index 58d5657253..2ff7187f3c 100644 --- a/data/transactions/logic/langspec_v11.json +++ b/data/transactions/logic/langspec_v11.json @@ -1,6 +1,6 @@ { "Version": 11, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v2.json b/data/transactions/logic/langspec_v2.json index 24f9ad97f7..584339b88a 100644 --- a/data/transactions/logic/langspec_v2.json +++ b/data/transactions/logic/langspec_v2.json @@ -1,6 +1,6 @@ { "Version": 2, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v3.json b/data/transactions/logic/langspec_v3.json index 085084359a..8ed4c5f45c 100644 --- a/data/transactions/logic/langspec_v3.json +++ b/data/transactions/logic/langspec_v3.json @@ -1,6 +1,6 @@ { "Version": 3, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v4.json b/data/transactions/logic/langspec_v4.json index ddbf651876..988f628246 100644 --- a/data/transactions/logic/langspec_v4.json +++ b/data/transactions/logic/langspec_v4.json @@ -1,6 +1,6 @@ { "Version": 4, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v5.json b/data/transactions/logic/langspec_v5.json index 2cca3941da..5a7cbb6532 100644 --- a/data/transactions/logic/langspec_v5.json +++ b/data/transactions/logic/langspec_v5.json @@ -1,6 +1,6 @@ { "Version": 5, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v6.json b/data/transactions/logic/langspec_v6.json index 6795706db7..5cd1de7fc3 100644 --- a/data/transactions/logic/langspec_v6.json +++ b/data/transactions/logic/langspec_v6.json @@ -1,6 +1,6 @@ { "Version": 6, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v7.json b/data/transactions/logic/langspec_v7.json index 12d2594194..4152b01675 100644 --- a/data/transactions/logic/langspec_v7.json +++ b/data/transactions/logic/langspec_v7.json @@ -1,6 +1,6 @@ { "Version": 7, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v8.json b/data/transactions/logic/langspec_v8.json index c5fcdbf58d..d667cbb0d1 100644 --- a/data/transactions/logic/langspec_v8.json +++ b/data/transactions/logic/langspec_v8.json @@ -1,6 +1,6 @@ { "Version": 8, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/data/transactions/logic/langspec_v9.json b/data/transactions/logic/langspec_v9.json index 01e951cc3c..0d5dedf63c 100644 --- a/data/transactions/logic/langspec_v9.json +++ b/data/transactions/logic/langspec_v9.json @@ -1,6 +1,6 @@ { "Version": 9, - "LogicSigVersion": 10, + "LogicSigVersion": 11, "NamedTypes": [ { "Name": "[]byte", diff --git a/ledger/applications_test.go b/ledger/applications_test.go index 315cfd2c47..f140d6c7dd 100644 --- a/ledger/applications_test.go +++ b/ledger/applications_test.go @@ -587,6 +587,7 @@ return` blk.TxnCounter = blk.TxnCounter + 2 blk.Payset = append(blk.Payset, txib1, txib2) blk.TxnCommitments, err = blk.PaysetCommit() + blk.FeesCollected = basics.MicroAlgos{Raw: txib1.Txn.Fee.Raw + txib2.Txn.Fee.Raw} a.NoError(err) err = l.appendUnvalidated(blk) a.NoError(err) @@ -731,6 +732,7 @@ return` blk.TxnCounter = blk.TxnCounter + 2 blk.Payset = append(blk.Payset, txib1, txib2) blk.TxnCommitments, err = blk.PaysetCommit() + blk.FeesCollected = basics.MicroAlgos{Raw: txib1.Txn.Fee.Raw + txib2.Txn.Fee.Raw} a.NoError(err) err = l.appendUnvalidated(blk) a.NoError(err) @@ -867,6 +869,7 @@ return` blk.TxnCounter = blk.TxnCounter + 2 blk.Payset = append(blk.Payset, txib1, txib2) blk.TxnCommitments, err = blk.PaysetCommit() + blk.FeesCollected = basics.MicroAlgos{Raw: txib1.Txn.Fee.Raw + txib2.Txn.Fee.Raw} a.NoError(err) err = l.appendUnvalidated(blk) a.NoError(err) diff --git a/ledger/catchpointfilewriter.go b/ledger/catchpointfilewriter.go index 01e78a59eb..606da98aff 100644 --- a/ledger/catchpointfilewriter.go +++ b/ledger/catchpointfilewriter.go @@ -373,7 +373,7 @@ func (cw *catchpointFileWriter) readDatabaseStep(ctx context.Context) error { if !cw.onlineAccountsDone { // Create the OnlineAccounts iterator JIT if cw.onlineAccountRows == nil { - rows, err := cw.tx.MakeOnlineAccountsIter(ctx) + rows, err := cw.tx.MakeOnlineAccountsIter(ctx, false) if err != nil { return err } @@ -402,7 +402,7 @@ func (cw *catchpointFileWriter) readDatabaseStep(ctx context.Context) error { if !cw.onlineRoundParamsDone { // Create the OnlineRoundParams iterator JIT if cw.onlineRoundParamsRows == nil { - rows, err := cw.tx.MakeOnlineRoundParamsIter(ctx) + rows, err := cw.tx.MakeOnlineRoundParamsIter(ctx, false) if err != nil { return err } diff --git a/ledger/catchpointfilewriter_test.go b/ledger/catchpointfilewriter_test.go index 553942ad0b..d091cd5331 100644 --- a/ledger/catchpointfilewriter_test.go +++ b/ledger/catchpointfilewriter_test.go @@ -1095,18 +1095,18 @@ assert t.Log("DB round generator", genDBRound, "validator", valDBRound) t.Log("Latest round generator", genLatestRound, "validator", valLatestRound) - genOAHash, genOARows, err := calculateVerificationHash(context.Background(), dl.generator.trackerDB().MakeOnlineAccountsIter) + genOAHash, genOARows, err := calculateVerificationHash(context.Background(), dl.generator.trackerDB().MakeOnlineAccountsIter, false) require.NoError(t, err) - valOAHash, valOARows, err := calculateVerificationHash(context.Background(), dl.validator.trackerDB().MakeOnlineAccountsIter) + valOAHash, valOARows, err := calculateVerificationHash(context.Background(), dl.validator.trackerDB().MakeOnlineAccountsIter, false) require.NoError(t, err) require.Equal(t, genOAHash, valOAHash) require.NotZero(t, genOAHash) require.Equal(t, genOARows, valOARows) require.NotZero(t, genOARows) - genORPHash, genORPRows, err := calculateVerificationHash(context.Background(), dl.generator.trackerDB().MakeOnlineRoundParamsIter) + genORPHash, genORPRows, err := calculateVerificationHash(context.Background(), dl.generator.trackerDB().MakeOnlineRoundParamsIter, false) require.NoError(t, err) - valORPHash, valORPRows, err := calculateVerificationHash(context.Background(), dl.validator.trackerDB().MakeOnlineRoundParamsIter) + valORPHash, valORPRows, err := calculateVerificationHash(context.Background(), dl.validator.trackerDB().MakeOnlineRoundParamsIter, false) require.NoError(t, err) require.Equal(t, genORPHash, valORPHash) require.NotZero(t, genORPHash) @@ -1123,13 +1123,13 @@ assert l := testNewLedgerFromCatchpoint(t, dl.generator.trackerDB(), catchpointFilePath) defer l.Close() - catchpointOAHash, catchpointOARows, err := calculateVerificationHash(context.Background(), l.trackerDBs.MakeOnlineAccountsIter) + catchpointOAHash, catchpointOARows, err := calculateVerificationHash(context.Background(), l.trackerDBs.MakeOnlineAccountsIter, false) require.NoError(t, err) require.Equal(t, genOAHash, catchpointOAHash) t.Log("catchpoint onlineaccounts hash", catchpointOAHash, "matches") require.Equal(t, genOARows, catchpointOARows) - catchpointORPHash, catchpointORPRows, err := calculateVerificationHash(context.Background(), l.trackerDBs.MakeOnlineRoundParamsIter) + catchpointORPHash, catchpointORPRows, err := calculateVerificationHash(context.Background(), l.trackerDBs.MakeOnlineRoundParamsIter, false) require.NoError(t, err) require.Equal(t, genORPHash, catchpointORPHash) t.Log("catchpoint onlineroundparams hash", catchpointORPHash, "matches") diff --git a/ledger/catchpointtracker.go b/ledger/catchpointtracker.go index 8adbdc8dfb..603672f8e6 100644 --- a/ledger/catchpointtracker.go +++ b/ledger/catchpointtracker.go @@ -238,13 +238,13 @@ func (ct *catchpointTracker) finishFirstStage(ctx context.Context, dbRound basic // Generate hashes of the onlineaccounts and onlineroundparams tables. err := ct.dbs.Snapshot(func(ctx context.Context, tx trackerdb.SnapshotScope) error { var dbErr error - onlineAccountsHash, _, dbErr = calculateVerificationHash(ctx, tx.MakeOnlineAccountsIter) + onlineAccountsHash, _, dbErr = calculateVerificationHash(ctx, tx.MakeOnlineAccountsIter, false) if dbErr != nil { return dbErr } - onlineRoundParamsHash, _, dbErr = calculateVerificationHash(ctx, tx.MakeOnlineRoundParamsIter) + onlineRoundParamsHash, _, dbErr = calculateVerificationHash(ctx, tx.MakeOnlineRoundParamsIter, false) if dbErr != nil { return dbErr } diff --git a/ledger/catchupaccessor.go b/ledger/catchupaccessor.go index de10baa0e1..7418ebc98c 100644 --- a/ledger/catchupaccessor.go +++ b/ledger/catchupaccessor.go @@ -1031,12 +1031,12 @@ func (c *catchpointCatchupAccessorImpl) GetVerifyData(ctx context.Context) (bala return fmt.Errorf("unable to get state proof verification data: %v", err) } - onlineAccountsHash, _, err = calculateVerificationHash(ctx, tx.MakeOnlineAccountsIter) + onlineAccountsHash, _, err = calculateVerificationHash(ctx, tx.MakeOnlineAccountsIter, true) if err != nil { return fmt.Errorf("unable to get online accounts verification data: %v", err) } - onlineRoundParamsHash, _, err = calculateVerificationHash(ctx, tx.MakeOnlineRoundParamsIter) + onlineRoundParamsHash, _, err = calculateVerificationHash(ctx, tx.MakeOnlineRoundParamsIter, true) if err != nil { return fmt.Errorf("unable to get online round params verification data: %v", err) } @@ -1058,10 +1058,11 @@ func (c *catchpointCatchupAccessorImpl) GetVerifyData(ctx context.Context) (bala // both at restore time (in catchpointCatchupAccessorImpl) and snapshot time (in catchpointTracker). func calculateVerificationHash[T crypto.Hashable]( ctx context.Context, - iterFactory func(context.Context) (trackerdb.TableIterator[T], error), + iterFactory func(context.Context, bool) (trackerdb.TableIterator[T], error), + useStaging bool, ) (crypto.Digest, uint64, error) { - rows, err := iterFactory(ctx) + rows, err := iterFactory(ctx, useStaging) if err != nil { return crypto.Digest{}, 0, err } diff --git a/ledger/eval_simple_test.go b/ledger/eval_simple_test.go index 6ec44b99f3..f518f074f0 100644 --- a/ledger/eval_simple_test.go +++ b/ledger/eval_simple_test.go @@ -33,6 +33,7 @@ import ( "github.com/algorand/go-algorand/crypto/merklesignature" "github.com/algorand/go-algorand/data/basics" "github.com/algorand/go-algorand/data/bookkeeping" + "github.com/algorand/go-algorand/data/committee" "github.com/algorand/go-algorand/data/transactions" "github.com/algorand/go-algorand/data/txntest" "github.com/algorand/go-algorand/ledger/ledgercore" @@ -1238,11 +1239,11 @@ func TestRekeying(t *testing.T) { if err != nil { return err } - validatedBlock := ledgercore.MakeValidatedBlock(unfinishedBlock.UnfinishedBlock(), unfinishedBlock.UnfinishedDeltas()) + fb := unfinishedBlock.FinishBlock(committee.Seed{0x01}, basics.Address{0x01}, false) backlogPool := execpool.MakeBacklog(nil, 0, execpool.LowPriority, nil) defer backlogPool.Shutdown() - _, err = l.Validate(context.Background(), validatedBlock.Block(), backlogPool) + _, err = l.Validate(context.Background(), fb, backlogPool) return err } diff --git a/ledger/ledger_test.go b/ledger/ledger_test.go index 8941452d4c..219b12bc3e 100644 --- a/ledger/ledger_test.go +++ b/ledger/ledger_test.go @@ -155,6 +155,10 @@ func makeNewEmptyBlock(t *testing.T, l *Ledger, GenesisID string, initAccounts m // UpgradeVote: empty, } + if proto.Payouts.Enabled { + blk.BlockHeader.Proposer = basics.Address{0x01} // Must be set to _something_. + } + blk.TxnCommitments, err = blk.PaysetCommit() require.NoError(t, err) @@ -262,6 +266,8 @@ func TestLedgerBlockHeaders(t *testing.T) { Round: l.Latest() + 1, Branch: lastBlock.Hash(), // Seed: does not matter, + Bonus: bookkeeping.NextBonus(lastBlock.BlockHeader, &proto), + Proposer: basics.Address{0x01}, // Must be set to _something_. TimeStamp: 0, GenesisID: t.Name(), RewardsState: lastBlock.NextRewardsState(l.Latest()+1, proto, poolBal.MicroAlgos, totalRewardUnits, logging.Base()), diff --git a/ledger/store/trackerdb/dualdriver/dualdriver.go b/ledger/store/trackerdb/dualdriver/dualdriver.go index ed23528675..382db683a7 100644 --- a/ledger/store/trackerdb/dualdriver/dualdriver.go +++ b/ledger/store/trackerdb/dualdriver/dualdriver.go @@ -278,13 +278,13 @@ func (*reader) MakeKVsIter(ctx context.Context) (trackerdb.KVsIter, error) { } // MakeOnlineAccountsIter implements trackerdb.Reader -func (*reader) MakeOnlineAccountsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { +func (*reader) MakeOnlineAccountsIter(context.Context, bool) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { // TODO: catchpoint return nil, nil } // MakeOnlineRoundParamsIter implements trackerdb.Reader -func (*reader) MakeOnlineRoundParamsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { +func (*reader) MakeOnlineRoundParamsIter(context.Context, bool) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { // TODO: catchpoint return nil, nil } diff --git a/ledger/store/trackerdb/generickv/reader.go b/ledger/store/trackerdb/generickv/reader.go index f8422792e5..bbbfadc9c9 100644 --- a/ledger/store/trackerdb/generickv/reader.go +++ b/ledger/store/trackerdb/generickv/reader.go @@ -79,13 +79,13 @@ func (r *reader) MakeKVsIter(ctx context.Context) (trackerdb.KVsIter, error) { } // MakeOnlineAccountsIter implements trackerdb.Reader -func (r *reader) MakeOnlineAccountsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { +func (r *reader) MakeOnlineAccountsIter(context.Context, bool) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { // TODO: catchpoint panic("unimplemented") } // MakeOnlineRoundParamsIter implements trackerdb.Reader -func (r *reader) MakeOnlineRoundParamsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { +func (r *reader) MakeOnlineRoundParamsIter(context.Context, bool) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { // TODO: catchpoint panic("unimplemented") } diff --git a/ledger/store/trackerdb/sqlitedriver/kvsIter.go b/ledger/store/trackerdb/sqlitedriver/kvsIter.go index b85d6c48cb..05fc769d6b 100644 --- a/ledger/store/trackerdb/sqlitedriver/kvsIter.go +++ b/ledger/store/trackerdb/sqlitedriver/kvsIter.go @@ -73,8 +73,13 @@ func (iter *tableIterator[T]) GetItem() (T, error) { } // MakeOnlineAccountsIter creates an onlineAccounts iterator. -func MakeOnlineAccountsIter(ctx context.Context, q db.Queryable) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { - rows, err := q.QueryContext(ctx, "SELECT address, updround, normalizedonlinebalance, votelastvalid, data FROM onlineaccounts ORDER BY address, updround") +func MakeOnlineAccountsIter(ctx context.Context, q db.Queryable, useStaging bool) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { + table := "onlineaccounts" + if useStaging { + table = "catchpointonlineaccounts" + } + + rows, err := q.QueryContext(ctx, fmt.Sprintf("SELECT address, updround, normalizedonlinebalance, votelastvalid, data FROM %s ORDER BY address, updround", table)) if err != nil { return nil, err } @@ -131,8 +136,12 @@ func scanOnlineAccount(rows *sql.Rows) (*encoded.OnlineAccountRecordV6, error) { } // MakeOnlineRoundParamsIter creates an onlineRoundParams iterator. -func MakeOnlineRoundParamsIter(ctx context.Context, q db.Queryable) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { - rows, err := q.QueryContext(ctx, "SELECT rnd, data FROM onlineroundparamstail ORDER BY rnd") +func MakeOnlineRoundParamsIter(ctx context.Context, q db.Queryable, useStaging bool) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { + table := "onlineroundparamstail" + if useStaging { + table = "catchpointonlineroundparamstail" + } + rows, err := q.QueryContext(ctx, fmt.Sprintf("SELECT rnd, data FROM %s ORDER BY rnd", table)) if err != nil { return nil, err } diff --git a/ledger/store/trackerdb/sqlitedriver/sqlitedriver.go b/ledger/store/trackerdb/sqlitedriver/sqlitedriver.go index d29fdb9abc..247744e01f 100644 --- a/ledger/store/trackerdb/sqlitedriver/sqlitedriver.go +++ b/ledger/store/trackerdb/sqlitedriver/sqlitedriver.go @@ -212,13 +212,13 @@ func (r *sqlReader) MakeKVsIter(ctx context.Context) (trackerdb.KVsIter, error) } // MakeOnlineAccountsIter implements trackerdb.Reader -func (r *sqlReader) MakeOnlineAccountsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { - return MakeOnlineAccountsIter(ctx, r.q) +func (r *sqlReader) MakeOnlineAccountsIter(ctx context.Context, useStaging bool) (trackerdb.TableIterator[*encoded.OnlineAccountRecordV6], error) { + return MakeOnlineAccountsIter(ctx, r.q, useStaging) } // MakeOnlineRoundParamsIter implements trackerdb.Reader -func (r *sqlReader) MakeOnlineRoundParamsIter(ctx context.Context) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { - return MakeOnlineRoundParamsIter(ctx, r.q) +func (r *sqlReader) MakeOnlineRoundParamsIter(ctx context.Context, useStaging bool) (trackerdb.TableIterator[*encoded.OnlineRoundParamsRecordV6], error) { + return MakeOnlineRoundParamsIter(ctx, r.q, useStaging) } type sqlWriter struct { diff --git a/ledger/store/trackerdb/store.go b/ledger/store/trackerdb/store.go index 968c313a81..66f7fd0f19 100644 --- a/ledger/store/trackerdb/store.go +++ b/ledger/store/trackerdb/store.go @@ -66,8 +66,8 @@ type Reader interface { MakeCatchpointReader() (CatchpointReader, error) MakeEncodedAccountsBatchIter() EncodedAccountsBatchIter MakeKVsIter(ctx context.Context) (KVsIter, error) - MakeOnlineAccountsIter(ctx context.Context) (TableIterator[*encoded.OnlineAccountRecordV6], error) - MakeOnlineRoundParamsIter(ctx context.Context) (TableIterator[*encoded.OnlineRoundParamsRecordV6], error) + MakeOnlineAccountsIter(ctx context.Context, useStaging bool) (TableIterator[*encoded.OnlineAccountRecordV6], error) + MakeOnlineRoundParamsIter(ctx context.Context, useStaging bool) (TableIterator[*encoded.OnlineRoundParamsRecordV6], error) } // Writer is the interface for the trackerdb write operations. diff --git a/ledger/testing/consensusRange.go b/ledger/testing/consensusRange.go index 199a462afc..882fb0f05d 100644 --- a/ledger/testing/consensusRange.go +++ b/ledger/testing/consensusRange.go @@ -61,6 +61,7 @@ var consensusByNumber = []protocol.ConsensusVersion{ protocol.ConsensusV37, protocol.ConsensusV38, // AVM v9, ECDSA pre-check, stateproofs recoverability protocol.ConsensusV39, // AVM v10, logicsig opcode budget pooling, elliptic curve ops, dynamic round times + protocol.ConsensusV40, // Consensus incentives, AVM v11, mimc protocol.ConsensusFuture, } diff --git a/ledger/testing/consensusRange_test.go b/ledger/testing/consensusRange_test.go index 9b270e3bf7..1ee2fee8f1 100644 --- a/ledger/testing/consensusRange_test.go +++ b/ledger/testing/consensusRange_test.go @@ -56,6 +56,6 @@ func TestReleasedVersion(t *testing.T) { } require.Equal(t, versionStringFromIndex(len(consensusByNumber)-1), "vFuture") - require.Equal(t, versionStringFromIndex(39), "v39") + require.Equal(t, versionStringFromIndex(40), "v40") } diff --git a/node/follower_node_test.go b/node/follower_node_test.go index cd82ea4e34..4983b68c8c 100644 --- a/node/follower_node_test.go +++ b/node/follower_node_test.go @@ -39,6 +39,8 @@ import ( "github.com/algorand/go-algorand/test/partitiontest" ) +var testAddr = basics.Address{0x6, 0xda, 0xcc, 0x4b, 0x6d, 0x9e, 0xd1, 0x41, 0xb1, 0x75, 0x76, 0xbd, 0x45, 0x9a, 0xe6, 0x42, 0x1d, 0x48, 0x6d, 0xa3, 0xd4, 0xef, 0x21, 0x47, 0xc4, 0x9, 0xa3, 0x96, 0xb8, 0x2e, 0xa2, 0x21} + func followNodeDefaultGenesis() bookkeeping.Genesis { return bookkeeping.Genesis{ SchemaID: "go-test-follower-node-genesis", @@ -56,7 +58,13 @@ func followNodeDefaultGenesis() bookkeeping.Genesis { { Address: sinkAddr.String(), State: bookkeeping.GenesisAccountData{ - MicroAlgos: basics.MicroAlgos{Raw: 1000000}, + MicroAlgos: basics.MicroAlgos{Raw: 500000}, + }, + }, + { + Address: testAddr.String(), + State: bookkeeping.GenesisAccountData{ + MicroAlgos: basics.MicroAlgos{Raw: 500000}, }, }, }, @@ -73,20 +81,6 @@ func setupFollowNode(t *testing.T) *AlgorandFollowerNode { return node } -func remakeableFollowNode(t *testing.T, tempDir string, maxAcctLookback uint64) (*AlgorandFollowerNode, string) { - cfg := config.GetDefaultLocal() - cfg.EnableFollowMode = true - cfg.DisableNetworking = true - cfg.MaxAcctLookback = maxAcctLookback - genesis := followNodeDefaultGenesis() - if tempDir == "" { - tempDir = t.TempDir() - } - followNode, err := MakeFollower(logging.Base(), tempDir, cfg, []string{}, genesis) - require.NoError(t, err) - return followNode, tempDir -} - func TestSyncRound(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() @@ -317,7 +311,7 @@ func TestSimulate(t *testing.T) { stxn := txntest.Txn{ Type: protocol.PaymentTx, - Sender: sinkAddr, + Sender: testAddr, Receiver: poolAddr, Amount: 1, Fee: 1000, diff --git a/protocol/consensus.go b/protocol/consensus.go index 51c023ec2a..1549ae76bd 100644 --- a/protocol/consensus.go +++ b/protocol/consensus.go @@ -223,6 +223,11 @@ const ConsensusV39 = ConsensusVersion( "https://github.com/algorandfoundation/specs/tree/925a46433742afb0b51bb939354bd907fa88bf95", ) +// ConsensusV40 enables consensus incentives and TEAL v11 featuring the mimc opcode +const ConsensusV40 = ConsensusVersion( + "https://github.com/algorandfoundation/specs/tree/236dcc18c9c507d794813ab768e467ea42d1b4d9", +) + // 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( @@ -252,7 +257,7 @@ const ConsensusVAlpha5 = ConsensusVersion("alpha5") // ConsensusCurrentVersion is the latest version and should be used // when a specific version is not provided. -const ConsensusCurrentVersion = ConsensusV39 +const ConsensusCurrentVersion = ConsensusV40 // Error is used to indicate that an unsupported protocol has been detected. type Error ConsensusVersion diff --git a/test/e2e-go/features/catchup/catchpointCatchup_test.go b/test/e2e-go/features/catchup/catchpointCatchup_test.go index e7408ed55a..ec6171cbfd 100644 --- a/test/e2e-go/features/catchup/catchpointCatchup_test.go +++ b/test/e2e-go/features/catchup/catchpointCatchup_test.go @@ -474,7 +474,7 @@ func TestNodeTxHandlerRestart(t *testing.T) { a := require.New(fixtures.SynchronizedTest(t)) consensus := make(config.ConsensusProtocols) - protoVersion := protocol.ConsensusFuture + protoVersion := protocol.ConsensusCurrentVersion catchpointCatchupProtocol := config.Consensus[protoVersion] applyCatchpointConsensusChanges(&catchpointCatchupProtocol) catchpointCatchupProtocol.StateProofInterval = 0 @@ -581,7 +581,7 @@ func TestReadyEndpoint(t *testing.T) { a := require.New(fixtures.SynchronizedTest(t)) consensus := make(config.ConsensusProtocols) - protoVersion := protocol.ConsensusFuture + protoVersion := protocol.ConsensusCurrentVersion catchpointCatchupProtocol := config.Consensus[protoVersion] applyCatchpointConsensusChanges(&catchpointCatchupProtocol) catchpointCatchupProtocol.StateProofInterval = 0 @@ -720,7 +720,7 @@ func TestNodeTxSyncRestart(t *testing.T) { a := require.New(fixtures.SynchronizedTest(t)) consensus := make(config.ConsensusProtocols) - protoVersion := protocol.ConsensusFuture + protoVersion := protocol.ConsensusCurrentVersion catchpointCatchupProtocol := config.Consensus[protoVersion] prevMaxTxnLife := catchpointCatchupProtocol.MaxTxnLife applyCatchpointConsensusChanges(&catchpointCatchupProtocol) diff --git a/test/e2e-go/features/catchup/stateproofsCatchup_test.go b/test/e2e-go/features/catchup/stateproofsCatchup_test.go index 69c50f5ccd..5e5e34a067 100644 --- a/test/e2e-go/features/catchup/stateproofsCatchup_test.go +++ b/test/e2e-go/features/catchup/stateproofsCatchup_test.go @@ -146,7 +146,7 @@ func TestStateProofAfterCatchpoint(t *testing.T) { } a := require.New(fixtures.SynchronizedTest(t)) - consensusParams := config.Consensus[protocol.ConsensusFuture] + consensusParams := config.Consensus[protocol.ConsensusCurrentVersion] applyCatchpointConsensusChanges(&consensusParams) applyCatchpointStateProofConsensusChanges(&consensusParams) consensusParams.StateProofInterval = 16