Skip to content

Commit 25e5ca3

Browse files
authored
chore: retract v1.13.14-0.1.0-rc.1 (#81)
## Why this should be merged I messed up the format of `rc` version tags, resulting in `rc.1` being considered a later version that `rc.2`. ## How this works The [release tagging](#37) pattern that includes a combination of `geth` and `libevm` semver triplets (e.g. `1.13.14-0.1.0`) doesn't work well with extra identifiers like `rc` because more pre-release identifiers (those after `-`) take higher precedence if all those before them match. We therefore have to use a `release` suffix (`"release" > "rc"` in ASCII). This all became too much to expect to be done manually so I chucked it in code instead. ## How this was tested Unit test demonstrates expectation of version ordering.
1 parent c2f1269 commit 25e5ca3

File tree

3 files changed

+181
-0
lines changed

3 files changed

+181
-0
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module github.com/ava-labs/libevm
22

33
go 1.20
44

5+
retract v1.13.14-0.1.0-rc.1 // bad semver format ("0-rc" grouping) considered > .rc-2
6+
57
require (
68
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
79
github.com/Microsoft/go-winio v0.6.1

params/version.libevm.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Copyright 2024 the libevm authors.
2+
//
3+
// The libevm additions to go-ethereum are free software: you can redistribute
4+
// them and/or modify them under the terms of the GNU Lesser General Public License
5+
// as published by the Free Software Foundation, either version 3 of the License,
6+
// or (at your option) any later version.
7+
//
8+
// The libevm additions are distributed in the hope that they will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11+
// General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU Lesser General Public License
14+
// along with the go-ethereum library. If not, see
15+
// <http://www.gnu.org/licenses/>.
16+
17+
package params
18+
19+
import "fmt"
20+
21+
const (
22+
LibEVMVersionMajor = 0
23+
LibEVMVersionMinor = 1
24+
LibEVMVersionPatch = 0
25+
26+
libEVMReleaseType releaseType = betaRelease
27+
libEVMReleaseCandidate uint = 0 // ignored unless [libEVMReleaseType] == [releaseCandidate]
28+
)
29+
30+
// LibEVMVersion holds the textual version string of `libevm` modifications.
31+
//
32+
// Although compliant with [semver v2], it follows additional rules:
33+
//
34+
// 1. Major, minor, and patch MUST be the respective `geth` values;
35+
// 2. The first three pre-release identifiers MUST be a semver-compliant
36+
// triplet denoting the `libevm` "version";
37+
// 3. On the `main` (development) branch, the final identifier MUST be "alpha"
38+
// or "beta";
39+
// 3. If a production version, the final identifier MUST be "release"; and
40+
// 4. If a release candidate, the final two identifiers MUST be "rc" and an
41+
// incrementing numeric value.
42+
//
43+
// The benefits of this pattern are that (a) it captures all relevant
44+
// information; and (b) it follows an intuitive ordering under semver rules.
45+
// Precedence is determined first by the `geth` version then the `libevm`
46+
// version, with release candidates being lower than actual releases.
47+
//
48+
// The primary drawbacks is that it requires an explicit "release" identifier
49+
// because of the use of pre-release identifiers to capture the `libevm`
50+
// triplet.
51+
//
52+
// [semver v2]: https://semver.org/
53+
var LibEVMVersion = func() string {
54+
v := libEVMSemver{
55+
geth: semverTriplet{VersionMajor, VersionMinor, VersionPatch},
56+
libEVM: semverTriplet{LibEVMVersionMajor, LibEVMVersionMinor, LibEVMVersionPatch},
57+
typ: libEVMReleaseType,
58+
rc: libEVMReleaseCandidate,
59+
}
60+
return v.String()
61+
}()
62+
63+
type semverTriplet struct {
64+
major, minor, patch uint
65+
}
66+
67+
func (t semverTriplet) String() string {
68+
return fmt.Sprintf("%d.%d.%d", t.major, t.minor, t.patch)
69+
}
70+
71+
type releaseType string
72+
73+
const (
74+
// betaRelease MUST be used on `main` branch
75+
betaRelease = releaseType("beta")
76+
// Reserved for `release/*` branches
77+
releaseCandidate = releaseType("rc")
78+
productionRelease = releaseType("release")
79+
)
80+
81+
type libEVMSemver struct {
82+
geth, libEVM semverTriplet
83+
typ releaseType
84+
rc uint
85+
}
86+
87+
func (v libEVMSemver) String() string {
88+
suffix := v.typ
89+
if suffix == releaseCandidate {
90+
suffix = releaseType(fmt.Sprintf("%s.%d", suffix, v.rc))
91+
}
92+
return fmt.Sprintf("%s-%s.%s", v.geth, v.libEVM, suffix)
93+
}

params/version.libevm_test.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright 2024 the libevm authors.
2+
//
3+
// The libevm additions to go-ethereum are free software: you can redistribute
4+
// them and/or modify them under the terms of the GNU Lesser General Public License
5+
// as published by the Free Software Foundation, either version 3 of the License,
6+
// or (at your option) any later version.
7+
//
8+
// The libevm additions are distributed in the hope that they will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
11+
// General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU Lesser General Public License
14+
// along with the go-ethereum library. If not, see
15+
// <http://www.gnu.org/licenses/>.
16+
17+
package params
18+
19+
import (
20+
"testing"
21+
22+
"golang.org/x/mod/semver"
23+
)
24+
25+
func TestLibEVMVersioning(t *testing.T) {
26+
// We have an unusual version structure as defined by [LibEVMVersion] that
27+
// is easy to mess up, so it's easier to just automate it and test the
28+
// ordering assumptions.
29+
30+
// This is a deliberate change-detector test to provide us with a copyable
31+
// string of the current version, useful for git tagging.
32+
const curr = "1.13.14-0.1.0.beta"
33+
if got, want := LibEVMVersion, curr; got != want {
34+
t.Errorf("got LibEVMVersion %q; want %q", got, want)
35+
}
36+
37+
ordered := []libEVMSemver{
38+
{
39+
semverTriplet{1, 13, 14},
40+
semverTriplet{0, 1, 0},
41+
betaRelease,
42+
0, // ignored
43+
},
44+
{
45+
semverTriplet{1, 13, 14},
46+
semverTriplet{0, 1, 0},
47+
releaseCandidate, 1,
48+
},
49+
{
50+
semverTriplet{1, 13, 14},
51+
semverTriplet{0, 1, 0},
52+
releaseCandidate, 2,
53+
},
54+
{
55+
semverTriplet{1, 13, 14},
56+
semverTriplet{0, 1, 0},
57+
productionRelease,
58+
0, // ignored,
59+
},
60+
{
61+
semverTriplet{1, 13, 14},
62+
semverTriplet{0, 1, 1}, // bump takes precedence
63+
betaRelease, 0,
64+
},
65+
{
66+
semverTriplet{1, 13, 14},
67+
semverTriplet{0, 1, 1},
68+
productionRelease, 0,
69+
},
70+
{
71+
semverTriplet{1, 13, 15}, // bump takes precedence
72+
semverTriplet{0, 1, 1},
73+
betaRelease, 0,
74+
},
75+
}
76+
77+
for i, low := range ordered[:len(ordered)-1] {
78+
// The `go mod` semver package requires the "v" prefix, which
79+
// technically isn't valid semver.
80+
lo := "v" + low.String()
81+
hi := "v" + ordered[i+1].String()
82+
if got := semver.Compare(lo, hi); got != -1 {
83+
t.Errorf("Version pattern is not strictly ordered; semver.Compare(%q, %q) = %d", lo, hi, got)
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)