diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 853c044266..34e18a5051 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [ main ] + branches: [ main, "release/*" ] pull_request: branches: [ main ] workflow_dispatch: diff --git a/Makefile b/Makefile index f3d7f48f2f..9f666b537e 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,11 @@ GOBIN = ./build/bin GO ?= latest GORUN = go run +COMMIT = $(shell git log -1 --format='%H') +BRANCH = $(shell git rev-parse --abbrev-ref HEAD) +TAG := $(shell git describe --tags --abbrev=0 --match "v*") +BUILD_FLAGS := -git-commit=$(COMMIT) -git-branch=$(BRANCH) -git-tag=$(TAG) + #? geth: Build geth. geth: $(GORUN) build/ci.go install ./cmd/geth diff --git a/beacon/engine/types.go b/beacon/engine/types.go index 1bfbcce506..f52082d640 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -362,8 +362,8 @@ type ExecutionPayloadBody struct { // Client identifiers to support ClientVersionV1. const ( - ClientCode = "GE" - ClientName = "go-ethereum" + ClientCode = "BG" + ClientName = "bera-geth" ) // ClientVersionV1 contains information which identifies a client implementation. diff --git a/build/ci.go b/build/ci.go index a4a58c7fad..86b483f3ed 100644 --- a/build/ci.go +++ b/build/ci.go @@ -237,6 +237,7 @@ func buildFlags(env build.Environment, staticLinking bool, buildTags []string) ( if env.Commit != "" { ld = append(ld, "-X", "github.com/ethereum/go-ethereum/internal/version.gitCommit="+env.Commit) ld = append(ld, "-X", "github.com/ethereum/go-ethereum/internal/version.gitDate="+env.Date) + ld = append(ld, "-X", "github.com/ethereum/go-ethereum/internal/version.gitTag="+env.Tag) } // Strip DWARF on darwin. This used to be required for certain things, // and there is no downside to this, so we just keep doing it. diff --git a/cmd/geth/consolecmd_test.go b/cmd/geth/consolecmd_test.go index 4e1f6340a0..d04371ffba 100644 --- a/cmd/geth/consolecmd_test.go +++ b/cmd/geth/consolecmd_test.go @@ -69,7 +69,7 @@ func TestConsoleWelcome(t *testing.T) { geth.Expect(` Welcome to the Geth JavaScript console! -instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}} +instance: bera-geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}} at block: 0 ({{niltime}}) datadir: {{.Datadir}} modules: {{apis}} @@ -89,9 +89,9 @@ func TestAttachWelcome(t *testing.T) { ) // Configure the instance for IPC attachment if runtime.GOOS == "windows" { - ipc = `\\.\pipe\geth` + strconv.Itoa(trulyRandInt(100000, 999999)) + ipc = `\\.\pipe\bera-geth` + strconv.Itoa(trulyRandInt(100000, 999999)) } else { - ipc = filepath.Join(t.TempDir(), "geth.ipc") + ipc = filepath.Join(t.TempDir(), "bera-geth.ipc") } // And HTTP + WS attachment p := trulyRandInt(1024, 65533) // Yeah, sometimes this will fail, sorry :P @@ -140,7 +140,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) { attach.Expect(` Welcome to the Geth JavaScript console! -instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}} +instance: bera-geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}} at block: 0 ({{niltime}}){{if ipc}} datadir: {{datadir}}{{end}} modules: {{apis}} diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 7d32e3877a..a15175b5ea 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -46,7 +46,7 @@ import ( ) const ( - clientIdentifier = "geth" // Client identifier to advertise over the network + clientIdentifier = "bera-geth" // Client identifier to advertise over the network ) var ( diff --git a/cmd/geth/misccmd.go b/cmd/geth/misccmd.go index 2d31f3abe7..b6ba0cfb5a 100644 --- a/cmd/geth/misccmd.go +++ b/cmd/geth/misccmd.go @@ -72,7 +72,12 @@ func printVersion(ctx *cli.Context) error { git, _ := version.VCS() fmt.Println(strings.Title(clientIdentifier)) - fmt.Println("Version:", version.WithMeta) + // Use git tag if available, otherwise fall back to hardcoded version + if git.Tag != "" { + fmt.Println("Version:", git.Tag) + } else { + fmt.Println("Version:", version.WithMeta) + } if git.Commit != "" { fmt.Println("Git Commit:", git.Commit) } diff --git a/eth/backend.go b/eth/backend.go index 7616ec9d31..82716e1e40 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -59,9 +59,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/dnsdisc" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" - gethversion "github.com/ethereum/go-ethereum/version" ) const ( @@ -359,13 +357,14 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { func makeExtraData(extra []byte) []byte { if len(extra) == 0 { - // create default extradata - extra, _ = rlp.EncodeToBytes([]interface{}{ - uint(gethversion.Major<<16 | gethversion.Minor<<8 | gethversion.Patch), - "geth", - runtime.Version(), - runtime.GOOS, - }) + // create default extradata in ASCII format similar to reth + // Format: "bera-geth/vX.Y.Z/platform" + tag := version.WithMeta + if vcs, ok := version.VCS(); ok && vcs.Tag != "" { + tag = vcs.Tag + } + versionStr := fmt.Sprintf("bera-geth/v%s/%s", tag, runtime.GOOS) + extra = []byte(versionStr) } if uint64(len(extra)) > params.MaximumExtraDataSize { log.Warn("Miner extra data exceed limit", "extra", hexutil.Bytes(extra), "limit", params.MaximumExtraDataSize) diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index a1db760585..f514696d1b 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -1034,14 +1034,18 @@ func (api *ConsensusAPI) ExchangeCapabilities([]string) []string { func (api *ConsensusAPI) GetClientVersionV1(info engine.ClientVersionV1) []engine.ClientVersionV1 { log.Trace("Engine API request received", "method", "GetClientVersionV1", "info", info.String()) commit := make([]byte, 4) + vsn := version.WithMeta if vcs, ok := version.VCS(); ok { commit = common.FromHex(vcs.Commit)[0:4] + if vcs.Tag != "" { + vsn = vcs.Tag + } } return []engine.ClientVersionV1{ { Code: engine.ClientCode, Name: engine.ClientName, - Version: version.WithMeta, + Version: vsn, Commit: hexutil.Encode(commit), }, } diff --git a/internal/build/env.go b/internal/build/env.go index 0b928f847d..1ebdcb3877 100644 --- a/internal/build/env.go +++ b/internal/build/env.go @@ -172,7 +172,12 @@ func LocalEnv() Environment { } } if info, err := os.Stat(".git/objects"); err == nil && info.IsDir() && env.Tag == "" { + // Try to get tag at HEAD first env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD")) + // If no tag points at HEAD, get the most recent tag + if env.Tag == "" { + env.Tag = firstLine(RunGit("describe", "--tags", "--abbrev=0")) + } } return env } diff --git a/internal/version/vcs.go b/internal/version/vcs.go index 7ee87bb1b9..05047c352c 100644 --- a/internal/version/vcs.go +++ b/internal/version/vcs.go @@ -30,10 +30,11 @@ const ( // These variables are set at build-time by the linker when the build is // done by build/ci.go. -var gitCommit, gitDate string +var gitCommit, gitDate, gitTag string // VCSInfo represents the git repository state. type VCSInfo struct { + Tag string // git tag Commit string // head commit hash Date string // commit time in YYYYMMDD format Dirty bool @@ -43,7 +44,7 @@ type VCSInfo struct { func VCS() (VCSInfo, bool) { if gitCommit != "" { // Use information set by the build script if present. - return VCSInfo{Commit: gitCommit, Date: gitDate}, true + return VCSInfo{Tag: gitTag, Commit: gitCommit, Date: gitDate}, true } if buildInfo, ok := debug.ReadBuildInfo(); ok { if buildInfo.Main.Path == ourPath { diff --git a/internal/version/version.go b/internal/version/version.go index 90d1410cd5..ff93368ecf 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -28,9 +28,6 @@ import ( const ourPath = "github.com/ethereum/go-ethereum" // Path to our module -// Family holds the textual version string for major.minor -var Family = fmt.Sprintf("%d.%d", version.Major, version.Minor) - // Semantic holds the textual version string for major.minor.patch. var Semantic = fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch) @@ -114,9 +111,9 @@ func Info() (version, vcs string) { // information. If it is unable to determine which module is related to our // package it falls back to the hardcoded values in the params package. func versionInfo(info *debug.BuildInfo) string { - // If the main package is from our repo, prefix version with "geth". + // If the main package is from our repo, prefix version with "bera-geth". if strings.HasPrefix(info.Path, ourPath) { - return fmt.Sprintf("geth %s", info.Main.Version) + return fmt.Sprintf("bera-geth %s", info.Main.Version) } // Not our main package, so explicitly print out the module path and // version. @@ -130,7 +127,7 @@ func versionInfo(info *debug.BuildInfo) string { // If our module path wasn't imported, it's unclear which // version of our code they are running. Fallback to hardcoded // version. - return version + fmt.Sprintf("geth %s", WithMeta) + return version + fmt.Sprintf("bera-geth %s", WithMeta) } // Our package is a dependency for the main module. Return path and // version data for both. diff --git a/node/config_test.go b/node/config_test.go index 067796d665..a94bce9267 100644 --- a/node/config_test.go +++ b/node/config_test.go @@ -79,15 +79,15 @@ func TestIPCPathResolution(t *testing.T) { }{ {"", "", false, ""}, {"data", "", false, ""}, - {"", "geth.ipc", false, filepath.Join(os.TempDir(), "geth.ipc")}, - {"data", "geth.ipc", false, "data/geth.ipc"}, - {"data", "./geth.ipc", false, "./geth.ipc"}, - {"data", "/geth.ipc", false, "/geth.ipc"}, + {"", "bera-geth.ipc", false, filepath.Join(os.TempDir(), "bera-geth.ipc")}, + {"data", "bera-geth.ipc", false, "data/bera-geth.ipc"}, + {"data", "./bera-geth.ipc", false, "./bera-geth.ipc"}, + {"data", "/bera-geth.ipc", false, "/bera-geth.ipc"}, {"", "", true, ``}, {"data", "", true, ``}, - {"", "geth.ipc", true, `\\.\pipe\geth.ipc`}, - {"data", "geth.ipc", true, `\\.\pipe\geth.ipc`}, - {"data", `\\.\pipe\geth.ipc`, true, `\\.\pipe\geth.ipc`}, + {"", "bera-geth.ipc", true, `\\.\pipe\bera-geth.ipc`}, + {"data", "bera-geth.ipc", true, `\\.\pipe\bera-geth.ipc`}, + {"data", `\\.\pipe\bera-geth.ipc`, true, `\\.\pipe\bera-geth.ipc`}, } for i, test := range tests { // Only run when platform/test match