Skip to content

Commit

Permalink
Add op-geth version in addition to geth version (ethereum#43)
Browse files Browse the repository at this point in the history
There are now two versions stored in params/version.go. One for
upstream geth and one for op-geth. We keep the upstream version
in the source to make it easier to determine the base version.

We retain a unique versioning system for op-geth because we do
not expect a 1:1 correspondence between our versions & upstream
versions.
  • Loading branch information
trianglesphere authored and protolambda committed Sep 6, 2022
1 parent f0b6887 commit 93afadf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func doDocker(cmdline []string) {
case env.Branch == "master":
tags = []string{"latest"}
case strings.HasPrefix(env.Tag, "v1."):
tags = []string{"stable", fmt.Sprintf("release-1.%d", params.VersionMinor), "v" + params.Version}
tags = []string{"stable", fmt.Sprintf("release-1.%d", params.OPVersionMinor), "v" + params.Version}
}
// If architecture specific image builds are requested, build and push them
if *image {
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/misccmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func version(ctx *cli.Context) error {
if gitDate != "" {
fmt.Println("Git Commit Date:", gitDate)
}
fmt.Println("Upstream Version:", params.GethVersionWithMeta)
fmt.Println("Architecture:", runtime.GOARCH)
fmt.Println("Go Version:", runtime.Version())
fmt.Println("Operating System:", runtime.GOOS)
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func makeExtraData(extra []byte) []byte {
if len(extra) == 0 {
// create default extradata
extra, _ = rlp.EncodeToBytes([]interface{}{
uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch),
uint(params.OPVersionMajor<<16 | params.OPVersionMinor<<8 | params.OPVersionPatch),
"geth",
runtime.Version(),
runtime.GOOS,
Expand Down
29 changes: 25 additions & 4 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,41 @@ import (
)

const (
// Version is the version of upstream geth
VersionMajor = 1 // Major version component of the current release
VersionMinor = 11 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "unstable" // Version metadata to append to the version string

// OPVersion is the version of op-geth
OPVersionMajor = 0 // Major version component of the current release
OPVersionMinor = 1 // Minor version component of the current release
OPVersionPatch = 0 // Patch version component of the current release
OPVersionMeta = "unstable" // Version metadata to append to the version string
)

// Version holds the textual version string.
var Version = func() string {
return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
return fmt.Sprintf("%d.%d.%d", OPVersionMajor, OPVersionMinor, OPVersionPatch)
}()

// VersionWithMeta holds the textual version string including the metadata.
var VersionWithMeta = func() string {
v := Version
if OPVersionMeta != "" {
v += "-" + OPVersionMeta
}
return v
}()

// GethVersion holds the textual geth version string.
var GethVersion = func() string {
return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
}()

// GethVersionWithMeta holds the textual geth version string including the metadata.
var GethVersionWithMeta = func() string {
v := GethVersion
if VersionMeta != "" {
v += "-" + VersionMeta
}
Expand All @@ -46,8 +67,8 @@ var VersionWithMeta = func() string {
// releases.
func ArchiveVersion(gitCommit string) string {
vsn := Version
if VersionMeta != "stable" {
vsn += "-" + VersionMeta
if OPVersionMeta != "stable" {
vsn += "-" + OPVersionMeta
}
if len(gitCommit) >= 8 {
vsn += "-" + gitCommit[:8]
Expand All @@ -60,7 +81,7 @@ func VersionWithCommit(gitCommit, gitDate string) string {
if len(gitCommit) >= 8 {
vsn += "-" + gitCommit[:8]
}
if (VersionMeta != "stable") && (gitDate != "") {
if (OPVersionMeta != "stable") && (gitDate != "") {
vsn += "-" + gitDate
}
return vsn
Expand Down

0 comments on commit 93afadf

Please sign in to comment.