Skip to content

Commit

Permalink
Merge pull request #5482 from Algo-devops-service/relstable3.16.2-rem…
Browse files Browse the repository at this point in the history
…erge
  • Loading branch information
algojohnlee committed Jun 21, 2023
2 parents 5f496cf + 9d425e3 commit 5d65abf
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const VersionMajor = 3

// 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 = 16
const VersionMinor = 17

// Version is the type holding our full version information.
type Version struct {
Expand Down Expand Up @@ -72,7 +72,7 @@ func (v Version) AsUInt64() (versionInfo uint64) {
versionInfo = uint64(v.Major)
versionInfo <<= 16
versionInfo |= uint64(v.Minor)
versionInfo <<= 16
versionInfo <<= 24
versionInfo |= uint64(v.BuildNumber)
return
}
Expand Down
60 changes: 60 additions & 0 deletions config/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (C) 2019-2023 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 <https://www.gnu.org/licenses/>.

package config

import (
"fmt"
"testing"

"github.com/algorand/go-algorand/test/partitiontest"
"github.com/algorand/go-algorand/util/s3"
"github.com/stretchr/testify/require"
)

func TestAlgodVsUpdatedVersions(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

tests := []struct {
major int
minor int
build int
}{
{major: 1, minor: 1, build: 32111},
{major: 2, minor: 0, build: 0},
{major: 3, minor: 13, build: 170018},
{major: 3, minor: 15, build: 157},
{major: 3, minor: 16, build: 0},
{major: 3, minor: 16, build: 100},
}

for _, tt := range tests {
t.Run(fmt.Sprintf("%d.%d.%d", tt.major, tt.minor, tt.build), func(t *testing.T) {
version := Version{Major: tt.major, Minor: tt.minor, BuildNumber: tt.build}
str := version.String()
ver, err := s3.GetVersionFromName("_" + str)
require.NoError(t, err)
require.Equal(t, version.AsUInt64(), ver)
major, minor, patch, err := s3.GetVersionPartsFromVersion(ver)
require.NoError(t, err)
require.Equal(t, uint64(tt.major), major)
require.Equal(t, uint64(tt.minor), minor)
require.Equal(t, uint64(tt.build), patch)

})
}
}
26 changes: 24 additions & 2 deletions ledger/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,8 +1323,30 @@ func (eval *BlockEvaluator) endOfBlock() error {
if !eval.block.StateProofTracking[protocol.StateProofBasic].StateProofVotersCommitment.IsEqual(expectedVoters) {
return fmt.Errorf("StateProofVotersCommitment wrong: %v != %v", eval.block.StateProofTracking[protocol.StateProofBasic].StateProofVotersCommitment, expectedVoters)
}
if eval.block.StateProofTracking[protocol.StateProofBasic].StateProofOnlineTotalWeight != expectedVotersWeight {
return fmt.Errorf("StateProofOnlineTotalWeight wrong: %v != %v", eval.block.StateProofTracking[protocol.StateProofBasic].StateProofOnlineTotalWeight, expectedVotersWeight)
if eval.proto.ExcludeExpiredCirculation {
if eval.block.StateProofTracking[protocol.StateProofBasic].StateProofOnlineTotalWeight != expectedVotersWeight {
return fmt.Errorf("StateProofOnlineTotalWeight wrong: %v != %v", eval.block.StateProofTracking[protocol.StateProofBasic].StateProofOnlineTotalWeight, expectedVotersWeight)
}
} else {
if eval.block.StateProofTracking[protocol.StateProofBasic].StateProofOnlineTotalWeight != expectedVotersWeight {
actualVotersWeight := eval.block.StateProofTracking[protocol.StateProofBasic].StateProofOnlineTotalWeight
var highWeight, lowWeight basics.MicroAlgos
if expectedVotersWeight.LessThan(actualVotersWeight) {
highWeight = actualVotersWeight
lowWeight = expectedVotersWeight
} else {
highWeight = expectedVotersWeight
lowWeight = actualVotersWeight
}
const stakeDiffusionFactor = 5
allowedDelta, overflowed := basics.Muldiv(expectedVotersWeight.Raw, stakeDiffusionFactor, 100)
if overflowed {
return fmt.Errorf("StateProofOnlineTotalWeight overflow: %v != %v", actualVotersWeight, expectedVotersWeight)
}
if (highWeight.Raw - lowWeight.Raw) > allowedDelta {
return fmt.Errorf("StateProofOnlineTotalWeight wrong: %v != %v greater than %d", actualVotersWeight, expectedVotersWeight, allowedDelta)
}
}
}
if eval.block.StateProofTracking[protocol.StateProofBasic].StateProofNextRound != eval.state.GetStateProofNextRound() {
return fmt.Errorf("StateProofNextRound wrong: %v != %v", eval.block.StateProofTracking[protocol.StateProofBasic].StateProofNextRound, eval.state.GetStateProofNextRound())
Expand Down
1 change: 1 addition & 0 deletions util/s3/s3Helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func TestGetPartsFromVersion(t *testing.T) {
{name: "test 4 (minor)", version: 1*1<<40 + 2*1<<24, expMajor: 1, expMinor: 2, expPatch: 0},
{name: "test 5 (patch)", version: 1*1<<40 + 1, expMajor: 1, expMinor: 0, expPatch: 1},
{name: "test 6 (patch)", version: 1*1<<40 + 2, expMajor: 1, expMinor: 0, expPatch: 2},
{name: "test 6 (patch)", version: 3298803318784, expMajor: 3, expMinor: 16, expPatch: 0},
}

for _, test := range tests {
Expand Down

0 comments on commit 5d65abf

Please sign in to comment.