mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
refactor(params): make LibEVMVersion a constant (#162)
> [!NOTE] > This will be merged into `main` once the current target branch has been merged. ## Why this should be merged My original implementation was back to front and it's been bugging me. ## How this works Originally `params.LibEVMVersion` was a `var` (because it needed to be computed) and the test used a `const`. This change simply inverts the two and moves some code around without any change in logic. I bumped the minor version to 2 (a no-op when not on a release branch) to bring it in line with the latest release candidate and to avoid forgetting to do so when performing an actual release. ## How this was tested Unit test of version-string constant.
This commit is contained in:
parent
08490a9b76
commit
0ed61356ed
6 changed files with 36 additions and 55 deletions
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
|
|
@ -5,8 +5,6 @@ on:
|
||||||
branches: [main, "release/**"]
|
branches: [main, "release/**"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, "release/**"]
|
branches: [main, "release/**"]
|
||||||
merge_group:
|
|
||||||
types: [checks_requested]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|
|
||||||
2
.github/workflows/libevm-delta.yml
vendored
2
.github/workflows/libevm-delta.yml
vendored
|
|
@ -5,8 +5,6 @@ on:
|
||||||
branches: [main, "release/**"]
|
branches: [main, "release/**"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, "release/**"]
|
branches: [main, "release/**"]
|
||||||
merge_group:
|
|
||||||
types: [checks_requested]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|
|
||||||
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
|
@ -5,8 +5,6 @@ on:
|
||||||
branches: [main, "release/**"]
|
branches: [main, "release/**"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, "release/**"]
|
branches: [main, "release/**"]
|
||||||
merge_group:
|
|
||||||
types: [checks_requested]
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/ava-labs/libevm/common"
|
|
||||||
"github.com/ava-labs/libevm/libevm/pseudo"
|
"github.com/ava-labs/libevm/libevm/pseudo"
|
||||||
"github.com/ava-labs/libevm/libevm/register"
|
"github.com/ava-labs/libevm/libevm/register"
|
||||||
"github.com/ava-labs/libevm/libevm/testonly"
|
"github.com/ava-labs/libevm/libevm/testonly"
|
||||||
|
|
@ -366,8 +365,3 @@ func (e *StateAccountExtra) Format(s fmt.State, verb rune) {
|
||||||
}
|
}
|
||||||
_, _ = s.Write([]byte(out))
|
_, _ = s.Write([]byte(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RLPHash returns the hash of the RLP encoding of `x`.
|
|
||||||
func RLPHash(x any) common.Hash {
|
|
||||||
return rlpHash(x)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,9 @@
|
||||||
|
|
||||||
package params
|
package params
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LibEVMVersionMajor = 0
|
LibEVMVersionMajor = 0
|
||||||
LibEVMVersionMinor = 1
|
LibEVMVersionMinor = 2
|
||||||
LibEVMVersionPatch = 0
|
LibEVMVersionPatch = 0
|
||||||
|
|
||||||
LibEVMReleaseType ReleaseType = BetaRelease
|
LibEVMReleaseType ReleaseType = BetaRelease
|
||||||
|
|
@ -50,23 +48,7 @@ const (
|
||||||
// triplet.
|
// triplet.
|
||||||
//
|
//
|
||||||
// [semver v2]: https://semver.org/
|
// [semver v2]: https://semver.org/
|
||||||
var LibEVMVersion = func() string {
|
const LibEVMVersion = "1.13.14-0.2.0.beta"
|
||||||
v := libEVMSemver{
|
|
||||||
geth: semverTriplet{VersionMajor, VersionMinor, VersionPatch},
|
|
||||||
libEVM: semverTriplet{LibEVMVersionMajor, LibEVMVersionMinor, LibEVMVersionPatch},
|
|
||||||
typ: LibEVMReleaseType,
|
|
||||||
rc: libEVMReleaseCandidate,
|
|
||||||
}
|
|
||||||
return v.String()
|
|
||||||
}()
|
|
||||||
|
|
||||||
type semverTriplet struct {
|
|
||||||
major, minor, patch uint
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t semverTriplet) String() string {
|
|
||||||
return fmt.Sprintf("%d.%d.%d", t.major, t.minor, t.patch)
|
|
||||||
}
|
|
||||||
|
|
||||||
// A ReleaseType is a suffix for [LibEVMVersion].
|
// A ReleaseType is a suffix for [LibEVMVersion].
|
||||||
type ReleaseType string
|
type ReleaseType string
|
||||||
|
|
@ -86,17 +68,3 @@ const (
|
||||||
func (t ReleaseType) ForReleaseBranch() bool {
|
func (t ReleaseType) ForReleaseBranch() bool {
|
||||||
return t == ReleaseCandidate || t == ProductionRelease
|
return t == ReleaseCandidate || t == ProductionRelease
|
||||||
}
|
}
|
||||||
|
|
||||||
type libEVMSemver struct {
|
|
||||||
geth, libEVM semverTriplet
|
|
||||||
typ ReleaseType
|
|
||||||
rc uint
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v libEVMSemver) String() string {
|
|
||||||
suffix := v.typ
|
|
||||||
if suffix == ReleaseCandidate {
|
|
||||||
suffix = ReleaseType(fmt.Sprintf("%s.%d", suffix, v.rc))
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s-%s.%s", v.geth, v.libEVM, suffix)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -17,22 +17,47 @@
|
||||||
package params
|
package params
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestLibEVMVersioning(t *testing.T) {
|
// libEVMServer automates the version rules described by the [LibEVMVersion]
|
||||||
// We have an unusual version structure as defined by [LibEVMVersion] that
|
// documentation.
|
||||||
// is easy to mess up, so it's easier to just automate it and test the
|
type libEVMSemver struct {
|
||||||
// ordering assumptions.
|
geth, libEVM semverTriplet
|
||||||
|
typ ReleaseType
|
||||||
|
rc uint
|
||||||
|
}
|
||||||
|
|
||||||
// This is a deliberate change-detector test to provide us with a copyable
|
func (v libEVMSemver) String() string {
|
||||||
// string of the current version, useful for git tagging.
|
suffix := v.typ
|
||||||
const curr = "1.13.14-0.1.0.beta"
|
if suffix == ReleaseCandidate {
|
||||||
if got, want := LibEVMVersion, curr; got != want {
|
suffix = ReleaseType(fmt.Sprintf("%s.%d", suffix, v.rc))
|
||||||
t.Errorf("got LibEVMVersion %q; want %q", got, want)
|
|
||||||
}
|
}
|
||||||
|
return fmt.Sprintf("%s-%s.%s", v.geth, v.libEVM, suffix)
|
||||||
|
}
|
||||||
|
|
||||||
|
type semverTriplet struct {
|
||||||
|
major, minor, patch uint
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t semverTriplet) String() string {
|
||||||
|
return fmt.Sprintf("%d.%d.%d", t.major, t.minor, t.patch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLibEVMVersioning(t *testing.T) {
|
||||||
|
t.Run("current", func(t *testing.T) {
|
||||||
|
want := libEVMSemver{
|
||||||
|
geth: semverTriplet{VersionMajor, VersionMinor, VersionPatch},
|
||||||
|
libEVM: semverTriplet{LibEVMVersionMajor, LibEVMVersionMinor, LibEVMVersionPatch},
|
||||||
|
typ: LibEVMReleaseType,
|
||||||
|
rc: libEVMReleaseCandidate,
|
||||||
|
}.String()
|
||||||
|
assert.Equal(t, want, LibEVMVersion, "LibEVMVersion")
|
||||||
|
})
|
||||||
|
|
||||||
ordered := []libEVMSemver{
|
ordered := []libEVMSemver{
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue