diff --git a/Makefile b/Makefile index 3eb694970..7a4ef6f9e 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,8 @@ OUTPUT?=$(BUILDDIR)/tendermint BUILD_TAGS?=tendermint -# If building a release, please checkout the version tag to get the correct version setting -ifneq ($(shell git symbolic-ref -q --short HEAD),) -VERSION := unreleased-$(shell git symbolic-ref -q --short HEAD)-$(shell git rev-parse HEAD) -else -VERSION := $(shell git describe) -endif - -LD_FLAGS = -X github.com/tendermint/tendermint/version.TMCoreSemVer=$(VERSION) +COMMIT_HASH := $(shell git rev-parse --short HEAD) +LD_FLAGS = -X github.com/tendermint/tendermint/version.TMGitCommitHash=$(COMMIT_HASH) BUILD_FLAGS = -mod=readonly -ldflags "$(LD_FLAGS)" HTTPS_GIT := https://github.com/tendermint/tendermint.git CGO_ENABLED ?= 0 diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index e39291390..3188c9425 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -79,7 +79,7 @@ func NewApplication() *Application { func (app *Application) Info(req types.RequestInfo) (resInfo types.ResponseInfo) { return types.ResponseInfo{ Data: fmt.Sprintf("{\"size\":%v}", app.state.Size), - Version: version.ABCIVersion, + Version: version.ABCISemVer, AppVersion: ProtocolVersion, LastBlockHeight: app.state.Height, LastBlockAppHash: app.state.AppHash, diff --git a/abci/version/version.go b/abci/version/version.go index f4dc4d235..2314c2852 100644 --- a/abci/version/version.go +++ b/abci/version/version.go @@ -6,4 +6,4 @@ import ( // TODO: eliminate this after some version refactor -const Version = version.ABCIVersion +const Version = version.ABCISemVer diff --git a/cmd/tendermint/commands/version.go b/cmd/tendermint/commands/version.go index d33a7c3a3..16fb878c9 100644 --- a/cmd/tendermint/commands/version.go +++ b/cmd/tendermint/commands/version.go @@ -14,6 +14,11 @@ var VersionCmd = &cobra.Command{ Use: "version", Short: "Show version info", Run: func(cmd *cobra.Command, args []string) { + tmVersion := version.TMCoreSemVer + if version.TMGitCommitHash != "" { + tmVersion += "+" + version.TMGitCommitHash + } + if verbose { values, _ := json.MarshalIndent(struct { Tendermint string `json:"tendermint"` @@ -21,14 +26,14 @@ var VersionCmd = &cobra.Command{ BlockProtocol uint64 `json:"block_protocol"` P2PProtocol uint64 `json:"p2p_protocol"` }{ - Tendermint: version.TMCoreSemVer, - ABCI: version.ABCIVersion, + Tendermint: tmVersion, + ABCI: version.ABCISemVer, BlockProtocol: version.BlockProtocol, P2PProtocol: version.P2PProtocol, }, "", " ") fmt.Println(string(values)) } else { - fmt.Println(version.TMCoreSemVer) + fmt.Println(tmVersion) } }, } diff --git a/node/node.go b/node/node.go index 902943288..ac0eca873 100644 --- a/node/node.go +++ b/node/node.go @@ -335,8 +335,10 @@ func logNodeStartupInfo(state sm.State, pubKey crypto.PubKey, logger, consensusL // Log the version info. logger.Info("Version info", "tendermint_version", version.TMCoreSemVer, + "abci", version.ABCISemVer, "block", version.BlockProtocol, "p2p", version.P2PProtocol, + "commit_hash", version.TMGitCommitHash, ) // If the state and software differ in block version, at least log it. diff --git a/version/version.go b/version/version.go index 272bd0326..46fb32a97 100644 --- a/version/version.go +++ b/version/version.go @@ -1,18 +1,12 @@ package version -var TMCoreSemVer = TMVersionDefault - const ( // TMVersionDefault is the used as the fallback version of Tendermint Core // when not using git describe. It is formatted with semantic versioning. - TMVersionDefault = "0.38.0-dev" + TMCoreSemVer = "0.38.0-dev" // ABCISemVer is the semantic version of the ABCI protocol - ABCISemVer = "1.0.0" - + ABCISemVer = "1.0.0" ABCIVersion = ABCISemVer -) - -var ( // P2PProtocol versions all p2p behavior and msgs. // This includes proposer selection. P2PProtocol uint64 = 8 @@ -21,3 +15,9 @@ var ( // This includes validity of blocks and state updates. BlockProtocol uint64 = 11 ) + +var ( + // TMGitCommitHash uses git rev-parse HEAD to find commit hash which is helpful + // for the engineering team when working with the tendermint binary. See Makefile + TMGitCommitHash = "" +)